Changeset 279861 in webkit
- Timestamp:
- Jul 12, 2021 6:47:47 PM (3 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/CMakeLists.txt
r279630 r279861 671 671 heap/IsoSubspaceInlines.h 672 672 heap/IsoSubspacePerVM.h 673 heap/JITStubRoutineSet.h674 673 heap/LocalAllocator.h 675 674 heap/LocalAllocatorInlines.h -
trunk/Source/JavaScriptCore/ChangeLog
r279850 r279861 1 2021-07-12 Mark Lam <mark.lam@apple.com> 2 3 Revert r277027: breaks GC. 4 https://bugs.webkit.org/show_bug.cgi?id=227888 5 6 Reviewed by Saam Barati. 7 8 The patch in r277027 to make deletion of GCAwareJITStubRoutines incremental has a 9 bug: the routine may not be deleted yet by the incremental sweeper before the next 10 GC cycle, and the GC will not be happy visiting dead cell pointers in that routine. 11 There is also another bug with the triggering of sweeping. 12 13 For now, we're reverting the patch, and will revisit this at a later time. 14 15 * CMakeLists.txt: 16 * heap/Heap.cpp: 17 (JSC::Heap::deleteUnmarkedCompiledCode): 18 (JSC::Heap::sweepSynchronously): 19 * heap/Heap.h: 20 * heap/HeapInlines.h: 21 (JSC::Heap::mayHaveJITStubRoutinesToDelete): Deleted. 22 (JSC::Heap::deleteDeadJITStubRoutines): Deleted. 23 * heap/IncrementalSweeper.cpp: 24 (JSC::IncrementalSweeper::doSweep): 25 * heap/JITStubRoutineSet.cpp: 26 (JSC::JITStubRoutineSet::deleteUnmarkedJettisonedStubRoutines): 27 * heap/JITStubRoutineSet.h: 28 (JSC::JITStubRoutineSet::deleteUnmarkedJettisonedStubRoutines): 29 (JSC::JITStubRoutineSet::traceMarkedStubRoutines): 30 (JSC::JITStubRoutineSet::mayHaveRoutinesToDelete): Deleted. 31 (JSC::JITStubRoutineSet::notifyHaveRoutinesToDelete): Deleted. 32 * jit/GCAwareJITStubRoutine.cpp: 33 (JSC::GCAwareJITStubRoutine::observeZeroRefCount): 34 * jit/JITStubRoutine.h: 35 (JSC::JITStubRoutine::createSelfManagedRoutine): 36 1 37 2021-07-12 Yijia Huang <yijia_huang@apple.com> 2 38 -
trunk/Source/JavaScriptCore/heap/Heap.cpp
r279689 r279861 975 975 // And CodeBlock destructor is assuming that CodeBlock gets destroyed before UnlinkedCodeBlock gets destroyed. 976 976 vm().forEachCodeBlockSpace([] (auto& space) { space.space.sweep(); }); 977 if (mayHaveJITStubRoutinesToDelete()) 978 deleteDeadJITStubRoutines(5_ms); 977 m_jitStubRoutines->deleteUnmarkedJettisonedStubRoutines(); 979 978 } 980 979 … … 1043 1042 m_objectSpace.sweepBlocks(); 1044 1043 m_objectSpace.shrink(); 1045 1046 unsigned passes = 0;1047 while (mayHaveJITStubRoutinesToDelete()) {1048 constexpr Seconds unlimitedTime = 600_s;1049 deleteDeadJITStubRoutines(unlimitedTime);1050 RELEASE_ASSERT(passes++ < 100);1051 }1052 1053 1044 if (UNLIKELY(Options::logGC())) { 1054 1045 MonotonicTime after = MonotonicTime::now(); -
trunk/Source/JavaScriptCore/heap/Heap.h
r278253 r279861 407 407 bool isMarkingForGCVerifier() const { return m_isMarkingForGCVerifier; } 408 408 409 static bool mayHaveJITStubRoutinesToDelete();410 void deleteDeadJITStubRoutines(Seconds timeSlice);411 412 409 private: 413 410 friend class AllocatingScope; -
trunk/Source/JavaScriptCore/heap/HeapInlines.h
r277027 r279861 30 30 #include "HeapCellInlines.h" 31 31 #include "IndexingHeader.h" 32 #include "JITStubRoutineSet.h"33 32 #include "JSCast.h" 34 33 #include "Structure.h" … … 281 280 } 282 281 283 inline bool Heap::mayHaveJITStubRoutinesToDelete()284 {285 return JITStubRoutineSet::mayHaveRoutinesToDelete();286 }287 288 inline void Heap::deleteDeadJITStubRoutines(Seconds timeSlice)289 {290 m_jitStubRoutines->deleteUnmarkedJettisonedStubRoutines(timeSlice);291 }292 293 282 } // namespace JSC -
trunk/Source/JavaScriptCore/heap/IncrementalSweeper.cpp
r277027 r279861 37 37 static constexpr double sweepTimeTotal = .10; 38 38 static constexpr double sweepTimeMultiplier = 1.0 / sweepTimeTotal; 39 static constexpr Seconds deleteJITStubRoutinesTimeSlice = std::min(sweepTimeSlice / 10, 1_ms);40 39 41 40 void IncrementalSweeper::scheduleTimer() … … 57 56 void IncrementalSweeper::doSweep(VM& vm, MonotonicTime sweepBeginTime) 58 57 { 59 bool hasMoreBlocksToSweep = true; 60 bool hasMoreWork = true; 61 while (hasMoreWork) { 62 if (hasMoreBlocksToSweep) 63 hasMoreBlocksToSweep = sweepNextBlock(vm); 64 65 if (Heap::mayHaveJITStubRoutinesToDelete()) 66 vm.heap.deleteDeadJITStubRoutines(deleteJITStubRoutinesTimeSlice); 67 68 hasMoreWork = hasMoreBlocksToSweep || Heap::mayHaveJITStubRoutinesToDelete(); 69 58 while (sweepNextBlock(vm)) { 70 59 Seconds elapsedTime = MonotonicTime::now() - sweepBeginTime; 71 60 if (elapsedTime < sweepTimeSlice) -
trunk/Source/JavaScriptCore/heap/JITStubRoutineSet.cpp
r277850 r279861 30 30 31 31 #include "GCAwareJITStubRoutine.h" 32 #include <algorithm>33 32 34 33 namespace JSC { 35 36 using WTF::Range;37 38 bool JITStubRoutineSet::s_mayHaveRoutinesToDelete = false;39 34 40 35 JITStubRoutineSet::JITStubRoutineSet() { } … … 120 115 } 121 116 122 void JITStubRoutineSet::deleteUnmarkedJettisonedStubRoutines( Seconds timeSlice)117 void JITStubRoutineSet::deleteUnmarkedJettisonedStubRoutines() 123 118 { 124 ASSERT(s_mayHaveRoutinesToDelete);125 126 MonotonicTime startTime = MonotonicTime::now();127 Seconds elapsedTime;128 constexpr unsigned maxBatchSize = 100;129 130 unsigned endIndex = m_routines.size();131 132 // Clear the s_mayHaveRoutinesToDelete flag before we start.133 // Destruction of a MarkingGCAwareJITStubRoutine can trigger more routines134 // to be deleted, and some of those may be the ones we have already iterated135 // pass.136 s_mayHaveRoutinesToDelete = false;137 138 119 unsigned srcIndex = 0; 139 while (srcIndex < endIndex) { 140 unsigned batchSize = std::min<unsigned>(maxBatchSize, endIndex - srcIndex); 141 while (batchSize--) { 142 Routine routine = m_routines[srcIndex]; 143 if (!routine.routine->m_isJettisoned || routine.routine->m_mayBeExecuting) { 144 srcIndex++; 145 continue; 146 } 147 m_routines[srcIndex] = m_routines[--endIndex]; 148 149 routine.routine->deleteFromGC(); 120 unsigned dstIndex = srcIndex; 121 while (srcIndex < m_routines.size()) { 122 Routine routine = m_routines[srcIndex++]; 123 if (!routine.routine->m_isJettisoned || routine.routine->m_mayBeExecuting) { 124 m_routines[dstIndex++] = routine; 125 continue; 150 126 } 151 152 elapsedTime = MonotonicTime::now() - startTime; 153 if (elapsedTime > timeSlice) { 154 // We timed out. Assume there's more to do, and that we should check 155 // again next time slice. 156 s_mayHaveRoutinesToDelete = true; 157 break; 158 } 127 routine.routine->deleteFromGC(); 159 128 } 160 161 m_routines.shrinkCapacity(endIndex); 129 m_routines.shrinkCapacity(dstIndex); 162 130 } 163 131 -
trunk/Source/JavaScriptCore/heap/JITStubRoutineSet.h
r277027 r279861 32 32 #include <wtf/Vector.h> 33 33 34 using WTF::Range; 35 34 36 namespace JSC { 35 37 … … 60 62 void prepareForConservativeScan(); 61 63 62 void deleteUnmarkedJettisonedStubRoutines( Seconds timeSlice);64 void deleteUnmarkedJettisonedStubRoutines(); 63 65 64 66 template<typename Visitor> void traceMarkedStubRoutines(Visitor&); 65 66 static bool mayHaveRoutinesToDelete() { return s_mayHaveRoutinesToDelete; } 67 static void notifyHaveRoutinesToDelete() { s_mayHaveRoutinesToDelete = true; } 68 67 69 68 private: 70 69 void markSlow(uintptr_t address); … … 75 74 }; 76 75 Vector<Routine> m_routines; 77 WTF::Range<uintptr_t> m_range { 0, 0 }; 78 79 static bool s_mayHaveRoutinesToDelete; 76 Range<uintptr_t> m_range { 0, 0 }; 80 77 }; 81 78 … … 94 91 void mark(void*) { } 95 92 void prepareForConservativeScan() { } 96 void deleteUnmarkedJettisonedStubRoutines( Seconds) { }93 void deleteUnmarkedJettisonedStubRoutines() { } 97 94 template<typename Visitor> void traceMarkedStubRoutines(Visitor&) { } 98 99 static bool mayHaveRoutinesToDelete() { return false; }100 static void notifyHaveRoutinesToDelete() { }101 95 }; 102 96 -
trunk/Source/JavaScriptCore/jit/GCAwareJITStubRoutine.cpp
r278656 r279861 68 68 69 69 m_isJettisoned = true; 70 JITStubRoutineSet::notifyHaveRoutinesToDelete();71 70 } 72 71 -
trunk/Source/JavaScriptCore/jit/JITStubRoutine.h
r278656 r279861 1 1 /* 2 * Copyright (C) 2012-20 21Apple Inc. All rights reserved.2 * Copyright (C) 2012-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 64 64 } 65 65 66 // Use this if you want to pass a CodePtr to someone who insists on taking 67 // a RefPtr<JITStubRoutine>. 68 static Ref<JITStubRoutine> createSelfManagedRoutine( 69 MacroAssemblerCodePtr<JITStubRoutinePtrTag> rawCodePointer) 70 { 71 return adoptRef(*new JITStubRoutine(MacroAssemblerCodeRef<JITStubRoutinePtrTag>::createSelfManagedCodeRef(rawCodePointer))); 72 } 73 66 74 virtual ~JITStubRoutine(); 67 75 virtual void aboutToDie() { }
Note: See TracChangeset
for help on using the changeset viewer.