Ignore:
Timestamp:
Oct 22, 2021, 9:36:49 AM (4 years ago)
Author:
[email protected]
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):

Location:
trunk/Source/JavaScriptCore/bytecompiler
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r283168 r284690  
    149149}
    150150
    151 ParserError BytecodeGenerator::generate()
     151ParserError BytecodeGenerator::generate(unsigned& size)
    152152{
    153153    if (UNLIKELY(m_outOfMemoryDuringConstruction))
     
    286286
    287287    RELEASE_ASSERT(m_codeBlock->numCalleeLocals() < static_cast<unsigned>(FirstConstantRegisterIndex));
     288    size = instructions().size();
    288289    m_codeBlock->finalize(m_writer.finalize());
    289290    if (m_expressionTooDeep)
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h

    r284435 r284690  
    385385            DeferGC deferGC(vm.heap);
    386386            auto bytecodeGenerator = makeUnique<BytecodeGenerator>(vm, node, unlinkedCodeBlock, codeGenerationMode, parentScopeTDZVariables, privateNameEnvironment);
    387             auto result = bytecodeGenerator->generate();
     387            unsigned size;
     388            auto result = bytecodeGenerator->generate(size);
    388389
    389390            if (UNLIKELY(Options::reportBytecodeCompileTimes())) {
    390391                MonotonicTime after = MonotonicTime::now();
    391                 dataLogLn(result.isValid() ? "Failed to compile #" : "Compiled #", CodeBlockHash(sourceCode, unlinkedCodeBlock->isConstructor() ? CodeForConstruct : CodeForCall), " into bytecode ", bytecodeGenerator->instructions().size(), " instructions in ", (after - before).milliseconds(), " ms.");
     392                dataLogLn(result.isValid() ? "Failed to compile #" : "Compiled #", CodeBlockHash(sourceCode, unlinkedCodeBlock->isConstructor() ? CodeForConstruct : CodeForCall), " into bytecode ", size, " instructions in ", (after - before).milliseconds(), " ms.");
    392393            }
    393394            return result;
     
    10751076
    10761077    private:
    1077         ParserError generate();
     1078        ParserError generate(unsigned&);
    10781079        Variable variableForLocalEntry(const Identifier&, const SymbolTableEntry&, int symbolTableConstantIndex, bool isLexicallyScoped);
    10791080
Note: See TracChangeset for help on using the changeset viewer.