Ignore:
Timestamp:
Mar 23, 2015, 10:37:19 PM (10 years ago)
Author:
[email protected]
Message:

JSC should have a low-cost asynchronous disassembler
https://bugs.webkit.org/show_bug.cgi?id=142997

Reviewed by Mark Lam.
Source/JavaScriptCore:


This adds a JSC_asyncDisassembly option that disassembles on a thread. Disassembly
doesn't block execution. Some code will live a little longer because of this, since the
work tasks hold a ref to the code, but other than that there is basically no overhead.

At present, this isn't really a replacement for JSC_showDisassembly, since it doesn't
provide contextual IR information for Baseline and DFG disassemblies, and it doesn't do
the separate IR dumps for FTL. Using JSC_showDisassembly and friends along with
JSC_asyncDisassembly has bizarre behavior - so just choose one.

A simple way of understanding how great this is, is to run a small benchmark like
V8Spider/earley-boyer.

Performance without any disassembly flags: 60ms
Performance with JSC_showDisassembly=true: 477ms
Performance with JSC_asyncDisassembly=true: 65ms

So, the overhead of disassembly goes from 8x to 8%.

Note that JSC_asyncDisassembly=true does make it incorrect to run "time" as a way of
measuring benchmark performance. This is because at VM exit, we wait for all async
disassembly requests to finish. For example, for earley-boyer, we spend an extra ~130ms
after the benchmark completely finishes to finish the disassemblies. This small weirdness
should be OK for the intended use-cases, since all you have to do to get around it is to
measure the execution time of the benchmark payload rather than the end-to-end time of
launching the VM.

  • assembler/LinkBuffer.cpp:

(JSC::LinkBuffer::finalizeCodeWithDisassembly):

  • assembler/LinkBuffer.h:

(JSC::LinkBuffer::wasAlreadyDisassembled):
(JSC::LinkBuffer::didAlreadyDisassemble):

  • dfg/DFGJITCompiler.cpp:

(JSC::DFG::JITCompiler::disassemble):

  • dfg/DFGJITFinalizer.cpp:

(JSC::DFG::JITFinalizer::finalize):
(JSC::DFG::JITFinalizer::finalizeFunction):

  • disassembler/Disassembler.cpp:

(JSC::disassembleAsynchronously):
(JSC::waitForAsynchronousDisassembly):

  • disassembler/Disassembler.h:
  • ftl/FTLCompile.cpp:

(JSC::FTL::mmAllocateDataSection):

  • ftl/FTLLink.cpp:

(JSC::FTL::link):

  • jit/JIT.cpp:

(JSC::JIT::privateCompile):

  • jsc.cpp:
  • runtime/Options.h:
  • runtime/VM.cpp:

(JSC::VM::~VM):

Source/WTF:

  • wtf/StringPrintStream.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ftl/FTLCompile.cpp

    r180903 r181887  
    804804            recordMap, didSeeUnwindInfo);
    805805       
    806         if (shouldShowDisassembly()) {
     806        if (shouldShowDisassembly() || Options::asyncDisassembly()) {
    807807            for (unsigned i = 0; i < state.jitCode->handles().size(); ++i) {
    808808                if (state.codeSectionNames[i] != SECTION_NAME("text"))
     
    810810               
    811811                ExecutableMemoryHandle* handle = state.jitCode->handles()[i].get();
    812                 dataLog(
     812               
     813                CString header = toCString(
    813814                    "Generated LLVM code after stackmap-based fix-up for ",
    814815                    CodeBlockWithJITType(state.graph.m_codeBlock, JITCode::FTLJIT),
    815816                    " in ", state.graph.m_plan.mode, " #", i, ", ",
    816817                    state.codeSectionNames[i], ":\n");
     818               
     819                if (Options::asyncDisassembly()) {
     820                    disassembleAsynchronously(
     821                        header, MacroAssemblerCodeRef(handle), handle->sizeInBytes(), "    ",
     822                        LLVMSubset);
     823                    continue;
     824                }
     825               
     826                dataLog(header);
    817827                disassemble(
    818828                    MacroAssemblerCodePtr(handle->start()), handle->sizeInBytes(),
Note: See TracChangeset for help on using the changeset viewer.