X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/6fe7ccc865dc7d7541b93c5bcaf6368d2c98a174..4be4e30906bcb8ee30b4d189205cb70bad6707ce:/jit/SpecializedThunkJIT.h diff --git a/jit/SpecializedThunkJIT.h b/jit/SpecializedThunkJIT.h index 74e94ea..9a0e0a3 100644 --- a/jit/SpecializedThunkJIT.h +++ b/jit/SpecializedThunkJIT.h @@ -37,12 +37,10 @@ namespace JSC { class SpecializedThunkJIT : public JSInterfaceJIT { public: static const int ThisArgument = -1; - SpecializedThunkJIT(int expectedArgCount, JSGlobalData* globalData) - : m_expectedArgCount(expectedArgCount) - , m_globalData(globalData) + SpecializedThunkJIT(int expectedArgCount) { // Check that we have the expected number of arguments - m_failures.append(branch32(NotEqual, payloadFor(RegisterFile::ArgumentCount), TrustedImm32(expectedArgCount + 1))); + m_failures.append(branch32(NotEqual, payloadFor(JSStack::ArgumentCount), TrustedImm32(expectedArgCount + 1))); } void loadDoubleArgument(int argument, FPRegisterID dst, RegisterID scratch) @@ -57,10 +55,10 @@ namespace JSC { m_failures.append(emitLoadJSCell(src, dst)); } - void loadJSStringArgument(int argument, RegisterID dst) + void loadJSStringArgument(VM& vm, int argument, RegisterID dst) { loadCellArgument(argument, dst); - m_failures.append(branchPtr(NotEqual, Address(dst, JSCell::classInfoOffset()), TrustedImmPtr(&JSString::s_info))); + m_failures.append(branchPtr(NotEqual, Address(dst, JSCell::structureOffset()), TrustedImmPtr(vm.stringStructure.get()))); } void loadInt32Argument(int argument, RegisterID dst, Jump& failTarget) @@ -85,16 +83,16 @@ namespace JSC { { if (src != regT0) move(src, regT0); - loadPtr(payloadFor(RegisterFile::CallerFrame, callFrameRegister), callFrameRegister); + loadPtr(payloadFor(JSStack::CallerFrame, callFrameRegister), callFrameRegister); ret(); } void returnDouble(FPRegisterID src) { #if USE(JSVALUE64) - moveDoubleToPtr(src, regT0); - Jump zero = branchTestPtr(Zero, regT0); - subPtr(tagTypeNumberRegister, regT0); + moveDoubleTo64(src, regT0); + Jump zero = branchTest64(Zero, regT0); + sub64(tagTypeNumberRegister, regT0); Jump done = jump(); zero.link(this); move(tagTypeNumberRegister, regT0); @@ -110,7 +108,7 @@ namespace JSC { lowNonZero.link(this); highNonZero.link(this); #endif - loadPtr(payloadFor(RegisterFile::CallerFrame, callFrameRegister), callFrameRegister); + loadPtr(payloadFor(JSStack::CallerFrame, callFrameRegister), callFrameRegister); ret(); } @@ -119,7 +117,7 @@ namespace JSC { if (src != regT0) move(src, regT0); tagReturnAsInt32(); - loadPtr(payloadFor(RegisterFile::CallerFrame, callFrameRegister), callFrameRegister); + loadPtr(payloadFor(JSStack::CallerFrame, callFrameRegister), callFrameRegister); ret(); } @@ -128,17 +126,17 @@ namespace JSC { if (src != regT0) move(src, regT0); tagReturnAsJSCell(); - loadPtr(payloadFor(RegisterFile::CallerFrame, callFrameRegister), callFrameRegister); + loadPtr(payloadFor(JSStack::CallerFrame, callFrameRegister), callFrameRegister); ret(); } - MacroAssemblerCodeRef finalize(JSGlobalData& globalData, MacroAssemblerCodePtr fallback) + MacroAssemblerCodeRef finalize(VM& vm, MacroAssemblerCodePtr fallback, const char* thunkKind) { - LinkBuffer patchBuffer(globalData, this, GLOBAL_THUNK_ID); + LinkBuffer patchBuffer(vm, this, GLOBAL_THUNK_ID); patchBuffer.link(m_failures, CodeLocationLabel(fallback)); for (unsigned i = 0; i < m_calls.size(); i++) patchBuffer.link(m_calls[i].first, m_calls[i].second); - return patchBuffer.finalizeCode(); + return FINALIZE_CODE(patchBuffer, ("Specialized thunk for %s", thunkKind)); } // Assumes that the target function uses fpRegister0 as the first argument @@ -147,13 +145,22 @@ namespace JSC { { m_calls.append(std::make_pair(call(), function)); } + + void callDoubleToDoublePreservingReturn(FunctionPtr function) + { + if (!isX86()) + preserveReturnAddressAfterCall(regT3); + callDoubleToDouble(function); + if (!isX86()) + restoreReturnAddressBeforeReturn(regT3); + } private: void tagReturnAsInt32() { #if USE(JSVALUE64) - orPtr(tagTypeNumberRegister, regT0); + or64(tagTypeNumberRegister, regT0); #else move(TrustedImm32(JSValue::Int32Tag), regT1); #endif @@ -166,8 +173,6 @@ namespace JSC { #endif } - int m_expectedArgCount; - JSGlobalData* m_globalData; MacroAssembler::JumpList m_failures; Vector > m_calls; };