Skip to content
Permalink
Browse files
[JSC] Remove per-host-function CTI stub in 32bit environment
https://bugs.webkit.org/show_bug.cgi?id=178581

Reviewed by Saam Barati.

JIT::privateCompileCTINativeCall only exists in 32bit environment and it is almost the same to native call CTI stub.
The only difference is that it embed the address of the host function directly in the generated stub. This means
that we have per-host-function CTI stub only in 32bit environment.

This patch just removes it and use one CTI stub instead. This design is the same to the current 64bit implementation.

* jit/JIT.cpp:
(JSC::JIT::compileCTINativeCall): Deleted.
* jit/JIT.h:
* jit/JITOpcodes.cpp:
(JSC::JIT::privateCompileCTINativeCall): Deleted.
* jit/JITOpcodes32_64.cpp:
(JSC::JIT::privateCompileCTINativeCall): Deleted.
* jit/JITThunks.cpp:
(JSC::JITThunks::hostFunctionStub):


Canonical link: https://commits.webkit.org/194815@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223813 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Constellation committed Oct 21, 2017
1 parent 413477a commit af757d29a662df234110b398f22b97bc255d82b9
@@ -1,3 +1,26 @@
2017-10-21 Yusuke Suzuki <utatane.tea@gmail.com>

[JSC] Remove per-host-function CTI stub in 32bit environment
https://bugs.webkit.org/show_bug.cgi?id=178581

Reviewed by Saam Barati.

JIT::privateCompileCTINativeCall only exists in 32bit environment and it is almost the same to native call CTI stub.
The only difference is that it embed the address of the host function directly in the generated stub. This means
that we have per-host-function CTI stub only in 32bit environment.

This patch just removes it and use one CTI stub instead. This design is the same to the current 64bit implementation.

* jit/JIT.cpp:
(JSC::JIT::compileCTINativeCall): Deleted.
* jit/JIT.h:
* jit/JITOpcodes.cpp:
(JSC::JIT::privateCompileCTINativeCall): Deleted.
* jit/JITOpcodes32_64.cpp:
(JSC::JIT::privateCompileCTINativeCall): Deleted.
* jit/JITThunks.cpp:
(JSC::JITThunks::hostFunctionStub):

2017-10-20 Antoine Quint <graouts@apple.com>

[Web Animations] Provide basic timeline and animation interfaces
@@ -71,14 +71,6 @@ void ctiPatchCallByReturnAddress(ReturnAddressPtr returnAddress, FunctionPtr new
newCalleeFunction);
}

JIT::CodeRef JIT::compileCTINativeCall(VM* vm, NativeFunction func)
{
if (!vm->canUseJIT())
return CodeRef::createLLIntCodeRef(llint_native_call_trampoline);
JIT jit(vm, 0);
return jit.privateCompileCTINativeCall(vm, func);
}

JIT::JIT(VM* vm, CodeBlock* codeBlock, unsigned loopOSREntryBytecodeOffset)
: JSInterfaceJIT(vm, codeBlock)
, m_interpreter(vm->interpreter)
@@ -245,8 +245,6 @@ namespace JSC {
jit.privateCompileHasIndexedProperty(byValInfo, returnAddress, arrayMode);
}

static CodeRef compileCTINativeCall(VM*, NativeFunction);

static unsigned frameRegisterCountFor(CodeBlock*);
static int stackPointerOffsetFor(CodeBlock*);

