source: webkit/trunk/Source/JavaScriptCore/dfg/DFGDoesGCCheck.cpp

Last change on this file was 285636, checked in by [email protected], 4 years ago

Move m_doesGC from Heap to VM.
https://bugs.webkit.org/show_bug.cgi?id=232975
rdar://85277492

Reviewed by Filip Pizlo.

Source/JavaScriptCore:

m_doesGC is only needed for ENABLE(DFG_DOES_GC_VALIDATION), and is used for checking
if the VM thread's execution is in a state that can allow GC to run. Hence, it is
more related to VM thread execution as opposed to the state of the Heap. This patch
moves m_doesGC from Heap to VM to get it out of the way of upcoming Global GC work.

Also change DeferGC, DeferGCForAWhile, and GCDeferralContext to take a VM& instead
of a Heap&. DeferGC and GCDeferralContext need to access VM& in order to call
VM::verifyCanGC(). DeferGCForAWhile does not need VM&, but we're changing it to be
consistent with DeferGC. There should be no perf impact for this change.

  • CMakeLists.txt:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::jettison):

  • bytecode/UnlinkedFunctionExecutable.cpp:

(JSC::UnlinkedFunctionExecutable::decodeCachedCodeBlocks):

  • bytecode/Watchpoint.cpp:

(JSC::WatchpointSet::fireAllWatchpoints):

  • bytecompiler/BytecodeGenerator.h:

(JSC::BytecodeGenerator::generate):

  • dfg/DFGDoesGCCheck.cpp:
  • dfg/DFGOSRExit.cpp:

(JSC::DFG::JSC_DEFINE_JIT_OPERATION):
(JSC::DFG::OSRExit::compileExit):

  • dfg/DFGOperations.cpp:

(JSC::DFG::JSC_DEFINE_JIT_OPERATION):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileLoopHint):

  • dfg/DFGSpeculativeJIT32_64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • dfg/DFGSpeculativeJIT64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::compileNode):
(JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq):

  • ftl/FTLOSRExitCompiler.cpp:

(JSC::FTL::compileStub):
(JSC::FTL::JSC_DEFINE_JIT_OPERATION):

  • ftl/FTLOperations.cpp:

(JSC::FTL::JSC_DEFINE_JIT_OPERATION):

  • heap/CompleteSubspace.cpp:

(JSC::CompleteSubspace::tryAllocateSlow):
(JSC::CompleteSubspace::reallocatePreciseAllocationNonVirtual):

  • heap/CompleteSubspaceInlines.h:

(JSC::CompleteSubspace::allocateNonVirtual):

  • heap/DeferGC.h:

(JSC::DeferGC::DeferGC): Deleted.
(JSC::DeferGC::~DeferGC): Deleted.
(JSC::DeferGCForAWhile::DeferGCForAWhile): Deleted.
(JSC::DeferGCForAWhile::~DeferGCForAWhile): Deleted.

  • heap/DeferGCInlines.h: Added.

(JSC::DeferGC::DeferGC):
(JSC::DeferGC::~DeferGC):
(JSC::DeferGCForAWhile::DeferGCForAWhile):
(JSC::DeferGCForAWhile::~DeferGCForAWhile):

  • heap/GCDeferralContext.h:
  • heap/GCDeferralContextInlines.h:

(JSC::GCDeferralContext::GCDeferralContext):
(JSC::GCDeferralContext::~GCDeferralContext):

  • heap/Heap.cpp:

(JSC::Heap::collectNow):
(JSC::Heap::collectAsync):
(JSC::Heap::collectSync):
(JSC::Heap::stopIfNecessarySlow):
(JSC::Heap::collectIfNecessaryOrDefer):

  • heap/Heap.h:

(JSC::Heap::addressOfDoesGC): Deleted.
(JSC::Heap::setDoesGCExpectation): Deleted.
(JSC::Heap::verifyCanGC): Deleted.

  • heap/HeapInlines.h:

(JSC::Heap::acquireAccess):
(JSC::Heap::stopIfNecessary):

  • heap/HeapSnapshotBuilder.cpp:

