diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
commit | 32761a6cee1d0dee366b885b7b9c777e67885688 (patch) | |
tree | d6bec92bebfb216f4126356e55518842c2f476a1 /Source/JavaScriptCore/llint/LLIntThunks.cpp | |
parent | a4e969f4965059196ca948db781e52f7cfebf19e (diff) | |
download | WebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz |
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/JavaScriptCore/llint/LLIntThunks.cpp')
-rw-r--r-- | Source/JavaScriptCore/llint/LLIntThunks.cpp | 76 |
1 files changed, 52 insertions, 24 deletions
diff --git a/Source/JavaScriptCore/llint/LLIntThunks.cpp b/Source/JavaScriptCore/llint/LLIntThunks.cpp index af6884e5e..9429e6cb5 100644 --- a/Source/JavaScriptCore/llint/LLIntThunks.cpp +++ b/Source/JavaScriptCore/llint/LLIntThunks.cpp @@ -29,7 +29,6 @@ #include "CallData.h" #include "ExceptionHelpers.h" #include "Interpreter.h" -#include "JSCJSValueInlines.h" #include "JSInterfaceJIT.h" #include "JSObject.h" #include "JSStackInlines.h" @@ -37,12 +36,12 @@ #include "LinkBuffer.h" #include "LowLevelInterpreter.h" #include "ProtoCallFrame.h" -#include "StackAlignment.h" #include "VM.h" namespace JSC { #if ENABLE(JIT) +#if ENABLE(LLINT) namespace LLInt { @@ -54,71 +53,100 @@ static MacroAssemblerCodeRef generateThunkWithJumpTo(VM* vm, void (*target)(), c jit.move(JSInterfaceJIT::TrustedImmPtr(bitwise_cast<void*>(target)), JSInterfaceJIT::regT0); jit.jump(JSInterfaceJIT::regT0); - LinkBuffer patchBuffer(*vm, jit, GLOBAL_THUNK_ID); + LinkBuffer patchBuffer(*vm, &jit, GLOBAL_THUNK_ID); return FINALIZE_CODE(patchBuffer, ("LLInt %s prologue thunk", thunkKind)); } MacroAssemblerCodeRef functionForCallEntryThunkGenerator(VM* vm) { - return generateThunkWithJumpTo(vm, LLInt::getCodeFunctionPtr(llint_function_for_call_prologue), "function for call"); + return generateThunkWithJumpTo(vm, llint_function_for_call_prologue, "function for call"); } MacroAssemblerCodeRef functionForConstructEntryThunkGenerator(VM* vm) { - return generateThunkWithJumpTo(vm, LLInt::getCodeFunctionPtr(llint_function_for_construct_prologue), "function for construct"); + return generateThunkWithJumpTo(vm, llint_function_for_construct_prologue, "function for construct"); } MacroAssemblerCodeRef functionForCallArityCheckThunkGenerator(VM* vm) { - return generateThunkWithJumpTo(vm, LLInt::getCodeFunctionPtr(llint_function_for_call_arity_check), "function for call with arity check"); + return generateThunkWithJumpTo(vm, llint_function_for_call_arity_check, "function for call with arity check"); } MacroAssemblerCodeRef functionForConstructArityCheckThunkGenerator(VM* vm) { - return generateThunkWithJumpTo(vm, LLInt::getCodeFunctionPtr(llint_function_for_construct_arity_check), "function for construct with arity check"); + return generateThunkWithJumpTo(vm, llint_function_for_construct_arity_check, "function for construct with arity check"); } MacroAssemblerCodeRef evalEntryThunkGenerator(VM* vm) { - return generateThunkWithJumpTo(vm, LLInt::getCodeFunctionPtr(llint_eval_prologue), "eval"); + return generateThunkWithJumpTo(vm, llint_eval_prologue, "eval"); } MacroAssemblerCodeRef programEntryThunkGenerator(VM* vm) { - return generateThunkWithJumpTo(vm, LLInt::getCodeFunctionPtr(llint_program_prologue), "program"); -} - -MacroAssemblerCodeRef moduleProgramEntryThunkGenerator(VM* vm) -{ - return generateThunkWithJumpTo(vm, LLInt::getCodeFunctionPtr(llint_module_program_prologue), "module_program"); + return generateThunkWithJumpTo(vm, llint_program_prologue, "program"); } } // namespace LLInt +#endif // ENABLE(LLINT) #else // ENABLE(JIT) // Non-JIT (i.e. C Loop LLINT) case: -EncodedJSValue vmEntryToJavaScript(void* executableAddress, VM* vm, ProtoCallFrame* protoCallFrame) +typedef JSValue (*ExecuteCode) (CallFrame*, void* executableAddress); + +template<ExecuteCode execute> +EncodedJSValue doCallToJavaScript(void* executableAddress, ProtoCallFrame* protoCallFrame) { - JSValue result = CLoop::execute(llint_vm_entry_to_javascript, executableAddress, vm, protoCallFrame); + CodeBlock* codeBlock = protoCallFrame->codeBlock(); + JSScope* scope = protoCallFrame->scope(); + JSObject* callee = protoCallFrame->callee(); + int argCountIncludingThis = protoCallFrame->argumentCountIncludingThis(); + int argCount = protoCallFrame->argumentCount(); + JSValue thisValue = protoCallFrame->thisValue(); + JSStack& stack = scope->vm()->interpreter->stack(); + + CallFrame* newCallFrame = stack.pushFrame(codeBlock, scope, argCountIncludingThis, callee); + if (UNLIKELY(!newCallFrame)) { + JSGlobalObject* globalObject = scope->globalObject(); + ExecState* exec = globalObject->globalExec(); + return JSValue::encode(throwStackOverflowError(exec)); + } + + // Set the arguments for the callee: + newCallFrame->setThisValue(thisValue); + for (int i = 0; i < argCount; ++i) + newCallFrame->setArgument(i, protoCallFrame->argument(i)); + + JSValue result = execute(newCallFrame, executableAddress); + + stack.popFrame(newCallFrame); + return JSValue::encode(result); } -EncodedJSValue vmEntryToNative(void* executableAddress, VM* vm, ProtoCallFrame* protoCallFrame) +static inline JSValue executeJS(CallFrame* newCallFrame, void* executableAddress) { - JSValue result = CLoop::execute(llint_vm_entry_to_native, executableAddress, vm, protoCallFrame); - return JSValue::encode(result); + Opcode entryOpcode = *reinterpret_cast<Opcode*>(&executableAddress); + return CLoop::execute(newCallFrame, entryOpcode); } -extern "C" VMEntryRecord* vmEntryRecord(VMEntryFrame* entryFrame) +EncodedJSValue callToJavaScript(void* executableAddress, ExecState**, ProtoCallFrame* protoCallFrame, Register*) { - // The C Loop doesn't have any callee save registers, so the VMEntryRecord is allocated at the base of the frame. - intptr_t stackAlignment = stackAlignmentBytes(); - intptr_t VMEntryTotalFrameSize = (sizeof(VMEntryRecord) + (stackAlignment - 1)) & ~(stackAlignment - 1); - return reinterpret_cast<VMEntryRecord*>(static_cast<char*>(entryFrame) - VMEntryTotalFrameSize); + return doCallToJavaScript<executeJS>(executableAddress, protoCallFrame); } +static inline JSValue executeNative(CallFrame* newCallFrame, void* executableAddress) +{ + NativeFunction function = reinterpret_cast<NativeFunction>(executableAddress); + return JSValue::decode(function(newCallFrame)); +} + +EncodedJSValue callToNativeFunction(void* executableAddress, ExecState**, ProtoCallFrame* protoCallFrame, Register*) +{ + return doCallToJavaScript<executeNative>(executableAddress, protoCallFrame); +} #endif // ENABLE(JIT) |