Changeset 39370 in webkit
- Timestamp:
- Dec 17, 2008 7:38:10 PM (15 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r39368 r39370 1 2008-12-17 Gavin Barraclough <barraclough@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 print("Hello, 64-bit jitted world!"); 6 Get hello-world working through the JIT, on x86-64. 7 8 * assembler/X86Assembler.h: 9 Fix encoding of opcode + RegisterID format instructions for 64-bit. 10 * interpreter/Interpreter.cpp: 11 * interpreter/Interpreter.h: 12 Make VoidPtrPair actually be a pair of void*s. 13 (Possibly should make this change for 32-bit Mac platforms, too - but won't change 32-bit behaviour in this patch). 14 * jit/JIT.cpp: 15 * jit/JIT.h: 16 Provide names for the timeoutCheckRegister & callFrameRegister on x86-64, 17 force x86-64 ctiTrampoline arguments onto the stack, 18 implement the asm trampolines for x86-64, 19 implement the restoreArgumentReference methods for x86-64 calling conventions. 20 * jit/JITCall.cpp: 21 * jit/JITInlineMethods.h: 22 * wtf/Platform.h: 23 Add switch settings to ENABLE(JIT), on PLATFORM(X86_64) (currently still disabled). 24 1 25 2008-12-17 Sam Weinig <sam@webkit.org> 2 26 -
trunk/JavaScriptCore/assembler/X86Assembler.h
r39342 r39370 1118 1118 { 1119 1119 m_buffer.ensureSpace(maxInstructionSize); 1120 emitRexIfNeeded( reg, 0, 0);1121 m_buffer.putByteUnchecked(opcode + reg);1120 emitRexIfNeeded(0, 0, reg); 1121 m_buffer.putByteUnchecked(opcode + (reg & 7)); 1122 1122 } 1123 1123 … … 1206 1206 { 1207 1207 m_buffer.ensureSpace(maxInstructionSize); 1208 emitRexW( reg, 0, 0);1209 m_buffer.putByteUnchecked(opcode + reg);1208 emitRexW(0, 0, reg); 1209 m_buffer.putByteUnchecked(opcode + (reg & 7)); 1210 1210 } 1211 1211 -
trunk/JavaScriptCore/interpreter/Interpreter.cpp
r39354 r39370 4211 4211 #endif 4212 4212 4213 #if USE(CTI_ARGUMENT) 4214 #define SETUP_VL_ARGS 4215 #else 4216 #define SETUP_VL_ARGS va_list vl_args; va_start(vl_args, args) 4217 #endif 4218 4213 4219 #ifndef NDEBUG 4214 4220 … … 4240 4246 }; 4241 4247 4242 #define CTI_STACK_HACK() va_list vl_args; va_start(vl_args, args); StackHack stackHack(&CTI_RETURN_ADDRESS_SLOT)4248 #define CTI_STACK_HACK() SETUP_VL_ARGS; StackHack stackHack(&CTI_RETURN_ADDRESS_SLOT) 4243 4249 #define CTI_SET_RETURN_ADDRESS(address) stackHack.savedReturnAddress = address 4244 4250 #define CTI_RETURN_ADDRESS stackHack.savedReturnAddress … … 4246 4252 #else 4247 4253 4248 #define CTI_STACK_HACK() va_list vl_args; va_start(vl_args, args)4254 #define CTI_STACK_HACK() SETUP_VL_ARGS 4249 4255 #define CTI_SET_RETURN_ADDRESS(address) ctiSetReturnAddress(&CTI_RETURN_ADDRESS_SLOT, address); 4250 4256 #define CTI_RETURN_ADDRESS CTI_RETURN_ADDRESS_SLOT … … 4277 4283 do { \ 4278 4284 VM_THROW_EXCEPTION_AT_END(); \ 4279 VoidPtrPairValue pair = {{ 0, 0 }}; \ 4280 return pair.i; \ 4285 RETURN_PAIR(0, 0); \ 4281 4286 } while (0) 4282 4287 #define VM_THROW_EXCEPTION_AT_END() \ … … 4849 4854 ARG_setCallFrame(oldCallFrame); 4850 4855 throwStackOverflowError(oldCallFrame, ARG_globalData, ARG_returnAddress2, CTI_RETURN_ADDRESS); 4851 VoidPtrPairValue pair = {{ 0, 0 }}; 4852 return pair.i; 4856 RETURN_PAIR(0, 0); 4853 4857 } 4854 4858 … … 4861 4865 } 4862 4866 4863 VoidPtrPairValue pair = {{ newCodeBlock, callFrame }}; 4864 return pair.i; 4867 RETURN_PAIR(newCodeBlock, callFrame); 4865 4868 } 4866 4869 … … 5161 5164 CHECK_FOR_EXCEPTION_AT_END(); 5162 5165 5163 VoidPtrPairValue pair = {{ thisObj, asPointer(result) }}; 5164 return pair.i; 5166 RETURN_PAIR(thisObj, asPointer(result)); 5165 5167 } 5166 5168 ++iter; … … 5442 5444 CHECK_FOR_EXCEPTION_AT_END(); 5443 5445 5444 VoidPtrPairValue pair = {{ asPointer(number), asPointer(jsNumber(ARG_globalData, number->uncheckedGetNumber() + 1)) }}; 5445 return pair.i; 5446 RETURN_PAIR(asPointer(number), asPointer(jsNumber(ARG_globalData, number->uncheckedGetNumber() + 1))); 5446 5447 } 5447 5448 … … 5558 5559 CHECK_FOR_EXCEPTION_AT_END(); 5559 5560 5560 VoidPtrPairValue pair = {{ base, asPointer(result) }}; 5561 return pair.i; 5561 RETURN_PAIR(base, asPointer(result)); 5562 5562 } 5563 5563 ++iter; … … 5627 5627 CHECK_FOR_EXCEPTION_AT_END(); 5628 5628 5629 VoidPtrPairValue pair = {{ asPointer(number), asPointer(jsNumber(ARG_globalData, number->uncheckedGetNumber() - 1)) }}; 5630 return pair.i; 5629 RETURN_PAIR(asPointer(number), asPointer(jsNumber(ARG_globalData, number->uncheckedGetNumber() - 1))); 5631 5630 } 5632 5631 -
trunk/JavaScriptCore/interpreter/Interpreter.h
r39325 r39370 81 81 #endif 82 82 83 #endif 84 83 #endif // USE(FAST_CALL_CTI_ARGUMENT) 84 85 86 // FIXME: Could this be #if COMPILER(MSVC)? - or #if !PLATFORM(MAC)? 87 #if !PLATFORM(X86_64) 85 88 typedef uint64_t VoidPtrPair; 86 87 typedef union 88 { 89 union VoidPtrPairValue { 89 90 struct { void* first; void* second; } s; 90 91 VoidPtrPair i; 91 } VoidPtrPairValue; 92 #endif 92 }; 93 #define RETURN_PAIR(a,b) VoidPtrPairValue pair = {{ a, b }}; return pair.i 94 #else 95 struct VoidPtrPair { 96 void* first; 97 void* second; 98 }; 99 #define RETURN_PAIR(a,b) VoidPtrPair pair = { a, b }; return pair 100 #endif 101 102 #endif // ENABLE(JIT) 93 103 94 104 enum DebugHookID { -
trunk/JavaScriptCore/jit/JIT.cpp
r39342 r39370 110 110 ".globl " SYMBOL_STRING(ctiTrampoline) "\n" 111 111 SYMBOL_STRING(ctiTrampoline) ":" "\n" 112 "int3" "\n" 112 "pushq %rbp" "\n" 113 "movq %rsp, %rbp" "\n" 114 "pushq %r12" "\n" 115 "pushq %r13" "\n" 116 "pushq %rbx" "\n" 117 "subq $0x38, %rsp" "\n" 118 "movq $512, %r12" "\n" 119 "movq 0x70(%rsp), %r13" "\n" // Ox70 = 0x0E * 8, 0x0E = CTI_ARGS_callFrame (see assertion above) 120 "call *0x60(%rsp)" "\n" // Ox60 = 0x0C * 8, 0x0C = CTI_ARGS_code (see assertion above) 121 "addq $0x38, %rsp" "\n" 122 "popq %rbx" "\n" 123 "popq %r13" "\n" 124 "popq %r12" "\n" 125 "popq %rbp" "\n" 126 "ret" "\n" 113 127 ); 114 128 … … 116 130 ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" 117 131 SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" 118 "int3" "\n" 132 #if USE(CTI_ARGUMENT) && !USE(FAST_CALL_CTI_ARGUMENT) 133 "movq %rsp, %rdi" "\n" 134 "call " SYMBOL_STRING(_ZN3JSC11Interpreter12cti_vm_throwEPPv) "\n" 135 #else 136 #error "CTI_ARGUMENT configuration not supported." 137 #endif 138 "addq $0x38, %rsp" "\n" 139 "popq %rbx" "\n" 140 "popq %r13" "\n" 141 "popq %r12" "\n" 142 "popq %rbp" "\n" 143 "ret" "\n" 119 144 ); 120 145 … … 229 254 void JIT::emitSlowScriptCheck() 230 255 { 231 Jump skipTimeout = jnzSub32(Imm32(1), X86::esi);256 Jump skipTimeout = jnzSub32(Imm32(1), timeoutCheckRegister); 232 257 emitCTICall(Interpreter::cti_timeout_check); 233 move(X86::eax, X86::esi);258 move(X86::eax, timeoutCheckRegister); 234 259 skipTimeout.link(this); 235 260 … … 970 995 emitPutJITStubArgFromVirtualRegister(currentInstruction[1].u.operand, 1, X86::ecx); 971 996 emitCTICall(Interpreter::cti_op_throw); 972 __ addl_ir(0x1c, X86::esp); 973 __ pop_r(X86::ebx); 974 __ pop_r(X86::edi); 975 __ pop_r(X86::esi); 976 __ pop_r(X86::ebp); 977 __ ret(); 997 #if PLATFORM(X86_64) 998 addPtr(Imm32(0x38), X86::esp); 999 pop(X86::ebx); 1000 pop(X86::r13); 1001 pop(X86::r12); 1002 pop(X86::ebp); 1003 ret(); 1004 #else 1005 addPtr(Imm32(0x1c), X86::esp); 1006 pop(X86::ebx); 1007 pop(X86::edi); 1008 pop(X86::esi); 1009 pop(X86::ebp); 1010 ret(); 1011 #endif 978 1012 NEXT_OPCODE(op_throw); 979 1013 } … … 1853 1887 } 1854 1888 #endif 1889 #if ENABLE(JIT_OPTIMIZE_CALL) 1855 1890 for (unsigned i = 0; i < m_codeBlock->numberOfCallLinkInfos(); ++i) { 1856 1891 CallLinkInfo& info = m_codeBlock->callLinkInfo(i); … … 1860 1895 info.coldPathOther = X86Assembler::getRelocatedAddress(code, m_callStructureStubCompilationInfo[i].coldPathOther); 1861 1896 } 1897 #endif 1862 1898 1863 1899 m_codeBlock->setJITCode(codeRef); -
trunk/JavaScriptCore/jit/JIT.h
r39351 r39370 189 189 190 190 extern "C" { 191 JSValue* ctiTrampoline(void* code, RegisterFile*, CallFrame*, JSValue** exception, Profiler**, JSGlobalData*); 191 JSValue* ctiTrampoline( 192 #if PLATFORM(X86_64) 193 // FIXME: (bug #22910) this will force all arguments onto the stack (regparm(0) does not appear to have any effect). 194 // We can allow register passing here, and move the writes of these values into the trampoline. 195 void*, void*, void*, void*, void*, void*, 196 #endif 197 void* code, RegisterFile*, CallFrame*, JSValue** exception, Profiler**, JSGlobalData*); 192 198 void ctiVMThrowTrampoline(); 193 199 }; … … 201 207 using MacroAssembler::Label; 202 208 209 #if PLATFORM(X86_64) 210 static const RegisterID timeoutCheckRegister = X86::r12; 211 static const RegisterID callFrameRegister = X86::r13; 212 #else 213 static const RegisterID timeoutCheckRegister = X86::esi; 203 214 static const RegisterID callFrameRegister = X86::edi; 215 #endif 204 216 205 217 static const int repatchGetByIdDefaultStructure = -1; … … 304 316 inline static JSValue* execute(void* code, RegisterFile* registerFile, CallFrame* callFrame, JSGlobalData* globalData, JSValue** exception) 305 317 { 306 return ctiTrampoline(code, registerFile, callFrame, exception, Profiler::enabledProfilerReference(), globalData); 318 return ctiTrampoline( 319 #if PLATFORM(X86_64) 320 0, 0, 0, 0, 0, 0, 321 #endif 322 code, registerFile, callFrame, exception, Profiler::enabledProfilerReference(), globalData); 307 323 } 308 324 -
trunk/JavaScriptCore/jit/JITCall.cpp
r39351 r39370 74 74 void JIT::compileOpCallInitializeCallFrame() 75 75 { 76 store32(X86::edx, Address( X86::edi, RegisterFile::ArgumentCount * static_cast<int>(sizeof(Register))));76 store32(X86::edx, Address(callFrameRegister, RegisterFile::ArgumentCount * static_cast<int>(sizeof(Register)))); 77 77 78 78 loadPtr(Address(X86::ecx, FIELD_OFFSET(JSFunction, m_scopeChain) + FIELD_OFFSET(ScopeChain, m_node)), X86::edx); // newScopeChain 79 79 80 storePtr(ImmPtr(noValue()), Address( X86::edi, RegisterFile::OptionalCalleeArguments * static_cast<int>(sizeof(Register))));81 storePtr(X86::ecx, Address( X86::edi, RegisterFile::Callee * static_cast<int>(sizeof(Register))));82 storePtr(X86::edx, Address( X86::edi, RegisterFile::ScopeChain * static_cast<int>(sizeof(Register))));80 storePtr(ImmPtr(noValue()), Address(callFrameRegister, RegisterFile::OptionalCalleeArguments * static_cast<int>(sizeof(Register)))); 81 storePtr(X86::ecx, Address(callFrameRegister, RegisterFile::Callee * static_cast<int>(sizeof(Register)))); 82 storePtr(X86::edx, Address(callFrameRegister, RegisterFile::ScopeChain * static_cast<int>(sizeof(Register)))); 83 83 } 84 84 … … 158 158 159 159 // Speculatively roll the callframe, assuming argCount will match the arity. 160 storePtr( X86::edi, Address(X86::edi, (RegisterFile::CallerFrame + registerOffset) * static_cast<int>(sizeof(Register))));161 addPtr(Imm32(registerOffset * static_cast<int>(sizeof(Register))), X86::edi);160 storePtr(callFrameRegister, Address(callFrameRegister, (RegisterFile::CallerFrame + registerOffset) * static_cast<int>(sizeof(Register)))); 161 addPtr(Imm32(registerOffset * static_cast<int>(sizeof(Register))), callFrameRegister); 162 162 move(Imm32(argCount), X86::edx); 163 163 -
trunk/JavaScriptCore/jit/JITInlineMethods.h
r39325 r39370 206 206 ALWAYS_INLINE void JIT::restoreArgumentReference() 207 207 { 208 #if PLATFORM(X86_64) 209 #if USE(FAST_CALL_CTI_ARGUMENT) || !USE(CTI_ARGUMENT) 210 #error "CTI_ARGUMENT configuration not supported." 211 #endif 212 move(X86::esp, X86::edi); 213 #else 208 214 #if USE(CTI_ARGUMENT) 209 215 #if USE(FAST_CALL_CTI_ARGUMENT) 210 m _assembler.movl_rr(X86::esp, X86::ecx);216 move(X86::esp, X86::ecx); 211 217 #else 212 m_assembler.movl_rm(X86::esp, 0, X86::esp); 218 storePtr(X86::esp, X86::esp); 219 #endif 213 220 #endif 214 221 #endif … … 218 225 { 219 226 #if USE(CTI_ARGUMENT) && USE(FAST_CALL_CTI_ARGUMENT) 220 m _assembler.movl_rr(X86::esp, X86::ecx);221 m_assembler.addl_ir(4, X86::ecx);227 move(X86::esp, X86::ecx); 228 addPtr(Imm32(4), X86::ecx); 222 229 #endif 223 230 } -
trunk/JavaScriptCore/wtf/Platform.h
r39362 r39370 435 435 #define ENABLE_JIT_OPTIMIZE_ARITHMETIC 1 436 436 #endif 437 #if !defined(ENABLE_JIT) && PLATFORM(X86_64) && PLATFORM(MAC) 438 #define ENABLE_JIT 0 439 #define WTF_USE_CTI_ARGUMENT 0 440 #endif 437 441 438 442 /* WREC supports x86 & x86-64, and has been tested on Mac and Windows ('cept on 64-bit on Mac). */
Note: See TracChangeset
for help on using the changeset viewer.