Changeset 249706 in webkit
- Timestamp:
- Sep 9, 2019, 10:03:13 PM (7 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 7 edited
-
ChangeLog (modified) (1 diff)
-
bytecode/CodeBlock.cpp (modified) (2 diffs)
-
bytecode/CodeBlock.h (modified) (2 diffs)
-
dfg/DFGDesiredWatchpoints.cpp (modified) (3 diffs)
-
dfg/DFGGraph.cpp (modified) (2 diffs)
-
dfg/DFGJITFinalizer.cpp (modified) (1 diff)
-
dfg/DFGLazyJSValue.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r249677 r249706 1 2019-09-09 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] CodeBlock::m_constantRegisters should be guarded by ConcurrentJSLock when Vector reallocate memory 4 https://bugs.webkit.org/show_bug.cgi?id=201622 5 6 Reviewed by Mark Lam. 7 8 CodeBlock::visitChildren takes ConcurrentJSLock while iterating m_constantRegisters, some of the places reallocate 9 this Vector without taking a lock. If a Vector memory is reallocated while iterating it in concurrent collector, 10 the concurrent collector can see a garbage. This patch guards m_constantRegisters reallocation with ConcurrentJSLock. 11 12 * bytecode/CodeBlock.cpp: 13 (JSC::CodeBlock::finishCreation): 14 (JSC::CodeBlock::setConstantRegisters): 15 * bytecode/CodeBlock.h: 16 (JSC::CodeBlock::addConstant): 17 (JSC::CodeBlock::addConstantLazily): 18 * dfg/DFGDesiredWatchpoints.cpp: 19 (JSC::DFG::ArrayBufferViewWatchpointAdaptor::add): 20 (JSC::DFG::SymbolTableAdaptor::add): 21 (JSC::DFG::FunctionExecutableAdaptor::add): 22 * dfg/DFGGraph.cpp: 23 (JSC::DFG::Graph::registerFrozenValues): 24 * dfg/DFGJITFinalizer.cpp: 25 (JSC::DFG::JITFinalizer::finalizeCommon): 26 * dfg/DFGLazyJSValue.cpp: 27 (JSC::DFG::LazyJSValue::emit const): 28 1 29 2019-09-09 Robin Morisset <rmorisset@apple.com> 2 30 -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r249668 r249706 597 597 // Keep the linked module environment strongly referenced. 598 598 if (stronglyReferencedModuleEnvironments.add(jsCast<JSModuleEnvironment*>(op.lexicalEnvironment)).isNewEntry) 599 addConstant( op.lexicalEnvironment);599 addConstant(ConcurrentJSLocker(m_lock), op.lexicalEnvironment); 600 600 metadata.m_lexicalEnvironment.set(vm, this, op.lexicalEnvironment); 601 601 } else … … 900 900 ASSERT(constants.size() == constantsSourceCodeRepresentation.size()); 901 901 size_t count = constants.size(); 902 m_constantRegisters.resizeToFit(count); 902 { 903 ConcurrentJSLocker locker(m_lock); 904 m_constantRegisters.resizeToFit(count); 905 } 903 906 for (size_t i = 0; i < count; i++) { 904 907 JSValue constant = constants[i].get(); -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.h
r249319 r249706 547 547 Vector<WriteBarrier<Unknown>>& constants() { return m_constantRegisters; } 548 548 Vector<SourceCodeRepresentation>& constantsSourceCodeRepresentation() { return m_constantsSourceCodeRepresentation; } 549 unsigned addConstant( JSValue v)549 unsigned addConstant(const ConcurrentJSLocker&, JSValue v) 550 550 { 551 551 unsigned result = m_constantRegisters.size(); … … 556 556 } 557 557 558 unsigned addConstantLazily( )558 unsigned addConstantLazily(const ConcurrentJSLocker&) 559 559 { 560 560 unsigned result = m_constantRegisters.size(); -
trunk/Source/JavaScriptCore/dfg/DFGDesiredWatchpoints.cpp
r249175 r249706 44 44 ArrayBufferNeuteringWatchpointSet::create(vm); 45 45 neuteringWatchpoint->set().add(watchpoint); 46 codeBlock->addConstant( neuteringWatchpoint);46 codeBlock->addConstant(ConcurrentJSLocker(codeBlock->m_lock), neuteringWatchpoint); 47 47 // FIXME: We don't need to set this watchpoint at all for shared buffers. 48 48 // https://bugs.webkit.org/show_bug.cgi?id=164108 … … 53 53 CodeBlock* codeBlock, SymbolTable* symbolTable, CommonData& common) 54 54 { 55 codeBlock->addConstant( 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.55 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. 56 56 symbolTable->singleton().add(common.watchpoints.add(codeBlock)); 57 57 } … … 60 60 CodeBlock* codeBlock, FunctionExecutable* executable, CommonData& common) 61 61 { 62 codeBlock->addConstant( 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.62 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. 63 63 executable->singleton().add(common.watchpoints.add(codeBlock)); 64 64 } -
trunk/Source/JavaScriptCore/dfg/DFGGraph.cpp
r249509 r249706 1406 1406 void Graph::registerFrozenValues() 1407 1407 { 1408 ConcurrentJSLocker locker(m_codeBlock->m_lock); 1408 1409 m_codeBlock->constants().shrink(0); 1409 1410 m_codeBlock->constantsSourceCodeRepresentation().resize(0); … … 1421 1422 } 1422 1423 case StrongValue: { 1423 unsigned constantIndex = m_codeBlock->addConstantLazily( );1424 unsigned constantIndex = m_codeBlock->addConstantLazily(locker); 1424 1425 // We already have a barrier on the code block. 1425 1426 m_codeBlock->constants()[constantIndex].setWithoutWriteBarrier(value->value()); -
trunk/Source/JavaScriptCore/dfg/DFGJITFinalizer.cpp
r244764 r249706 83 83 { 84 84 // Some JIT finalizers may have added more constants. Shrink-to-fit those things now. 85 m_plan.codeBlock()->constants().shrinkToFit(); 86 m_plan.codeBlock()->constantsSourceCodeRepresentation().shrinkToFit(); 85 { 86 ConcurrentJSLocker locker(m_plan.codeBlock()->m_lock); 87 m_plan.codeBlock()->constants().shrinkToFit(); 88 m_plan.codeBlock()->constantsSourceCodeRepresentation().shrinkToFit(); 89 } 87 90 88 91 #if ENABLE(FTL_JIT) -
trunk/Source/JavaScriptCore/dfg/DFGLazyJSValue.cpp
r249175 r249706 255 255 RELEASE_ASSERT(realValue.isCell()); 256 256 257 codeBlock->addConstant( realValue);257 codeBlock->addConstant(ConcurrentJSLocker(codeBlock->m_lock), realValue); 258 258 259 259 if (thisValue.m_kind == NewStringImpl)
Note:
See TracChangeset
for help on using the changeset viewer.