(JSC::HeapSnapshotBuilder::json):

  • heap/IncrementalSweeper.cpp:

(JSC::IncrementalSweeper::sweepNextBlock):

  • heap/LocalAllocatorInlines.h:

(JSC::LocalAllocator::allocate):

  • heap/PreciseAllocation.cpp:

(JSC::PreciseAllocation::tryCreate):
(JSC::PreciseAllocation::createForLowerTier):

  • inspector/JSInjectedScriptHost.cpp:

(Inspector::JSInjectedScriptHost::queryHolders):

  • inspector/agents/InspectorHeapAgent.cpp:

(Inspector::InspectorHeapAgent::getPreview):
(Inspector::InspectorHeapAgent::getRemoteObject):

  • inspector/agents/InspectorScriptProfilerAgent.cpp:

(Inspector::InspectorScriptProfilerAgent::trackingComplete):

  • interpreter/ShadowChickenInlines.h:

(JSC::ShadowChicken::iterate):

  • jit/JITOperations.cpp:

(JSC::JSC_DEFINE_JIT_OPERATION):

  • jit/JITWorklist.cpp:

(JSC::JITWorklist::completeAllReadyPlansForVM):
(JSC::JITWorklist::waitUntilAllPlansForVMAreReady):
(JSC::JITWorklist::completeAllPlansForVM):
(JSC::JITWorklist::removeAllReadyPlansForVM):

  • jit/Repatch.cpp:

(JSC::fireWatchpointsAndClearStubIfNeeded):
(JSC::tryCacheGetBy):
(JSC::tryCacheArrayGetByVal):
(JSC::tryCachePutBy):
(JSC::tryCacheArrayPutByVal):
(JSC::tryCacheDeleteBy):
(JSC::tryCacheInBy):
(JSC::tryCacheHasPrivateBrand):
(JSC::tryCacheCheckPrivateBrand):
(JSC::tryCacheSetPrivateBrand):
(JSC::tryCacheInstanceOf):
(JSC::linkPolymorphicCall):

  • jsc.cpp:

(JSC_DEFINE_HOST_FUNCTION):

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::jitCompileAndSetHeuristics):
(JSC::LLInt::LLINT_SLOW_PATH_DECL):

  • runtime/CachedTypes.cpp:

(JSC::decodeCodeBlockImpl):

  • runtime/ConcurrentJSLock.h:

(JSC::GCSafeConcurrentJSLocker::GCSafeConcurrentJSLocker):

  • runtime/ExceptionFuzz.cpp:

(JSC::doExceptionFuzzing):

  • runtime/JSArray.cpp:

(JSC::JSArray::unshiftCountWithArrayStorage):

  • runtime/JSArrayBufferView.cpp:

(JSC::JSArrayBufferView::slowDownAndWasteMemory):

  • runtime/JSCellInlines.h:
  • runtime/JSGenericTypedArrayViewInlines.h:
  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::haveABadTime):

  • runtime/JSObject.cpp:

(JSC::JSObject::enterDictionaryIndexingModeWhenArrayStorageAlreadyExists):
(JSC::JSObject::createInitialUndecided):
(JSC::JSObject::createInitialInt32):
(JSC::JSObject::createInitialDouble):
(JSC::JSObject::createInitialContiguous):
(JSC::JSObject::createArrayStorage):
(JSC::JSObject::convertUndecidedToArrayStorage):
(JSC::JSObject::convertInt32ToArrayStorage):
(JSC::JSObject::convertDoubleToArrayStorage):
(JSC::JSObject::convertContiguousToArrayStorage):
(JSC::JSObject::increaseVectorLength):
(JSC::JSObject::ensureLengthSlow):
(JSC::JSObject::reallocateAndShrinkButterfly):
(JSC::createCustomGetterFunction):
(JSC::createCustomSetterFunction):

  • runtime/JSString.h:

(JSC::jsSingleCharacterString):
(JSC::JSString::toAtomString const):
(JSC::JSString::toExistingAtomString const):
(JSC::JSString::value const):
(JSC::JSString::tryGetValue const):
(JSC::JSRopeString::unsafeView const):
(JSC::JSRopeString::viewWithUnderlyingString const):
(JSC::JSString::unsafeView const):

  • runtime/JSSymbolTableObject.h:

