Changeset 284668 in webkit
- Timestamp:
- Oct 22, 2021, 12:19:52 AM (5 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
heap/Heap.cpp (modified) (26 diffs)
-
heap/Heap.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r284664 r284668 1 2021-10-22 Mark Lam <mark.lam@apple.com> 2 3 Remove unneeded Heap::m_vm. 4 https://bugs.webkit.org/show_bug.cgi?id=232132 5 6 Reviewed by Yusuke Suzuki. 7 8 Heap::vm() already computes the associated VM& using offset math. This entails 9 subtracting a constant from Heap's this pointer, which is faster than loading from 10 a field. 11 12 * heap/Heap.cpp: 13 (JSC::Heap::Heap): 14 (JSC::Heap::lastChanceToFinalize): 15 (JSC::Heap::releaseDelayedReleasedObjects): 16 (JSC::Heap::protect): 17 (JSC::Heap::unprotect): 18 (JSC::Heap::finalizeUnconditionalFinalizers): 19 (JSC::Heap::completeAllJITPlans): 20 (JSC::Heap::iterateExecutingAndCompilingCodeBlocks): 21 (JSC::Heap::gatherJSStackRoots): 22 (JSC::Heap::gatherScratchBufferRoots): 23 (JSC::Heap::removeDeadCompilerWorklistEntries): 24 (JSC::Heap::gatherExtraHeapData): 25 (JSC::Heap::deleteAllCodeBlocks): 26 (JSC::Heap::deleteAllUnlinkedCodeBlocks): 27 (JSC::Heap::finishChangingPhase): 28 (JSC::Heap::collectInMutatorThread): 29 (JSC::Heap::finishRelinquishingConn): 30 (JSC::Heap::deleteSourceProviderCaches): 31 (JSC::Heap::didFinishCollection): 32 (JSC::Heap::isValidAllocation): 33 (JSC::Heap::addCoreConstraints): 34 * heap/Heap.h: 35 1 36 2021-10-21 Saam Barati <sbarati@apple.com> 2 37 -
trunk/Source/JavaScriptCore/heap/Heap.cpp
r282707 r284668 292 292 , m_codeBlocks(makeUnique<CodeBlockSet>()) 293 293 , m_jitStubRoutines(makeUnique<JITStubRoutineSet>()) 294 , m_vm(vm) 295 // We seed with 10ms so that GCActivityCallback::didAllocate doesn't continuously 294 // We seed with 10ms so that GCActivityCallback::didAllocate doesn't continuously 296 295 // schedule the timer if we've never done a collection. 297 296 , m_fullActivityCallback(GCActivityCallback::tryCreateFullTimer(this)) … … 396 395 m_isShuttingDown = true; 397 396 398 RELEASE_ASSERT(! m_vm.entryScope);397 RELEASE_ASSERT(!vm().entryScope); 399 398 RELEASE_ASSERT(m_mutatorState == MutatorState::Running); 400 399 … … 484 483 if (!m_delayedReleaseRecursionCount++) { 485 484 while (!m_delayedReleaseObjects.isEmpty()) { 486 ASSERT( m_vm.currentThreadIsHoldingAPILock());485 ASSERT(vm().currentThreadIsHoldingAPILock()); 487 486 488 487 auto objectsToRelease = WTFMove(m_delayedReleaseObjects); … … 490 489 { 491 490 // We need to drop locks before calling out to arbitrary code. 492 JSLock::DropAllLocks dropAllLocks( m_vm);491 JSLock::DropAllLocks dropAllLocks(vm()); 493 492 494 493 #if USE(FOUNDATION) … … 557 556 { 558 557 ASSERT(k); 559 ASSERT( m_vm.currentThreadIsHoldingAPILock());558 ASSERT(vm().currentThreadIsHoldingAPILock()); 560 559 561 560 if (!k.isCell()) … … 568 567 { 569 568 ASSERT(k); 570 ASSERT( m_vm.currentThreadIsHoldingAPILock());569 ASSERT(vm().currentThreadIsHoldingAPILock()); 571 570 572 571 if (!k.isCell()) … … 595 594 void Heap::finalizeUnconditionalFinalizers() 596 595 { 597 vm().builtinExecutables()->finalizeUnconditionally(); 598 finalizeMarkedUnconditionalFinalizers<FunctionExecutable>(vm().functionExecutableSpace.space); 599 finalizeMarkedUnconditionalFinalizers<SymbolTable>(vm().symbolTableSpace); 600 finalizeMarkedUnconditionalFinalizers<ExecutableToCodeBlockEdge>(vm().executableToCodeBlockEdgesWithFinalizers); // We run this before CodeBlock's unconditional finalizer since CodeBlock looks at the owner executable's installed CodeBlock in its finalizeUnconditionally. 601 vm().forEachCodeBlockSpace( 596 VM& vm = this->vm(); 597 vm.builtinExecutables()->finalizeUnconditionally(); 598 finalizeMarkedUnconditionalFinalizers<FunctionExecutable>(vm.functionExecutableSpace.space); 599 finalizeMarkedUnconditionalFinalizers<SymbolTable>(vm.symbolTableSpace); 600 finalizeMarkedUnconditionalFinalizers<ExecutableToCodeBlockEdge>(vm.executableToCodeBlockEdgesWithFinalizers); // We run this before CodeBlock's unconditional finalizer since CodeBlock looks at the owner executable's installed CodeBlock in its finalizeUnconditionally. 601 vm.forEachCodeBlockSpace( 602 602 [&] (auto& space) { 603 603 this->finalizeMarkedUnconditionalFinalizers<CodeBlock>(space.set); 604 604 }); 605 finalizeMarkedUnconditionalFinalizers<StructureRareData>(vm ().structureRareDataSpace);606 finalizeMarkedUnconditionalFinalizers<UnlinkedFunctionExecutable>(vm ().unlinkedFunctionExecutableSpace.set);607 if (vm ().m_weakSetSpace)608 finalizeMarkedUnconditionalFinalizers<JSWeakSet>(*vm ().m_weakSetSpace);609 if (vm ().m_weakMapSpace)610 finalizeMarkedUnconditionalFinalizers<JSWeakMap>(*vm ().m_weakMapSpace);611 if (vm ().m_weakObjectRefSpace)612 finalizeMarkedUnconditionalFinalizers<JSWeakObjectRef>(*vm ().m_weakObjectRefSpace);613 if (vm ().m_errorInstanceSpace)614 finalizeMarkedUnconditionalFinalizers<ErrorInstance>(*vm ().m_errorInstanceSpace);605 finalizeMarkedUnconditionalFinalizers<StructureRareData>(vm.structureRareDataSpace); 606 finalizeMarkedUnconditionalFinalizers<UnlinkedFunctionExecutable>(vm.unlinkedFunctionExecutableSpace.set); 607 if (vm.m_weakSetSpace) 608 finalizeMarkedUnconditionalFinalizers<JSWeakSet>(*vm.m_weakSetSpace); 609 if (vm.m_weakMapSpace) 610 finalizeMarkedUnconditionalFinalizers<JSWeakMap>(*vm.m_weakMapSpace); 611 if (vm.m_weakObjectRefSpace) 612 finalizeMarkedUnconditionalFinalizers<JSWeakObjectRef>(*vm.m_weakObjectRefSpace); 613 if (vm.m_errorInstanceSpace) 614 finalizeMarkedUnconditionalFinalizers<ErrorInstance>(*vm.m_errorInstanceSpace); 615 615 616 616 // FinalizationRegistries currently rely on serial finalization because they can post tasks to the deferredWorkTimer, which normally expects tasks to only be posted by the API lock holder. 617 if (vm ().m_finalizationRegistrySpace)618 finalizeMarkedUnconditionalFinalizers<JSFinalizationRegistry>(*vm ().m_finalizationRegistrySpace);617 if (vm.m_finalizationRegistrySpace) 618 finalizeMarkedUnconditionalFinalizers<JSFinalizationRegistry>(*vm.m_finalizationRegistrySpace); 619 619 620 620 #if ENABLE(WEBASSEMBLY) 621 if (vm ().m_webAssemblyCodeBlockSpace)622 finalizeMarkedUnconditionalFinalizers<JSWebAssemblyCodeBlock>(*vm ().m_webAssemblyCodeBlockSpace);621 if (vm.m_webAssemblyCodeBlockSpace) 622 finalizeMarkedUnconditionalFinalizers<JSWebAssemblyCodeBlock>(*vm.m_webAssemblyCodeBlockSpace); 623 623 #endif 624 624 } … … 639 639 return; 640 640 #if ENABLE(JIT) 641 JITWorklist::ensureGlobalWorklist().completeAllPlansForVM( m_vm);641 JITWorklist::ensureGlobalWorklist().completeAllPlansForVM(vm()); 642 642 #endif // ENABLE(JIT) 643 643 } … … 649 649 #if ENABLE(JIT) 650 650 if (Options::useJIT()) 651 JITWorklist::ensureGlobalWorklist().iterateCodeBlocksForGC(visitor, m_vm, func);651 JITWorklist::ensureGlobalWorklist().iterateCodeBlocksForGC(visitor, vm(), func); 652 652 #else 653 653 UNUSED_PARAM(visitor); … … 701 701 { 702 702 #if ENABLE(C_LOOP) 703 m_vm.interpreter->cloopStack().gatherConservativeRoots(roots, *m_jitStubRoutines, *m_codeBlocks);703 vm().interpreter->cloopStack().gatherConservativeRoots(roots, *m_jitStubRoutines, *m_codeBlocks); 704 704 #else 705 705 UNUSED_PARAM(roots); … … 712 712 if (!Options::useJIT()) 713 713 return; 714 m_vm.gatherScratchBufferRoots(roots); 715 m_vm.scanSideState(roots); 714 VM& vm = this->vm(); 715 vm.gatherScratchBufferRoots(roots); 716 vm.scanSideState(roots); 716 717 #else 717 718 UNUSED_PARAM(roots); … … 732 733 return; 733 734 #if ENABLE(JIT) 734 JITWorklist::ensureGlobalWorklist().removeDeadPlans( m_vm);735 JITWorklist::ensureGlobalWorklist().removeDeadPlans(vm()); 735 736 #endif // ENABLE(JIT) 736 737 } … … 760 761 if (auto* analyzer = heapProfiler.activeHeapAnalyzer()) { 761 762 HeapIterationScope heapIterationScope(*this); 762 GatherExtraHeapData functor( m_vm, *analyzer);763 GatherExtraHeapData functor(vm(), *analyzer); 763 764 m_objectSpace.forEachLiveCell(heapIterationScope, functor); 764 765 } … … 911 912 return; 912 913 913 VM& vm = m_vm;914 VM& vm = this->vm(); 914 915 PreventCollectionScope preventCollectionScope(*this); 915 916 … … 956 957 return; 957 958 958 VM& vm = m_vm;959 VM& vm = this->vm(); 959 960 PreventCollectionScope preventCollectionScope(*this); 960 961 … … 1615 1616 } 1616 1617 } else { 1617 sanitizeStackForVM( m_vm);1618 sanitizeStackForVM(vm()); 1618 1619 handleNeedFinalize(); 1619 1620 } … … 1830 1831 break; 1831 1832 case RunCurrentPhaseResult::NeedCurrentThreadState: 1832 sanitizeStackForVM( m_vm);1833 sanitizeStackForVM(vm()); 1833 1834 auto lambda = [&] (CurrentThreadState& state) { 1834 1835 for (;;) { … … 1974 1975 dataLog("Relinquished the conn.\n"); 1975 1976 1976 sanitizeStackForVM( m_vm);1977 sanitizeStackForVM(vm()); 1977 1978 1978 1979 Locker locker { *m_threadLock }; … … 2205 2206 { 2206 2207 if (m_lastCollectionScope && m_lastCollectionScope.value() == CollectionScope::Full) 2207 m_vm.clearSourceProviderCaches();2208 vm().clearSourceProviderCaches(); 2208 2209 } 2209 2210 … … 2324 2325 #endif 2325 2326 2326 if (HeapProfiler* heapProfiler = m_vm.heapProfiler()) {2327 if (HeapProfiler* heapProfiler = vm().heapProfiler()) { 2327 2328 gatherExtraHeapData(*heapProfiler); 2328 2329 removeDeadHeapSnapshotNodes(*heapProfiler); … … 2382 2383 bool Heap::isValidAllocation(size_t) 2383 2384 { 2384 if (!isValidThreadState( m_vm))2385 if (!isValidThreadState(vm())) 2385 2386 return false; 2386 2387 … … 2750 2751 "Msr", "Misc Small Roots", 2751 2752 MAKE_MARKING_CONSTRAINT_EXECUTOR_PAIR(([this] (auto& visitor) { 2753 VM& vm = this->vm(); 2752 2754 if constexpr (objcAPIEnabled) { 2753 2755 SetRootMarkReasonScope rootScope(visitor, RootMarkReason::ExternalRememberedSet); 2754 scanExternalRememberedSet( m_vm, visitor);2756 scanExternalRememberedSet(vm, visitor); 2755 2757 } 2756 2758 2757 if ( m_vm.smallStrings.needsToBeVisited(*m_collectionScope)) {2759 if (vm.smallStrings.needsToBeVisited(*m_collectionScope)) { 2758 2760 SetRootMarkReasonScope rootScope(visitor, RootMarkReason::StrongReferences); 2759 m_vm.smallStrings.visitStrongReferences(visitor);2761 vm.smallStrings.visitStrongReferences(visitor); 2760 2762 } 2761 2763 … … 2780 2782 { 2781 2783 SetRootMarkReasonScope rootScope(visitor, RootMarkReason::VMExceptions); 2782 visitor.appendUnbarriered( m_vm.exception());2783 visitor.appendUnbarriered( m_vm.lastException());2784 visitor.appendUnbarriered(vm.exception()); 2785 visitor.appendUnbarriered(vm.lastException()); 2784 2786 2785 2787 // We're going to m_terminationException directly instead of going through … … 2787 2789 // TerminationException has been reified. Here, we don't care if it is 2788 2790 // reified or not. 2789 visitor.appendUnbarriered( m_vm.m_terminationException);2791 visitor.appendUnbarriered(vm.m_terminationException); 2790 2792 } 2791 2793 })), … … 2805 2807 SetRootMarkReasonScope rootScope(visitor, RootMarkReason::Debugger); 2806 2808 2809 VM& vm = this->vm(); 2807 2810 if constexpr (samplingProfilerSupported) 2808 visitSamplingProfiler( m_vm, visitor);2809 2810 if ( m_vm.typeProfiler())2811 m_vm.typeProfilerLog()->visit(visitor);2811 visitSamplingProfiler(vm, visitor); 2812 2813 if (vm.typeProfiler()) 2814 vm.typeProfilerLog()->visit(visitor); 2812 2815 2813 if (auto* shadowChicken = m_vm.shadowChicken())2816 if (auto* shadowChicken = vm.shadowChicken()) 2814 2817 shadowChicken->visitChildren(visitor); 2815 2818 })), … … 2869 2872 // https://bugs.webkit.org/show_bug.cgi?id=166829 2870 2873 JITWorklist::ensureGlobalWorklist().iterateCodeBlocksForGC(visitor, 2871 m_vm,2874 vm(), 2872 2875 [&] (CodeBlock* codeBlock) { 2873 2876 visitor.appendUnbarriered(codeBlock); -
trunk/Source/JavaScriptCore/heap/Heap.h
r284663 r284668 656 656 unsigned m_barrierThreshold { Options::forceFencedBarrier() ? tautologicalThreshold : blackThreshold }; 657 657 658 VM& m_vm;659 658 Seconds m_lastFullGCLength { 10_ms }; 660 659 Seconds m_lastEdenGCLength { 10_ms };
Note:
See TracChangeset
for help on using the changeset viewer.