Title: [284690] trunk/Source/_javascript_Core
Revision
284690
Author
rmoris...@apple.com
Date
2021-10-22 09:36:49 -0700 (Fri, 22 Oct 2021)

Log Message

--reportBytecodeCompileTimes=1 should correctly report the bytecode size
https://bugs.webkit.org/show_bug.cgi?id=232118

Reviewed by Michael Saboff.

generate() calls m_writer.finalize() which moves m_instructions, so when we later query its size we get 0.
The solution is simply to put the size in an out-parameter just before calling finalize().

* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::generate):
* bytecompiler/BytecodeGenerator.h:
(JSC::BytecodeGenerator::generate):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (284689 => 284690)


--- trunk/Source/_javascript_Core/ChangeLog	2021-10-22 16:31:34 UTC (rev 284689)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-10-22 16:36:49 UTC (rev 284690)
@@ -1,3 +1,18 @@
+2021-10-22  Robin Morisset  <rmoris...@apple.com>
+
+        --reportBytecodeCompileTimes=1 should correctly report the bytecode size
+        https://bugs.webkit.org/show_bug.cgi?id=232118
+
+        Reviewed by Michael Saboff.
+
+        generate() calls m_writer.finalize() which moves m_instructions, so when we later query its size we get 0.
+        The solution is simply to put the size in an out-parameter just before calling finalize().
+
+        * bytecompiler/BytecodeGenerator.cpp:
+        (JSC::BytecodeGenerator::generate):
+        * bytecompiler/BytecodeGenerator.h:
+        (JSC::BytecodeGenerator::generate):
+
 2021-10-22  Mark Lam  <mark....@apple.com>
 
         Remove unneeded Heap::m_vm.

Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp (284689 => 284690)


--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp	2021-10-22 16:31:34 UTC (rev 284689)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp	2021-10-22 16:36:49 UTC (rev 284690)
@@ -148,7 +148,7 @@
     generator.moveEmptyValue(completionValueRegister());
 }
 
-ParserError BytecodeGenerator::generate()
+ParserError BytecodeGenerator::generate(unsigned& size)
 {
     if (UNLIKELY(m_outOfMemoryDuringConstruction))
         return ParserError(ParserError::OutOfMemory);
@@ -285,6 +285,7 @@
         performGeneratorification(*this, m_codeBlock.get(), m_writer, m_generatorFrameSymbolTable.get(), m_generatorFrameSymbolTableIndex);
 
     RELEASE_ASSERT(m_codeBlock->numCalleeLocals() < static_cast<unsigned>(FirstConstantRegisterIndex));
+    size = instructions().size();
     m_codeBlock->finalize(m_writer.finalize());
     if (m_expressionTooDeep)
         return ParserError(ParserError::OutOfMemory);

Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h (284689 => 284690)


--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h	2021-10-22 16:31:34 UTC (rev 284689)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h	2021-10-22 16:36:49 UTC (rev 284690)
@@ -384,11 +384,12 @@
 
             DeferGC deferGC(vm.heap);
             auto bytecodeGenerator = makeUnique<BytecodeGenerator>(vm, node, unlinkedCodeBlock, codeGenerationMode, parentScopeTDZVariables, privateNameEnvironment);
-            auto result = bytecodeGenerator->generate();
+            unsigned size;
+            auto result = bytecodeGenerator->generate(size);
 
             if (UNLIKELY(Options::reportBytecodeCompileTimes())) {
                 MonotonicTime after = MonotonicTime::now();
-                dataLogLn(result.isValid() ? "Failed to compile #" : "Compiled #", CodeBlockHash(sourceCode, unlinkedCodeBlock->isConstructor() ? CodeForConstruct : CodeForCall), " into bytecode ", bytecodeGenerator->instructions().size(), " instructions in ", (after - before).milliseconds(), " ms.");
+                dataLogLn(result.isValid() ? "Failed to compile #" : "Compiled #", CodeBlockHash(sourceCode, unlinkedCodeBlock->isConstructor() ? CodeForConstruct : CodeForCall), " into bytecode ", size, " instructions in ", (after - before).milliseconds(), " ms.");
             }
             return result;
         }
@@ -1074,7 +1075,7 @@
         int labelScopeDepth() const;
 
     private:
-        ParserError generate();
+        ParserError generate(unsigned&);
         Variable variableForLocalEntry(const Identifier&, const SymbolTableEntry&, int symbolTableConstantIndex, bool isLexicallyScoped);
 
         RegisterID* kill(RegisterID* dst)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to