(JSC::symbolTablePut):

  • runtime/RegExpKey.h:
  • runtime/RegExpMatchesArray.cpp:

(JSC::createEmptyRegExpMatchesArray):

  • runtime/RegExpMatchesArray.h:

(JSC::createRegExpMatchesArray):

  • runtime/SamplingProfiler.cpp:

(JSC::SamplingProfiler::stackTracesAsJSON):
(JSC::SamplingProfiler::reportTopFunctions):
(JSC::SamplingProfiler::reportTopBytecodes):

  • runtime/ScriptExecutable.cpp:

(JSC::ScriptExecutable::prepareForExecutionImpl):

  • runtime/Structure.cpp:

(JSC::Structure::materializePropertyTable):
(JSC::Structure::addNewPropertyTransition):
(JSC::Structure::removeNewPropertyTransition):
(JSC::Structure::changePrototypeTransition):
(JSC::Structure::attributeChangeTransition):
(JSC::Structure::toDictionaryTransition):
(JSC::Structure::nonPropertyTransitionSlow):
(JSC::Structure::flattenDictionaryStructure):

  • runtime/StructureInlines.h:

(JSC::Structure::add):
(JSC::Structure::remove):
(JSC::Structure::attributeChange):

  • runtime/VM.h:

(JSC::VM::addressOfDoesGC):
(JSC::VM::setDoesGCExpectation):
(JSC::VM::verifyCanGC):

Source/WebCore:

  • bindings/js/GCController.cpp:

(WebCore::GCController::dumpHeap):

  • bindings/js/JSDOMGlobalObject.cpp:

(WebCore::JSDOMGlobalObject::createCrossOriginFunction):
(WebCore::JSDOMGlobalObject::createCrossOriginGetterSetter):

File size: 2.9 KB
Line 
1/*
2 * Copyright (C) 2020-2021 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "config.h"
27#include "DFGDoesGCCheck.h"
28
29#include "CallFrameInlines.h"
30#include "CodeBlock.h"
31#include "DFGGraph.h"
32#include "DFGNodeType.h"
33#include "JSCJSValueInlines.h"
34#include "Options.h"
35#include "VMInspector.h"
36#include <wtf/DataLog.h>
37
38namespace JSC {
39namespace DFG {
40
41#if ENABLE(DFG_DOES_GC_VALIDATION)
42
43void DoesGCCheck::verifyCanGC(VM& vm)
44{
45 // We do this check here just so we don't have to #include DFGNodeType.h
46 // in the header file.
47 static_assert(numberOfNodeTypes <= (1 << nodeOpBits));
48
49 if (!Options::validateDoesGC())
50 return;
51
52 if (!expectDoesGC()) {
53 dataLog("Error: DoesGC failed");
54 if (isSpecial()) {
55 switch (special()) {
56 case Special::Uninitialized:
57 break;
58 case Special::DFGOSRExit:
59 dataLog(" @ DFG osr exit");
60 break;
61 case Special::FTLOSRExit:
62 dataLog(" @ FTL osr exit");
63 break;
64 case Special::NumberOfSpecials:
65 RELEASE_ASSERT_NOT_REACHED();
66 }
67 } else
68 dataLog(" @ D@", nodeIndex(), " ", DFG::Graph::opName(static_cast<DFG::NodeType>(nodeOp())));
69
70 CallFrame* callFrame = vm.topCallFrame;
71 if (callFrame) {
72 CodeBlock* codeBlock = callFrame->codeBlock();
73 dataLogLn(" in ", codeBlock);
74 VMInspector::dumpStack(&vm, callFrame);
75 }
76 dataLogLn();
77 }
78 RELEASE_ASSERT(expectDoesGC());
79}
80#endif // ENABLE(DFG_DOES_GC_VALIDATION)
81
82} // namespace DFG
83} // namespace JSC
84
Note: See TracBrowser for help on using the repository browser.