Changeset 279598 in webkit
- Timestamp:
- Jul 6, 2021, 10:59:46 AM (4 years ago)
- Location:
- branches/safari-612.1.22.3-branch/Source/JavaScriptCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-612.1.22.3-branch/Source/JavaScriptCore/ChangeLog
r279436 r279598 1 2021-07-06 Ruben Turcios <rubent_22@apple.com> 2 3 Cherry-pick r279560. rdar://problem/80212160 4 5 ActiveScratchBufferScope should take the buffer as argument 6 https://bugs.webkit.org/show_bug.cgi?id=227670 7 rdar://80011612 8 9 Reviewed by Mark Lam. 10 11 https://bugs.webkit.org/show_bug.cgi?id=227013 created ActiveScratchBufferScope. 12 It is used by operations that can cause the GC to run, to mark as roots the contents of the scratch buffer that is live during that time (if any). 13 The bug is that it simply asks the VM for a scratch buffer of the right size, but this will always return the last scratch buffer, and not necessarily the one that the operation is actually using. 14 15 A fairly simple fix is to pass it directly the scratch buffer, since the operation normally can get it easily enough. 16 In most cases the operation has access to the m_buffer field of the ScratchBuffer, but getting a pointer to the entire structure from that is fairly simple (I added ScratchBuffer::fromData() to do so). 17 18 * dfg/DFGOSRExit.cpp: 19 (JSC::DFG::JSC_DEFINE_JIT_OPERATION): 20 * dfg/DFGOSRExit.h: 21 * dfg/DFGOperations.cpp: 22 (JSC::DFG::JSC_DEFINE_JIT_OPERATION): 23 * dfg/DFGSpeculativeJIT.cpp: 24 (JSC::DFG::SpeculativeJIT::compileNewArray): 25 * dfg/DFGThunks.cpp: 26 (JSC::DFG::osrExitGenerationThunkGenerator): 27 * runtime/JSGlobalObject.cpp: 28 (JSC::JSGlobalObject::haveABadTime): 29 * runtime/VM.h: 30 (JSC::ScratchBuffer::fromData): 31 * runtime/VMInlines.h: 32 (JSC::ActiveScratchBufferScope::ActiveScratchBufferScope): 33 (JSC::ActiveScratchBufferScope::~ActiveScratchBufferScope): 34 35 36 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279560 268f45cc-cd09-0410-ab3c-d52691b4dbfc 37 38 2021-07-04 Robin Morisset <rmorisset@apple.com> 39 40 ActiveScratchBufferScope should take the buffer as argument 41 https://bugs.webkit.org/show_bug.cgi?id=227670 42 rdar://80011612 43 44 Reviewed by Mark Lam. 45 46 https://bugs.webkit.org/show_bug.cgi?id=227013 created ActiveScratchBufferScope. 47 It is used by operations that can cause the GC to run, to mark as roots the contents of the scratch buffer that is live during that time (if any). 48 The bug is that it simply asks the VM for a scratch buffer of the right size, but this will always return the last scratch buffer, and not necessarily the one that the operation is actually using. 49 50 A fairly simple fix is to pass it directly the scratch buffer, since the operation normally can get it easily enough. 51 In most cases the operation has access to the m_buffer field of the ScratchBuffer, but getting a pointer to the entire structure from that is fairly simple (I added ScratchBuffer::fromData() to do so). 52 53 * dfg/DFGOSRExit.cpp: 54 (JSC::DFG::JSC_DEFINE_JIT_OPERATION): 55 * dfg/DFGOSRExit.h: 56 * dfg/DFGOperations.cpp: 57 (JSC::DFG::JSC_DEFINE_JIT_OPERATION): 58 * dfg/DFGSpeculativeJIT.cpp: 59 (JSC::DFG::SpeculativeJIT::compileNewArray): 60 * dfg/DFGThunks.cpp: 61 (JSC::DFG::osrExitGenerationThunkGenerator): 62 * runtime/JSGlobalObject.cpp: 63 (JSC::JSGlobalObject::haveABadTime): 64 * runtime/VM.h: 65 (JSC::ScratchBuffer::fromData): 66 * runtime/VMInlines.h: 67 (JSC::ActiveScratchBufferScope::ActiveScratchBufferScope): 68 (JSC::ActiveScratchBufferScope::~ActiveScratchBufferScope): 69 1 70 2021-06-30 Alan Coon <alancoon@apple.com> 2 71 -
branches/safari-612.1.22.3-branch/Source/JavaScriptCore/dfg/DFGOSRExit.cpp
r279256 r279598 142 142 } 143 143 144 JSC_DEFINE_JIT_OPERATION(operationCompileOSRExit, void, (CallFrame* callFrame ))144 JSC_DEFINE_JIT_OPERATION(operationCompileOSRExit, void, (CallFrame* callFrame, void* bufferToPreserve)) 145 145 { 146 146 VM& vm = callFrame->deprecatedVM(); 147 147 auto scope = DECLARE_THROW_SCOPE(vm); 148 ActiveScratchBufferScope activeScratchBufferScope( vm, GPRInfo::numberOfRegisters + FPRInfo::numberOfRegisters);148 ActiveScratchBufferScope activeScratchBufferScope(ScratchBuffer::fromData(bufferToPreserve), GPRInfo::numberOfRegisters + FPRInfo::numberOfRegisters); 149 149 150 150 if constexpr (validateDFGDoesGC) { … … 931 931 VM& vm = callFrame->deprecatedVM(); 932 932 NativeCallFrameTracer tracer(vm, callFrame); 933 ActiveScratchBufferScope activeScratchBufferScope( vm, GPRInfo::numberOfRegisters + FPRInfo::numberOfRegisters);933 ActiveScratchBufferScope activeScratchBufferScope(ScratchBuffer::fromData(scratch), GPRInfo::numberOfRegisters + FPRInfo::numberOfRegisters); 934 934 935 935 SpeculationFailureDebugInfo* debugInfo = static_cast<SpeculationFailureDebugInfo*>(debugInfoRaw); -
branches/safari-612.1.22.3-branch/Source/JavaScriptCore/dfg/DFGOSRExit.h
r274024 r279598 139 139 }; 140 140 141 JSC_DECLARE_JIT_OPERATION(operationCompileOSRExit, void, (CallFrame* ));141 JSC_DECLARE_JIT_OPERATION(operationCompileOSRExit, void, (CallFrame*, void*)); 142 142 JSC_DECLARE_JIT_OPERATION(operationDebugPrintSpeculationFailure, void, (CallFrame*, void*, void*)); 143 143 JSC_DECLARE_JIT_OPERATION(operationMaterializeOSRExitSideState, void, (VM*, const OSRExitBase*, EncodedJSValue*)); … … 150 150 OSRExit(ExitKind, JSValueSource, MethodOfGettingAValueProfile, SpeculativeJIT*, unsigned streamIndex, unsigned recoveryIndex = UINT_MAX); 151 151 152 friend void JIT_OPERATION_ATTRIBUTES operationCompileOSRExit(CallFrame* );152 friend void JIT_OPERATION_ATTRIBUTES operationCompileOSRExit(CallFrame*, void*); 153 153 154 154 CodeLocationLabel<JSInternalPtrTag> m_patchableJumpLocation; -
branches/safari-612.1.22.3-branch/Source/JavaScriptCore/dfg/DFGOperations.cpp
r278875 r279598 1040 1040 CallFrame* callFrame = DECLARE_CALL_FRAME(vm); 1041 1041 JITOperationPrologueCallFrameTracer tracer(vm, callFrame); 1042 ActiveScratchBufferScope activeScratchBufferScope(vm, elementCount); 1043 auto scope = DECLARE_THROW_SCOPE(vm); 1042 ActiveScratchBufferScope activeScratchBufferScope(ScratchBuffer::fromData(buffer), elementCount); 1043 auto scope = DECLARE_THROW_SCOPE(vm); 1044 1044 1045 1045 1046 // We assume that multiple JSArray::push calls with ArrayWithInt32/ArrayWithContiguous do not cause JS traps. … … 1735 1736 CallFrame* callFrame = DECLARE_CALL_FRAME(vm); 1736 1737 JITOperationPrologueCallFrameTracer tracer(vm, callFrame); 1737 ActiveScratchBufferScope activeScratchBufferScope( vm, size);1738 ActiveScratchBufferScope activeScratchBufferScope(ScratchBuffer::fromData(buffer), size); 1738 1739 1739 1740 return bitwise_cast<char*>(constructArray(globalObject, arrayStructure, static_cast<JSValue*>(buffer), size)); … … 3043 3044 CallFrame* callFrame = DECLARE_CALL_FRAME(vm); 3044 3045 JITOperationPrologueCallFrameTracer tracer(vm, callFrame); 3045 ActiveScratchBufferScope activeScratchBufferScope( vm, numItems);3046 ActiveScratchBufferScope activeScratchBufferScope(ScratchBuffer::fromData(buffer), numItems); 3046 3047 auto scope = DECLARE_THROW_SCOPE(vm); 3047 3048 -
branches/safari-612.1.22.3-branch/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
r279216 r279598 9239 9239 9240 9240 GPRFlushedCallResult result(this); 9241 GPRReg resultGPR = result.gpr(); 9241 9242 9242 9243 callOperation( 9243 operationNewArray, result .gpr(), TrustedImmPtr::weakPointer(m_graph, globalObject), m_jit.graph().registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(node->indexingType())),9244 operationNewArray, resultGPR, TrustedImmPtr::weakPointer(m_graph, globalObject), m_jit.graph().registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(node->indexingType())), 9244 9245 static_cast<void*>(buffer), size_t(node->numChildren())); 9245 9246 m_jit.exceptionCheck(); 9246 9247 9247 cellResult(result .gpr(), node, UseChildrenCalledExplicitly);9248 cellResult(resultGPR, node, UseChildrenCalledExplicitly); 9248 9249 } 9249 9250 -
branches/safari-612.1.22.3-branch/Source/JavaScriptCore/dfg/DFGThunks.cpp
r279256 r279598 90 90 storeSpooler.finalizeFPR(); 91 91 92 // Set up one argument.93 jit. move(GPRInfo::callFrameRegister, GPRInfo::argumentGPR0);92 // This will implicitly pass GPRInfo::callFrameRegister as the first argument based on the operation type. 93 jit.setupArguments<decltype(operationCompileOSRExit)>(bufferGPR); 94 94 jit.prepareCallOperation(vm); 95 95 -
branches/safari-612.1.22.3-branch/Source/JavaScriptCore/runtime/VM.h
r279216 r279598 261 261 } 262 262 263 static ScratchBuffer* fromData(void* buffer) 264 { 265 return bitwise_cast<ScratchBuffer*>(static_cast<char*>(buffer) - OBJECT_OFFSETOF(ScratchBuffer, m_buffer)); 266 } 267 263 268 static size_t allocationSize(Checked<size_t> bufferSize) { return sizeof(ScratchBuffer) + bufferSize; } 264 269 void setActiveLength(size_t activeLength) { u.m_activeLength = activeLength; } … … 283 288 class ActiveScratchBufferScope { 284 289 public: 285 ActiveScratchBufferScope( VM&, size_t activeScratchBufferSizeInJSValues);290 ActiveScratchBufferScope(ScratchBuffer*, size_t activeScratchBufferSizeInJSValues); 286 291 ~ActiveScratchBufferScope(); 287 292 -
branches/safari-612.1.22.3-branch/Source/JavaScriptCore/runtime/VMInlines.h
r278875 r279598 33 33 namespace JSC { 34 34 35 inline ActiveScratchBufferScope::ActiveScratchBufferScope( VM& vm, size_t activeScratchBufferSizeInJSValues)36 : m_scratchBuffer( vm.scratchBufferForSize(activeScratchBufferSizeInJSValues * sizeof(EncodedJSValue)))35 inline ActiveScratchBufferScope::ActiveScratchBufferScope(ScratchBuffer* buffer, size_t activeScratchBufferSizeInJSValues) 36 : m_scratchBuffer(buffer) 37 37 { 38 38 // Tell GC mark phase how much of the scratch buffer is active during the call operation this scope is used in. 39 39 if (m_scratchBuffer) 40 m_scratchBuffer-> u.m_activeLength = activeScratchBufferSizeInJSValues * sizeof(EncodedJSValue);40 m_scratchBuffer->setActiveLength(activeScratchBufferSizeInJSValues * sizeof(EncodedJSValue)); 41 41 } 42 42 … … 45 45 // Tell the GC that we're not using the scratch buffer anymore. 46 46 if (m_scratchBuffer) 47 m_scratchBuffer-> u.m_activeLength = 0;47 m_scratchBuffer->setActiveLength(0); 48 48 } 49 49
Note:
See TracChangeset
for help on using the changeset viewer.