@@ -265,8 +263,6 @@ namespace JSC {

void privateCompileHasIndexedProperty(ByValInfo*, ReturnAddressPtr, JITArrayMode);

Label privateCompileCTINativeCall(VM*, bool isConstruct = false);
CodeRef privateCompileCTINativeCall(VM*, NativeFunction);
void privateCompilePatchGetArrayLength(ReturnAddressPtr returnAddress);

// Add a call out from JIT code, without an exception check.
@@ -51,11 +51,6 @@ namespace JSC {

#if USE(JSVALUE64)

JIT::CodeRef JIT::privateCompileCTINativeCall(VM* vm, NativeFunction)
{
return vm->getCTIStub(nativeCallGenerator);
}

void JIT::emit_op_mov(Instruction* currentInstruction)
{
int dst = currentInstruction[1].u.operand;
@@ -47,92 +47,6 @@

namespace JSC {

JIT::CodeRef JIT::privateCompileCTINativeCall(VM* vm, NativeFunction func)
{
// FIXME: This should be able to log ShadowChicken prologue packets.
// https://bugs.webkit.org/show_bug.cgi?id=155689

Call nativeCall;

emitFunctionPrologue();
emitPutToCallFrameHeader(0, CallFrameSlot::codeBlock);
storePtr(callFrameRegister, &vm->topCallFrame);

#if CPU(X86)
// Calling convention: f(ecx, edx, ...);
// Host function signature: f(ExecState*);
move(callFrameRegister, X86Registers::ecx);

subPtr(TrustedImm32(8), stackPointerRegister); // Align stack for call.
storePtr(X86Registers::ecx, Address(stackPointerRegister));

// call the function
nativeCall = call();

addPtr(TrustedImm32(8), stackPointerRegister);

#elif CPU(ARM) || CPU(MIPS)
#if CPU(MIPS)
// Allocate stack space for (unused) 16 bytes (8-byte aligned) for 4 arguments.
subPtr(TrustedImm32(16), stackPointerRegister);
#endif

// Calling convention is f(argumentGPR0, argumentGPR1, ...).
// Host function signature is f(ExecState*).
move(callFrameRegister, argumentGPR0);

emitGetFromCallFrameHeaderPtr(CallFrameSlot::callee, argumentGPR1);
loadPtr(Address(argumentGPR1, OBJECT_OFFSETOF(JSFunction, m_executable)), regT2);

// call the function
nativeCall = call();

#if CPU(MIPS)
// Restore stack space
addPtr(TrustedImm32(16), stackPointerRegister);
#endif

restoreReturnAddressBeforeReturn(regT3);
#else
#error "JIT not supported on this platform."
abortWithReason(JITNotSupported);
#endif // CPU(X86)

// Check for an exception
Jump sawException = branch32(NotEqual, AbsoluteAddress(vm->addressOfException()), TrustedImm32(0));

emitFunctionEpilogue();
// Return.
ret();

// Handle an exception
sawException.link(this);

storePtr(callFrameRegister, &vm->topCallFrame);

#if CPU(X86)
addPtr(TrustedImm32(-4), stackPointerRegister);
move(callFrameRegister, X86Registers::ecx);
push(X86Registers::ecx);
#else
move(callFrameRegister, argumentGPR0);
#endif
move(TrustedImmPtr(FunctionPtr(operationVMHandleException).value()), regT3);
call(regT3);

#if CPU(X86)
addPtr(TrustedImm32(8), stackPointerRegister);
#endif

jumpToExceptionHandler(*vm);

// All trampolines constructed! copy the code, link up calls, and set the pointers on the Machine object.
LinkBuffer patchBuffer(*this, GLOBAL_THUNK_ID);

patchBuffer.link(nativeCall, FunctionPtr(func));
return FINALIZE_CODE(patchBuffer, ("JIT CTI native call"));
}

void JIT::emit_op_mov(Instruction* currentInstruction)
{
int dst = currentInstruction[1].u.operand;
@@ -116,7 +116,7 @@ NativeExecutable* JITThunks::hostFunctionStub(VM* vm, NativeFunction function, N
MacroAssemblerCodeRef entry = generator(vm);
forCall = adoptRef(new DirectJITCode(entry, entry.code(), JITCode::HostCallThunk));
} else
forCall = adoptRef(new NativeJITCode(JIT::compileCTINativeCall(vm, function), JITCode::HostCallThunk));
forCall = adoptRef(new NativeJITCode(MacroAssemblerCodeRef::createSelfManagedCodeRef(ctiNativeCall(vm)), JITCode::HostCallThunk));

Ref<JITCode> forConstruct = adoptRef(*new NativeJITCode(MacroAssemblerCodeRef::createSelfManagedCodeRef(ctiNativeConstruct(vm)), JITCode::HostCallThunk));

0 comments on commit af757d2

Please sign in to comment.