Changeset 276226 in webkit
- Timestamp:
- Apr 18, 2021, 1:06:48 AM (5 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 18 edited
-
ChangeLog (modified) (1 diff)
-
bytecode/AdaptiveInferredPropertyValueWatchpointBase.cpp (modified) (1 diff)
-
bytecode/AdaptiveInferredPropertyValueWatchpointBase.h (modified) (1 diff)
-
bytecode/CodeBlockJettisoningWatchpoint.h (modified) (1 diff)
-
dfg/DFGAdaptiveInferredPropertyValueWatchpoint.cpp (modified) (1 diff)
-
dfg/DFGAdaptiveInferredPropertyValueWatchpoint.h (modified) (2 diffs)
-
dfg/DFGAdaptiveStructureWatchpoint.cpp (modified) (1 diff)
-
dfg/DFGAdaptiveStructureWatchpoint.h (modified) (1 diff)
-
dfg/DFGCommonData.cpp (modified) (2 diffs)
-
dfg/DFGCommonData.h (modified) (1 diff)
-
dfg/DFGDesiredGlobalProperties.cpp (modified) (1 diff)
-
dfg/DFGDesiredGlobalProperties.h (modified) (2 diffs)
-
dfg/DFGDesiredWatchpoints.cpp (modified) (5 diffs)
-
dfg/DFGDesiredWatchpoints.h (modified) (9 diffs)
-
dfg/DFGGraph.cpp (modified) (1 diff)
-
dfg/DFGGraph.h (modified) (1 diff)
-
dfg/DFGPlan.cpp (modified) (3 diffs)
-
dfg/DFGPlan.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r276224 r276226 1 2021-04-18 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Do not use Bag<> for DFG / FTL watchpoints 4 https://bugs.webkit.org/show_bug.cgi?id=224715 5 6 Reviewed by Darin Adler. 7 8 While Bag<> is useful since its allocated memory will not be moved, 9 this is really memory-inefficient data structure. Each entry gets a 10 tail pointer (so adding 8 bytes) and we allocate each entry separately. 11 12 In DFG and FTL, we are using Bag<> for watchpoints. But this is not necessary actually: thanks to 13 concurrent compilers, our watchpoint registration is batched at the end of compilation. This means 14 that we have a way to know how many watchpoints we should register at that point. 15 16 In this patch, we introduce WatchpointCollector. In DesiredGlobalProperties, we run reallyAdd twice 17 with WatchpointCollector. First time, we just count # of watchpoints. Then we allocate FixedVector<XXXWatchpoint> 18 and install them. Since we do not (cannot) grow this fixed vector, watchpoint's address will not be changed as required. 19 20 We also move DesiredGlobalProperties under DesiredWatchpoints since this basically registers watchpoints. 21 22 * bytecode/AdaptiveInferredPropertyValueWatchpointBase.cpp: 23 (JSC::AdaptiveInferredPropertyValueWatchpointBase::AdaptiveInferredPropertyValueWatchpointBase): 24 (JSC::AdaptiveInferredPropertyValueWatchpointBase::initialize): 25 * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: 26 * bytecode/CodeBlockJettisoningWatchpoint.h: 27 * dfg/DFGAdaptiveInferredPropertyValueWatchpoint.cpp: 28 (JSC::DFG::AdaptiveInferredPropertyValueWatchpoint::AdaptiveInferredPropertyValueWatchpoint): 29 (JSC::DFG::AdaptiveInferredPropertyValueWatchpoint::initialize): 30 * dfg/DFGAdaptiveInferredPropertyValueWatchpoint.h: 31 * dfg/DFGAdaptiveStructureWatchpoint.cpp: 32 (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): 33 (JSC::DFG::AdaptiveStructureWatchpoint::initialize): 34 * dfg/DFGAdaptiveStructureWatchpoint.h: 35 * dfg/DFGCommonData.cpp: 36 (JSC::DFG::CommonData::validateReferences): 37 (JSC::DFG::CommonData::clearWatchpoints): 38 * dfg/DFGCommonData.h: 39 * dfg/DFGDesiredGlobalProperties.cpp: 40 (JSC::DFG::DesiredGlobalProperties::reallyAdd): 41 * dfg/DFGDesiredGlobalProperties.h: 42 * dfg/DFGDesiredWatchpoints.cpp: 43 (JSC::DFG::ArrayBufferViewWatchpointAdaptor::add): 44 (JSC::DFG::SymbolTableAdaptor::add): 45 (JSC::DFG::FunctionExecutableAdaptor::add): 46 (JSC::DFG::AdaptiveStructureWatchpointAdaptor::add): 47 (JSC::DFG::DesiredWatchpoints::addLazily): 48 (JSC::DFG::DesiredWatchpoints::reallyAdd): 49 (JSC::DFG::DesiredWatchpoints::areStillValidOnMainThread): 50 (JSC::DFG::WatchpointCollector::finalize): 51 * dfg/DFGDesiredWatchpoints.h: 52 (JSC::DFG::SetPointerAdaptor::add): 53 (JSC::DFG::GenericDesiredWatchpoints::reallyAdd): 54 * dfg/DFGGraph.cpp: 55 (JSC::DFG::Graph::watchGlobalProperty): 56 * dfg/DFGGraph.h: 57 * dfg/DFGPlan.cpp: 58 (JSC::DFG::Plan::reallyAdd): 59 (JSC::DFG::Plan::isStillValidOnMainThread): 60 (JSC::DFG::Plan::cancel): 61 * dfg/DFGPlan.h: 62 (JSC::DFG::Plan::transitions): 63 (JSC::DFG::Plan::globalProperties): Deleted. 64 1 65 2021-04-18 Yusuke Suzuki <ysuzuki@apple.com> 2 66 -
trunk/Source/JavaScriptCore/bytecode/AdaptiveInferredPropertyValueWatchpointBase.cpp
r243420 r276226 34 34 : m_key(key) 35 35 { 36 RELEASE_ASSERT(key.kind() == PropertyCondition::Equivalence); 37 } 38 39 void AdaptiveInferredPropertyValueWatchpointBase::initialize(const ObjectPropertyCondition& key) 40 { 41 m_key = key; 36 42 RELEASE_ASSERT(key.kind() == PropertyCondition::Equivalence); 37 43 } -
trunk/Source/JavaScriptCore/bytecode/AdaptiveInferredPropertyValueWatchpointBase.h
r250540 r276226 41 41 public: 42 42 AdaptiveInferredPropertyValueWatchpointBase(const ObjectPropertyCondition&); 43 AdaptiveInferredPropertyValueWatchpointBase() = default; 43 44 44 45 const ObjectPropertyCondition& key() const { return m_key; } 45 46 47 void initialize(const ObjectPropertyCondition&); 46 48 void install(VM&); 47 49 -
trunk/Source/JavaScriptCore/bytecode/CodeBlockJettisoningWatchpoint.h
r247843 r276226 34 34 class CodeBlockJettisoningWatchpoint final : public Watchpoint { 35 35 public: 36 CodeBlockJettisoningWatchpoint(CodeBlock* codeBlock )36 CodeBlockJettisoningWatchpoint(CodeBlock* codeBlock = nullptr) 37 37 : Watchpoint(Watchpoint::Type::CodeBlockJettisoning) 38 38 , m_codeBlock(codeBlock) 39 39 { 40 } 41 42 void initialize(CodeBlock* codeBlock) 43 { 44 m_codeBlock = codeBlock; 40 45 } 41 46 -
trunk/Source/JavaScriptCore/dfg/DFGAdaptiveInferredPropertyValueWatchpoint.cpp
r261755 r276226 40 40 } 41 41 42 void AdaptiveInferredPropertyValueWatchpoint::initialize(const ObjectPropertyCondition& key, CodeBlock* codeBlock) 43 { 44 Base::initialize(key); 45 m_codeBlock = codeBlock; 46 } 47 42 48 void AdaptiveInferredPropertyValueWatchpoint::handleFire(VM&, const FireDetail& detail) 43 49 { -
trunk/Source/JavaScriptCore/dfg/DFGAdaptiveInferredPropertyValueWatchpoint.h
r261569 r276226 36 36 typedef AdaptiveInferredPropertyValueWatchpointBase Base; 37 37 AdaptiveInferredPropertyValueWatchpoint(const ObjectPropertyCondition&, CodeBlock*); 38 AdaptiveInferredPropertyValueWatchpoint() = default; 39 40 void initialize(const ObjectPropertyCondition&, CodeBlock*); 38 41 39 42 private: … … 42 45 void handleFire(VM&, const FireDetail&) final; 43 46 44 CodeBlock* m_codeBlock ;47 CodeBlock* m_codeBlock { nullptr }; 45 48 }; 46 49 -
trunk/Source/JavaScriptCore/dfg/DFGAdaptiveStructureWatchpoint.cpp
r261895 r276226 43 43 } 44 44 45 AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint() 46 : Watchpoint(Watchpoint::Type::AdaptiveStructure) 47 , m_codeBlock(nullptr) 48 { 49 } 50 51 void AdaptiveStructureWatchpoint::initialize(const ObjectPropertyCondition& key, CodeBlock* codeBlock) 52 { 53 m_codeBlock = codeBlock; 54 m_key = key; 55 RELEASE_ASSERT(key.watchingRequiresStructureTransitionWatchpoint()); 56 RELEASE_ASSERT(!key.watchingRequiresReplacementWatchpoint()); 57 } 58 45 59 void AdaptiveStructureWatchpoint::install(VM& vm) 46 60 { -
trunk/Source/JavaScriptCore/dfg/DFGAdaptiveStructureWatchpoint.h
r247843 r276226 38 38 public: 39 39 AdaptiveStructureWatchpoint(const ObjectPropertyCondition&, CodeBlock*); 40 AdaptiveStructureWatchpoint(); 40 41 41 42 const ObjectPropertyCondition& key() const { return m_key; } 42 43 44 void initialize(const ObjectPropertyCondition&, CodeBlock*); 45 43 46 void install(VM&); 44 47 -
trunk/Source/JavaScriptCore/dfg/DFGCommonData.cpp
r276005 r276226 149 149 } 150 150 151 for ( AdaptiveStructureWatchpoint* watchpoint :adaptiveStructureWatchpoints)152 watchpoint ->key().validateReferences(trackedReferences);151 for (auto& watchpoint : m_adaptiveStructureWatchpoints) 152 watchpoint.key().validateReferences(trackedReferences); 153 153 } 154 154 … … 168 168 void CommonData::clearWatchpoints() 169 169 { 170 watchpoints.clear();171 adaptiveStructureWatchpoints.clear();172 adaptiveInferredPropertyValueWatchpoints.clear();170 m_watchpoints = FixedVector<CodeBlockJettisoningWatchpoint>(); 171 m_adaptiveStructureWatchpoints = FixedVector<AdaptiveStructureWatchpoint>(); 172 m_adaptiveInferredPropertyValueWatchpoints = FixedVector<AdaptiveInferredPropertyValueWatchpoint>(); 173 173 } 174 174 -
trunk/Source/JavaScriptCore/dfg/DFGCommonData.h
r276005 r276226 114 114 FixedVector<StructureID> m_weakStructureReferences; 115 115 FixedVector<CatchEntrypointData> m_catchEntrypoints; 116 Bag<CodeBlockJettisoningWatchpoint>watchpoints;117 Bag<AdaptiveStructureWatchpoint>adaptiveStructureWatchpoints;118 Bag<AdaptiveInferredPropertyValueWatchpoint>adaptiveInferredPropertyValueWatchpoints;116 FixedVector<CodeBlockJettisoningWatchpoint> m_watchpoints; 117 FixedVector<AdaptiveStructureWatchpoint> m_adaptiveStructureWatchpoints; 118 FixedVector<AdaptiveInferredPropertyValueWatchpoint> m_adaptiveInferredPropertyValueWatchpoints; 119 119 RecordedStatuses recordedStatuses; 120 120 Vector<JumpReplacement> m_jumpReplacements; -
trunk/Source/JavaScriptCore/dfg/DFGDesiredGlobalProperties.cpp
r261755 r276226 55 55 } 56 56 57 void DesiredGlobalProperties::reallyAdd(CodeBlock* codeBlock, DesiredIdentifiers& identifiers, CommonData& common)57 void DesiredGlobalProperties::reallyAdd(CodeBlock* codeBlock, DesiredIdentifiers& identifiers, WatchpointCollector& collector) 58 58 { 59 59 for (const auto& property : m_set) { 60 auto* uid = identifiers.at(property.identifierNumber()); 61 auto& watchpointSet = property.globalObject()->ensureReferencedPropertyWatchpointSet(uid); 62 ASSERT(watchpointSet.isStillValid()); 63 CodeBlockJettisoningWatchpoint* watchpoint = nullptr; 64 { 65 ConcurrentJSLocker locker(codeBlock->m_lock); 66 watchpoint = common.watchpoints.add(codeBlock); 67 } 68 watchpointSet.add(WTFMove(watchpoint)); 60 collector.addWatchpoint([&](CodeBlockJettisoningWatchpoint& watchpoint) { 61 { 62 ConcurrentJSLocker locker(codeBlock->m_lock); 63 watchpoint.initialize(codeBlock); 64 } 65 auto* uid = identifiers.at(property.identifierNumber()); 66 auto& watchpointSet = property.globalObject()->ensureReferencedPropertyWatchpointSet(uid); 67 ASSERT(watchpointSet.isStillValid()); 68 watchpointSet.add(&watchpoint); 69 }); 69 70 } 70 71 } -
trunk/Source/JavaScriptCore/dfg/DFGDesiredGlobalProperties.h
r240254 r276226 40 40 class CommonData; 41 41 class DesiredIdentifiers; 42 class WatchpointCollector; 42 43 43 44 class DesiredGlobalProperties { … … 50 51 bool isStillValidOnMainThread(VM&, DesiredIdentifiers&); 51 52 52 void reallyAdd(CodeBlock*, DesiredIdentifiers&, CommonData&);53 void reallyAdd(CodeBlock*, DesiredIdentifiers&, WatchpointCollector&); 53 54 54 55 private: -
trunk/Source/JavaScriptCore/dfg/DFGDesiredWatchpoints.cpp
r269343 r276226 35 35 namespace JSC { namespace DFG { 36 36 37 void ArrayBufferViewWatchpointAdaptor::add( 38 CodeBlock* codeBlock, JSArrayBufferView* view, CommonData& common) 39 { 40 // view is already frozen. If it is deallocated, jettisoning happens. 41 CodeBlockJettisoningWatchpoint* watchpoint = nullptr; 42 { 43 ConcurrentJSLocker locker(codeBlock->m_lock); 44 watchpoint = common.watchpoints.add(codeBlock); 45 } 46 ArrayBuffer* arrayBuffer = view->possiblySharedBuffer(); 47 if (!arrayBuffer) { 48 watchpoint->fire(codeBlock->vm(), StringFireDetail("ArrayBuffer could not be allocated, probably because of OOM.")); 49 return; 50 } 51 52 // FIXME: We don't need to set this watchpoint at all for shared buffers. 53 // https://bugs.webkit.org/show_bug.cgi?id=164108 54 arrayBuffer->detachingWatchpointSet().add(WTFMove(watchpoint)); 55 } 56 57 void SymbolTableAdaptor::add( 58 CodeBlock* codeBlock, SymbolTable* symbolTable, CommonData& common) 59 { 60 codeBlock->addConstant(ConcurrentJSLocker(codeBlock->m_lock), symbolTable); // For common users, it doesn't really matter if it's weak or not. If references to it go away, we go away, too. 61 CodeBlockJettisoningWatchpoint* watchpoint = nullptr; 62 { 63 ConcurrentJSLocker locker(codeBlock->m_lock); 64 watchpoint = common.watchpoints.add(codeBlock); 65 } 66 symbolTable->singleton().add(WTFMove(watchpoint)); 67 } 68 69 void FunctionExecutableAdaptor::add( 70 CodeBlock* codeBlock, FunctionExecutable* executable, CommonData& common) 71 { 72 codeBlock->addConstant(ConcurrentJSLocker(codeBlock->m_lock), executable); // For common users, it doesn't really matter if it's weak or not. If references to it go away, we go away, too. 73 CodeBlockJettisoningWatchpoint* watchpoint = nullptr; 74 { 75 ConcurrentJSLocker locker(codeBlock->m_lock); 76 watchpoint = common.watchpoints.add(codeBlock); 77 } 78 executable->singleton().add(WTFMove(watchpoint)); 79 } 80 81 void AdaptiveStructureWatchpointAdaptor::add( 82 CodeBlock* codeBlock, const ObjectPropertyCondition& key, CommonData& common) 37 void ArrayBufferViewWatchpointAdaptor::add(CodeBlock* codeBlock, JSArrayBufferView* view, WatchpointCollector& collector) 38 { 39 collector.addWatchpoint([&](CodeBlockJettisoningWatchpoint& watchpoint) { 40 // view is already frozen. If it is deallocated, jettisoning happens. 41 { 42 ConcurrentJSLocker locker(codeBlock->m_lock); 43 watchpoint.initialize(codeBlock); 44 } 45 ArrayBuffer* arrayBuffer = view->possiblySharedBuffer(); 46 if (!arrayBuffer) { 47 watchpoint.fire(codeBlock->vm(), StringFireDetail("ArrayBuffer could not be allocated, probably because of OOM.")); 48 return; 49 } 50 51 // FIXME: We don't need to set this watchpoint at all for shared buffers. 52 // https://bugs.webkit.org/show_bug.cgi?id=164108 53 arrayBuffer->detachingWatchpointSet().add(&watchpoint); 54 }); 55 } 56 57 void SymbolTableAdaptor::add(CodeBlock* codeBlock, SymbolTable* symbolTable, WatchpointCollector& collector) 58 { 59 collector.addWatchpoint([&](CodeBlockJettisoningWatchpoint& watchpoint) { 60 { 61 ConcurrentJSLocker locker(codeBlock->m_lock); 62 watchpoint.initialize(codeBlock); 63 } 64 codeBlock->addConstant(ConcurrentJSLocker(codeBlock->m_lock), symbolTable); // For common users, it doesn't really matter if it's weak or not. If references to it go away, we go away, too. 65 symbolTable->singleton().add(&watchpoint); 66 }); 67 } 68 69 void FunctionExecutableAdaptor::add(CodeBlock* codeBlock, FunctionExecutable* executable, WatchpointCollector& collector) 70 { 71 collector.addWatchpoint([&](CodeBlockJettisoningWatchpoint& watchpoint) { 72 { 73 ConcurrentJSLocker locker(codeBlock->m_lock); 74 watchpoint.initialize(codeBlock); 75 } 76 codeBlock->addConstant(ConcurrentJSLocker(codeBlock->m_lock), executable); // For common users, it doesn't really matter if it's weak or not. If references to it go away, we go away, too. 77 executable->singleton().add(&watchpoint); 78 }); 79 } 80 81 void AdaptiveStructureWatchpointAdaptor::add(CodeBlock* codeBlock, const ObjectPropertyCondition& key, WatchpointCollector& collector) 83 82 { 84 83 VM& vm = codeBlock->vm(); 85 84 switch (key.kind()) { 86 85 case PropertyCondition::Equivalence: { 87 AdaptiveInferredPropertyValueWatchpoint* watchpoint = nullptr; 88 { 89 ConcurrentJSLocker locker(codeBlock->m_lock); 90 watchpoint = common.adaptiveInferredPropertyValueWatchpoints.add(key, codeBlock); 91 } 92 watchpoint->install(vm); 86 collector.addAdaptiveInferredPropertyValueWatchpoint([&](AdaptiveInferredPropertyValueWatchpoint& watchpoint) { 87 { 88 ConcurrentJSLocker locker(codeBlock->m_lock); 89 watchpoint.initialize(key, codeBlock); 90 } 91 watchpoint.install(vm); 92 }); 93 93 break; 94 94 } 95 95 default: { 96 AdaptiveStructureWatchpoint* watchpoint = nullptr; 97 { 98 ConcurrentJSLocker locker(codeBlock->m_lock); 99 watchpoint = common.adaptiveStructureWatchpoints.add(key, codeBlock); 100 } 101 watchpoint->install(vm); 96 collector.addAdaptiveStructureWatchpoint([&](AdaptiveStructureWatchpoint& watchpoint) { 97 { 98 ConcurrentJSLocker locker(codeBlock->m_lock); 99 watchpoint.initialize(key, codeBlock); 100 } 101 watchpoint.install(vm); 102 }); 102 103 break; 103 104 } … … 136 137 { 137 138 m_adaptiveStructureSets.addLazily(key); 139 } 140 141 void DesiredWatchpoints::addLazily(DesiredGlobalProperty&& property) 142 { 143 m_globalProperties.addLazily(WTFMove(property)); 138 144 } 139 145 … … 146 152 } 147 153 148 void DesiredWatchpoints::reallyAdd(CodeBlock* codeBlock, CommonData& commonData) 149 { 150 m_sets.reallyAdd(codeBlock, commonData); 151 m_inlineSets.reallyAdd(codeBlock, commonData); 152 m_symbolTables.reallyAdd(codeBlock, commonData); 153 m_functionExecutables.reallyAdd(codeBlock, commonData); 154 m_bufferViews.reallyAdd(codeBlock, commonData); 155 m_adaptiveStructureSets.reallyAdd(codeBlock, commonData); 154 void DesiredWatchpoints::reallyAdd(CodeBlock* codeBlock, DesiredIdentifiers& identifiers, CommonData* commonData) 155 { 156 WatchpointCollector collector; 157 158 auto reallyAdd = [&]() { 159 m_sets.reallyAdd(codeBlock, collector); 160 m_inlineSets.reallyAdd(codeBlock, collector); 161 m_symbolTables.reallyAdd(codeBlock, collector); 162 m_functionExecutables.reallyAdd(codeBlock, collector); 163 m_bufferViews.reallyAdd(codeBlock, collector); 164 m_adaptiveStructureSets.reallyAdd(codeBlock, collector); 165 m_globalProperties.reallyAdd(codeBlock, identifiers, collector); 166 }; 167 reallyAdd(); 168 collector.materialize(); 169 170 reallyAdd(); 171 collector.finalize(codeBlock, *commonData); 156 172 } 157 173 … … 164 180 && m_bufferViews.areStillValid() 165 181 && m_adaptiveStructureSets.areStillValid(); 182 } 183 184 bool DesiredWatchpoints::areStillValidOnMainThread(VM& vm, DesiredIdentifiers& identifiers) 185 { 186 return m_globalProperties.isStillValidOnMainThread(vm, identifiers); 166 187 } 167 188 … … 179 200 } 180 201 202 void WatchpointCollector::finalize(CodeBlock* codeBlock, CommonData& common) 203 { 204 ConcurrentJSLocker locker(codeBlock->m_lock); 205 common.m_watchpoints = WTFMove(m_watchpoints); 206 common.m_adaptiveStructureWatchpoints = WTFMove(m_adaptiveStructureWatchpoints); 207 common.m_adaptiveInferredPropertyValueWatchpoints = WTFMove(m_adaptiveInferredPropertyValueWatchpoints); 208 } 209 181 210 } } // namespace JSC::DFG 182 211 -
trunk/Source/JavaScriptCore/dfg/DFGDesiredWatchpoints.h
r254087 r276226 29 29 30 30 #include "DFGCommonData.h" 31 #include "DFGDesiredGlobalProperties.h" 31 32 #include "FunctionExecutable.h" 32 33 #include "JSArrayBufferView.h" … … 42 43 struct Prefix; 43 44 45 enum class WatchpointRegistrationMode : uint8_t { Collect, Add }; 46 class WatchpointCollector final { 47 WTF_MAKE_NONCOPYABLE(WatchpointCollector); 48 public: 49 void materialize() 50 { 51 m_watchpoints = FixedVector<CodeBlockJettisoningWatchpoint>(m_watchpointCount); 52 m_adaptiveStructureWatchpoints = FixedVector<AdaptiveStructureWatchpoint>(m_adaptiveStructureWatchpointCount); 53 m_adaptiveInferredPropertyValueWatchpoints = FixedVector<AdaptiveInferredPropertyValueWatchpoint>(m_adaptiveInferredPropertyValueWatchpointCount); 54 m_mode = WatchpointRegistrationMode::Add; 55 } 56 57 template<typename Func> 58 void addWatchpoint(const Func& function) 59 { 60 if (m_mode == WatchpointRegistrationMode::Add) 61 function(m_watchpoints[m_watchpointIndex++]); 62 else 63 ++m_watchpointCount; 64 } 65 66 template<typename Func> 67 void addAdaptiveStructureWatchpoint(const Func& function) 68 { 69 if (m_mode == WatchpointRegistrationMode::Add) 70 function(m_adaptiveStructureWatchpoints[m_adaptiveStructureWatchpointsIndex++]); 71 else 72 ++m_adaptiveStructureWatchpointCount; 73 } 74 75 template<typename Func> 76 void addAdaptiveInferredPropertyValueWatchpoint(const Func& function) 77 { 78 if (m_mode == WatchpointRegistrationMode::Add) 79 function(m_adaptiveInferredPropertyValueWatchpoints[m_adaptiveInferredPropertyValueWatchpointsIndex++]); 80 else 81 ++m_adaptiveInferredPropertyValueWatchpointCount; 82 } 83 84 void finalize(CodeBlock*, CommonData&); 85 86 WatchpointRegistrationMode mode() const { return m_mode; } 87 88 private: 89 unsigned m_watchpointCount { 0 }; 90 unsigned m_adaptiveStructureWatchpointCount { 0 }; 91 unsigned m_adaptiveInferredPropertyValueWatchpointCount { 0 }; 92 93 unsigned m_watchpointIndex { 0 }; 94 unsigned m_adaptiveStructureWatchpointsIndex { 0 }; 95 unsigned m_adaptiveInferredPropertyValueWatchpointsIndex { 0 }; 96 97 FixedVector<CodeBlockJettisoningWatchpoint> m_watchpoints; 98 FixedVector<AdaptiveStructureWatchpoint> m_adaptiveStructureWatchpoints; 99 FixedVector<AdaptiveInferredPropertyValueWatchpoint> m_adaptiveInferredPropertyValueWatchpoints; 100 WatchpointRegistrationMode m_mode { WatchpointRegistrationMode::Collect }; 101 }; 102 44 103 template<typename T> 45 104 struct SetPointerAdaptor { 46 static void add(CodeBlock* codeBlock, T set, CommonData& common) 47 { 48 CodeBlockJettisoningWatchpoint* watchpoint = nullptr; 49 { 50 ConcurrentJSLocker locker(codeBlock->m_lock); 51 watchpoint = common.watchpoints.add(codeBlock); 52 } 53 return set->add(WTFMove(watchpoint)); 105 static void add(CodeBlock* codeBlock, T set, WatchpointCollector& collector) 106 { 107 collector.addWatchpoint([&](CodeBlockJettisoningWatchpoint& watchpoint) { 108 { 109 ConcurrentJSLocker locker(codeBlock->m_lock); 110 watchpoint.initialize(codeBlock); 111 } 112 set->add(&watchpoint); 113 }); 54 114 } 55 115 static bool hasBeenInvalidated(T set) … … 64 124 65 125 struct SymbolTableAdaptor { 66 static void add(CodeBlock*, SymbolTable*, CommonData&);126 static void add(CodeBlock*, SymbolTable*, WatchpointCollector&); 67 127 static bool hasBeenInvalidated(SymbolTable* symbolTable) 68 128 { … … 76 136 77 137 struct FunctionExecutableAdaptor { 78 static void add(CodeBlock*, FunctionExecutable*, CommonData&);138 static void add(CodeBlock*, FunctionExecutable*, WatchpointCollector&); 79 139 static bool hasBeenInvalidated(FunctionExecutable* executable) 80 140 { … … 88 148 89 149 struct ArrayBufferViewWatchpointAdaptor { 90 static void add(CodeBlock*, JSArrayBufferView*, CommonData&);150 static void add(CodeBlock*, JSArrayBufferView*, WatchpointCollector&); 91 151 static bool hasBeenInvalidated(JSArrayBufferView* view) 92 152 { … … 100 160 101 161 struct AdaptiveStructureWatchpointAdaptor { 102 static void add(CodeBlock*, const ObjectPropertyCondition&, CommonData&);162 static void add(CodeBlock*, const ObjectPropertyCondition&, WatchpointCollector&); 103 163 static bool hasBeenInvalidated(const ObjectPropertyCondition& key) 104 164 { … … 128 188 } 129 189 130 void reallyAdd(CodeBlock* codeBlock, CommonData& common) 131 { 132 RELEASE_ASSERT(!m_reallyAdded); 190 void reallyAdd(CodeBlock* codeBlock, WatchpointCollector& collector) 191 { 192 if (collector.mode() == WatchpointRegistrationMode::Add) 193 RELEASE_ASSERT(!m_reallyAdded); 133 194 134 195 for (auto& set : m_sets) 135 Adaptor::add(codeBlock, set, co mmon);196 Adaptor::add(codeBlock, set, collector); 136 197 137 m_reallyAdded = true; 198 if (collector.mode() == WatchpointRegistrationMode::Add) 199 m_reallyAdded = true; 138 200 } 139 201 … … 181 243 // the required GC magic as well as some other bookkeeping. 182 244 void addLazily(const ObjectPropertyCondition&); 245 246 void addLazily(DesiredGlobalProperty&&); 183 247 184 248 bool consider(Structure*); 185 249 186 void reallyAdd(CodeBlock*, CommonData&);250 void reallyAdd(CodeBlock*, DesiredIdentifiers&, CommonData*); 187 251 188 252 bool areStillValid() const; 253 bool areStillValidOnMainThread(VM&, DesiredIdentifiers&); 189 254 190 255 bool isWatched(WatchpointSet* set) … … 221 286 GenericDesiredWatchpoints<JSArrayBufferView*, ArrayBufferViewWatchpointAdaptor> m_bufferViews; 222 287 GenericDesiredWatchpoints<ObjectPropertyCondition, AdaptiveStructureWatchpointAdaptor> m_adaptiveStructureSets; 288 DesiredGlobalProperties m_globalProperties; 223 289 }; 224 290 -
trunk/Source/JavaScriptCore/dfg/DFGGraph.cpp
r275866 r276226 1105 1105 return false; 1106 1106 } 1107 globalProperties().addLazily(DesiredGlobalProperty(globalObject, identifierNumber));1107 watchpoints().addLazily(DesiredGlobalProperty(globalObject, identifierNumber)); 1108 1108 return true; 1109 1109 } -
trunk/Source/JavaScriptCore/dfg/DFGGraph.h
r276005 r276226 836 836 DesiredIdentifiers& identifiers() { return m_plan.identifiers(); } 837 837 DesiredWatchpoints& watchpoints() { return m_plan.watchpoints(); } 838 DesiredGlobalProperties& globalProperties() { return m_plan.globalProperties(); }839 838 840 839 // Returns false if the key is already invalid or unwatchable. If this is a Presence condition, -
trunk/Source/JavaScriptCore/dfg/DFGPlan.cpp
r276005 r276226 572 572 { 573 573 ASSERT(m_vm->heap.isDeferred()); 574 m_watchpoints.reallyAdd(m_codeBlock, *commonData);575 574 m_identifiers.reallyAdd(*m_vm, commonData); 576 575 m_weakReferences.reallyAdd(*m_vm, commonData); 577 576 m_transitions.reallyAdd(*m_vm, commonData); 578 m_ globalProperties.reallyAdd(m_codeBlock, m_identifiers, *commonData);577 m_watchpoints.reallyAdd(m_codeBlock, m_identifiers, commonData); 579 578 { 580 579 ConcurrentJSLocker locker(m_codeBlock->m_lock); … … 596 595 bool Plan::isStillValidOnMainThread() 597 596 { 598 return m_ globalProperties.isStillValidOnMainThread(*m_vm, m_identifiers);597 return m_watchpoints.areStillValidOnMainThread(*m_vm, m_identifiers); 599 598 } 600 599 … … 758 757 m_watchpoints = DesiredWatchpoints(); 759 758 m_identifiers = DesiredIdentifiers(); 760 m_globalProperties = DesiredGlobalProperties();761 759 m_weakReferences = DesiredWeakReferences(); 762 760 m_transitions = DesiredTransitions(); -
trunk/Source/JavaScriptCore/dfg/DFGPlan.h
r275542 r276226 101 101 DesiredWeakReferences& weakReferences() { return m_weakReferences; } 102 102 DesiredTransitions& transitions() { return m_transitions; } 103 DesiredGlobalProperties& globalProperties() { return m_globalProperties; }104 103 RecordedStatuses& recordedStatuses() { return m_recordedStatuses; } 105 104 … … 157 156 DesiredWeakReferences m_weakReferences; 158 157 DesiredTransitions m_transitions; 159 DesiredGlobalProperties m_globalProperties;160 158 RecordedStatuses m_recordedStatuses; 161 159
Note:
See TracChangeset
for help on using the changeset viewer.