Ignore:
Timestamp:
May 20, 2021, 11:35:06 PM (4 years ago)
Author:
[email protected]
Message:

[ Catalina Release JSC] A large number of JSC test appear to be flaky failing
https://bugs.webkit.org/show_bug.cgi?id=225998
<rdar://problem/78235001>

Reviewed by Yusuke Suzuki.

JSTests:

  • stress/dont-link-virtual-calls-on-compiler-thread.js: Added.

Source/JavaScriptCore:

This patch is fixing some fallout from moving JIT::link() to a background
thread:

  1. We can't shrink the CodeBlock's constant pool on a background thread

since we read from it without grabbing a lock on the main thread (when
reading things off the stack in slow path calls).

  1. We can't create GCAwareJITStubRoutines on the compilation thread, since

creating a GCAwareJITStubRoutines adds to a global hash table inside Heap. This
means that we have to do that step of emitting virtual calls for eval when
we're finalizing code on the main thread.

This patch also makes it so that a baseline JIT compilation thread is
correctly marked as such.

  • heap/JITStubRoutineSet.cpp:

(JSC::JITStubRoutineSet::add):

  • jit/AssemblyHelpers.cpp:

(JSC::AssemblyHelpers::emitUnlinkedVirtualCall):
(JSC::AssemblyHelpers::emitVirtualCall):

  • jit/AssemblyHelpers.h:
  • jit/JIT.cpp:

(JSC::JIT::link):
(JSC::JIT::finalizeOnMainThread):

  • jit/JIT.h:
  • jit/JITCall.cpp:

(JSC::JIT::compileCallEvalSlowCase):

  • jit/JITCall32_64.cpp:

(JSC::JIT::compileCallEvalSlowCase):

  • jit/JITWorklist.cpp:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/jit/JIT.cpp

    r277758 r277850  
    978978        "Baseline JIT code for %s", toCString(CodeBlockWithJITType(m_codeBlock, JITType::BaselineJIT)).data());
    979979   
     980    MacroAssemblerCodePtr<JSEntryPtrTag> withArityCheck = patchBuffer.locationOf<JSEntryPtrTag>(m_arityCheck);
     981    m_jitCode = adoptRef(*new DirectJITCode(result, withArityCheck, JITType::BaselineJIT));
     982
     983    if (JITInternal::verbose)
     984        dataLogF("JIT generated code for %p at [%p, %p).\n", m_codeBlock, result.executableMemory()->start().untaggedPtr(), result.executableMemory()->end().untaggedPtr());
     985}
     986
     987CompilationResult JIT::finalizeOnMainThread()
     988{
     989    RELEASE_ASSERT(!isCompilationThread());
     990
     991    if (!m_jitCode)
     992        return CompilationFailed;
     993
     994    for (auto pair : m_virtualCalls) {
     995        auto callLocation = m_linkBuffer->locationOfNearCall<JITThunkPtrTag>(pair.first);
     996
     997        CallLinkInfo& info = pair.second;
     998        MacroAssemblerCodeRef<JITStubRoutinePtrTag> virtualThunk = virtualThunkFor(*m_vm, info);
     999        info.setSlowStub(GCAwareJITStubRoutine::create(virtualThunk, *m_vm));
     1000        MacroAssembler::repatchNearCall(callLocation, CodeLocationLabel<JITStubRoutinePtrTag>(virtualThunk.code()));
     1001    }
     1002
    9801003    {
    9811004        ConcurrentJSLocker locker(m_codeBlock->m_lock);
    9821005        m_codeBlock->shrinkToFit(locker, CodeBlock::ShrinkMode::LateShrink);
    9831006    }
    984 
    985     MacroAssemblerCodePtr<JSEntryPtrTag> withArityCheck = patchBuffer.locationOf<JSEntryPtrTag>(m_arityCheck);
    986     m_jitCode = adoptRef(*new DirectJITCode(result, withArityCheck, JITType::BaselineJIT));
    987 
    988     if (JITInternal::verbose)
    989         dataLogF("JIT generated code for %p at [%p, %p).\n", m_codeBlock, result.executableMemory()->start().untaggedPtr(), result.executableMemory()->end().untaggedPtr());
    990 }
    991 
    992 CompilationResult JIT::finalizeOnMainThread()
    993 {
    994     RELEASE_ASSERT(!isCompilationThread());
    995 
    996     if (!m_jitCode)
    997         return CompilationFailed;
    9981007
    9991008    for (size_t i = 0; i < m_codeBlock->numberOfExceptionHandlers(); ++i) {
Note: See TracChangeset for help on using the changeset viewer.