Title: [238281] trunk
Revision
238281
Author
[email protected]
Date
2018-11-16 07:24:04 -0800 (Fri, 16 Nov 2018)

Log Message

Fix assertion failure on BytecodeGenerator::recordOpcode
https://bugs.webkit.org/show_bug.cgi?id=191724
<rdar://problem/45724395>

Reviewed by Saam Barati.

JSTests:

* stress/regress-187373-2.js: Added.
(foo):

Source/_javascript_Core:

Since https://bugs.webkit.org/show_bug.cgi?id=187373, we were not
restoring m_lastInstruction after patching the bytecode when
finalizing StructureForInContexts, only m_lastOpcodeID, which led to
the assertion failure.

* bytecompiler/BytecodeGenerator.cpp:
(JSC::StructureForInContext::finalize):

Modified Paths

Added Paths

Diff

Modified: trunk/JSTests/ChangeLog (238280 => 238281)


--- trunk/JSTests/ChangeLog	2018-11-16 15:07:17 UTC (rev 238280)
+++ trunk/JSTests/ChangeLog	2018-11-16 15:24:04 UTC (rev 238281)
@@ -1,3 +1,14 @@
+2018-11-16  Tadeu Zagallo  <[email protected]>
+
+        Fix assertion failure on BytecodeGenerator::recordOpcode
+        https://bugs.webkit.org/show_bug.cgi?id=191724
+        <rdar://problem/45724395>
+
+        Reviewed by Saam Barati.
+
+        * stress/regress-187373-2.js: Added.
+        (foo):
+
 2018-11-15  Mark Lam  <[email protected]>
 
         RegExpObject's collectMatches should not be using JSArray::push to fill in its match results.

Added: trunk/JSTests/stress/regress-187373-2.js (0 => 238281)


--- trunk/JSTests/stress/regress-187373-2.js	                        (rev 0)
+++ trunk/JSTests/stress/regress-187373-2.js	2018-11-16 15:24:04 UTC (rev 238281)
@@ -0,0 +1,8 @@
+//@ runDefault("--useControlFlowProfiler=true")
+
+function foo() {
+    for (var x in []) {
+        o[++x];
+    }
+}
+foo()

Modified: trunk/Source/_javascript_Core/ChangeLog (238280 => 238281)


--- trunk/Source/_javascript_Core/ChangeLog	2018-11-16 15:07:17 UTC (rev 238280)
+++ trunk/Source/_javascript_Core/ChangeLog	2018-11-16 15:24:04 UTC (rev 238281)
@@ -1,3 +1,19 @@
+2018-11-16  Tadeu Zagallo  <[email protected]>
+
+        Fix assertion failure on BytecodeGenerator::recordOpcode
+        https://bugs.webkit.org/show_bug.cgi?id=191724
+        <rdar://problem/45724395>
+
+        Reviewed by Saam Barati.
+
+        Since https://bugs.webkit.org/show_bug.cgi?id=187373, we were not
+        restoring m_lastInstruction after patching the bytecode when
+        finalizing StructureForInContexts, only m_lastOpcodeID, which led to
+        the assertion failure.
+
+        * bytecompiler/BytecodeGenerator.cpp:
+        (JSC::StructureForInContext::finalize):
+
 2018-11-15  Mark Lam  <[email protected]>
 
         RegExpObject's collectMatches should not be using JSArray::push to fill in its match results.

Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp (238280 => 238281)


--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp	2018-11-16 15:07:17 UTC (rev 238280)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp	2018-11-16 15:24:04 UTC (rev 238281)
@@ -4833,6 +4833,8 @@
     if (isValid())
         return;
 
+    OpcodeID lastOpcodeID = generator.m_lastOpcodeID;
+    InstructionStream::MutableRef lastInstruction = generator.m_lastInstruction;
     for (const auto& instTuple : m_getInsts) {
         unsigned instIndex = std::get<0>(instTuple);
         int propertyRegIndex = std::get<1>(instTuple);
@@ -4845,7 +4847,6 @@
         auto bytecode = instruction->as<OpGetDirectPname>();
 
         // disable peephole optimizations
-        OpcodeID lastOpcodeID = generator.m_lastOpcodeID;
         generator.m_lastOpcodeID = op_end;
 
         // Change the opcode to get_by_val.
@@ -4857,8 +4858,11 @@
         // 4. nop out the remaining bytes
         while (generator.m_writer.position() < end)
             OpNop::emit<OpcodeSize::Narrow>(&generator);
-        generator.m_writer.seek(generator.m_writer.size());
+    }
+    generator.m_writer.seek(generator.m_writer.size());
+    if (generator.m_lastInstruction.offset() + generator.m_lastInstruction->size() != generator.m_writer.size()) {
         generator.m_lastOpcodeID = lastOpcodeID;
+        generator.m_lastInstruction = lastInstruction;
     }
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to