Ignore:
Timestamp:
Sep 30, 2020, 10:15:14 PM (5 years ago)
Author:
[email protected]
Message:

[JSC] We should not tag C function with JIT code related ptr tag
https://bugs.webkit.org/show_bug.cgi?id=217150

Reviewed by Mark Lam.

We are tagging getHostCallReturnValue function with JIT related PtrTag. As a part of JIT-caging effort, we are restricting our
PtrTag usage more for code types (e.g. JIT code should be tagged with JIT related PtrTag). So, we should not tag getHostCallReturnValue
with that. This patch implements getHostCallReturnValue in JIT code if JIT is enabled. If not, it is implemented by LLInt.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Sources.txt:
  • bytecode/BytecodeList.rb:
  • dfg/DFGCapabilities.cpp:

(JSC::DFG::capabilityLevel):

  • heap/MarkedBlock.h:

(JSC::MarkedBlock::Footer::offsetOfVM):

  • heap/PreciseAllocation.h:

(JSC::PreciseAllocation::offsetOfWeakSet):

  • heap/WeakSet.h:

(JSC::WeakSet::offsetOfVM):

  • jit/HostCallReturnValue.cpp: Removed.
  • jit/HostCallReturnValue.h: Removed.
  • jit/JITOperations.cpp:
  • jit/JITOperationsMSVC64.cpp: Removed.
  • jit/JITStubsMSVC64.asm:
  • llint/LLIntEntrypoint.cpp:

(JSC::LLInt::getHostCallReturnValueEntrypoint):

  • llint/LLIntEntrypoint.h:
  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::handleHostCall):
(JSC::LLInt::commonCallEval):

  • llint/LLIntThunks.cpp:

(JSC::LLInt::getHostCallReturnValueThunk):

  • llint/LLIntThunks.h:
  • llint/LowLevelInterpreter.cpp:

(JSC::CLoop::execute):

  • llint/LowLevelInterpreter32_64.asm:
  • llint/LowLevelInterpreter64.asm:
  • runtime/JSCellInlines.h:

(JSC::tryAllocateCellHelper):

  • runtime/JSGlobalObject.h:

(JSC::JSGlobalObject::offsetOfVM):

  • runtime/VM.cpp:

(JSC::VM::VM):

  • runtime/VM.h:

(JSC::VM::offsetOfEncodedHostCallReturnValue):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/llint/LLIntThunks.cpp

    r267239 r267820  
    153153#endif // ENABLE(WEBASSEMBLY)
    154154
     155MacroAssemblerCodeRef<JSEntryPtrTag> getHostCallReturnValueThunk()
     156{
     157    static LazyNeverDestroyed<MacroAssemblerCodeRef<JSEntryPtrTag>> codeRef;
     158    static std::once_flag onceKey;
     159    std::call_once(onceKey, [&] {
     160        CCallHelpers jit;
     161
     162        jit.emitFunctionPrologue();
     163        jit.emitGetFromCallFrameHeaderPtr(CallFrameSlot::callee, GPRInfo::regT0);
     164
     165        auto preciseAllocationCase = jit.branchTestPtr(CCallHelpers::NonZero, GPRInfo::regT0, CCallHelpers::TrustedImm32(PreciseAllocation::halfAlignment));
     166        jit.andPtr(CCallHelpers::TrustedImmPtr(MarkedBlock::blockMask), GPRInfo::regT0);
     167        jit.loadPtr(CCallHelpers::Address(GPRInfo::regT0, MarkedBlock::offsetOfFooter + MarkedBlock::Footer::offsetOfVM()), GPRInfo::regT0);
     168        auto loadedCase = jit.jump();
     169
     170        preciseAllocationCase.link(&jit);
     171        jit.loadPtr(CCallHelpers::Address(GPRInfo::regT0, PreciseAllocation::offsetOfWeakSet() + WeakSet::offsetOfVM() - PreciseAllocation::headerSize()), GPRInfo::regT0);
     172
     173        loadedCase.link(&jit);
     174#if USE(JSVALUE64)
     175        jit.loadValue(CCallHelpers::Address(GPRInfo::regT0, VM::offsetOfEncodedHostCallReturnValue()), JSValueRegs { GPRInfo::returnValueGPR });
     176#else
     177        jit.loadValue(CCallHelpers::Address(GPRInfo::regT0, VM::offsetOfEncodedHostCallReturnValue()), JSValueRegs { GPRInfo::returnValueGPR2, GPRInfo::returnValueGPR });
     178#endif
     179        jit.emitFunctionEpilogue();
     180        jit.ret();
     181
     182        LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID);
     183        codeRef.construct(FINALIZE_CODE(patchBuffer, JSEntryPtrTag, "LLInt::getHostCallReturnValue thunk"));
     184    });
     185    return codeRef;
     186}
     187
    155188} // namespace LLInt
    156189
    157 #endif
     190#endif // ENABLE(JIT)
    158191
    159192#if ENABLE(C_LOOP)
Note: See TracChangeset for help on using the changeset viewer.