[JSC] Remove per-host-function CTI stub in 32bit environment
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Oct 2017 15:34:58 +0000 (15:34 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Oct 2017 15:34:58 +0000 (15:34 +0000)
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):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223813 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/jit/JIT.cpp
Source/JavaScriptCore/jit/JIT.h
Source/JavaScriptCore/jit/JITOpcodes.cpp
Source/JavaScriptCore/jit/JITOpcodes32_64.cpp
Source/JavaScriptCore/jit/JITThunks.cpp

index a91d47c..743c14d 100644 (file)
@@ -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
index 6af450b..ae117a0 100644 (file)
@@ -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)
index 6d086c4..dd9e6c5 100644 (file)
@@ -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.
index 39ec99e..16d50c7 100644 (file)
@@ -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;
index 06bb3f6..2a58848 100644 (file)
 
 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;
index 68c5643..dffd802 100644 (file)
@@ -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));