Changeset 40813 in webkit
- Timestamp:
- Feb 10, 2009 12:43:32 AM (15 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r40811 r40813 1 2009-02-09 Gavin Barraclough <barraclough@apple.com> 2 3 Reviewed by Oliver Hunt. 4 5 Provide a class type for a generated block of JIT code. 6 Also changes the return address -> bytecode index map to 7 track the return addess as an unsigned offset into the code 8 instead of a ptrdiff_t in terms of void**s - the latter is 9 equal to the actual offset / sizeof(void*), making it a 10 potentially lossy representation. 11 12 * JavaScriptCore.xcodeproj/project.pbxproj: 13 * assembler/AbstractMacroAssembler.h: 14 (JSC::AbstractMacroAssembler::PatchBuffer::returnAddressOffset): 15 * assembler/X86Assembler.h: 16 (JSC::X86Assembler::getCallReturnOffset): 17 * bytecode/CodeBlock.h: 18 (JSC::CallReturnOffsetToBytecodeIndex::CallReturnOffsetToBytecodeIndex): 19 (JSC::getCallReturnOffset): 20 (JSC::CodeBlock::getBytecodeIndex): 21 (JSC::CodeBlock::jitCode): 22 (JSC::CodeBlock::callReturnIndexVector): 23 * interpreter/Interpreter.cpp: 24 (JSC::Interpreter::execute): 25 (JSC::Interpreter::cti_vm_dontLazyLinkCall): 26 (JSC::Interpreter::cti_vm_lazyLinkCall): 27 * jit/JIT.cpp: 28 (JSC::JIT::privateCompile): 29 * jit/JIT.h: 30 (JSC::): 31 * jit/JITCall.cpp: 32 (JSC::JIT::linkCall): 33 * jit/JITCode.h: Added. 34 (JSC::): 35 (JSC::JITCode::JITCode): 36 (JSC::JITCode::operator bool): 37 (JSC::JITCode::addressForCall): 38 (JSC::JITCode::offsetOf): 39 (JSC::JITCode::execute): 40 1 41 2009-02-09 John Grabowski <jrg@chromium.org> 2 42 -
trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r40678 r40813 121 121 86CC85A30EE79B7400288682 /* JITCall.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86CC85A20EE79B7400288682 /* JITCall.cpp */; }; 122 122 86CC85C40EE7A89400288682 /* JITPropertyAccess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86CC85C30EE7A89400288682 /* JITPropertyAccess.cpp */; }; 123 86CCEFDE0F413F8900FD7F9E /* JITCode.h in Headers */ = {isa = PBXBuildFile; fileRef = 86CCEFDD0F413F8900FD7F9E /* JITCode.h */; }; 123 124 905B02AE0E28640F006DF882 /* RefCountedLeakCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 905B02AD0E28640F006DF882 /* RefCountedLeakCounter.cpp */; }; 124 125 90D3469C0E285280009492EE /* RefCountedLeakCounter.h in Headers */ = {isa = PBXBuildFile; fileRef = 90D3469B0E285280009492EE /* RefCountedLeakCounter.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 596 597 86CC85A20EE79B7400288682 /* JITCall.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITCall.cpp; sourceTree = "<group>"; }; 597 598 86CC85C30EE7A89400288682 /* JITPropertyAccess.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITPropertyAccess.cpp; sourceTree = "<group>"; }; 599 86CCEFDD0F413F8900FD7F9E /* JITCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITCode.h; sourceTree = "<group>"; }; 598 600 905B02AD0E28640F006DF882 /* RefCountedLeakCounter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RefCountedLeakCounter.cpp; sourceTree = "<group>"; }; 599 601 90D3469B0E285280009492EE /* RefCountedLeakCounter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RefCountedLeakCounter.h; sourceTree = "<group>"; }; … … 973 975 isa = PBXGroup; 974 976 children = ( 977 86CCEFDD0F413F8900FD7F9E /* JITCode.h */, 975 978 A7B48DB60EE74CFC00DCBDB6 /* ExecutableAllocator.cpp */, 976 979 A7B48DB50EE74CFC00DCBDB6 /* ExecutableAllocator.h */, … … 1731 1734 860161E50F3A83C100F84710 /* MacroAssemblerX86_64.h in Headers */, 1732 1735 860161E60F3A83C100F84710 /* MacroAssemblerX86Common.h in Headers */, 1736 86CCEFDE0F413F8900FD7F9E /* JITCode.h in Headers */, 1733 1737 ); 1734 1738 runOnlyForDeploymentPostprocessing = 0; -
trunk/JavaScriptCore/assembler/AbstractMacroAssembler.h
r40660 r40813 359 359 } 360 360 361 ptrdiff_t returnAddressOffset(Jump call) 362 { 363 return AssemblerType::getCallReturnOffset(call.m_jmp); 364 } 365 361 366 void setPtr(DataLabelPtr label, void* value) 362 367 { -
trunk/JavaScriptCore/assembler/X86Assembler.h
r40562 r40813 1247 1247 } 1248 1248 1249 static ptrdiff_t getCallReturnOffset(JmpSrc call) 1250 { 1251 return call.m_offset; 1252 } 1253 1249 1254 static void* getRelocatedAddress(void* code, JmpSrc jump) 1250 1255 { -
trunk/JavaScriptCore/bytecode/CodeBlock.h
r40046 r40813 33 33 #include "EvalCodeCache.h" 34 34 #include "Instruction.h" 35 #include "JITCode.h" 35 36 #include "JSGlobalObject.h" 36 37 #include "JumpTable.h" … … 66 67 // The code, and the associated pool from which it was allocated. 67 68 struct JITCodeRef { 68 void*code;69 JITCode code; 69 70 #ifndef NDEBUG 70 71 unsigned codeSize; … … 162 163 }; 163 164 164 struct PC { 165 PC(ptrdiff_t nativePCOffset, unsigned bytecodeIndex) 166 : nativePCOffset(nativePCOffset) 165 // This structure is used to map from a call return location 166 // (given as an offset in bytes into the JIT code) back to 167 // the bytecode index of the corresponding bytecode operation. 168 // This is then used to look up the corresponding handler. 169 struct CallReturnOffsetToBytecodeIndex { 170 CallReturnOffsetToBytecodeIndex(unsigned callReturnOffset, unsigned bytecodeIndex) 171 : callReturnOffset(callReturnOffset) 167 172 , bytecodeIndex(bytecodeIndex) 168 173 { 169 174 } 170 175 171 ptrdiff_t nativePCOffset;176 unsigned callReturnOffset; 172 177 unsigned bytecodeIndex; 173 178 }; … … 185 190 } 186 191 187 inline ptrdiff_t getNativePCOffset(PC* pc)192 inline unsigned getCallReturnOffset(CallReturnOffsetToBytecodeIndex* pc) 188 193 { 189 return pc-> nativePCOffset;194 return pc->callReturnOffset; 190 195 } 191 196 … … 312 317 { 313 318 reparseForExceptionInfoIfNecessary(callFrame); 314 ptrdiff_t nativePCOffset = reinterpret_cast<void**>(nativePC) - reinterpret_cast<void**>(m_jitCode.code); 315 return binaryChop<PC, ptrdiff_t, getNativePCOffset>(m_exceptionInfo->m_pcVector.begin(), m_exceptionInfo->m_pcVector.size(), nativePCOffset)->bytecodeIndex; 319 return binaryChop<CallReturnOffsetToBytecodeIndex, unsigned, getCallReturnOffset>(m_exceptionInfo->m_callReturnIndexVector.begin(), m_exceptionInfo->m_callReturnIndexVector.size(), m_jitCode.code.offsetOf(nativePC))->bytecodeIndex; 316 320 } 317 321 … … 326 330 #if ENABLE(JIT) 327 331 void setJITCode(JITCodeRef& jitCode); 328 void*jitCode() { return m_jitCode.code; }332 JITCode jitCode() { return m_jitCode.code; } 329 333 ExecutablePool* executablePool() { return m_jitCode.executablePool.get(); } 330 334 #endif … … 391 395 392 396 #if ENABLE(JIT) 393 Vector< PC>& pcVector() { ASSERT(m_exceptionInfo); return m_exceptionInfo->m_pcVector; }397 Vector<CallReturnOffsetToBytecodeIndex>& callReturnIndexVector() { ASSERT(m_exceptionInfo); return m_exceptionInfo->m_callReturnIndexVector; } 394 398 #endif 395 399 … … 511 515 512 516 #if ENABLE(JIT) 513 Vector< PC> m_pcVector;517 Vector<CallReturnOffsetToBytecodeIndex> m_callReturnIndexVector; 514 518 #endif 515 519 }; -
trunk/JavaScriptCore/interpreter/Interpreter.cpp
r40396 r40813 866 866 if (!codeBlock->jitCode()) 867 867 JIT::compile(scopeChain->globalData, codeBlock); 868 result = JIT::execute(codeBlock->jitCode(),&m_registerFile, newCallFrame, scopeChain->globalData, exception);868 result = codeBlock->jitCode().execute(&m_registerFile, newCallFrame, scopeChain->globalData, exception); 869 869 #else 870 870 result = privateExecute(Normal, &m_registerFile, newCallFrame, exception); … … 932 932 if (!codeBlock->jitCode()) 933 933 JIT::compile(scopeChain->globalData, codeBlock); 934 result = JIT::execute(codeBlock->jitCode(),&m_registerFile, newCallFrame, scopeChain->globalData, exception);934 result = codeBlock->jitCode().execute(&m_registerFile, newCallFrame, scopeChain->globalData, exception); 935 935 #else 936 936 result = privateExecute(Normal, &m_registerFile, newCallFrame, exception); … … 1024 1024 if (!codeBlock->jitCode()) 1025 1025 JIT::compile(scopeChain->globalData, codeBlock); 1026 result = JIT::execute(codeBlock->jitCode(),&m_registerFile, newCallFrame, scopeChain->globalData, exception);1026 result = codeBlock->jitCode().execute(&m_registerFile, newCallFrame, scopeChain->globalData, exception); 1027 1027 #else 1028 1028 result = privateExecute(Normal, &m_registerFile, newCallFrame, exception); … … 4830 4830 ctiPatchCallByReturnAddress(ARG_returnAddress2, ARG_globalData->interpreter->m_ctiVirtualCallLink); 4831 4831 4832 return codeBlock->jitCode() ;4832 return codeBlock->jitCode().addressForCall(); 4833 4833 } 4834 4834 … … 4845 4845 JIT::linkCall(callee, codeBlock, codeBlock->jitCode(), callLinkInfo, ARG_int3); 4846 4846 4847 return codeBlock->jitCode() ;4847 return codeBlock->jitCode().addressForCall(); 4848 4848 } 4849 4849 -
trunk/JavaScriptCore/jit/JIT.cpp
r40562 r40813 1709 1709 1710 1710 if (m_codeBlock->hasExceptionInfo()) { 1711 m_codeBlock-> pcVector().reserveCapacity(m_calls.size());1711 m_codeBlock->callReturnIndexVector().reserveCapacity(m_calls.size()); 1712 1712 for (Vector<CallRecord>::iterator iter = m_calls.begin(); iter != m_calls.end(); ++iter) 1713 m_codeBlock-> pcVector().append(PC(reinterpret_cast<void**>(patchBuffer.addressOf(iter->from)) - reinterpret_cast<void**>(code), iter->bytecodeIndex));1713 m_codeBlock->callReturnIndexVector().append(CallReturnOffsetToBytecodeIndex(patchBuffer.returnAddressOffset(iter->from), iter->bytecodeIndex)); 1714 1714 } 1715 1715 -
trunk/JavaScriptCore/jit/JIT.h
r40004 r40813 28 28 29 29 #include <wtf/Platform.h> 30 #include <bytecode/SamplingTool.h>31 30 32 31 #if ENABLE(JIT) … … 35 34 36 35 #include "Interpreter.h" 36 #include "JITCode.h" 37 37 #include "Opcode.h" 38 38 #include "RegisterFile.h" 39 39 #include "MacroAssembler.h" 40 40 #include "Profiler.h" 41 #include <bytecode/SamplingTool.h> 41 42 #include <wtf/AlwaysInline.h> 42 43 #include <wtf/Vector.h> … … 201 202 202 203 extern "C" { 203 JSValueEncodedAsPointer* ctiTrampoline(204 #if PLATFORM(X86_64)205 // FIXME: (bug #22910) this will force all arguments onto the stack (regparm(0) does not appear to have any effect).206 // We can allow register passing here, and move the writes of these values into the trampoline.207 void*, void*, void*, void*, void*, void*,208 #endif209 void* code, RegisterFile*, CallFrame*, JSValuePtr* exception, Profiler**, JSGlobalData*);210 204 void ctiVMThrowTrampoline(); 211 205 }; … … 348 342 } 349 343 350 static void linkCall(JSFunction* callee, CodeBlock* calleeCodeBlock, void*ctiCode, CallLinkInfo* callLinkInfo, int callerArgCount);344 static void linkCall(JSFunction* callee, CodeBlock* calleeCodeBlock, JITCode ctiCode, CallLinkInfo* callLinkInfo, int callerArgCount); 351 345 static void unlinkCall(CallLinkInfo*); 352 353 inline static JSValuePtr execute(void* code, RegisterFile* registerFile, CallFrame* callFrame, JSGlobalData* globalData, JSValuePtr* exception)354 {355 return JSValuePtr::decode(ctiTrampoline(356 #if PLATFORM(X86_64)357 0, 0, 0, 0, 0, 0,358 #endif359 code, registerFile, callFrame, exception, Profiler::enabledProfilerReference(), globalData));360 }361 346 362 347 private: -
trunk/JavaScriptCore/jit/JITCall.cpp
r40562 r40813 53 53 } 54 54 55 void JIT::linkCall(JSFunction* callee, CodeBlock* calleeCodeBlock, void*ctiCode, CallLinkInfo* callLinkInfo, int callerArgCount)55 void JIT::linkCall(JSFunction* callee, CodeBlock* calleeCodeBlock, JITCode ctiCode, CallLinkInfo* callLinkInfo, int callerArgCount) 56 56 { 57 57 // Currently we only link calls with the exact number of arguments. … … 62 62 63 63 DataLabelPtr::patch(callLinkInfo->hotPathBegin, callee); 64 Jump::patch(callLinkInfo->hotPathOther, ctiCode );64 Jump::patch(callLinkInfo->hotPathOther, ctiCode.addressForCall()); 65 65 } 66 66
Note: See TracChangeset
for help on using the changeset viewer.