diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-05-20 09:56:07 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-05-20 09:56:07 +0000 |
commit | 41386e9cb918eed93b3f13648cbef387e371e451 (patch) | |
tree | a97f9d7bd1d9d091833286085f72da9d83fd0606 /Source/JavaScriptCore/jit/JITCode.cpp | |
parent | e15dd966d523731101f70ccf768bba12435a0208 (diff) | |
download | WebKitGtk-tarball-41386e9cb918eed93b3f13648cbef387e371e451.tar.gz |
webkitgtk-2.4.9webkitgtk-2.4.9
Diffstat (limited to 'Source/JavaScriptCore/jit/JITCode.cpp')
-rw-r--r-- | Source/JavaScriptCore/jit/JITCode.cpp | 199 |
1 files changed, 52 insertions, 147 deletions
diff --git a/Source/JavaScriptCore/jit/JITCode.cpp b/Source/JavaScriptCore/jit/JITCode.cpp index 5310b5da6..213b7000c 100644 --- a/Source/JavaScriptCore/jit/JITCode.cpp +++ b/Source/JavaScriptCore/jit/JITCode.cpp @@ -27,9 +27,7 @@ #include "JITCode.h" #include "LLIntThunks.h" -#include "JSCInlines.h" -#include "ProtoCallFrame.h" -#include "RegisterPreservationWrapperGenerator.h" +#include "Operations.h" #include <wtf/PrintStream.h> namespace JSC { @@ -43,42 +41,11 @@ JITCode::~JITCode() { } -const char* JITCode::typeName(JITType jitType) +JSValue JITCode::execute(VM* vm, ProtoCallFrame* protoCallFrame, Register* topOfStack) { - switch (jitType) { - case None: - return "None"; - case HostCallThunk: - return "Host"; - case InterpreterThunk: - return "LLInt"; - case BaselineJIT: - return "Baseline"; - case DFGJIT: - return "DFG"; - case FTLJIT: - return "FTL"; - default: - CRASH(); - return ""; - } -} - -void JITCode::validateReferences(const TrackedReferences&) -{ -} - -JSValue JITCode::execute(VM* vm, ProtoCallFrame* protoCallFrame) -{ - void* entryAddress; - JSFunction* function = jsDynamicCast<JSFunction*>(protoCallFrame->callee()); + ASSERT(!vm->topCallFrame || ((Register*)(vm->topCallFrame) >= topOfStack)); - if (!function || !protoCallFrame->needArityCheck()) { - ASSERT(!protoCallFrame->needArityCheck()); - entryAddress = executableAddress(); - } else - entryAddress = addressForCall(*vm, function->executable(), MustCheckArity, RegisterPreservationNotRequired).executableAddress(); - JSValue result = JSValue::decode(vmEntryToJavaScript(entryAddress, vm, protoCallFrame)); + JSValue result = JSValue::decode(callToJavaScript(executableAddress(), &vm->topCallFrame, protoCallFrame, topOfStack)); return vm->exception() ? jsNull() : result; } @@ -106,38 +73,52 @@ FTL::ForOSREntryJITCode* JITCode::ftlForOSREntry() return 0; } -JITCodeWithCodeRef::JITCodeWithCodeRef(JITType jitType) +PassRefPtr<JITCode> JITCode::hostFunction(JITCode::CodeRef code) +{ + return adoptRef(new DirectJITCode(code, HostCallThunk)); +} + +DirectJITCode::DirectJITCode(JITType jitType) : JITCode(jitType) { } -JITCodeWithCodeRef::JITCodeWithCodeRef(CodeRef ref, JITType jitType) +DirectJITCode::DirectJITCode(const JITCode::CodeRef ref, JITType jitType) : JITCode(jitType) , m_ref(ref) { } -JITCodeWithCodeRef::~JITCodeWithCodeRef() +DirectJITCode::~DirectJITCode() +{ +} + +void DirectJITCode::initializeCodeRef(const JITCode::CodeRef ref) { - if ((Options::showDisassembly() || (isOptimizingJIT(jitType()) && Options::showDFGDisassembly())) - && m_ref.executableMemory()) - dataLog("Destroying JIT code at ", pointerDump(m_ref.executableMemory()), "\n"); + RELEASE_ASSERT(!m_ref); + m_ref = ref; } -void* JITCodeWithCodeRef::executableAddressAtOffset(size_t offset) +JITCode::CodePtr DirectJITCode::addressForCall() +{ + RELEASE_ASSERT(m_ref); + return m_ref.code(); +} + +void* DirectJITCode::executableAddressAtOffset(size_t offset) { RELEASE_ASSERT(m_ref); return reinterpret_cast<char*>(m_ref.code().executableAddress()) + offset; } -void* JITCodeWithCodeRef::dataAddressAtOffset(size_t offset) +void* DirectJITCode::dataAddressAtOffset(size_t offset) { RELEASE_ASSERT(m_ref); ASSERT(offset <= size()); // use <= instead of < because it is valid to ask for an address at the exclusive end of the code. return reinterpret_cast<char*>(m_ref.code().dataLocation()) + offset; } -unsigned JITCodeWithCodeRef::offsetOf(void* pointerIntoCode) +unsigned DirectJITCode::offsetOf(void* pointerIntoCode) { RELEASE_ASSERT(m_ref); intptr_t result = reinterpret_cast<intptr_t>(pointerIntoCode) - reinterpret_cast<intptr_t>(m_ref.code().executableAddress()); @@ -145,123 +126,47 @@ unsigned JITCodeWithCodeRef::offsetOf(void* pointerIntoCode) return static_cast<unsigned>(result); } -size_t JITCodeWithCodeRef::size() +size_t DirectJITCode::size() { RELEASE_ASSERT(m_ref); return m_ref.size(); } -bool JITCodeWithCodeRef::contains(void* address) +bool DirectJITCode::contains(void* address) { RELEASE_ASSERT(m_ref); return m_ref.executableMemory()->contains(address); } -DirectJITCode::DirectJITCode(JITType jitType) - : JITCodeWithCodeRef(jitType) -{ -} - -DirectJITCode::DirectJITCode(JITCode::CodeRef ref, JITCode::CodePtr withArityCheck, JITType jitType) - : JITCodeWithCodeRef(ref, jitType) - , m_withArityCheck(withArityCheck) -{ -} - -DirectJITCode::~DirectJITCode() -{ -} - -void DirectJITCode::initializeCodeRef(JITCode::CodeRef ref, JITCode::CodePtr withArityCheck) -{ - RELEASE_ASSERT(!m_ref); - m_ref = ref; - m_withArityCheck = withArityCheck; -} - -DirectJITCode::RegisterPreservationWrappers* DirectJITCode::ensureWrappers() -{ - if (!m_wrappers) - m_wrappers = std::make_unique<RegisterPreservationWrappers>(); - return m_wrappers.get(); -} - -JITCode::CodePtr DirectJITCode::addressForCall( - VM& vm, ExecutableBase* executable, ArityCheckMode arity, - RegisterPreservationMode registers) -{ - switch (arity) { - case ArityCheckNotRequired: - switch (registers) { - case RegisterPreservationNotRequired: - RELEASE_ASSERT(m_ref); - return m_ref.code(); - case MustPreserveRegisters: { -#if ENABLE(JIT) - RegisterPreservationWrappers* wrappers = ensureWrappers(); - if (!wrappers->withoutArityCheck) - wrappers->withoutArityCheck = generateRegisterPreservationWrapper(vm, executable, m_ref.code()); - return wrappers->withoutArityCheck.code(); -#else - UNUSED_PARAM(vm); - UNUSED_PARAM(executable); - RELEASE_ASSERT_NOT_REACHED(); -#endif - } } - case MustCheckArity: - switch (registers) { - case RegisterPreservationNotRequired: - RELEASE_ASSERT(m_withArityCheck); - return m_withArityCheck; - case MustPreserveRegisters: { -#if ENABLE(JIT) - RegisterPreservationWrappers* wrappers = ensureWrappers(); - if (!wrappers->withArityCheck) - wrappers->withArityCheck = generateRegisterPreservationWrapper(vm, executable, m_withArityCheck); - return wrappers->withArityCheck.code(); -#else - RELEASE_ASSERT_NOT_REACHED(); -#endif - } } - } - RELEASE_ASSERT_NOT_REACHED(); - return CodePtr(); -} - -NativeJITCode::NativeJITCode(JITType jitType) - : JITCodeWithCodeRef(jitType) -{ -} - -NativeJITCode::NativeJITCode(CodeRef ref, JITType jitType) - : JITCodeWithCodeRef(ref, jitType) -{ -} - -NativeJITCode::~NativeJITCode() -{ -} - -void NativeJITCode::initializeCodeRef(CodeRef ref) -{ - ASSERT(!m_ref); - m_ref = ref; -} - -JITCode::CodePtr NativeJITCode::addressForCall( - VM&, ExecutableBase*, ArityCheckMode, RegisterPreservationMode) -{ - RELEASE_ASSERT(!!m_ref); - return m_ref.code(); -} - } // namespace JSC namespace WTF { void printInternal(PrintStream& out, JSC::JITCode::JITType type) { - out.print(JSC::JITCode::typeName(type)); + switch (type) { + case JSC::JITCode::None: + out.print("None"); + return; + case JSC::JITCode::HostCallThunk: + out.print("Host"); + return; + case JSC::JITCode::InterpreterThunk: + out.print("LLInt"); + return; + case JSC::JITCode::BaselineJIT: + out.print("Baseline"); + return; + case JSC::JITCode::DFGJIT: + out.print("DFG"); + return; + case JSC::JITCode::FTLJIT: + out.print("FTL"); + return; + default: + CRASH(); + return; + } } } // namespace WTF |