Changeset 190589 in webkit
- Timestamp:
- Oct 5, 2015, 4:31:53 PM (10 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 57 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r190569 r190589 1 2015-10-01 Geoffrey Garen <[email protected]> 2 3 Unreviewed, rolling back in r190450 4 https://bugs.webkit.org/show_bug.cgi?id=149727 5 6 The cause of the leak was VM shutdown, which happens in workers. 7 8 The fix is for CodeBlockSet to participate in lastChanceToFinalize, 9 since it's responsible for running CodeBlock destructors. 10 11 I ran the leaks tests locally and did not see any CodeBlock-related leaks. 12 13 Restored changesets: 14 15 "CodeBlock should be a GC object" 16 https://bugs.webkit.org/show_bug.cgi?id=149727 17 http://trac.webkit.org/changeset/190450 18 1 19 2015-10-03 Filip Pizlo <[email protected]> 2 20 -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r190569 r190589 83 83 namespace JSC { 84 84 85 const ClassInfo CodeBlock::s_info = { 86 "CodeBlock", 0, 0, 87 CREATE_METHOD_TABLE(CodeBlock) 88 }; 89 90 const ClassInfo FunctionCodeBlock::s_info = { 91 "FunctionCodeBlock", &Base::s_info, 0, 92 CREATE_METHOD_TABLE(FunctionCodeBlock) 93 }; 94 95 #if ENABLE(WEBASSEMBLY) 96 const ClassInfo WebAssemblyCodeBlock::s_info = { 97 "WebAssemblyCodeBlock", &Base::s_info, 0, 98 CREATE_METHOD_TABLE(WebAssemblyCodeBlock) 99 }; 100 #endif 101 102 const ClassInfo GlobalCodeBlock::s_info = { 103 "GlobalCodeBlock", &Base::s_info, 0, 104 CREATE_METHOD_TABLE(GlobalCodeBlock) 105 }; 106 107 const ClassInfo ProgramCodeBlock::s_info = { 108 "ProgramCodeBlock", &Base::s_info, 0, 109 CREATE_METHOD_TABLE(ProgramCodeBlock) 110 }; 111 112 const ClassInfo ModuleProgramCodeBlock::s_info = { 113 "ModuleProgramCodeBlock", &Base::s_info, 0, 114 CREATE_METHOD_TABLE(ModuleProgramCodeBlock) 115 }; 116 117 const ClassInfo EvalCodeBlock::s_info = { 118 "EvalCodeBlock", &Base::s_info, 0, 119 CREATE_METHOD_TABLE(EvalCodeBlock) 120 }; 121 122 void FunctionCodeBlock::destroy(JSCell* cell) 123 { 124 jsCast<FunctionCodeBlock*>(cell)->~FunctionCodeBlock(); 125 } 126 127 #if ENABLE(WEBASSEMBLY) 128 void WebAssemblyCodeBlock::destroy(JSCell* cell) 129 { 130 jsCast<WebAssemblyCodeBlock*>(cell)->~WebAssemblyCodeBlock(); 131 } 132 #endif 133 134 void ProgramCodeBlock::destroy(JSCell* cell) 135 { 136 jsCast<ProgramCodeBlock*>(cell)->~ProgramCodeBlock(); 137 } 138 139 void ModuleProgramCodeBlock::destroy(JSCell* cell) 140 { 141 jsCast<ModuleProgramCodeBlock*>(cell)->~ModuleProgramCodeBlock(); 142 } 143 144 void EvalCodeBlock::destroy(JSCell* cell) 145 { 146 jsCast<EvalCodeBlock*>(cell)->~EvalCodeBlock(); 147 } 148 85 149 CString CodeBlock::inferredName() const 86 150 { … … 154 218 out.print(":[", RawPointer(this), "->"); 155 219 if (!!m_alternative) 156 out.print(RawPointer( m_alternative.get()), "->");220 out.print(RawPointer(alternative()), "->"); 157 221 out.print(RawPointer(ownerExecutable()), ", ", jitType, codeType()); 158 222 … … 1582 1646 } // anonymous namespace 1583 1647 1584 CodeBlock::CodeBlock(CopyParsedBlockTag, CodeBlock& other) 1585 : m_globalObject(other.m_globalObject) 1648 CodeBlock::CodeBlock(VM* vm, Structure* structure, CopyParsedBlockTag, CodeBlock& other) 1649 : JSCell(*vm, structure) 1650 , m_globalObject(other.m_globalObject) 1586 1651 , m_heap(other.m_heap) 1587 1652 , m_numCalleeRegisters(other.m_numCalleeRegisters) … … 1591 1656 , m_didFailFTLCompilation(false) 1592 1657 , m_hasBeenCompiledWithFTL(false) 1593 , m_unlinkedCode(*other.m_vm, other.m_ownerExecutable.get(), other.m_unlinkedCode.get())1658 , m_unlinkedCode(*other.m_vm, this, other.m_unlinkedCode.get()) 1594 1659 , m_hasDebuggerStatement(false) 1595 1660 , m_steppingMode(SteppingModeDisabled) 1596 1661 , m_numBreakpoints(0) 1597 , m_ownerExecutable(*other.m_vm, other.m_ownerExecutable.get(), other.m_ownerExecutable.get())1662 , m_ownerExecutable(*other.m_vm, this, other.m_ownerExecutable.get()) 1598 1663 , m_vm(other.m_vm) 1599 1664 , m_instructions(other.m_instructions) … … 1620 1685 #endif 1621 1686 { 1622 m_visitStronglyHasBeenCalled.store(false, std::memory_order_relaxed); 1623 m_visitAggregateHasBeenCalled.store(false, std::memory_order_relaxed); 1687 m_visitWeaklyHasBeenCalled.store(false, std::memory_order_relaxed); 1624 1688 1625 1689 ASSERT(m_heap->isDeferred()); … … 1627 1691 1628 1692 setNumParameters(other.numParameters()); 1693 } 1694 1695 void CodeBlock::finishCreation(VM& vm, CopyParsedBlockTag, CodeBlock& other) 1696 { 1697 Base::finishCreation(vm); 1698 1629 1699 optimizeAfterWarmUp(); 1630 1700 jitAfterWarmUp(); … … 1640 1710 1641 1711 m_heap->m_codeBlocks.add(this); 1642 m_heap->reportExtraMemoryAllocated(sizeof(CodeBlock)); 1643 } 1644 1645 CodeBlock::CodeBlock(ScriptExecutable* ownerExecutable, UnlinkedCodeBlock* unlinkedCodeBlock, JSScope* scope, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, unsigned firstLineColumnOffset) 1646 : m_globalObject(scope->globalObject()->vm(), ownerExecutable, scope->globalObject()) 1712 } 1713 1714 CodeBlock::CodeBlock(VM* vm, Structure* structure, ScriptExecutable* ownerExecutable, UnlinkedCodeBlock* unlinkedCodeBlock, 1715 JSScope* scope, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, unsigned firstLineColumnOffset) 1716 : JSCell(*vm, structure) 1717 , m_globalObject(scope->globalObject()->vm(), this, scope->globalObject()) 1647 1718 , m_heap(&m_globalObject->vm().heap) 1648 1719 , m_numCalleeRegisters(unlinkedCodeBlock->m_numCalleeRegisters) … … 1652 1723 , m_didFailFTLCompilation(false) 1653 1724 , m_hasBeenCompiledWithFTL(false) 1654 , m_unlinkedCode(m_globalObject->vm(), ownerExecutable, unlinkedCodeBlock)1725 , m_unlinkedCode(m_globalObject->vm(), this, unlinkedCodeBlock) 1655 1726 , m_hasDebuggerStatement(false) 1656 1727 , m_steppingMode(SteppingModeDisabled) 1657 1728 , m_numBreakpoints(0) 1658 , m_ownerExecutable(m_globalObject->vm(), ownerExecutable, ownerExecutable)1729 , m_ownerExecutable(m_globalObject->vm(), this, ownerExecutable) 1659 1730 , m_vm(unlinkedCodeBlock->vm()) 1660 1731 , m_thisRegister(unlinkedCodeBlock->thisRegister()) … … 1675 1746 #endif 1676 1747 { 1677 m_visitStronglyHasBeenCalled.store(false, std::memory_order_relaxed); 1678 m_visitAggregateHasBeenCalled.store(false, std::memory_order_relaxed); 1748 m_visitWeaklyHasBeenCalled.store(false, std::memory_order_relaxed); 1679 1749 1680 1750 ASSERT(m_heap->isDeferred()); … … 1683 1753 ASSERT(m_source); 1684 1754 setNumParameters(unlinkedCodeBlock->numParameters()); 1685 1686 if (vm()->typeProfiler() || vm()->controlFlowProfiler()) 1687 vm()->functionHasExecutedCache()->removeUnexecutedRange(ownerExecutable->sourceID(), ownerExecutable->typeProfilingStartOffset(), ownerExecutable->typeProfilingEndOffset()); 1755 } 1756 1757 void CodeBlock::finishCreation(VM& vm, ScriptExecutable* ownerExecutable, UnlinkedCodeBlock* unlinkedCodeBlock, 1758 JSScope* scope) 1759 { 1760 Base::finishCreation(vm); 1761 1762 if (vm.typeProfiler() || vm.controlFlowProfiler()) 1763 vm.functionHasExecutedCache()->removeUnexecutedRange(ownerExecutable->sourceID(), ownerExecutable->typeProfilingStartOffset(), ownerExecutable->typeProfilingEndOffset()); 1688 1764 1689 1765 setConstantRegisters(unlinkedCodeBlock->constantRegisters(), unlinkedCodeBlock->constantsSourceCodeRepresentation()); 1690 1766 if (unlinkedCodeBlock->usesGlobalObject()) 1691 m_constantRegisters[unlinkedCodeBlock->globalObjectRegister().toConstantIndex()].set(*m_vm, ownerExecutable, m_globalObject.get());1767 m_constantRegisters[unlinkedCodeBlock->globalObjectRegister().toConstantIndex()].set(*m_vm, this, m_globalObject.get()); 1692 1768 1693 1769 for (unsigned i = 0; i < LinkTimeConstantCount; i++) { 1694 1770 LinkTimeConstant type = static_cast<LinkTimeConstant>(i); 1695 1771 if (unsigned registerIndex = unlinkedCodeBlock->registerIndexForLinkTimeConstant(type)) 1696 m_constantRegisters[registerIndex].set(*m_vm, ownerExecutable, m_globalObject->jsCellForLinkTimeConstant(type));1772 m_constantRegisters[registerIndex].set(*m_vm, this, m_globalObject->jsCellForLinkTimeConstant(type)); 1697 1773 } 1698 1774 … … 1709 1785 symbolTable->prepareForTypeProfiling(locker); 1710 1786 } 1711 m_constantRegisters[i].set(*m_vm, ownerExecutable, symbolTable->cloneScopePart(*m_vm));1787 m_constantRegisters[i].set(*m_vm, this, symbolTable->cloneScopePart(*m_vm)); 1712 1788 clonedConstantSymbolTables.add(i + FirstConstantRegisterIndex); 1713 1789 } … … 1729 1805 for (size_t count = unlinkedCodeBlock->numberOfFunctionDecls(), i = 0; i < count; ++i) { 1730 1806 UnlinkedFunctionExecutable* unlinkedExecutable = unlinkedCodeBlock->functionDecl(i); 1731 if (vm ()->typeProfiler() || vm()->controlFlowProfiler())1732 vm ()->functionHasExecutedCache()->insertUnexecutedRange(ownerExecutable->sourceID(), unlinkedExecutable->typeProfilingStartOffset(), unlinkedExecutable->typeProfilingEndOffset());1733 m_functionDecls[i].set(*m_vm, ownerExecutable, unlinkedExecutable->link(*m_vm, ownerExecutable->source()));1807 if (vm.typeProfiler() || vm.controlFlowProfiler()) 1808 vm.functionHasExecutedCache()->insertUnexecutedRange(ownerExecutable->sourceID(), unlinkedExecutable->typeProfilingStartOffset(), unlinkedExecutable->typeProfilingEndOffset()); 1809 m_functionDecls[i].set(*m_vm, this, unlinkedExecutable->link(*m_vm, ownerExecutable->source())); 1734 1810 } 1735 1811 … … 1737 1813 for (size_t count = unlinkedCodeBlock->numberOfFunctionExprs(), i = 0; i < count; ++i) { 1738 1814 UnlinkedFunctionExecutable* unlinkedExecutable = unlinkedCodeBlock->functionExpr(i); 1739 if (vm ()->typeProfiler() || vm()->controlFlowProfiler())1740 vm ()->functionHasExecutedCache()->insertUnexecutedRange(ownerExecutable->sourceID(), unlinkedExecutable->typeProfilingStartOffset(), unlinkedExecutable->typeProfilingEndOffset());1741 m_functionExprs[i].set(*m_vm, ownerExecutable, unlinkedExecutable->link(*m_vm, ownerExecutable->source()));1815 if (vm.typeProfiler() || vm.controlFlowProfiler()) 1816 vm.functionHasExecutedCache()->insertUnexecutedRange(ownerExecutable->sourceID(), unlinkedExecutable->typeProfilingStartOffset(), unlinkedExecutable->typeProfilingEndOffset()); 1817 m_functionExprs[i].set(*m_vm, this, unlinkedExecutable->link(*m_vm, ownerExecutable->source())); 1742 1818 } 1743 1819 … … 1818 1894 unsigned opLength = opcodeLength(pc[0].u.opcode); 1819 1895 1820 instructions[i] = vm ()->interpreter->getOpcode(pc[0].u.opcode);1896 instructions[i] = vm.interpreter->getOpcode(pc[0].u.opcode); 1821 1897 for (size_t j = 1; j < opLength; ++j) { 1822 1898 if (sizeof(int32_t) != sizeof(intptr_t)) … … 1877 1953 1878 1954 instructions[i + opLength - 1] = objectAllocationProfile; 1879 objectAllocationProfile->initialize( *vm(),1955 objectAllocationProfile->initialize(vm, 1880 1956 ownerExecutable, m_globalObject->objectPrototype(), inferredInlineCapacity); 1881 1957 break; … … 1926 2002 if (stronglyReferencedModuleEnvironments.add(jsCast<JSModuleEnvironment*>(op.lexicalEnvironment)).isNewEntry) 1927 2003 addConstant(op.lexicalEnvironment); 1928 instructions[i + 6].u.jsCell.set( *vm(), ownerExecutable, op.lexicalEnvironment);2004 instructions[i + 6].u.jsCell.set(vm, this, op.lexicalEnvironment); 1929 2005 } else 1930 instructions[i + 6].u.symbolTable.set( *vm(), ownerExecutable, op.lexicalEnvironment->symbolTable());2006 instructions[i + 6].u.symbolTable.set(vm, this, op.lexicalEnvironment->symbolTable()); 1931 2007 } else if (JSScope* constantScope = JSScope::constantScopeForCodeBlock(op.type, this)) 1932 instructions[i + 6].u.jsCell.set( *vm(), ownerExecutable, constantScope);2008 instructions[i + 6].u.jsCell.set(vm, this, constantScope); 1933 2009 else 1934 2010 instructions[i + 6].u.pointer = nullptr; … … 1963 2039 instructions[i + 5].u.watchpointSet = op.watchpointSet; 1964 2040 else if (op.structure) 1965 instructions[i + 5].u.structure.set( *vm(), ownerExecutable, op.structure);2041 instructions[i + 5].u.structure.set(vm, this, op.structure); 1966 2042 instructions[i + 6].u.pointer = reinterpret_cast<void*>(op.operand); 1967 2043 break; … … 2000 2076 op.watchpointSet->invalidate(PutToScopeFireDetail(this, ident)); 2001 2077 } else if (op.structure) 2002 instructions[i + 5].u.structure.set( *vm(), ownerExecutable, op.structure);2078 instructions[i + 5].u.structure.set(vm, this, op.structure); 2003 2079 instructions[i + 6].u.pointer = reinterpret_cast<void*>(op.operand); 2004 2080 … … 2007 2083 2008 2084 case op_profile_type: { 2009 RELEASE_ASSERT(vm ()->typeProfiler());2085 RELEASE_ASSERT(vm.typeProfiler()); 2010 2086 // The format of this instruction is: op_profile_type regToProfile, TypeLocation*, flag, identifier?, resolveType? 2011 2087 size_t instructionOffset = i + opLength - 1; … … 2037 2113 // If our parent scope was created while profiling was disabled, it will not have prepared for profiling yet. 2038 2114 symbolTable->prepareForTypeProfiling(locker); 2039 globalVariableID = symbolTable->uniqueIDForVariable(locker, impl, *vm());2040 globalTypeSet = symbolTable->globalTypeSetForVariable(locker, impl, *vm());2115 globalVariableID = symbolTable->uniqueIDForVariable(locker, impl, vm); 2116 globalTypeSet = symbolTable->globalTypeSetForVariable(locker, impl, vm); 2041 2117 } else 2042 2118 globalVariableID = TypeProfilerNoGlobalIDExists; … … 2051 2127 ConcurrentJITLocker locker(symbolTable->m_lock); 2052 2128 // If our parent scope was created while profiling was disabled, it will not have prepared for profiling yet. 2053 globalVariableID = symbolTable->uniqueIDForVariable(locker, ident.impl(), *vm());2054 globalTypeSet = symbolTable->globalTypeSetForVariable(locker, ident.impl(), *vm());2129 globalVariableID = symbolTable->uniqueIDForVariable(locker, ident.impl(), vm); 2130 globalTypeSet = symbolTable->globalTypeSetForVariable(locker, ident.impl(), vm); 2055 2131 2056 2132 break; … … 2078 2154 } 2079 2155 2080 std::pair<TypeLocation*, bool> locationPair = vm ()->typeProfiler()->typeLocationCache()->getTypeLocation(globalVariableID,2081 ownerExecutable->sourceID(), divotStart, divotEnd, globalTypeSet, vm());2156 std::pair<TypeLocation*, bool> locationPair = vm.typeProfiler()->typeLocationCache()->getTypeLocation(globalVariableID, 2157 ownerExecutable->sourceID(), divotStart, divotEnd, globalTypeSet, &vm); 2082 2158 TypeLocation* location = locationPair.first; 2083 2159 bool isNewLocation = locationPair.second; … … 2087 2163 2088 2164 if (shouldAnalyze && isNewLocation) 2089 vm ()->typeProfiler()->insertNewLocation(location);2165 vm.typeProfiler()->insertNewLocation(location); 2090 2166 2091 2167 instructions[i + 2].u.location = location; … … 2105 2181 } 2106 2182 2107 if (vm ()->controlFlowProfiler())2183 if (vm.controlFlowProfiler()) 2108 2184 insertBasicBlockBoundariesForControlFlowProfiler(instructions); 2109 2185 … … 2125 2201 2126 2202 m_heap->m_codeBlocks.add(this); 2127 m_heap->reportExtraMemoryAllocated( sizeof(CodeBlock) +m_instructions.size() * sizeof(Instruction));2203 m_heap->reportExtraMemoryAllocated(m_instructions.size() * sizeof(Instruction)); 2128 2204 } 2129 2205 2130 2206 #if ENABLE(WEBASSEMBLY) 2131 CodeBlock::CodeBlock(WebAssemblyExecutable* ownerExecutable, VM& vm, JSGlobalObject* globalObject) 2132 : m_globalObject(globalObject->vm(), ownerExecutable, globalObject) 2207 CodeBlock::CodeBlock(VM* vm, Structure* structure, WebAssemblyExecutable* ownerExecutable, VM& vm, JSGlobalObject* globalObject) 2208 : JSCell(vm, structure) 2209 , m_globalObject(globalObject->vm(), this, globalObject) 2133 2210 , m_heap(&m_globalObject->vm().heap) 2134 2211 , m_numCalleeRegisters(0) … … 2141 2218 , m_steppingMode(SteppingModeDisabled) 2142 2219 , m_numBreakpoints(0) 2143 , m_ownerExecutable(m_globalObject->vm(), ownerExecutable, ownerExecutable)2220 , m_ownerExecutable(m_globalObject->vm(), this, ownerExecutable) 2144 2221 , m_vm(&vm) 2145 2222 , m_isStrictMode(false) … … 2155 2232 { 2156 2233 ASSERT(m_heap->isDeferred()); 2234 } 2235 2236 void CodeBlock::finishCreation(VM& vm, WebAssemblyExecutable*, JSGlobalObject*) 2237 { 2238 Base::finishCreation(vm); 2157 2239 2158 2240 m_heap->m_codeBlocks.add(this); 2159 m_heap->reportExtraMemoryAllocated(sizeof(CodeBlock));2160 2241 } 2161 2242 #endif … … 2169 2250 dumpValueProfiles(); 2170 2251 #endif 2171 while (m_incomingLLIntCalls.begin() != m_incomingLLIntCalls.end()) 2172 m_incomingLLIntCalls.begin()->remove(); 2173 #if ENABLE(JIT) 2252 2174 2253 // We may be destroyed before any CodeBlocks that refer to us are destroyed. 2175 2254 // Consider that two CodeBlocks become unreachable at the same time. There … … 2178 2257 // CodeBlock(s) that have calls into us, then the CallLinkInfo vector's 2179 2258 // destructor will try to remove nodes from our (no longer valid) linked list. 2180 while (m_incomingCalls.begin() != m_incomingCalls.end()) 2181 m_incomingCalls.begin()->remove(); 2182 while (m_incomingPolymorphicCalls.begin() != m_incomingPolymorphicCalls.end()) 2183 m_incomingPolymorphicCalls.begin()->remove(); 2259 unlinkIncomingCalls(); 2184 2260 2185 2261 // Note that our outgoing calls will be removed from other CodeBlocks' … … 2187 2263 // destructors. 2188 2264 2265 #if ENABLE(JIT) 2189 2266 for (Bag<StructureStubInfo>::iterator iter = m_stubInfos.begin(); !!iter; ++iter) 2190 2267 (*iter)->deref(); 2191 2268 #endif // ENABLE(JIT) 2269 } 2270 2271 void CodeBlock::setAlternative(VM& vm, CodeBlock* alternative) 2272 { 2273 m_alternative.set(vm, this, alternative); 2192 2274 } 2193 2275 … … 2212 2294 return 0; 2213 2295 DFG::JITCode* jitCode = m_jitCode->dfg(); 2214 return jitCode->osrEntryBlock .get();2296 return jitCode->osrEntryBlock(); 2215 2297 #else // ENABLE(FTL_JIT) 2216 2298 return 0; … … 2218 2300 } 2219 2301 2220 void CodeBlock::visit Strongly(SlotVisitor& visitor)2221 { 2222 bool setByMe = m_visit StronglyHasBeenCalled.compareExchangeStrong(false, true);2302 void CodeBlock::visitWeakly(SlotVisitor& visitor) 2303 { 2304 bool setByMe = m_visitWeaklyHasBeenCalled.compareExchangeStrong(false, true); 2223 2305 if (!setByMe) 2224 2306 return; 2225 2307 2226 visitAggregate(visitor); 2227 2228 stronglyVisitStrongReferences(visitor); 2229 stronglyVisitWeakReferences(visitor); 2230 propagateTransitions(visitor); 2231 } 2232 2233 void CodeBlock::visitAggregate(SlotVisitor& visitor) 2234 { 2235 // I may be asked to scan myself more than once, and it may even happen concurrently. 2236 // To this end, use an atomic operation to check (and set) if I've been called already. 2237 // Only one thread may proceed past this point - whichever one wins the atomic set race. 2238 bool setByMe = m_visitAggregateHasBeenCalled.compareExchangeStrong(false, true); 2239 if (!setByMe) 2308 if (Heap::isMarked(this)) 2240 2309 return; 2241 2242 if (!!m_alternative) 2243 m_alternative->visitAggregate(visitor); 2244 2245 if (CodeBlock* otherBlock = specialOSREntryBlockOrNull()) 2246 otherBlock->visitAggregate(visitor); 2247 2248 visitor.reportExtraMemoryVisited(sizeof(CodeBlock)); 2249 if (m_jitCode) 2250 visitor.reportExtraMemoryVisited(m_jitCode->size()); 2251 if (m_instructions.size()) { 2252 // Divide by refCount() because m_instructions points to something that is shared 2253 // by multiple CodeBlocks, and we only want to count it towards the heap size once. 2254 // Having each CodeBlock report only its proportional share of the size is one way 2255 // of accomplishing this. 2256 visitor.reportExtraMemoryVisited(m_instructions.size() * sizeof(Instruction) / m_instructions.refCount()); 2257 } 2258 2259 visitor.append(&m_unlinkedCode); 2310 2311 if (shouldVisitStrongly()) { 2312 visitor.appendUnbarrieredReadOnlyPointer(this); 2313 return; 2314 } 2260 2315 2261 2316 // There are two things that may use unconditional finalizers: inline cache clearing … … 2263 2318 // is probably quite close to 1. So we add one no matter what and when it runs, it 2264 2319 // figures out whether it has any work to do. 2265 visitor.addUnconditionalFinalizer(this); 2266 2267 m_allTransitionsHaveBeenMarked = false; 2268 2269 if (shouldVisitStrongly()) { 2270 visitStrongly(visitor); 2271 return; 2272 } 2273 2320 visitor.addUnconditionalFinalizer(&m_unconditionalFinalizer); 2321 2274 2322 if (!JITCode::isOptimizingJIT(jitType())) 2275 2323 return; 2276 2324 2325 // If we jettison ourselves we'll install our alternative, so make sure that it 2326 // survives GC even if we don't. 2327 visitor.append(&m_alternative); 2328 2277 2329 // There are two things that we use weak reference harvesters for: DFG fixpoint for 2278 2330 // jettisoning, and trying to find structures that would be live based on some 2279 2331 // inline cache. So it makes sense to register them regardless. 2280 visitor.addWeakReferenceHarvester( this);2332 visitor.addWeakReferenceHarvester(&m_weakReferenceHarvester); 2281 2333 2282 2334 #if ENABLE(DFG_JIT) … … 2289 2341 // other reasons, that this iteration should run again; it will notify us of this 2290 2342 // decision by calling harvestWeakReferences(). 2291 2343 2344 m_allTransitionsHaveBeenMarked = false; 2345 propagateTransitions(visitor); 2346 2292 2347 m_jitCode->dfgCommon()->livenessHasBeenProved = false; 2293 2294 propagateTransitions(visitor);2295 2348 determineLiveness(visitor); 2296 2349 #endif // ENABLE(DFG_JIT) 2350 } 2351 2352 void CodeBlock::visitChildren(JSCell* cell, SlotVisitor& visitor) 2353 { 2354 CodeBlock* thisObject = jsCast<CodeBlock*>(cell); 2355 ASSERT_GC_OBJECT_INHERITS(thisObject, info()); 2356 JSCell::visitChildren(thisObject, visitor); 2357 thisObject->visitChildren(visitor); 2358 } 2359 2360 void CodeBlock::visitChildren(SlotVisitor& visitor) 2361 { 2362 // There are two things that may use unconditional finalizers: inline cache clearing 2363 // and jettisoning. The probability of us wanting to do at least one of those things 2364 // is probably quite close to 1. So we add one no matter what and when it runs, it 2365 // figures out whether it has any work to do. 2366 visitor.addUnconditionalFinalizer(&m_unconditionalFinalizer); 2367 2368 if (CodeBlock* otherBlock = specialOSREntryBlockOrNull()) 2369 visitor.appendUnbarrieredReadOnlyPointer(otherBlock); 2370 2371 if (m_jitCode) 2372 visitor.reportExtraMemoryVisited(m_jitCode->size()); 2373 if (m_instructions.size()) 2374 visitor.reportExtraMemoryVisited(m_instructions.size() * sizeof(Instruction) / m_instructions.refCount()); 2375 2376 visitor.append(&m_unlinkedCode); 2377 2378 stronglyVisitStrongReferences(visitor); 2379 stronglyVisitWeakReferences(visitor); 2380 2381 m_allTransitionsHaveBeenMarked = false; 2382 propagateTransitions(visitor); 2297 2383 } 2298 2384 … … 2324 2410 // - Code blocks that don't have any dead weak references. 2325 2411 2326 if (m_visitStronglyHasBeenCalled.load(std::memory_order_relaxed)) 2327 return true; 2328 2329 #if ENABLE(DFG_JIT) 2330 if (JITCode::isOptimizingJIT(jitType())) { 2331 if (m_jitCode->dfgCommon()->livenessHasBeenProved) 2332 return true; 2333 } 2334 #endif 2335 2336 return false; 2412 return Heap::isMarked(this); 2337 2413 } 2338 2414 … … 2344 2420 } 2345 2421 2422 static std::chrono::milliseconds timeToLive(JITCode::JITType jitType) 2423 { 2424 switch (jitType) { 2425 case JITCode::InterpreterThunk: 2426 return std::chrono::duration_cast<std::chrono::milliseconds>( 2427 std::chrono::seconds(5)); 2428 case JITCode::BaselineJIT: 2429 // Effectively 10 additional seconds, since BaselineJIT and 2430 // InterpreterThunk share a CodeBlock. 2431 return std::chrono::duration_cast<std::chrono::milliseconds>( 2432 std::chrono::seconds(15)); 2433 case JITCode::DFGJIT: 2434 return std::chrono::duration_cast<std::chrono::milliseconds>( 2435 std::chrono::seconds(20)); 2436 case JITCode::FTLJIT: 2437 return std::chrono::duration_cast<std::chrono::milliseconds>( 2438 std::chrono::seconds(60)); 2439 default: 2440 return std::chrono::milliseconds::max(); 2441 } 2442 } 2443 2346 2444 bool CodeBlock::shouldJettisonDueToOldAge() 2347 2445 { 2348 if ( m_visitStronglyHasBeenCalled.load(std::memory_order_relaxed))2446 if (Heap::isMarked(this)) 2349 2447 return false; 2350 2448 2351 if (timeSinceCreation() < JITCode::timeToLive(jitType()))2449 if (timeSinceCreation() < timeToLive(jitType())) 2352 2450 return false; 2353 2451 … … 2502 2600 // come back here again, and scan the strong references. 2503 2601 dfgCommon->livenessHasBeenProved = true; 2504 stronglyVisitStrongReferences(visitor);2602 visitor.appendUnbarrieredReadOnlyPointer(this); 2505 2603 #endif // ENABLE(DFG_JIT) 2506 2604 } 2507 2605 2508 void CodeBlock::visitWeakReferences(SlotVisitor& visitor) 2509 { 2510 propagateTransitions(visitor); 2511 determineLiveness(visitor); 2606 void CodeBlock::WeakReferenceHarvester::visitWeakReferences(SlotVisitor& visitor) 2607 { 2608 CodeBlock* codeBlock = 2609 bitwise_cast<CodeBlock*>( 2610 bitwise_cast<char*>(this) - OBJECT_OFFSETOF(CodeBlock, m_weakReferenceHarvester)); 2611 2612 codeBlock->propagateTransitions(visitor); 2613 codeBlock->determineLiveness(visitor); 2512 2614 } 2513 2615 … … 2629 2731 } 2630 2732 2631 void CodeBlock::finalizeUnconditionally() 2632 { 2733 void CodeBlock::UnconditionalFinalizer::finalizeUnconditionally() 2734 { 2735 CodeBlock* codeBlock = bitwise_cast<CodeBlock*>( 2736 bitwise_cast<char*>(this) - OBJECT_OFFSETOF(CodeBlock, m_unconditionalFinalizer)); 2737 2633 2738 #if ENABLE(DFG_JIT) 2634 if ( shouldJettisonDueToWeakReference()) {2635 jettison(Profiler::JettisonDueToWeakReference);2739 if (codeBlock->shouldJettisonDueToWeakReference()) { 2740 codeBlock->jettison(Profiler::JettisonDueToWeakReference); 2636 2741 return; 2637 2742 } 2638 2743 #endif // ENABLE(DFG_JIT) 2639 2744 2640 if ( shouldJettisonDueToOldAge()) {2641 jettison(Profiler::JettisonDueToOldAge);2745 if (codeBlock->shouldJettisonDueToOldAge()) { 2746 codeBlock->jettison(Profiler::JettisonDueToOldAge); 2642 2747 return; 2643 2748 } 2644 2749 2645 if (JITCode::couldBeInterpreted( jitType()))2646 finalizeLLIntInlineCaches();2750 if (JITCode::couldBeInterpreted(codeBlock->jitType())) 2751 codeBlock->finalizeLLIntInlineCaches(); 2647 2752 2648 2753 #if ENABLE(JIT) 2649 if (!! jitCode())2650 finalizeBaselineJITInlineCaches();2754 if (!!codeBlock->jitCode()) 2755 codeBlock->finalizeBaselineJITInlineCaches(); 2651 2756 #endif 2652 2757 } … … 2743 2848 // the OSR exit against. 2744 2849 2745 alternative()->visitStrongly(visitor);2850 visitor.append(&m_alternative); 2746 2851 2747 2852 #if ENABLE(DFG_JIT) … … 2749 2854 if (dfgCommon->inlineCallFrames) { 2750 2855 for (auto* inlineCallFrame : *dfgCommon->inlineCallFrames) { 2751 ASSERT(inlineCallFrame->baselineCodeBlock ());2752 inlineCallFrame->baselineCodeBlock()->visitStrongly(visitor);2856 ASSERT(inlineCallFrame->baselineCodeBlock); 2857 visitor.append(&inlineCallFrame->baselineCodeBlock); 2753 2858 } 2754 2859 } … … 2959 3064 m_incomingLLIntCalls.begin()->unlink(); 2960 3065 #if ENABLE(JIT) 2961 if (m_incomingCalls.isEmpty() && m_incomingPolymorphicCalls.isEmpty())2962 return;2963 3066 while (m_incomingCalls.begin() != m_incomingCalls.end()) 2964 3067 m_incomingCalls.begin()->unlink(*vm()); … … 2974 3077 } 2975 3078 2976 PassRefPtr<CodeBlock>CodeBlock::newReplacement()3079 CodeBlock* CodeBlock::newReplacement() 2977 3080 { 2978 3081 return ownerScriptExecutable()->newReplacementCodeBlockFor(specializationKind()); … … 2980 3083 2981 3084 #if ENABLE(JIT) 2982 CodeBlock* ProgramCodeBlock::replacement() 2983 { 2984 return jsCast<ProgramExecutable*>(ownerExecutable())->codeBlock(); 2985 } 2986 2987 CodeBlock* ModuleProgramCodeBlock::replacement() 2988 { 2989 return jsCast<ModuleProgramExecutable*>(ownerExecutable())->codeBlock(); 2990 } 2991 2992 CodeBlock* EvalCodeBlock::replacement() 2993 { 2994 return jsCast<EvalExecutable*>(ownerExecutable())->codeBlock(); 2995 } 2996 2997 CodeBlock* FunctionCodeBlock::replacement() 2998 { 2999 return jsCast<FunctionExecutable*>(ownerExecutable())->codeBlockFor(m_isConstructor ? CodeForConstruct : CodeForCall); 3000 } 3001 3002 DFG::CapabilityLevel ProgramCodeBlock::capabilityLevelInternal() 3003 { 3004 return DFG::programCapabilityLevel(this); 3005 } 3006 3007 DFG::CapabilityLevel ModuleProgramCodeBlock::capabilityLevelInternal() 3008 { 3009 return DFG::programCapabilityLevel(this); 3010 } 3011 3012 DFG::CapabilityLevel EvalCodeBlock::capabilityLevelInternal() 3013 { 3014 return DFG::evalCapabilityLevel(this); 3015 } 3016 3017 DFG::CapabilityLevel FunctionCodeBlock::capabilityLevelInternal() 3018 { 3019 if (m_isConstructor) 3020 return DFG::functionForConstructCapabilityLevel(this); 3021 return DFG::functionForCallCapabilityLevel(this); 3022 } 3085 CodeBlock* CodeBlock::replacement() 3086 { 3087 const ClassInfo* classInfo = this->classInfo(); 3088 3089 if (classInfo == FunctionCodeBlock::info()) 3090 return jsCast<FunctionExecutable*>(ownerExecutable())->codeBlockFor(m_isConstructor ? CodeForConstruct : CodeForCall); 3091 3092 if (classInfo == EvalCodeBlock::info()) 3093 return jsCast<EvalExecutable*>(ownerExecutable())->codeBlock(); 3094 3095 if (classInfo == ProgramCodeBlock::info()) 3096 return jsCast<ProgramExecutable*>(ownerExecutable())->codeBlock(); 3097 3098 if (classInfo == ModuleProgramCodeBlock::info()) 3099 return jsCast<ModuleProgramExecutable*>(ownerExecutable())->codeBlock(); 3023 3100 3024 3101 #if ENABLE(WEBASSEMBLY) 3025 CodeBlock* WebAssemblyCodeBlock::replacement() 3026 { 3102 if (classInfo == WebAssemblyCodeBlock::info()) 3103 return nullptr 3104 #endif 3105 3106 RELEASE_ASSERT_NOT_REACHED(); 3027 3107 return nullptr; 3028 3108 } 3029 3109 3030 DFG::CapabilityLevel WebAssemblyCodeBlock::capabilityLevelInternal() 3031 { 3110 DFG::CapabilityLevel CodeBlock::computeCapabilityLevel() 3111 { 3112 const ClassInfo* classInfo = this->classInfo(); 3113 3114 if (classInfo == FunctionCodeBlock::info()) { 3115 if (m_isConstructor) 3116 return DFG::functionForConstructCapabilityLevel(this); 3117 return DFG::functionForCallCapabilityLevel(this); 3118 } 3119 3120 if (classInfo == EvalCodeBlock::info()) 3121 return DFG::evalCapabilityLevel(this); 3122 3123 if (classInfo == ProgramCodeBlock::info()) 3124 return DFG::programCapabilityLevel(this); 3125 3126 if (classInfo == ModuleProgramCodeBlock::info()) 3127 return DFG::programCapabilityLevel(this); 3128 3129 #if ENABLE(WEBASSEMBLY) 3130 if (classInfo == WebAssemblyCodeBlock::info()) 3131 return DFG::CannotCompile; 3132 #endif 3133 3134 RELEASE_ASSERT_NOT_REACHED(); 3032 3135 return DFG::CannotCompile; 3033 3136 } 3034 #endif 3035 #endif 3137 3138 #endif // ENABLE(JIT) 3036 3139 3037 3140 void CodeBlock::jettison(Profiler::JettisonReason reason, ReoptimizationMode mode, const FireDetail* detail) … … 3137 3240 if (!codeOrigin.inlineCallFrame) 3138 3241 return globalObject(); 3139 return jsCast<FunctionExecutable*>(codeOrigin.inlineCallFrame->executable.get())->eitherCodeBlock()->globalObject();3242 return codeOrigin.inlineCallFrame->baselineCodeBlock->globalObject(); 3140 3243 } 3141 3244 … … 3977 4080 DFG::CapabilityLevel CodeBlock::capabilityLevel() 3978 4081 { 3979 DFG::CapabilityLevel result = c apabilityLevelInternal();4082 DFG::CapabilityLevel result = computeCapabilityLevel(); 3980 4083 m_capabilityLevelState = result; 3981 4084 return result; -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.h
r190546 r190589 39 39 #include "CodeBlockHash.h" 40 40 #include "CodeBlockSet.h" 41 #include "ConcurrentJITLock.h"42 41 #include "CodeOrigin.h" 43 42 #include "CodeType.h" 44 43 #include "CompactJITCodeMap.h" 44 #include "ConcurrentJITLock.h" 45 45 #include "DFGCommon.h" 46 46 #include "DFGExitProfile.h" … … 50 50 #include "ExpressionRangeInfo.h" 51 51 #include "HandlerInfo.h" 52 #include "ObjectAllocationProfile.h"53 #include "Options.h"54 #include "PutPropertySlot.h"55 52 #include "Instruction.h" 56 53 #include "JITCode.h" 57 54 #include "JITWriteBarrier.h" 55 #include "JSCell.h" 58 56 #include "JSGlobalObject.h" 59 57 #include "JumpTable.h" 60 58 #include "LLIntCallLinkInfo.h" 61 59 #include "LazyOperandValueProfile.h" 60 #include "ObjectAllocationProfile.h" 61 #include "Options.h" 62 62 #include "ProfilerCompilation.h" 63 63 #include "ProfilerJettisonReason.h" 64 #include "PutPropertySlot.h" 64 65 #include "RegExpObject.h" 65 66 #include "StructureStubInfo.h" … … 86 87 enum ReoptimizationMode { DontCountReoptimization, CountReoptimization }; 87 88 88 class CodeBlock : public ThreadSafeRefCounted<CodeBlock>, public UnconditionalFinalizer, public WeakReferenceHarvester{89 WTF_MAKE_FAST_ALLOCATED;89 class CodeBlock : public JSCell { 90 typedef JSCell Base; 90 91 friend class BytecodeLivenessAnalysis; 91 92 friend class JIT; 92 93 friend class LLIntOffsetsExtractor; 94 95 class UnconditionalFinalizer : public JSC::UnconditionalFinalizer { 96 virtual void finalizeUnconditionally() override; 97 }; 98 99 class WeakReferenceHarvester : public JSC::WeakReferenceHarvester { 100 virtual void visitWeakReferences(SlotVisitor&) override; 101 }; 102 93 103 public: 94 104 enum CopyParsedBlockTag { CopyParsedBlock }; 105 106 static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal; 107 108 DECLARE_INFO; 109 95 110 protected: 96 CodeBlock(CopyParsedBlockTag, CodeBlock& other); 97 98 CodeBlock(ScriptExecutable* ownerExecutable, UnlinkedCodeBlock*, JSScope*, PassRefPtr<SourceProvider>, unsigned sourceOffset, unsigned firstLineColumnOffset); 111 CodeBlock(VM*, Structure*, CopyParsedBlockTag, CodeBlock& other); 112 CodeBlock(VM*, Structure*, ScriptExecutable* ownerExecutable, UnlinkedCodeBlock*, JSScope*, PassRefPtr<SourceProvider>, unsigned sourceOffset, unsigned firstLineColumnOffset); 99 113 #if ENABLE(WEBASSEMBLY) 100 CodeBlock(WebAssemblyExecutable* ownerExecutable, VM&, JSGlobalObject*); 114 CodeBlock(VM*, Structure*, WebAssemblyExecutable* ownerExecutable, VM&, JSGlobalObject*); 115 #endif 116 117 void finishCreation(VM&, CopyParsedBlockTag, CodeBlock& other); 118 void finishCreation(VM&, ScriptExecutable* ownerExecutable, UnlinkedCodeBlock*, JSScope*); 119 #if ENABLE(WEBASSEMBLY) 120 void finishCreation(VM&, WebAssemblyExecutable* ownerExecutable, JSGlobalObject*); 101 121 #endif 102 122 … … 105 125 106 126 public: 107 JS_EXPORT_PRIVATE virtual~CodeBlock();127 JS_EXPORT_PRIVATE ~CodeBlock(); 108 128 109 129 UnlinkedCodeBlock* unlinkedCodeBlock() const { return m_unlinkedCode.get(); } … … 125 145 static ptrdiff_t offsetOfNumParameters() { return OBJECT_OFFSETOF(CodeBlock, m_numParameters); } 126 146 127 CodeBlock* alternative() { return m_alternative.get(); }128 void setAlternative( PassRefPtr<CodeBlock> alternative) { m_alternative = alternative; }147 CodeBlock* alternative() const { return static_cast<CodeBlock*>(m_alternative.get()); } 148 void setAlternative(VM&, CodeBlock*); 129 149 130 150 template <typename Functor> void forEachRelatedCodeBlock(Functor&& functor) … … 149 169 return specializationFromIsConstruct(m_isConstructor); 150 170 } 151 171 172 CodeBlock* alternativeForJettison(); 152 173 CodeBlock* baselineAlternative(); 153 174 … … 156 177 CodeBlock* baselineVersion(); 157 178 158 void clearMarks(); 159 void visitAggregate(SlotVisitor&); 160 void visitStrongly(SlotVisitor&); 179 static void visitChildren(JSCell*, SlotVisitor&); 180 void visitChildren(SlotVisitor&); 181 void visitWeakly(SlotVisitor&); 182 void clearVisitWeaklyHasBeenCalled(); 161 183 162 184 void dumpSource(); … … 266 288 267 289 // Exactly equivalent to codeBlock->ownerExecutable()->newReplacementCodeBlockFor(codeBlock->specializationKind()) 268 PassRefPtr<CodeBlock>newReplacement();290 CodeBlock* newReplacement(); 269 291 270 292 void setJITCode(PassRefPtr<JITCode> code) … … 292 314 293 315 #if ENABLE(JIT) 294 virtual CodeBlock* replacement() = 0;295 296 virtual DFG::CapabilityLevel capabilityLevelInternal() = 0;316 CodeBlock* replacement(); 317 318 DFG::CapabilityLevel computeCapabilityLevel(); 297 319 DFG::CapabilityLevel capabilityLevel(); 298 320 DFG::CapabilityLevel capabilityLevelState() { return m_capabilityLevelState; } … … 544 566 unsigned result = m_constantRegisters.size(); 545 567 m_constantRegisters.append(WriteBarrier<Unknown>()); 546 m_constantRegisters.last().set(m_globalObject->vm(), m_ownerExecutable.get(), v);568 m_constantRegisters.last().set(m_globalObject->vm(), this, v); 547 569 m_constantsSourceCodeRepresentation.append(SourceCodeRepresentation::Other); 548 570 return result; … … 896 918 897 919 protected: 898 virtual void visitWeakReferences(SlotVisitor&) override;899 virtual void finalizeUnconditionally() override;900 920 void finalizeLLIntInlineCaches(); 901 921 void finalizeBaselineJITInlineCaches(); … … 924 944 m_constantRegisters.resizeToFit(count); 925 945 for (size_t i = 0; i < count; i++) 926 m_constantRegisters[i].set(*m_vm, ownerExecutable(), constants[i].get());946 m_constantRegisters[i].set(*m_vm, this, constants[i].get()); 927 947 m_constantsSourceCodeRepresentation = constantsSourceCodeRepresentation; 928 948 } … … 931 951 { 932 952 ASSERT(isConstantRegisterIndex(index) && static_cast<size_t>(index - FirstConstantRegisterIndex) < m_constantRegisters.size()); 933 m_constantRegisters[index - FirstConstantRegisterIndex].set(m_globalObject->vm(), m_ownerExecutable.get(), value);953 m_constantRegisters[index - FirstConstantRegisterIndex].set(m_globalObject->vm(), this, value); 934 954 } 935 955 … … 1003 1023 bool m_needsActivation; 1004 1024 1005 Atomic<bool> m_visitAggregateHasBeenCalled; 1006 Atomic<bool> m_visitStronglyHasBeenCalled; 1025 Atomic<bool> m_visitWeaklyHasBeenCalled; 1007 1026 1008 1027 RefPtr<SourceProvider> m_source; … … 1046 1065 Vector<WriteBarrier<FunctionExecutable>> m_functionExprs; 1047 1066 1048 RefPtr<CodeBlock> m_alternative;1067 WriteBarrier<CodeBlock> m_alternative; 1049 1068 1050 1069 BaselineExecutionCounter m_llintExecuteCounter; … … 1066 1085 DFG::CapabilityLevel m_capabilityLevelState; 1067 1086 #endif 1087 1088 UnconditionalFinalizer m_unconditionalFinalizer; 1089 WeakReferenceHarvester m_weakReferenceHarvester; 1068 1090 }; 1069 1091 … … 1072 1094 1073 1095 class GlobalCodeBlock : public CodeBlock { 1096 typedef CodeBlock Base; 1097 DECLARE_INFO; 1098 1074 1099 protected: 1075 GlobalCodeBlock( CopyParsedBlockTag, GlobalCodeBlock& other)1076 : CodeBlock(CopyParsedBlock, other)1077 { 1078 } 1079 1080 GlobalCodeBlock( ScriptExecutable* ownerExecutable, UnlinkedCodeBlock* unlinkedCodeBlock, JSScope* scope, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, unsigned firstLineColumnOffset)1081 : CodeBlock( ownerExecutable, unlinkedCodeBlock, scope, sourceProvider, sourceOffset, firstLineColumnOffset)1100 GlobalCodeBlock(VM* vm, Structure* structure, CopyParsedBlockTag, GlobalCodeBlock& other) 1101 : CodeBlock(vm, structure, CopyParsedBlock, other) 1102 { 1103 } 1104 1105 GlobalCodeBlock(VM* vm, Structure* structure, ScriptExecutable* ownerExecutable, UnlinkedCodeBlock* unlinkedCodeBlock, JSScope* scope, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, unsigned firstLineColumnOffset) 1106 : CodeBlock(vm, structure, ownerExecutable, unlinkedCodeBlock, scope, sourceProvider, sourceOffset, firstLineColumnOffset) 1082 1107 { 1083 1108 } … … 1086 1111 class ProgramCodeBlock : public GlobalCodeBlock { 1087 1112 public: 1088 ProgramCodeBlock(CopyParsedBlockTag, ProgramCodeBlock& other) 1089 : GlobalCodeBlock(CopyParsedBlock, other) 1090 { 1091 } 1092 1093 ProgramCodeBlock(ProgramExecutable* ownerExecutable, UnlinkedProgramCodeBlock* unlinkedCodeBlock, JSScope* scope, PassRefPtr<SourceProvider> sourceProvider, unsigned firstLineColumnOffset) 1094 : GlobalCodeBlock(ownerExecutable, unlinkedCodeBlock, scope, sourceProvider, 0, firstLineColumnOffset) 1095 { 1096 } 1097 1098 #if ENABLE(JIT) 1099 protected: 1100 virtual CodeBlock* replacement() override; 1101 virtual DFG::CapabilityLevel capabilityLevelInternal() override; 1102 #endif 1113 typedef GlobalCodeBlock Base; 1114 DECLARE_INFO; 1115 1116 static ProgramCodeBlock* create(VM* vm, CopyParsedBlockTag, ProgramCodeBlock& other) 1117 { 1118 ProgramCodeBlock* instance = new (NotNull, allocateCell<ProgramCodeBlock>(vm->heap)) 1119 ProgramCodeBlock(vm, vm->programCodeBlockStructure.get(), CopyParsedBlock, other); 1120 instance->finishCreation(*vm, CopyParsedBlock, other); 1121 return instance; 1122 } 1123 1124 static ProgramCodeBlock* create(VM* vm, ProgramExecutable* ownerExecutable, UnlinkedProgramCodeBlock* unlinkedCodeBlock, 1125 JSScope* scope, PassRefPtr<SourceProvider> sourceProvider, unsigned firstLineColumnOffset) 1126 { 1127 ProgramCodeBlock* instance = new (NotNull, allocateCell<ProgramCodeBlock>(vm->heap)) 1128 ProgramCodeBlock(vm, vm->programCodeBlockStructure.get(), ownerExecutable, unlinkedCodeBlock, scope, sourceProvider, firstLineColumnOffset); 1129 instance->finishCreation(*vm, ownerExecutable, unlinkedCodeBlock, scope); 1130 return instance; 1131 } 1132 1133 static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) 1134 { 1135 return Structure::create(vm, globalObject, prototype, TypeInfo(CellType, StructureFlags), info()); 1136 } 1137 1138 private: 1139 ProgramCodeBlock(VM* vm, Structure* structure, CopyParsedBlockTag, ProgramCodeBlock& other) 1140 : GlobalCodeBlock(vm, structure, CopyParsedBlock, other) 1141 { 1142 } 1143 1144 ProgramCodeBlock(VM* vm, Structure* structure, ProgramExecutable* ownerExecutable, UnlinkedProgramCodeBlock* unlinkedCodeBlock, 1145 JSScope* scope, PassRefPtr<SourceProvider> sourceProvider, unsigned firstLineColumnOffset) 1146 : GlobalCodeBlock(vm, structure, ownerExecutable, unlinkedCodeBlock, scope, sourceProvider, 0, firstLineColumnOffset) 1147 { 1148 } 1149 1150 static void destroy(JSCell*); 1103 1151 }; 1104 1152 1105 1153 class ModuleProgramCodeBlock : public GlobalCodeBlock { 1106 1154 public: 1107 ModuleProgramCodeBlock(CopyParsedBlockTag, ModuleProgramCodeBlock& other) 1108 : GlobalCodeBlock(CopyParsedBlock, other) 1109 { 1110 } 1111 1112 ModuleProgramCodeBlock(ModuleProgramExecutable* ownerExecutable, UnlinkedModuleProgramCodeBlock* unlinkedCodeBlock, JSScope* scope, PassRefPtr<SourceProvider> sourceProvider, unsigned firstLineColumnOffset) 1113 : GlobalCodeBlock(ownerExecutable, unlinkedCodeBlock, scope, sourceProvider, 0, firstLineColumnOffset) 1114 { 1115 } 1116 1117 #if ENABLE(JIT) 1118 protected: 1119 virtual CodeBlock* replacement() override; 1120 virtual DFG::CapabilityLevel capabilityLevelInternal() override; 1121 #endif 1155 typedef GlobalCodeBlock Base; 1156 DECLARE_INFO; 1157 1158 static ModuleProgramCodeBlock* create(VM* vm, CopyParsedBlockTag, ModuleProgramCodeBlock& other) 1159 { 1160 ModuleProgramCodeBlock* instance = new (NotNull, allocateCell<ModuleProgramCodeBlock>(vm->heap)) 1161 ModuleProgramCodeBlock(vm, vm->moduleProgramCodeBlockStructure.get(), CopyParsedBlock, other); 1162 instance->finishCreation(*vm, CopyParsedBlock, other); 1163 return instance; 1164 } 1165 1166 static ModuleProgramCodeBlock* create(VM* vm, ModuleProgramExecutable* ownerExecutable, UnlinkedModuleProgramCodeBlock* unlinkedCodeBlock, 1167 JSScope* scope, PassRefPtr<SourceProvider> sourceProvider, unsigned firstLineColumnOffset) 1168 { 1169 ModuleProgramCodeBlock* instance = new (NotNull, allocateCell<ModuleProgramCodeBlock>(vm->heap)) 1170 ModuleProgramCodeBlock(vm, vm->moduleProgramCodeBlockStructure.get(), ownerExecutable, unlinkedCodeBlock, scope, sourceProvider, firstLineColumnOffset); 1171 instance->finishCreation(*vm, ownerExecutable, unlinkedCodeBlock, scope); 1172 return instance; 1173 } 1174 1175 static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) 1176 { 1177 return Structure::create(vm, globalObject, prototype, TypeInfo(CellType, StructureFlags), info()); 1178 } 1179 1180 private: 1181 ModuleProgramCodeBlock(VM* vm, Structure* structure, CopyParsedBlockTag, ModuleProgramCodeBlock& other) 1182 : GlobalCodeBlock(vm, structure, CopyParsedBlock, other) 1183 { 1184 } 1185 1186 ModuleProgramCodeBlock(VM* vm, Structure* structure, ModuleProgramExecutable* ownerExecutable, UnlinkedModuleProgramCodeBlock* unlinkedCodeBlock, 1187 JSScope* scope, PassRefPtr<SourceProvider> sourceProvider, unsigned firstLineColumnOffset) 1188 : GlobalCodeBlock(vm, structure, ownerExecutable, unlinkedCodeBlock, scope, sourceProvider, 0, firstLineColumnOffset) 1189 { 1190 } 1191 1192 static void destroy(JSCell*); 1122 1193 }; 1123 1194 1124 1195 class EvalCodeBlock : public GlobalCodeBlock { 1125 1196 public: 1126 EvalCodeBlock(CopyParsedBlockTag, EvalCodeBlock& other) 1127 : GlobalCodeBlock(CopyParsedBlock, other) 1128 { 1129 } 1130 1131 EvalCodeBlock(EvalExecutable* ownerExecutable, UnlinkedEvalCodeBlock* unlinkedCodeBlock, JSScope* scope, PassRefPtr<SourceProvider> sourceProvider) 1132 : GlobalCodeBlock(ownerExecutable, unlinkedCodeBlock, scope, sourceProvider, 0, 1) 1133 { 1134 } 1135 1197 typedef GlobalCodeBlock Base; 1198 DECLARE_INFO; 1199 1200 static EvalCodeBlock* create(VM* vm, CopyParsedBlockTag, EvalCodeBlock& other) 1201 { 1202 EvalCodeBlock* instance = new (NotNull, allocateCell<EvalCodeBlock>(vm->heap)) 1203 EvalCodeBlock(vm, vm->evalCodeBlockStructure.get(), CopyParsedBlock, other); 1204 instance->finishCreation(*vm, CopyParsedBlock, other); 1205 return instance; 1206 } 1207 1208 static EvalCodeBlock* create(VM* vm, EvalExecutable* ownerExecutable, UnlinkedEvalCodeBlock* unlinkedCodeBlock, 1209 JSScope* scope, PassRefPtr<SourceProvider> sourceProvider) 1210 { 1211 EvalCodeBlock* instance = new (NotNull, allocateCell<EvalCodeBlock>(vm->heap)) 1212 EvalCodeBlock(vm, vm->evalCodeBlockStructure.get(), ownerExecutable, unlinkedCodeBlock, scope, sourceProvider); 1213 instance->finishCreation(*vm, ownerExecutable, unlinkedCodeBlock, scope); 1214 return instance; 1215 } 1216 1217 static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) 1218 { 1219 return Structure::create(vm, globalObject, prototype, TypeInfo(CellType, StructureFlags), info()); 1220 } 1221 1136 1222 const Identifier& variable(unsigned index) { return unlinkedEvalCodeBlock()->variable(index); } 1137 1223 unsigned numVariables() { return unlinkedEvalCodeBlock()->numVariables(); } 1138 1224 1139 #if ENABLE(JIT) 1140 protected: 1141 virtual CodeBlock* replacement() override; 1142 virtual DFG::CapabilityLevel capabilityLevelInternal() override; 1143 #endif 1144 1225 private: 1226 EvalCodeBlock(VM* vm, Structure* structure, CopyParsedBlockTag, EvalCodeBlock& other) 1227 : GlobalCodeBlock(vm, structure, CopyParsedBlock, other) 1228 { 1229 } 1230 1231 EvalCodeBlock(VM* vm, Structure* structure, EvalExecutable* ownerExecutable, UnlinkedEvalCodeBlock* unlinkedCodeBlock, 1232 JSScope* scope, PassRefPtr<SourceProvider> sourceProvider) 1233 : GlobalCodeBlock(vm, structure, ownerExecutable, unlinkedCodeBlock, scope, sourceProvider, 0, 1) 1234 { 1235 } 1236 1237 static void destroy(JSCell*); 1238 1145 1239 private: 1146 1240 UnlinkedEvalCodeBlock* unlinkedEvalCodeBlock() const { return jsCast<UnlinkedEvalCodeBlock*>(unlinkedCodeBlock()); } … … 1149 1243 class FunctionCodeBlock : public CodeBlock { 1150 1244 public: 1151 FunctionCodeBlock(CopyParsedBlockTag, FunctionCodeBlock& other) 1152 : CodeBlock(CopyParsedBlock, other) 1153 { 1154 } 1155 1156 FunctionCodeBlock(FunctionExecutable* ownerExecutable, UnlinkedFunctionCodeBlock* unlinkedCodeBlock, JSScope* scope, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, unsigned firstLineColumnOffset) 1157 : CodeBlock(ownerExecutable, unlinkedCodeBlock, scope, sourceProvider, sourceOffset, firstLineColumnOffset) 1158 { 1159 } 1160 1161 #if ENABLE(JIT) 1162 protected: 1163 virtual CodeBlock* replacement() override; 1164 virtual DFG::CapabilityLevel capabilityLevelInternal() override; 1165 #endif 1245 typedef CodeBlock Base; 1246 DECLARE_INFO; 1247 1248 static FunctionCodeBlock* create(VM* vm, CopyParsedBlockTag, FunctionCodeBlock& other) 1249 { 1250 FunctionCodeBlock* instance = new (NotNull, allocateCell<FunctionCodeBlock>(vm->heap)) 1251 FunctionCodeBlock(vm, vm->functionCodeBlockStructure.get(), CopyParsedBlock, other); 1252 instance->finishCreation(*vm, CopyParsedBlock, other); 1253 return instance; 1254 } 1255 1256 static FunctionCodeBlock* create(VM* vm, FunctionExecutable* ownerExecutable, UnlinkedFunctionCodeBlock* unlinkedCodeBlock, JSScope* scope, 1257 PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, unsigned firstLineColumnOffset) 1258 { 1259 FunctionCodeBlock* instance = new (NotNull, allocateCell<FunctionCodeBlock>(vm->heap)) 1260 FunctionCodeBlock(vm, vm->functionCodeBlockStructure.get(), ownerExecutable, unlinkedCodeBlock, scope, sourceProvider, sourceOffset, firstLineColumnOffset); 1261 instance->finishCreation(*vm, ownerExecutable, unlinkedCodeBlock, scope); 1262 return instance; 1263 } 1264 1265 static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) 1266 { 1267 return Structure::create(vm, globalObject, prototype, TypeInfo(CellType, StructureFlags), info()); 1268 } 1269 1270 private: 1271 FunctionCodeBlock(VM* vm, Structure* structure, CopyParsedBlockTag, FunctionCodeBlock& other) 1272 : CodeBlock(vm, structure, CopyParsedBlock, other) 1273 { 1274 } 1275 1276 FunctionCodeBlock(VM* vm, Structure* structure, FunctionExecutable* ownerExecutable, UnlinkedFunctionCodeBlock* unlinkedCodeBlock, JSScope* scope, 1277 PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, unsigned firstLineColumnOffset) 1278 : CodeBlock(vm, structure, ownerExecutable, unlinkedCodeBlock, scope, sourceProvider, sourceOffset, firstLineColumnOffset) 1279 { 1280 } 1281 1282 static void destroy(JSCell*); 1166 1283 }; 1167 1284 … … 1169 1286 class WebAssemblyCodeBlock : public CodeBlock { 1170 1287 public: 1171 WebAssemblyCodeBlock(CopyParsedBlockTag, WebAssemblyCodeBlock& other) 1172 : CodeBlock(CopyParsedBlock, other) 1173 { 1174 } 1175 1176 WebAssemblyCodeBlock(WebAssemblyExecutable* ownerExecutable, VM& vm, JSGlobalObject* globalObject) 1177 : CodeBlock(ownerExecutable, vm, globalObject) 1178 { 1179 } 1180 1181 #if ENABLE(JIT) 1182 protected: 1183 virtual CodeBlock* replacement() override; 1184 virtual DFG::CapabilityLevel capabilityLevelInternal() override; 1185 #endif 1288 DECLARE_INFO; 1289 1290 static WebAssemblyCodeBlock* create(VM* vm, CopyParsedBlockTag, WebAssemblyCodeBlock& other) 1291 { 1292 WebAssemblyCodeBlock* instance = new (NotNull, allocateCell<WebAssemblyCodeBlock>(vm->heap)) 1293 WebAssemblyCodeBlock(vm, vm->webAssemblyCodeBlockStructure.get(), CopyParsedBlock, other); 1294 instance->finishCreation(*vm); 1295 return instance; 1296 } 1297 1298 static WebAssemblyCodeBlock* create(VM* vm, WebAssemblyExecutable* ownerExecutable, JSGlobalObject* globalObject) 1299 { 1300 WebAssemblyCodeBlock* instance = new (NotNull, allocateCell<WebAssemblyCodeBlock>(vm->heap)) 1301 WebAssemblyCodeBlock(vm, vm->webAssemblyCodeBlockStructure.get(), ownerExecutable, globalObject); 1302 instance->finishCreation(*vm); 1303 return instance; 1304 } 1305 1306 static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) 1307 { 1308 return Structure::create(vm, globalObject, prototype, TypeInfo(CellType, StructureFlags), info()); 1309 } 1310 1311 private: 1312 WebAssemblyCodeBlock(VM& vm, Structure* structure, CopyParsedBlockTag, WebAssemblyCodeBlock& other) 1313 : CodeBlock(vm, structure, CopyParsedBlock, other) 1314 { 1315 } 1316 1317 WebAssemblyCodeBlock(VM& vm, Structure* structure, WebAssemblyExecutable* ownerExecutable, JSGlobalObject* globalObject) 1318 : CodeBlock(vm, structure, ownerExecutable, vm, globalObject) 1319 { 1320 } 1321 1322 static void destroy(JSCell*); 1186 1323 }; 1187 1324 #endif … … 1211 1348 } 1212 1349 1213 inline void CodeBlock::clear Marks()1350 inline void CodeBlock::clearVisitWeaklyHasBeenCalled() 1214 1351 { 1215 m_visitStronglyHasBeenCalled.store(false, std::memory_order_relaxed); 1216 m_visitAggregateHasBeenCalled.store(false, std::memory_order_relaxed); 1352 m_visitWeaklyHasBeenCalled.store(false, std::memory_order_relaxed); 1217 1353 } 1218 1354 … … 1239 1375 if (!codeBlock) 1240 1376 return; 1241 1242 // Force GC to visit all CodeBlocks on the stack, including old CodeBlocks 1243 // that have not executed a barrier. This is overkill, but we have always 1244 // done this, and it might help us recover gracefully if we forget to execute 1245 // a barrier when a CodeBlock needs it. 1246 codeBlock->clearMarks(); 1377 1378 // Try to recover gracefully if we forget to execute a barrier for a 1379 // CodeBlock that does value profiling. This is probably overkill, but we 1380 // have always done it. 1381 Heap::heap(codeBlock)->writeBarrier(codeBlock); 1247 1382 1248 1383 m_currentlyExecuting.add(codeBlock); … … 1253 1388 switch (type()) { 1254 1389 case ProgramExecutableType: { 1255 if (CodeBlock* codeBlock = jsCast<ProgramExecutable*>(this)->m_programCodeBlock.get())1390 if (CodeBlock* codeBlock = static_cast<CodeBlock*>(jsCast<ProgramExecutable*>(this)->m_programCodeBlock.get())) 1256 1391 codeBlock->forEachRelatedCodeBlock(std::forward<Functor>(functor)); 1257 1392 break; … … 1259 1394 1260 1395 case EvalExecutableType: { 1261 if (CodeBlock* codeBlock = jsCast<EvalExecutable*>(this)->m_evalCodeBlock.get())1396 if (CodeBlock* codeBlock = static_cast<CodeBlock*>(jsCast<EvalExecutable*>(this)->m_evalCodeBlock.get())) 1262 1397 codeBlock->forEachRelatedCodeBlock(std::forward<Functor>(functor)); 1263 1398 break; … … 1267 1402 Functor f(std::forward<Functor>(functor)); 1268 1403 FunctionExecutable* executable = jsCast<FunctionExecutable*>(this); 1269 if (CodeBlock* codeBlock = executable->m_codeBlockForCall.get())1404 if (CodeBlock* codeBlock = static_cast<CodeBlock*>(executable->m_codeBlockForCall.get())) 1270 1405 codeBlock->forEachRelatedCodeBlock(f); 1271 if (CodeBlock* codeBlock = executable->m_codeBlockForConstruct.get())1406 if (CodeBlock* codeBlock = static_cast<CodeBlock*>(executable->m_codeBlockForConstruct.get())) 1272 1407 codeBlock->forEachRelatedCodeBlock(f); 1273 1408 break; … … 1275 1410 1276 1411 case ModuleProgramExecutableType: { 1277 if (CodeBlock* codeBlock = jsCast<ModuleProgramExecutable*>(this)->m_moduleProgramCodeBlock.get())1412 if (CodeBlock* codeBlock = static_cast<CodeBlock*>(jsCast<ModuleProgramExecutable*>(this)->m_moduleProgramCodeBlock.get())) 1278 1413 codeBlock->forEachRelatedCodeBlock(std::forward<Functor>(functor)); 1279 1414 break; -
trunk/Source/JavaScriptCore/bytecode/CodeOrigin.cpp
r190546 r190589 76 76 return true; 77 77 78 if (a.inlineCallFrame-> executable.get() != b.inlineCallFrame->executable.get())78 if (a.inlineCallFrame->baselineCodeBlock.get() != b.inlineCallFrame->baselineCodeBlock.get()) 79 79 return false; 80 80 … … 99 99 return result; 100 100 101 result += WTF::PtrHash<JSCell*>::hash(codeOrigin.inlineCallFrame-> executable.get());101 result += WTF::PtrHash<JSCell*>::hash(codeOrigin.inlineCallFrame->baselineCodeBlock.get()); 102 102 103 103 codeOrigin = codeOrigin.inlineCallFrame->directCaller; … … 116 116 } 117 117 118 ScriptExecutable* CodeOrigin::codeOriginOwner() const118 CodeBlock* CodeOrigin::codeOriginOwner() const 119 119 { 120 120 if (!inlineCallFrame) 121 121 return 0; 122 return inlineCallFrame-> executable.get();122 return inlineCallFrame->baselineCodeBlock.get(); 123 123 } 124 124 … … 144 144 145 145 if (InlineCallFrame* frame = stack[i].inlineCallFrame) { 146 out.print(frame->briefFunctionInformation(), ":<", RawPointer(frame-> executable.get()), "> ");146 out.print(frame->briefFunctionInformation(), ":<", RawPointer(frame->baselineCodeBlock.get()), "> "); 147 147 if (frame->isClosureCall) 148 148 out.print("(closure) "); -
trunk/Source/JavaScriptCore/bytecode/CodeOrigin.h
r190546 r190589 88 88 // If the code origin corresponds to inlined code, gives you the heap object that 89 89 // would have owned the code if it had not been inlined. Otherwise returns 0. 90 ScriptExecutable* codeOriginOwner() const;90 CodeBlock* codeOriginOwner() const; 91 91 92 92 int stackOffset() const; -
trunk/Source/JavaScriptCore/bytecode/DeferredCompilationCallback.cpp
r190546 r190589 34 34 DeferredCompilationCallback::~DeferredCompilationCallback() { } 35 35 36 void DeferredCompilationCallback::compilationDidComplete(CodeBlock* codeBlock, Co mpilationResult result)36 void DeferredCompilationCallback::compilationDidComplete(CodeBlock* codeBlock, CodeBlock*, CompilationResult result) 37 37 { 38 38 dumpCompiledSourcesIfNeeded(); -
trunk/Source/JavaScriptCore/bytecode/DeferredCompilationCallback.h
r190546 r190589 43 43 virtual ~DeferredCompilationCallback(); 44 44 45 virtual void compilationDidBecomeReadyAsynchronously(CodeBlock* ) = 0;46 virtual void compilationDidComplete(CodeBlock*, Co mpilationResult);45 virtual void compilationDidBecomeReadyAsynchronously(CodeBlock*, CodeBlock* profiledDFGCodeBlock) = 0; 46 virtual void compilationDidComplete(CodeBlock*, CodeBlock* profiledDFGCodeBlock, CompilationResult); 47 47 48 48 Vector<DeferredSourceDump>& ensureDeferredSourceDump(); -
trunk/Source/JavaScriptCore/bytecode/EvalCodeCache.h
r190546 r190589 52 52 } 53 53 54 EvalExecutable* getSlow(ExecState* exec, ScriptExecutable* owner, bool inStrictContext, ThisTDZMode thisTDZMode, const String& evalSource, JSScope* scope)54 EvalExecutable* getSlow(ExecState* exec, JSCell* owner, bool inStrictContext, ThisTDZMode thisTDZMode, const String& evalSource, JSScope* scope) 55 55 { 56 56 VariableEnvironment variablesUnderTDZ; -
trunk/Source/JavaScriptCore/bytecode/InlineCallFrame.cpp
r190546 r190589 48 48 CodeBlockHash InlineCallFrame::hash() const 49 49 { 50 return jsCast<FunctionExecutable*>(executable.get())->codeBlockFor( 51 specializationKind())->hash(); 50 return baselineCodeBlock->hash(); 52 51 } 53 52 54 53 CString InlineCallFrame::hashAsStringIfPossible() const 55 54 { 56 return jsCast<FunctionExecutable*>(executable.get())->codeBlockFor( 57 specializationKind())->hashAsStringIfPossible(); 55 return baselineCodeBlock->hashAsStringIfPossible(); 58 56 } 59 57 60 58 CString InlineCallFrame::inferredName() const 61 59 { 62 return jsCast<FunctionExecutable*>(executable.get())->inferredName().utf8(); 63 } 64 65 CodeBlock* InlineCallFrame::baselineCodeBlock() const 66 { 67 return jsCast<FunctionExecutable*>(executable.get())->baselineCodeBlockFor(specializationKind()); 60 return jsCast<FunctionExecutable*>(baselineCodeBlock->ownerExecutable())->inferredName().utf8(); 68 61 } 69 62 … … 75 68 void InlineCallFrame::dumpInContext(PrintStream& out, DumpContext* context) const 76 69 { 77 out.print(briefFunctionInformation(), ":<", RawPointer( executable.get()));78 if ( executable->isStrictMode())70 out.print(briefFunctionInformation(), ":<", RawPointer(baselineCodeBlock.get())); 71 if (isStrictMode()) 79 72 out.print(" (StrictMode)"); 80 73 out.print(", bc#", directCaller.bytecodeIndex, ", ", static_cast<Kind>(kind)); -
trunk/Source/JavaScriptCore/bytecode/InlineCallFrame.h
r190546 r190589 30 30 #include "CodeBlockHash.h" 31 31 #include "CodeOrigin.h" 32 #include "Executable.h"33 32 #include "ValueRecovery.h" 34 33 #include "WriteBarrier.h" … … 43 42 struct InlineCallFrame; 44 43 class ExecState; 45 class ScriptExecutable;46 44 class JSFunction; 47 45 … … 175 173 176 174 Vector<ValueRecovery> arguments; // Includes 'this'. 177 WriteBarrier< ScriptExecutable> executable;175 WriteBarrier<CodeBlock> baselineCodeBlock; 178 176 ValueRecovery calleeRecovery; 179 177 CodeOrigin directCaller; … … 210 208 CString hashAsStringIfPossible() const; 211 209 212 CodeBlock* baselineCodeBlock() const;213 214 210 void setStackOffset(signed offset) 215 211 { … … 220 216 ptrdiff_t callerFrameOffset() const { return stackOffset * sizeof(Register) + CallFrame::callerFrameOffset(); } 221 217 ptrdiff_t returnPCOffset() const { return stackOffset * sizeof(Register) + CallFrame::returnPCOffset(); } 218 219 bool isStrictMode() const { return baselineCodeBlock->isStrictMode(); } 222 220 223 221 void dumpBriefFunctionInformation(PrintStream&) const; … … 232 230 { 233 231 RELEASE_ASSERT(inlineCallFrame); 234 ScriptExecutable* executable = inlineCallFrame->executable.get(); 235 RELEASE_ASSERT(executable->structure()->classInfo() == FunctionExecutable::info()); 236 return static_cast<FunctionExecutable*>(executable)->baselineCodeBlockFor(inlineCallFrame->specializationKind()); 232 return inlineCallFrame->baselineCodeBlock.get(); 237 233 } 238 234 -
trunk/Source/JavaScriptCore/bytecode/PolymorphicAccess.cpp
r190561 r190589 412 412 413 413 // We will emit code that has a weak reference that isn't otherwise listed anywhere. 414 state.weakReferences.append(WriteBarrier<JSCell>(vm, codeBlock ->ownerExecutable(), structure));414 state.weakReferences.append(WriteBarrier<JSCell>(vm, codeBlock, structure)); 415 415 416 416 jit.move(CCallHelpers::TrustedImmPtr(condition.object()), scratchGPR); … … 1178 1178 doesCalls |= entry->doesCalls(); 1179 1179 1180 m_stubRoutine = createJITStubRoutine(code, vm, codeBlock ->ownerExecutable(), doesCalls);1180 m_stubRoutine = createJITStubRoutine(code, vm, codeBlock, doesCalls); 1181 1181 m_watchpoints = WTF::move(state.watchpoints); 1182 1182 if (!state.weakReferences.isEmpty()) -
trunk/Source/JavaScriptCore/bytecode/StructureStubInfo.cpp
r190561 r190589 56 56 57 57 u.byIdSelf.baseObjectStructure.set( 58 *codeBlock->vm(), codeBlock ->ownerExecutable(), baseObjectStructure);58 *codeBlock->vm(), codeBlock, baseObjectStructure); 59 59 u.byIdSelf.offset = offset; 60 60 } … … 65 65 66 66 u.byIdSelf.baseObjectStructure.set( 67 *codeBlock->vm(), codeBlock ->ownerExecutable(), baseObjectStructure);67 *codeBlock->vm(), codeBlock, baseObjectStructure); 68 68 u.byIdSelf.offset = offset; 69 69 } … … 106 106 107 107 std::unique_ptr<AccessCase> previousCase = 108 AccessCase::fromStructureStubInfo(vm, codeBlock ->ownerExecutable(), *this);108 AccessCase::fromStructureStubInfo(vm, codeBlock, *this); 109 109 if (previousCase) 110 110 accessCases.append(WTF::move(previousCase)); -
trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
r190546 r190589 4634 4634 4635 4635 m_inlineCallFrame = byteCodeParser->m_graph.m_plan.inlineCallFrames->add(); 4636 byteCodeParser->m_graph.freeze(codeBlock-> ownerExecutable());4636 byteCodeParser->m_graph.freeze(codeBlock->baselineVersion()); 4637 4637 // The owner is the machine code block, and we already have a barrier on that when the 4638 4638 // plan finishes. 4639 m_inlineCallFrame-> executable.setWithoutWriteBarrier(codeBlock->ownerScriptExecutable());4639 m_inlineCallFrame->baselineCodeBlock.setWithoutWriteBarrier(codeBlock->baselineVersion()); 4640 4640 m_inlineCallFrame->setStackOffset(inlineCallFrameStart.offset() - JSStack::CallFrameHeaderSize); 4641 4641 if (callee) { … … 4829 4829 dataLog("Parsing ", *m_codeBlock, "\n"); 4830 4830 4831 m_dfgCodeBlock = m_graph.m_plan.profiledDFGCodeBlock .get();4831 m_dfgCodeBlock = m_graph.m_plan.profiledDFGCodeBlock; 4832 4832 if (isFTL(m_graph.m_plan.mode) && m_dfgCodeBlock 4833 4833 && Options::enablePolyvariantDevirtualization()) { -
trunk/Source/JavaScriptCore/dfg/DFGCommonData.cpp
r190546 r190589 90 90 } 91 91 92 if ( ScriptExecutable* executable = inlineCallFrame->executable.get())93 trackedReferences.check( executable);92 if (CodeBlock* baselineCodeBlock = inlineCallFrame->baselineCodeBlock.get()) 93 trackedReferences.check(baselineCodeBlock); 94 94 95 95 if (inlineCallFrame->calleeRecovery.isConstant()) -
trunk/Source/JavaScriptCore/dfg/DFGDesiredTransitions.cpp
r190546 r190589 35 35 namespace JSC { namespace DFG { 36 36 37 DesiredTransition::DesiredTransition(CodeBlock* codeBlock, ScriptExecutable* codeOriginOwner, Structure* oldStructure, Structure* newStructure)37 DesiredTransition::DesiredTransition(CodeBlock* codeBlock, CodeBlock* codeOriginOwner, Structure* oldStructure, Structure* newStructure) 38 38 : m_codeBlock(codeBlock) 39 39 , m_codeOriginOwner(codeOriginOwner) … … 47 47 common->transitions.append( 48 48 WeakReferenceTransition( 49 vm, m_codeBlock ->ownerExecutable(),49 vm, m_codeBlock, 50 50 m_codeOriginOwner, 51 51 m_oldStructure, m_newStructure)); … … 67 67 } 68 68 69 void DesiredTransitions::addLazily(CodeBlock* codeBlock, ScriptExecutable* codeOriginOwner, Structure* oldStructure, Structure* newStructure)69 void DesiredTransitions::addLazily(CodeBlock* codeBlock, CodeBlock* codeOriginOwner, Structure* oldStructure, Structure* newStructure) 70 70 { 71 71 m_transitions.append(DesiredTransition(codeBlock, codeOriginOwner, oldStructure, newStructure)); -
trunk/Source/JavaScriptCore/dfg/DFGDesiredTransitions.h
r190546 r190589 45 45 class DesiredTransition { 46 46 public: 47 DesiredTransition(CodeBlock*, ScriptExecutable*, Structure*, Structure*);47 DesiredTransition(CodeBlock*, CodeBlock* codeOriginOwner, Structure*, Structure*); 48 48 49 49 void reallyAdd(VM&, CommonData*); … … 53 53 private: 54 54 CodeBlock* m_codeBlock; 55 ScriptExecutable* m_codeOriginOwner;55 CodeBlock* m_codeOriginOwner; 56 56 Structure* m_oldStructure; 57 57 Structure* m_newStructure; … … 63 63 ~DesiredTransitions(); 64 64 65 void addLazily(CodeBlock*, ScriptExecutable*, Structure*, Structure*);65 void addLazily(CodeBlock*, CodeBlock* codeOriginOwner, Structure*, Structure*); 66 66 void reallyAdd(VM&, CommonData*); 67 67 void visitChildren(SlotVisitor&); -
trunk/Source/JavaScriptCore/dfg/DFGDesiredWeakReferences.cpp
r190546 r190589 71 71 if (Structure* structure = jsDynamicCast<Structure*>(target)) { 72 72 common->weakStructureReferences.append( 73 WriteBarrier<Structure>(vm, m_codeBlock ->ownerExecutable(), structure));73 WriteBarrier<Structure>(vm, m_codeBlock, structure)); 74 74 } else { 75 75 common->weakReferences.append( 76 WriteBarrier<JSCell>(vm, m_codeBlock ->ownerExecutable(), target));76 WriteBarrier<JSCell>(vm, m_codeBlock, target)); 77 77 } 78 78 } -
trunk/Source/JavaScriptCore/dfg/DFGDriver.cpp
r190546 r190589 122 122 callback); 123 123 if (result != CompilationDeferred) 124 callback->compilationDidComplete(codeBlock, result);124 callback->compilationDidComplete(codeBlock, profiledDFGCodeBlock, result); 125 125 return result; 126 126 } -
trunk/Source/JavaScriptCore/dfg/DFGGraph.cpp
r190546 r190589 62 62 : m_vm(vm) 63 63 , m_plan(plan) 64 , m_codeBlock(m_plan.codeBlock .get())64 , m_codeBlock(m_plan.codeBlock) 65 65 , m_profiledBlock(m_codeBlock->alternative()) 66 66 , m_allocator(longLivedState.m_allocator) -
trunk/Source/JavaScriptCore/dfg/DFGGraph.h
r190546 r190589 349 349 return m_codeBlock->ownerScriptExecutable(); 350 350 351 return inlineCallFrame-> executable.get();351 return inlineCallFrame->baselineCodeBlock->ownerScriptExecutable(); 352 352 } 353 353 … … 373 373 if (!codeOrigin.inlineCallFrame) 374 374 return m_codeBlock->isStrictMode(); 375 return jsCast<FunctionExecutable*>(codeOrigin.inlineCallFrame->executable.get())->isStrictMode();375 return codeOrigin.inlineCallFrame->isStrictMode(); 376 376 } 377 377 -
trunk/Source/JavaScriptCore/dfg/DFGJITCode.h
r190546 r190589 29 29 #if ENABLE(DFG_JIT) 30 30 31 #include "CodeBlock.h" 31 32 #include "CompilationResult.h" 32 33 #include "DFGCommonData.h" … … 115 116 116 117 void shrinkToFit(); 118 119 #if ENABLE(FTL_JIT) 120 CodeBlock* osrEntryBlock() { return m_osrEntryBlock.get(); } 121 void setOSREntryBlock(VM& vm, const JSCell* owner, CodeBlock* osrEntryBlock) { m_osrEntryBlock.set(vm, owner, osrEntryBlock); } 122 void clearOSREntryBlock() { m_osrEntryBlock.clear(); } 123 #endif 117 124 118 125 private: … … 129 136 uint8_t nestedTriggerIsSet { 0 }; 130 137 UpperTierExecutionCounter tierUpCounter; 131 RefPtr<CodeBlock>osrEntryBlock;138 WriteBarrier<CodeBlock> m_osrEntryBlock; 132 139 unsigned osrEntryRetry; 133 140 bool abandonOSREntry; -
trunk/Source/JavaScriptCore/dfg/DFGJITFinalizer.cpp
r190546 r190589 58 58 { 59 59 m_jitCode->initializeCodeRef( 60 FINALIZE_DFG_CODE(*m_linkBuffer, ("DFG JIT code for %s", toCString(CodeBlockWithJITType(m_plan.codeBlock .get(), JITCode::DFGJIT)).data())),60 FINALIZE_DFG_CODE(*m_linkBuffer, ("DFG JIT code for %s", toCString(CodeBlockWithJITType(m_plan.codeBlock, JITCode::DFGJIT)).data())), 61 61 MacroAssemblerCodePtr()); 62 62 … … 72 72 RELEASE_ASSERT(!m_withArityCheck.isEmptyValue()); 73 73 m_jitCode->initializeCodeRef( 74 FINALIZE_DFG_CODE(*m_linkBuffer, ("DFG JIT code for %s", toCString(CodeBlockWithJITType(m_plan.codeBlock .get(), JITCode::DFGJIT)).data())),74 FINALIZE_DFG_CODE(*m_linkBuffer, ("DFG JIT code for %s", toCString(CodeBlockWithJITType(m_plan.codeBlock, JITCode::DFGJIT)).data())), 75 75 m_withArityCheck); 76 76 m_plan.codeBlock->setJITCode(m_jitCode); … … 84 84 { 85 85 #if ENABLE(FTL_JIT) 86 m_jitCode->optimizeAfterWarmUp(m_plan.codeBlock .get());86 m_jitCode->optimizeAfterWarmUp(m_plan.codeBlock); 87 87 #endif // ENABLE(FTL_JIT) 88 88 -
trunk/Source/JavaScriptCore/dfg/DFGOSRExitCompilerCommon.cpp
r190546 r190589 70 70 AssemblyHelpers::NonZero, 71 71 AssemblyHelpers::AbsoluteAddress( 72 inlineCallFrame-> executable->addressOfDidTryToEnterInLoop())));72 inlineCallFrame->baselineCodeBlock->ownerScriptExecutable()->addressOfDidTryToEnterInLoop()))); 73 73 } 74 74 … … 269 269 void adjustAndJumpToTarget(CCallHelpers& jit, const OSRExitBase& exit, bool isExitingToOpCatch) 270 270 { 271 jit.move(AssemblyHelpers::TrustedImmPtr(jit.codeBlock()->ownerExecutable()), GPRInfo::argumentGPR1); 271 CodeBlock* baselineCodeBlock = jit.baselineCodeBlockFor(exit.m_codeOrigin); 272 jit.move(AssemblyHelpers::TrustedImmPtr(baselineCodeBlock), GPRInfo::argumentGPR1); 272 273 osrWriteBarrier(jit, GPRInfo::argumentGPR1, GPRInfo::nonArgGPR0); 273 274 InlineCallFrameSet* inlineCallFrames = jit.codeBlock()->jitCode()->dfgCommon()->inlineCallFrames.get(); 274 275 if (inlineCallFrames) { 275 276 for (InlineCallFrame* inlineCallFrame : *inlineCallFrames) { 276 ScriptExecutable* ownerExecutable = inlineCallFrame->executable.get();277 jit.move(AssemblyHelpers::TrustedImmPtr( ownerExecutable), GPRInfo::argumentGPR1);277 CodeBlock* baselineCodeBlock = inlineCallFrame->baselineCodeBlock.get(); 278 jit.move(AssemblyHelpers::TrustedImmPtr(baselineCodeBlock), GPRInfo::argumentGPR1); 278 279 osrWriteBarrier(jit, GPRInfo::argumentGPR1, GPRInfo::nonArgGPR0); 279 280 } … … 283 284 jit.addPtr(AssemblyHelpers::TrustedImm32(exit.m_codeOrigin.inlineCallFrame->stackOffset * sizeof(EncodedJSValue)), GPRInfo::callFrameRegister); 284 285 285 CodeBlock* baselineCodeBlock = jit.baselineCodeBlockFor(exit.m_codeOrigin);286 286 Vector<BytecodeAndMachineOffset>& decodedCodeMap = jit.decodedCodeMapFor(baselineCodeBlock); 287 287 -
trunk/Source/JavaScriptCore/dfg/DFGOSRExitPreparation.cpp
r190546 r190589 43 43 44 44 for (; codeOrigin.inlineCallFrame; codeOrigin = codeOrigin.inlineCallFrame->directCaller) { 45 CodeBlock* codeBlock = codeOrigin.inlineCallFrame->baselineCodeBlock ();45 CodeBlock* codeBlock = codeOrigin.inlineCallFrame->baselineCodeBlock.get(); 46 46 if (codeBlock->jitType() == JSC::JITCode::BaselineJIT) 47 47 continue; -
trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp
r190546 r190589 1308 1308 bool didTryToEnterIntoInlinedLoops = false; 1309 1309 for (InlineCallFrame* inlineCallFrame = exit->m_codeOrigin.inlineCallFrame; inlineCallFrame; inlineCallFrame = inlineCallFrame->directCaller.inlineCallFrame) { 1310 if (inlineCallFrame-> executable->didTryToEnterInLoop()) {1310 if (inlineCallFrame->baselineCodeBlock->ownerScriptExecutable()->didTryToEnterInLoop()) { 1311 1311 didTryToEnterIntoInlinedLoops = true; 1312 1312 break; … … 1378 1378 // We need to compile the code. 1379 1379 compile( 1380 *vm, codeBlock->newReplacement() .get(), codeBlock, FTLMode, UINT_MAX,1381 Operands<JSValue>(), ToFTLDeferredCompilationCallback::create( codeBlock));1380 *vm, codeBlock->newReplacement(), codeBlock, FTLMode, UINT_MAX, 1381 Operands<JSValue>(), ToFTLDeferredCompilationCallback::create()); 1382 1382 } 1383 1383 … … 1464 1464 return 0; 1465 1465 1466 if (CodeBlock* entryBlock = jitCode->osrEntryBlock .get()) {1466 if (CodeBlock* entryBlock = jitCode->osrEntryBlock()) { 1467 1467 void* address = FTL::prepareOSREntry( 1468 1468 exec, codeBlock, entryBlock, bytecodeIndex, streamIndex); … … 1478 1478 // OSR entry failed. Oh no! This implies that we need to retry. We retry 1479 1479 // without exponential backoff and we only do this for the entry code block. 1480 jitCode-> osrEntryBlock = nullptr;1480 jitCode->clearOSREntryBlock(); 1481 1481 jitCode->osrEntryRetry = 0; 1482 1482 return 0; … … 1495 1495 jitCode->reconstruct( 1496 1496 exec, codeBlock, CodeOrigin(bytecodeIndex), streamIndex, mustHandleValues); 1497 RefPtr<CodeBlock>replacementCodeBlock = codeBlock->newReplacement();1497 CodeBlock* replacementCodeBlock = codeBlock->newReplacement(); 1498 1498 CompilationResult forEntryResult = compile( 1499 *vm, replacementCodeBlock.get(), codeBlock, FTLForOSREntryMode, bytecodeIndex, 1500 mustHandleValues, ToFTLForOSREntryDeferredCompilationCallback::create(codeBlock)); 1501 1502 if (forEntryResult != CompilationSuccessful) { 1503 ASSERT(forEntryResult == CompilationDeferred || replacementCodeBlock->hasOneRef()); 1499 *vm, replacementCodeBlock, codeBlock, FTLForOSREntryMode, bytecodeIndex, 1500 mustHandleValues, ToFTLForOSREntryDeferredCompilationCallback::create()); 1501 1502 if (forEntryResult != CompilationSuccessful) 1504 1503 return 0; 1505 }1506 1504 1507 1505 // It's possible that the for-entry compile already succeeded. In that case OSR … … 1509 1507 // We signal to try again after a while if that happens. 1510 1508 void* address = FTL::prepareOSREntry( 1511 exec, codeBlock, jitCode->osrEntryBlock .get(), bytecodeIndex, streamIndex);1509 exec, codeBlock, jitCode->osrEntryBlock(), bytecodeIndex, streamIndex); 1512 1510 return static_cast<char*>(address); 1513 1511 } -
trunk/Source/JavaScriptCore/dfg/DFGPlan.cpp
r190546 r190589 132 132 } // anonymous namespace 133 133 134 Plan::Plan( PassRefPtr<CodeBlock>passedCodeBlock, CodeBlock* profiledDFGCodeBlock,134 Plan::Plan(CodeBlock* passedCodeBlock, CodeBlock* profiledDFGCodeBlock, 135 135 CompilationMode mode, unsigned osrEntryBytecodeIndex, 136 136 const Operands<JSValue>& mustHandleValues) … … 141 141 , osrEntryBytecodeIndex(osrEntryBytecodeIndex) 142 142 , mustHandleValues(mustHandleValues) 143 , compilation(codeBlock->vm()->m_perBytecodeProfiler ? adoptRef(new Profiler::Compilation(codeBlock->vm()->m_perBytecodeProfiler->ensureBytecodesFor(codeBlock .get()), profilerCompilationKindForMode(mode))) : 0)143 , compilation(codeBlock->vm()->m_perBytecodeProfiler ? adoptRef(new Profiler::Compilation(codeBlock->vm()->m_perBytecodeProfiler->ensureBytecodesFor(codeBlock), profilerCompilationKindForMode(mode))) : 0) 144 144 , inlineCallFrames(adoptRef(new InlineCallFrameSet())) 145 , identifiers(codeBlock .get())146 , weakReferences(codeBlock .get())145 , identifiers(codeBlock) 146 , weakReferences(codeBlock) 147 147 , willTryToTierUp(false) 148 148 , stage(Preparing) … … 536 536 void Plan::reallyAdd(CommonData* commonData) 537 537 { 538 watchpoints.reallyAdd(codeBlock .get(), *commonData);538 watchpoints.reallyAdd(codeBlock, *commonData); 539 539 identifiers.reallyAdd(vm, commonData); 540 540 weakReferences.reallyAdd(vm, commonData); … … 554 554 void Plan::notifyReady() 555 555 { 556 callback->compilationDidBecomeReadyAsynchronously(codeBlock .get());556 callback->compilationDidBecomeReadyAsynchronously(codeBlock, profiledDFGCodeBlock); 557 557 stage = Ready; 558 558 } … … 561 561 { 562 562 // We will establish new references from the code block to things. So, we need a barrier. 563 vm.heap.writeBarrier(codeBlock ->ownerExecutable());563 vm.heap.writeBarrier(codeBlock); 564 564 565 565 if (!isStillValid()) … … 597 597 void Plan::finalizeAndNotifyCallback() 598 598 { 599 callback->compilationDidComplete(codeBlock .get(), finalizeWithoutNotifyingCallback());599 callback->compilationDidComplete(codeBlock, profiledDFGCodeBlock, finalizeWithoutNotifyingCallback()); 600 600 } 601 601 … … 605 605 } 606 606 607 void Plan:: clearCodeBlockMarks()607 void Plan::rememberCodeBlocks() 608 608 { 609 609 // Compilation writes lots of values to a CodeBlock without performing … … 611 611 // all our CodeBlocks must be visited during GC. 612 612 613 codeBlock->clearMarks(); 614 codeBlock->alternative()->clearMarks(); 613 Heap::heap(codeBlock)->writeBarrier(codeBlock); 615 614 if (profiledDFGCodeBlock) 616 profiledDFGCodeBlock->clearMarks();615 Heap::heap(profiledDFGCodeBlock)->writeBarrier(profiledDFGCodeBlock); 617 616 } 618 617 … … 625 624 visitor.appendUnbarrieredValue(&mustHandleValues[i]); 626 625 627 codeBlock->visitStrongly(visitor); 628 codeBlock->alternative()->visitStrongly(visitor); 629 if (profiledDFGCodeBlock) 630 profiledDFGCodeBlock->visitStrongly(visitor); 626 visitor.appendUnbarrieredReadOnlyPointer(codeBlock); 627 visitor.appendUnbarrieredReadOnlyPointer(profiledDFGCodeBlock); 631 628 632 629 if (inlineCallFrames) { 633 630 for (auto* inlineCallFrame : *inlineCallFrames) { 634 ASSERT(inlineCallFrame->baselineCodeBlock ());635 inlineCallFrame->baselineCodeBlock()->visitStrongly(visitor);631 ASSERT(inlineCallFrame->baselineCodeBlock.get()); 632 visitor.appendUnbarrieredReadOnlyPointer(inlineCallFrame->baselineCodeBlock.get()); 636 633 } 637 634 } -
trunk/Source/JavaScriptCore/dfg/DFGPlan.h
r190546 r190589 56 56 struct Plan : public ThreadSafeRefCounted<Plan> { 57 57 Plan( 58 PassRefPtr<CodeBlock>codeBlockToCompile, CodeBlock* profiledDFGCodeBlock,58 CodeBlock* codeBlockToCompile, CodeBlock* profiledDFGCodeBlock, 59 59 CompilationMode, unsigned osrEntryBytecodeIndex, 60 60 const Operands<JSValue>& mustHandleValues); … … 72 72 CompilationKey key(); 73 73 74 void clearCodeBlockMarks();74 void rememberCodeBlocks(); 75 75 void checkLivenessAndVisitChildren(SlotVisitor&); 76 76 bool isKnownToBeLiveDuringGC(); … … 78 78 79 79 VM& vm; 80 RefPtr<CodeBlock> codeBlock; 81 RefPtr<CodeBlock> profiledDFGCodeBlock; 80 81 // These can be raw pointers because we visit them during every GC in checkLivenessAndVisitChildren. 82 CodeBlock* codeBlock; 83 CodeBlock* profiledDFGCodeBlock; 84 82 85 CompilationMode mode; 83 86 const unsigned osrEntryBytecodeIndex; -
trunk/Source/JavaScriptCore/dfg/DFGToFTLDeferredCompilationCallback.cpp
r190546 r190589 36 36 namespace JSC { namespace DFG { 37 37 38 ToFTLDeferredCompilationCallback::ToFTLDeferredCompilationCallback( 39 PassRefPtr<CodeBlock> dfgCodeBlock) 40 : m_dfgCodeBlock(dfgCodeBlock) 38 ToFTLDeferredCompilationCallback::ToFTLDeferredCompilationCallback() 41 39 { 42 40 } … … 44 42 ToFTLDeferredCompilationCallback::~ToFTLDeferredCompilationCallback() { } 45 43 46 Ref<ToFTLDeferredCompilationCallback> ToFTLDeferredCompilationCallback::create( PassRefPtr<CodeBlock> dfgCodeBlock)44 Ref<ToFTLDeferredCompilationCallback> ToFTLDeferredCompilationCallback::create() 47 45 { 48 return adoptRef(*new ToFTLDeferredCompilationCallback( dfgCodeBlock));46 return adoptRef(*new ToFTLDeferredCompilationCallback()); 49 47 } 50 48 51 49 void ToFTLDeferredCompilationCallback::compilationDidBecomeReadyAsynchronously( 52 CodeBlock* codeBlock )50 CodeBlock* codeBlock, CodeBlock* profiledDFGCodeBlock) 53 51 { 54 52 if (Options::verboseOSR()) { 55 53 dataLog( 56 "Optimizing compilation of ", *codeBlock, " (for ", * m_dfgCodeBlock,54 "Optimizing compilation of ", *codeBlock, " (for ", *profiledDFGCodeBlock, 57 55 ") did become ready.\n"); 58 56 } 59 57 60 m_dfgCodeBlock->jitCode()->dfg()->forceOptimizationSlowPathConcurrently(61 m_dfgCodeBlock.get());58 profiledDFGCodeBlock->jitCode()->dfg()->forceOptimizationSlowPathConcurrently( 59 profiledDFGCodeBlock); 62 60 } 63 61 64 62 void ToFTLDeferredCompilationCallback::compilationDidComplete( 65 CodeBlock* codeBlock, Co mpilationResult result)63 CodeBlock* codeBlock, CodeBlock* profiledDFGCodeBlock, CompilationResult result) 66 64 { 67 65 if (Options::verboseOSR()) { 68 66 dataLog( 69 "Optimizing compilation of ", *codeBlock, " (for ", * m_dfgCodeBlock,67 "Optimizing compilation of ", *codeBlock, " (for ", *profiledDFGCodeBlock, 70 68 ") result: ", result, "\n"); 71 69 } 72 70 73 if ( m_dfgCodeBlock->replacement() != m_dfgCodeBlock) {71 if (profiledDFGCodeBlock->replacement() != profiledDFGCodeBlock) { 74 72 if (Options::verboseOSR()) { 75 73 dataLog( 76 74 "Dropping FTL code block ", *codeBlock, " on the floor because the " 77 "DFG code block ", * m_dfgCodeBlock, " was jettisoned.\n");75 "DFG code block ", *profiledDFGCodeBlock, " was jettisoned.\n"); 78 76 } 79 77 return; … … 83 81 codeBlock->ownerScriptExecutable()->installCode(codeBlock); 84 82 85 m_dfgCodeBlock->jitCode()->dfg()->setOptimizationThresholdBasedOnCompilationResult(86 m_dfgCodeBlock.get(), result);83 profiledDFGCodeBlock->jitCode()->dfg()->setOptimizationThresholdBasedOnCompilationResult( 84 profiledDFGCodeBlock, result); 87 85 88 DeferredCompilationCallback::compilationDidComplete(codeBlock, result);86 DeferredCompilationCallback::compilationDidComplete(codeBlock, profiledDFGCodeBlock, result); 89 87 } 90 88 -
trunk/Source/JavaScriptCore/dfg/DFGToFTLDeferredCompilationCallback.h
r190546 r190589 41 41 class ToFTLDeferredCompilationCallback : public DeferredCompilationCallback { 42 42 protected: 43 ToFTLDeferredCompilationCallback( PassRefPtr<CodeBlock> dfgCodeBlock);43 ToFTLDeferredCompilationCallback(); 44 44 45 45 public: 46 46 virtual ~ToFTLDeferredCompilationCallback(); 47 47 48 static Ref<ToFTLDeferredCompilationCallback> create( PassRefPtr<CodeBlock> dfgCodeBlock);48 static Ref<ToFTLDeferredCompilationCallback> create(); 49 49 50 virtual void compilationDidBecomeReadyAsynchronously(CodeBlock*); 51 virtual void compilationDidComplete(CodeBlock*, CompilationResult); 52 53 private: 54 RefPtr<CodeBlock> m_dfgCodeBlock; 50 virtual void compilationDidBecomeReadyAsynchronously(CodeBlock*, CodeBlock* profiledDFGCodeBlock); 51 virtual void compilationDidComplete(CodeBlock*, CodeBlock* profiledDFGCodeBlock, CompilationResult); 55 52 }; 56 53 -
trunk/Source/JavaScriptCore/dfg/DFGToFTLForOSREntryDeferredCompilationCallback.cpp
r190546 r190589 36 36 namespace JSC { namespace DFG { 37 37 38 ToFTLForOSREntryDeferredCompilationCallback::ToFTLForOSREntryDeferredCompilationCallback( 39 PassRefPtr<CodeBlock> dfgCodeBlock) 40 : m_dfgCodeBlock(dfgCodeBlock) 38 ToFTLForOSREntryDeferredCompilationCallback::ToFTLForOSREntryDeferredCompilationCallback() 41 39 { 42 40 } … … 46 44 } 47 45 48 Ref<ToFTLForOSREntryDeferredCompilationCallback>ToFTLForOSREntryDeferredCompilationCallback::create( 49 PassRefPtr<CodeBlock> dfgCodeBlock) 46 Ref<ToFTLForOSREntryDeferredCompilationCallback>ToFTLForOSREntryDeferredCompilationCallback::create() 50 47 { 51 return adoptRef(*new ToFTLForOSREntryDeferredCompilationCallback( dfgCodeBlock));48 return adoptRef(*new ToFTLForOSREntryDeferredCompilationCallback()); 52 49 } 53 50 54 51 void ToFTLForOSREntryDeferredCompilationCallback::compilationDidBecomeReadyAsynchronously( 55 CodeBlock* codeBlock )52 CodeBlock* codeBlock, CodeBlock* profiledDFGCodeBlock) 56 53 { 57 54 if (Options::verboseOSR()) { 58 55 dataLog( 59 "Optimizing compilation of ", *codeBlock, " (for ", * m_dfgCodeBlock,56 "Optimizing compilation of ", *codeBlock, " (for ", *profiledDFGCodeBlock, 60 57 ") did become ready.\n"); 61 58 } 62 59 63 m_dfgCodeBlock->jitCode()->dfg()->forceOptimizationSlowPathConcurrently(64 m_dfgCodeBlock.get());60 profiledDFGCodeBlock->jitCode()->dfg()->forceOptimizationSlowPathConcurrently( 61 profiledDFGCodeBlock); 65 62 } 66 63 67 64 void ToFTLForOSREntryDeferredCompilationCallback::compilationDidComplete( 68 CodeBlock* codeBlock, Co mpilationResult result)65 CodeBlock* codeBlock, CodeBlock* profiledDFGCodeBlock, CompilationResult result) 69 66 { 70 67 if (Options::verboseOSR()) { 71 68 dataLog( 72 "Optimizing compilation of ", *codeBlock, " (for ", * m_dfgCodeBlock,69 "Optimizing compilation of ", *codeBlock, " (for ", *profiledDFGCodeBlock, 73 70 ") result: ", result, "\n"); 74 71 } 75 72 76 JITCode* jitCode = m_dfgCodeBlock->jitCode()->dfg();73 JITCode* jitCode = profiledDFGCodeBlock->jitCode()->dfg(); 77 74 78 75 switch (result) { 79 76 case CompilationSuccessful: 80 jitCode-> osrEntryBlock = codeBlock;77 jitCode->setOSREntryBlock(*codeBlock->vm(), profiledDFGCodeBlock, codeBlock); 81 78 break; 82 79 case CompilationFailed: … … 91 88 } 92 89 93 DeferredCompilationCallback::compilationDidComplete(codeBlock, result);90 DeferredCompilationCallback::compilationDidComplete(codeBlock, profiledDFGCodeBlock, result); 94 91 } 95 92 -
trunk/Source/JavaScriptCore/dfg/DFGToFTLForOSREntryDeferredCompilationCallback.h
r190546 r190589 41 41 class ToFTLForOSREntryDeferredCompilationCallback : public DeferredCompilationCallback { 42 42 protected: 43 ToFTLForOSREntryDeferredCompilationCallback( PassRefPtr<CodeBlock> dfgCodeBlock);43 ToFTLForOSREntryDeferredCompilationCallback(); 44 44 45 45 public: 46 46 virtual ~ToFTLForOSREntryDeferredCompilationCallback(); 47 47 48 static Ref<ToFTLForOSREntryDeferredCompilationCallback> create( PassRefPtr<CodeBlock> dfgCodeBlock);48 static Ref<ToFTLForOSREntryDeferredCompilationCallback> create(); 49 49 50 virtual void compilationDidBecomeReadyAsynchronously(CodeBlock*); 51 virtual void compilationDidComplete(CodeBlock*, CompilationResult); 52 53 private: 54 RefPtr<CodeBlock> m_dfgCodeBlock; 50 virtual void compilationDidBecomeReadyAsynchronously(CodeBlock*, CodeBlock* profiledDFGCodeBlock); 51 virtual void compilationDidComplete(CodeBlock*, CodeBlock* profiledDFGCodeBlock, CompilationResult); 55 52 }; 56 53 -
trunk/Source/JavaScriptCore/dfg/DFGWorklist.cpp
r190546 r190589 208 208 } 209 209 210 void Worklist:: clearCodeBlockMarks(VM& vm)210 void Worklist::rememberCodeBlocks(VM& vm) 211 211 { 212 212 LockHolder locker(m_lock); … … 215 215 if (&plan->vm != &vm) 216 216 continue; 217 plan-> clearCodeBlockMarks();217 plan->rememberCodeBlocks(); 218 218 } 219 219 } … … 468 468 } 469 469 470 void clearCodeBlockMarks(VM& vm)470 void rememberCodeBlocks(VM& vm) 471 471 { 472 472 for (unsigned i = DFG::numberOfWorklists(); i--;) { 473 473 if (DFG::Worklist* worklist = DFG::worklistForIndexOrNull(i)) 474 worklist-> clearCodeBlockMarks(vm);474 worklist->rememberCodeBlocks(vm); 475 475 } 476 476 } -
trunk/Source/JavaScriptCore/dfg/DFGWorklist.h
r190546 r190589 58 58 void completeAllPlansForVM(VM&); 59 59 60 void clearCodeBlockMarks(VM&);60 void rememberCodeBlocks(VM&); 61 61 62 62 void waitUntilAllPlansForVMAreReady(VM&); … … 142 142 143 143 void completeAllPlansForVM(VM&); 144 void clearCodeBlockMarks(VM&);144 void rememberCodeBlocks(VM&); 145 145 146 146 } } // namespace JSC::DFG -
trunk/Source/JavaScriptCore/ftl/FTLJITFinalizer.cpp
r190546 r190589 100 100 FINALIZE_DFG_CODE( 101 101 *exitThunksLinkBuffer, 102 ("FTL exit thunks for %s", toCString(CodeBlockWithJITType(m_plan.codeBlock .get(), JITCode::FTLJIT)).data())));102 ("FTL exit thunks for %s", toCString(CodeBlockWithJITType(m_plan.codeBlock, JITCode::FTLJIT)).data()))); 103 103 } // else this function had no OSR exits, so no exit thunks. 104 104 … … 117 117 *sideCodeLinkBuffer, 118 118 ("FTL side code for %s", 119 toCString(CodeBlockWithJITType(m_plan.codeBlock .get(), JITCode::FTLJIT)).data()))119 toCString(CodeBlockWithJITType(m_plan.codeBlock, JITCode::FTLJIT)).data())) 120 120 .executableMemory()); 121 121 } … … 125 125 *handleExceptionsLinkBuffer, 126 126 ("FTL exception handler for %s", 127 toCString(CodeBlockWithJITType(m_plan.codeBlock .get(), JITCode::FTLJIT)).data()))127 toCString(CodeBlockWithJITType(m_plan.codeBlock, JITCode::FTLJIT)).data())) 128 128 .executableMemory()); 129 129 } … … 138 138 FINALIZE_DFG_CODE( 139 139 *entrypointLinkBuffer, 140 ("FTL entrypoint thunk for %s with LLVM generated code at %p", toCString(CodeBlockWithJITType(m_plan.codeBlock .get(), JITCode::FTLJIT)).data(), function)));140 ("FTL entrypoint thunk for %s with LLVM generated code at %p", toCString(CodeBlockWithJITType(m_plan.codeBlock, JITCode::FTLJIT)).data(), function))); 141 141 142 142 m_plan.codeBlock->setJITCode(jitCode); -
trunk/Source/JavaScriptCore/heap/CodeBlockSet.cpp
r190569 r190589 42 42 CodeBlockSet::~CodeBlockSet() 43 43 { 44 for (CodeBlock* codeBlock : m_oldCodeBlocks)45 codeBlock->deref();46 47 for (CodeBlock* codeBlock : m_newCodeBlocks)48 codeBlock->deref();49 44 } 50 45 51 void CodeBlockSet::add( PassRefPtr<CodeBlock>codeBlock)46 void CodeBlockSet::add(CodeBlock* codeBlock) 52 47 { 53 CodeBlock* block = codeBlock.leakRef(); 54 bool isNewEntry = m_newCodeBlocks.add(block).isNewEntry; 48 bool isNewEntry = m_newCodeBlocks.add(codeBlock).isNewEntry; 55 49 ASSERT_UNUSED(isNewEntry, isNewEntry); 56 50 } … … 65 59 { 66 60 for (CodeBlock* codeBlock : m_oldCodeBlocks) 67 codeBlock->clear Marks();61 codeBlock->clearVisitWeaklyHasBeenCalled(); 68 62 69 63 // We promote after we clear marks on the old generation CodeBlocks because … … 72 66 } 73 67 74 void CodeBlockSet:: clearMarksForEdenCollection(const Vector<const JSCell*>& rememberedSet)68 void CodeBlockSet::lastChanceToFinalize() 75 69 { 76 // This ensures that we will revisit CodeBlocks in remembered Executables even if they were previously marked. 77 for (const JSCell* cell : rememberedSet) { 78 ScriptExecutable* executable = const_cast<ScriptExecutable*>(jsDynamicCast<const ScriptExecutable*>(cell)); 79 if (!executable) 80 continue; 81 executable->forEachCodeBlock([this](CodeBlock* codeBlock) { 82 codeBlock->clearMarks(); 83 m_remembered.add(codeBlock); 84 }); 85 } 70 for (CodeBlock* codeBlock : m_newCodeBlocks) 71 codeBlock->classInfo()->methodTable.destroy(codeBlock); 72 73 for (CodeBlock* codeBlock : m_oldCodeBlocks) 74 codeBlock->classInfo()->methodTable.destroy(codeBlock); 86 75 } 87 76 … … 89 78 { 90 79 HashSet<CodeBlock*>& set = collectionType == EdenCollection ? m_newCodeBlocks : m_oldCodeBlocks; 80 Vector<CodeBlock*> unmarked; 81 for (CodeBlock* codeBlock : set) { 82 if (Heap::isMarked(codeBlock)) 83 continue; 84 unmarked.append(codeBlock); 85 } 91 86 92 // This needs to be a fixpoint because code blocks that are unmarked may 93 // refer to each other. For example, a DFG code block that is owned by 94 // the GC may refer to an FTL for-entry code block that is also owned by 95 // the GC. 96 Vector<CodeBlock*, 16> toRemove; 97 if (verbose) 98 dataLog("Fixpointing over unmarked, set size = ", set.size(), "...\n"); 99 for (;;) { 100 for (CodeBlock* codeBlock : set) { 101 if (!codeBlock->hasOneRef()) 102 continue; 103 codeBlock->deref(); 104 toRemove.append(codeBlock); 105 } 106 if (verbose) 107 dataLog(" Removing ", toRemove.size(), " blocks.\n"); 108 if (toRemove.isEmpty()) 109 break; 110 for (CodeBlock* codeBlock : toRemove) 111 set.remove(codeBlock); 112 toRemove.resize(0); 87 for (CodeBlock* codeBlock : unmarked) { 88 codeBlock->classInfo()->methodTable.destroy(codeBlock); 89 set.remove(codeBlock); 113 90 } 114 91 … … 120 97 void CodeBlockSet::remove(CodeBlock* codeBlock) 121 98 { 122 codeBlock->deref();123 99 if (m_oldCodeBlocks.contains(codeBlock)) { 124 100 m_oldCodeBlocks.remove(codeBlock); … … 129 105 } 130 106 131 void CodeBlockSet::traceMarked(SlotVisitor& visitor) 132 { 133 if (verbose) 134 dataLog("Tracing ", m_currentlyExecuting.size(), " code blocks.\n"); 135 136 // We strongly visit the currently executing set because jettisoning code 137 // is not valuable once it's on the stack. We're past the point where 138 // jettisoning would avoid the cost of OSR exit. 139 for (const RefPtr<CodeBlock>& codeBlock : m_currentlyExecuting) 140 codeBlock->visitStrongly(visitor); 141 142 // We strongly visit the remembered set because jettisoning old code during 143 // Eden GC is unsound. There might be an old object with a strong reference 144 // to the code. 145 for (const RefPtr<CodeBlock>& codeBlock : m_remembered) 146 codeBlock->visitStrongly(visitor); 147 } 148 149 void CodeBlockSet::rememberCurrentlyExecutingCodeBlocks(Heap* heap) 107 void CodeBlockSet::writeBarrierCurrentlyExecutingCodeBlocks(Heap* heap) 150 108 { 151 109 if (verbose) 152 110 dataLog("Remembering ", m_currentlyExecuting.size(), " code blocks.\n"); 153 for ( const RefPtr<CodeBlock>&codeBlock : m_currentlyExecuting)154 heap->writeBarrier(codeBlock ->ownerExecutable());111 for (CodeBlock* codeBlock : m_currentlyExecuting) 112 heap->writeBarrier(codeBlock); 155 113 156 // It's safe to clear th ese RefPtr setsbecause we won't delete the CodeBlocks157 // in them until the next GC, and we'll recompute themat that time.114 // It's safe to clear this set because we won't delete the CodeBlocks 115 // in it until the next GC, and we'll recompute it at that time. 158 116 m_currentlyExecuting.clear(); 159 m_remembered.clear();160 117 } 161 118 … … 172 129 out.print("], currentlyExecuting = ["); 173 130 comma = CommaPrinter(); 174 for ( const RefPtr<CodeBlock>&codeBlock : m_currentlyExecuting)175 out.print(comma, pointerDump(codeBlock .get()));131 for (CodeBlock* codeBlock : m_currentlyExecuting) 132 out.print(comma, pointerDump(codeBlock)); 176 133 out.print("]}"); 177 134 } -
trunk/Source/JavaScriptCore/heap/CodeBlockSet.h
r190546 r190589 52 52 CodeBlockSet(); 53 53 ~CodeBlockSet(); 54 55 void lastChanceToFinalize(); 54 56 55 57 // Add a CodeBlock. This is only called by CodeBlock constructors. 56 void add( PassRefPtr<CodeBlock>);58 void add(CodeBlock*); 57 59 58 // Clear mark bits for certain CodeBlocks depending on the type of collection.59 void clearMarksForEdenCollection(const Vector<const JSCell*>&);60 61 60 // Clear all mark bits for all CodeBlocks. 62 61 void clearMarksForFullCollection(); … … 73 72 void remove(CodeBlock*); 74 73 75 // Trace all marked code blocks. The CodeBlock is free to make use of76 // mayBeExecuting.77 void traceMarked(SlotVisitor&);78 79 74 // Add all currently executing CodeBlocks to the remembered set to be 80 75 // re-scanned during the next collection. 81 void rememberCurrentlyExecutingCodeBlocks(Heap*);76 void writeBarrierCurrentlyExecutingCodeBlocks(Heap*); 82 77 83 78 // Visits each CodeBlock in the heap until the visitor function returns true … … 102 97 103 98 private: 104 void clearMarksForCodeBlocksInRememberedExecutables(const Vector<const JSCell*>&);105 99 void promoteYoungCodeBlocks(); 106 100 107 // This is not a set of RefPtr<CodeBlock> because we need to be able to find108 // arbitrary bogus pointers. I could have written a thingy that had peek types109 // and all, but that seemed like overkill.110 101 HashSet<CodeBlock*> m_oldCodeBlocks; 111 102 HashSet<CodeBlock*> m_newCodeBlocks; 112 HashSet<RefPtr<CodeBlock>> m_currentlyExecuting; 113 HashSet<RefPtr<CodeBlock>> m_remembered; 103 HashSet<CodeBlock*> m_currentlyExecuting; 114 104 }; 115 105 -
trunk/Source/JavaScriptCore/heap/Heap.cpp
r190569 r190589 383 383 RELEASE_ASSERT(m_operationInProgress == NoOperation); 384 384 385 m_codeBlocks.lastChanceToFinalize(); 385 386 m_objectSpace.lastChanceToFinalize(); 386 387 releaseDelayedReleasedObjects(); … … 521 522 ASSERT(isValidThreadState(m_vm)); 522 523 523 Vector<const JSCell*> rememberedSet(m_slotVisitor.markStack().size());524 m_slotVisitor.markStack().fillVector(rememberedSet);525 526 #if ENABLE(DFG_JIT)527 DFG::clearCodeBlockMarks(*m_vm);528 #endif529 if (m_operationInProgress == EdenCollection)530 m_codeBlocks.clearMarksForEdenCollection(rememberedSet);531 else532 m_codeBlocks.clearMarksForFullCollection();533 534 524 // We gather conservative roots before clearing mark bits because conservative 535 525 // gathering uses the mark bits to determine whether a reference is valid. … … 539 529 gatherScratchBufferRoots(conservativeRoots); 540 530 531 #if ENABLE(DFG_JIT) 532 DFG::rememberCodeBlocks(*m_vm); 533 #endif 534 535 if (m_operationInProgress == FullCollection) { 536 m_opaqueRoots.clear(); 537 m_slotVisitor.clearMarkStack(); 538 } 539 541 540 clearLivenessData(); 542 543 if (m_operationInProgress == FullCollection)544 m_opaqueRoots.clear();545 541 546 542 m_parallelMarkersShouldExit = false; … … 581 577 ParallelModeEnabler enabler(m_slotVisitor); 582 578 579 m_slotVisitor.donateAndDrain(); 583 580 visitExternalRememberedSet(); 584 581 visitSmallStrings(); … … 695 692 { 696 693 GCPHASE(ClearLivenessData); 694 if (m_operationInProgress == FullCollection) 695 m_codeBlocks.clearMarksForFullCollection(); 696 697 697 m_objectSpace.clearNewlyAllocated(); 698 698 m_objectSpace.clearMarks(); … … 816 816 { 817 817 GCPHASE(TraceCodeBlocksAndJITStubRoutines); 818 m_codeBlocks.traceMarked(m_slotVisitor);819 818 m_jitStubRoutines.traceMarkedStubRoutines(m_slotVisitor); 820 819 … … 950 949 // we'll end up returning to deleted code. 951 950 RELEASE_ASSERT(!m_vm->entryScope); 951 ASSERT(m_operationInProgress == NoOperation); 952 952 953 953 completeAllDFGPlans(); 954 954 955 for (ExecutableBase* current : m_executables) { 956 if (!current->isFunctionExecutable()) 957 continue; 958 static_cast<FunctionExecutable*>(current)->clearCode(); 959 } 960 961 ASSERT(m_operationInProgress == FullCollection || m_operationInProgress == NoOperation); 962 m_codeBlocks.clearMarksForFullCollection(); 963 m_codeBlocks.deleteUnmarkedAndUnreferenced(FullCollection); 955 for (ExecutableBase* executable : m_executables) 956 executable->clearCode(); 964 957 } 965 958 … … 981 974 continue; 982 975 983 // We do this because executable memory is limited on some platforms and because984 // CodeBlock requires eager finalization.985 ExecutableBase::clearCodeVirtual(current);976 // Eagerly dereference the Executable's JITCode in order to run watchpoint 977 // destructors. Otherwise, watchpoints might fire for deleted CodeBlocks. 978 current->clearCode(); 986 979 std::swap(m_executables[i], m_executables.last()); 987 980 m_executables.removeLast(); … … 1104 1097 deleteSourceProviderCaches(); 1105 1098 notifyIncrementalSweeper(); 1106 rememberCurrentlyExecutingCodeBlocks();1099 writeBarrierCurrentlyExecutingCodeBlocks(); 1107 1100 1108 1101 resetAllocators(); … … 1141 1134 if (shouldDoFullCollection(collectionType)) { 1142 1135 m_operationInProgress = FullCollection; 1143 m_slotVisitor.clearMarkStack();1144 1136 m_shouldDoFullCollection = false; 1145 1137 if (Options::logGC()) … … 1258 1250 } 1259 1251 1260 void Heap:: rememberCurrentlyExecutingCodeBlocks()1261 { 1262 GCPHASE( RememberCurrentlyExecutingCodeBlocks);1263 m_codeBlocks. rememberCurrentlyExecutingCodeBlocks(this);1252 void Heap::writeBarrierCurrentlyExecutingCodeBlocks() 1253 { 1254 GCPHASE(WriteBarrierCurrentlyExecutingCodeBlocks); 1255 m_codeBlocks.writeBarrierCurrentlyExecutingCodeBlocks(this); 1264 1256 } 1265 1257 -
trunk/Source/JavaScriptCore/heap/Heap.h
r190569 r190589 314 314 void deleteSourceProviderCaches(); 315 315 void notifyIncrementalSweeper(); 316 void rememberCurrentlyExecutingCodeBlocks();316 void writeBarrierCurrentlyExecutingCodeBlocks(); 317 317 void resetAllocators(); 318 318 void copyBackingStores(); -
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r190555 r190589 173 173 174 174 ThisTDZMode thisTDZMode = callerCodeBlock->unlinkedCodeBlock()->constructorKind() == ConstructorKind::Derived ? ThisTDZMode::AlwaysCheck : ThisTDZMode::CheckIfNeeded; 175 eval = callerCodeBlock->evalCodeCache().getSlow(callFrame, callerCodeBlock ->ownerScriptExecutable(), callerCodeBlock->isStrictMode(), thisTDZMode, programSource, callerScopeChain);175 eval = callerCodeBlock->evalCodeCache().getSlow(callFrame, callerCodeBlock, callerCodeBlock->isStrictMode(), thisTDZMode, programSource, callerScopeChain); 176 176 if (!eval) 177 177 return jsUndefined(); -
trunk/Source/JavaScriptCore/interpreter/StackVisitor.cpp
r190555 r190589 170 170 else 171 171 m_frame.m_argumentCountIncludingThis = inlineCallFrame->arguments.size(); 172 m_frame.m_codeBlock = inlineCallFrame->baselineCodeBlock ();172 m_frame.m_codeBlock = inlineCallFrame->baselineCodeBlock.get(); 173 173 m_frame.m_bytecodeOffset = codeOrigin->bytecodeIndex; 174 174 -
trunk/Source/JavaScriptCore/jit/AssemblyHelpers.cpp
r190546 r190589 39 39 return m_codeBlock->ownerExecutable(); 40 40 41 return codeOrigin.inlineCallFrame-> executable.get();41 return codeOrigin.inlineCallFrame->baselineCodeBlock->ownerExecutable(); 42 42 } 43 43 -
trunk/Source/JavaScriptCore/jit/AssemblyHelpers.h
r190569 r190589 1075 1075 if (!codeOrigin.inlineCallFrame) 1076 1076 return codeBlock()->isStrictMode(); 1077 return jsCast<FunctionExecutable*>(codeOrigin.inlineCallFrame->executable.get())->isStrictMode();1077 return codeOrigin.inlineCallFrame->isStrictMode(); 1078 1078 } 1079 1079 -
trunk/Source/JavaScriptCore/jit/GCAwareJITStubRoutine.h
r190546 r190589 116 116 // that codeBlock gets "executed" more than once. 117 117 #define FINALIZE_CODE_FOR_GC_AWARE_STUB(codeBlock, patchBuffer, makesCalls, cell, dataLogFArguments) \ 118 (createJITStubRoutine(FINALIZE_CODE_FOR((codeBlock), (patchBuffer), dataLogFArguments), *(codeBlock)->vm(), (codeBlock) ->ownerExecutable(), (makesCalls), (cell)))118 (createJITStubRoutine(FINALIZE_CODE_FOR((codeBlock), (patchBuffer), dataLogFArguments), *(codeBlock)->vm(), (codeBlock), (makesCalls), (cell))) 119 119 120 120 } // namespace JSC -
trunk/Source/JavaScriptCore/jit/JITCode.h
r190546 r190589 122 122 } 123 123 124 static std::chrono::milliseconds timeToLive(JITType jitType)125 {126 switch (jitType) {127 case InterpreterThunk:128 return std::chrono::duration_cast<std::chrono::milliseconds>(129 std::chrono::seconds(5));130 case BaselineJIT:131 // Effectively 10 additional seconds, since BaselineJIT and132 // InterpreterThunk share a CodeBlock.133 return std::chrono::duration_cast<std::chrono::milliseconds>(134 std::chrono::seconds(15));135 case DFGJIT:136 return std::chrono::duration_cast<std::chrono::milliseconds>(137 std::chrono::seconds(20));138 case FTLJIT:139 return std::chrono::duration_cast<std::chrono::milliseconds>(140 std::chrono::seconds(60));141 default:142 return std::chrono::milliseconds::max();143 }144 }145 146 124 static bool isLowerTier(JITType expectedLower, JITType expectedHigher) 147 125 { -
trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp
r190546 r190589 667 667 emitInitRegister(virtualRegisterForLocal(j).offset()); 668 668 669 emitWriteBarrier(m_codeBlock ->ownerExecutable());669 emitWriteBarrier(m_codeBlock); 670 670 671 671 emitEnterOptimizationCheck(); -
trunk/Source/JavaScriptCore/jit/JITOperations.cpp
r190561 r190589 1262 1262 } 1263 1263 1264 RefPtr<CodeBlock>replacementCodeBlock = codeBlock->newReplacement();1264 CodeBlock* replacementCodeBlock = codeBlock->newReplacement(); 1265 1265 CompilationResult result = DFG::compile( 1266 vm, replacementCodeBlock .get(), 0, DFG::DFGMode, bytecodeIndex,1266 vm, replacementCodeBlock, nullptr, DFG::DFGMode, bytecodeIndex, 1267 1267 mustHandleValues, JITToDFGDeferredCompilationCallback::create()); 1268 1268 1269 if (result != CompilationSuccessful) { 1270 ASSERT(result == CompilationDeferred || replacementCodeBlock->hasOneRef()); 1269 if (result != CompilationSuccessful) 1271 1270 return encodeResult(0, 0); 1272 }1273 1271 } 1274 1272 -
trunk/Source/JavaScriptCore/jit/JITToDFGDeferredCompilationCallback.cpp
r190546 r190589 44 44 45 45 void JITToDFGDeferredCompilationCallback::compilationDidBecomeReadyAsynchronously( 46 CodeBlock* codeBlock )46 CodeBlock* codeBlock, CodeBlock* profiledDFGCodeBlock) 47 47 { 48 ASSERT_UNUSED(profiledDFGCodeBlock, !profiledDFGCodeBlock); 48 49 ASSERT(codeBlock->alternative()->jitType() == JITCode::BaselineJIT); 49 50 … … 55 56 56 57 void JITToDFGDeferredCompilationCallback::compilationDidComplete( 57 CodeBlock* codeBlock, Co mpilationResult result)58 CodeBlock* codeBlock, CodeBlock* profiledDFGCodeBlock, CompilationResult result) 58 59 { 60 ASSERT(!profiledDFGCodeBlock); 59 61 ASSERT(codeBlock->alternative()->jitType() == JITCode::BaselineJIT); 60 62 … … 67 69 codeBlock->alternative()->setOptimizationThresholdBasedOnCompilationResult(result); 68 70 69 DeferredCompilationCallback::compilationDidComplete(codeBlock, result);71 DeferredCompilationCallback::compilationDidComplete(codeBlock, profiledDFGCodeBlock, result); 70 72 } 71 73 -
trunk/Source/JavaScriptCore/jit/JITToDFGDeferredCompilationCallback.h
r190546 r190589 45 45 static Ref<JITToDFGDeferredCompilationCallback> create(); 46 46 47 virtual void compilationDidBecomeReadyAsynchronously(CodeBlock* ) override;48 virtual void compilationDidComplete(CodeBlock*, Co mpilationResult) override;47 virtual void compilationDidBecomeReadyAsynchronously(CodeBlock*, CodeBlock* profiledDFGCodeBlock) override; 48 virtual void compilationDidComplete(CodeBlock*, CodeBlock* profiledDFGCodeBlock, CompilationResult) override; 49 49 }; 50 50 -
trunk/Source/JavaScriptCore/jit/Repatch.cpp
r190561 r190589 228 228 229 229 CodeBlock* codeBlock = exec->codeBlock(); 230 ScriptExecutable* owner = codeBlock->ownerScriptExecutable();231 230 VM& vm = exec->vm(); 232 231 … … 234 233 235 234 if (isJSArray(baseValue) && propertyName == exec->propertyNames().length) 236 newCase = AccessCase::getLength(vm, owner, AccessCase::ArrayLength);235 newCase = AccessCase::getLength(vm, codeBlock, AccessCase::ArrayLength); 237 236 else if (isJSString(baseValue) && propertyName == exec->propertyNames().length) 238 newCase = AccessCase::getLength(vm, owner, AccessCase::StringLength);237 newCase = AccessCase::getLength(vm, codeBlock, AccessCase::StringLength); 239 238 else { 240 239 if (!slot.isCacheable() && !slot.isUnset()) … … 280 279 if (slot.isUnset()) { 281 280 conditionSet = generateConditionsForPropertyMiss( 282 vm, codeBlock ->ownerExecutable(), exec, structure, propertyName.impl());281 vm, codeBlock, exec, structure, propertyName.impl()); 283 282 } else { 284 283 conditionSet = generateConditionsForPrototypePropertyHit( 285 vm, codeBlock ->ownerExecutable(), exec, structure, slot.slotBase(),284 vm, codeBlock, exec, structure, slot.slotBase(), 286 285 propertyName.impl()); 287 286 } … … 304 303 305 304 newCase = AccessCase::get( 306 vm, owner, type, offset, structure, conditionSet, loadTargetFromProxy,305 vm, codeBlock, type, offset, structure, conditionSet, loadTargetFromProxy, 307 306 slot.watchpointSet(), slot.isCacheableCustom() ? slot.customGetter() : nullptr, 308 307 slot.isCacheableCustom() ? slot.slotBase() : nullptr); … … 358 357 359 358 CodeBlock* codeBlock = exec->codeBlock(); 360 ScriptExecutable* owner = codeBlock->ownerScriptExecutable();361 359 VM& vm = exec->vm(); 362 360 … … 389 387 } 390 388 391 newCase = AccessCase::replace(vm, owner, structure, slot.cachedOffset());389 newCase = AccessCase::replace(vm, codeBlock, structure, slot.cachedOffset()); 392 390 } else { 393 391 ASSERT(slot.type() == PutPropertySlot::NewProperty); … … 411 409 conditionSet = 412 410 generateConditionsForPropertySetterMiss( 413 vm, owner, exec, newStructure, ident.impl());411 vm, codeBlock, exec, newStructure, ident.impl()); 414 412 if (!conditionSet.isValid()) 415 413 return GiveUpOnCache; 416 414 } 417 415 418 newCase = AccessCase::transition(vm, owner, structure, newStructure, offset, conditionSet);416 newCase = AccessCase::transition(vm, codeBlock, structure, newStructure, offset, conditionSet); 419 417 } 420 418 } else if (slot.isCacheableCustom() || slot.isCacheableSetter()) { … … 425 423 conditionSet = 426 424 generateConditionsForPrototypePropertyHitCustom( 427 vm, owner, exec, structure, slot.base(), ident.impl());425 vm, codeBlock, exec, structure, slot.base(), ident.impl()); 428 426 if (!conditionSet.isValid()) 429 427 return GiveUpOnCache; … … 431 429 432 430 newCase = AccessCase::setter( 433 vm, owner, AccessCase::CustomSetter, structure, invalidOffset, conditionSet,431 vm, codeBlock, AccessCase::CustomSetter, structure, invalidOffset, conditionSet, 434 432 slot.customSetter(), slot.base()); 435 433 } else { … … 440 438 conditionSet = 441 439 generateConditionsForPrototypePropertyHit( 442 vm, owner, exec, structure, slot.base(), ident.impl());440 vm, codeBlock, exec, structure, slot.base(), ident.impl()); 443 441 if (!conditionSet.isValid()) 444 442 return GiveUpOnCache; … … 448 446 449 447 newCase = AccessCase::setter( 450 vm, owner, AccessCase::Setter, structure, offset, conditionSet);448 vm, codeBlock, AccessCase::Setter, structure, offset, conditionSet); 451 449 } 452 450 } … … 490 488 491 489 CodeBlock* codeBlock = exec->codeBlock(); 492 ScriptExecutable* owner = codeBlock->ownerScriptExecutable();493 490 VM& vm = exec->vm(); 494 491 Structure* structure = base->structure(vm); … … 498 495 if (slot.slotBase() != base) { 499 496 conditionSet = generateConditionsForPrototypePropertyHit( 500 vm, codeBlock ->ownerExecutable(), exec, structure, slot.slotBase(), ident.impl());497 vm, codeBlock, exec, structure, slot.slotBase(), ident.impl()); 501 498 } 502 499 } else { 503 500 conditionSet = generateConditionsForPropertyMiss( 504 vm, codeBlock ->ownerExecutable(), exec, structure, ident.impl());501 vm, codeBlock, exec, structure, ident.impl()); 505 502 } 506 503 if (!conditionSet.isValid()) … … 508 505 509 506 std::unique_ptr<AccessCase> newCase = AccessCase::in( 510 vm, owner, wasFound ? AccessCase::InHit : AccessCase::InMiss, structure, conditionSet);507 vm, codeBlock, wasFound ? AccessCase::InHit : AccessCase::InMiss, structure, conditionSet); 511 508 512 509 MacroAssemblerCodePtr codePtr = stubInfo.addAccessCase(codeBlock, ident, WTF::move(newCase)); … … 557 554 558 555 ASSERT(!callLinkInfo.isLinked()); 559 callLinkInfo.setCallee(exec->callerFrame()->vm(), callLinkInfo.hotPathBegin(), callerCodeBlock ->ownerExecutable(), callee);560 callLinkInfo.setLastSeenCallee(exec->callerFrame()->vm(), callerCodeBlock ->ownerExecutable(), callee);556 callLinkInfo.setCallee(exec->callerFrame()->vm(), callLinkInfo.hotPathBegin(), callerCodeBlock, callee); 557 callLinkInfo.setLastSeenCallee(exec->callerFrame()->vm(), callerCodeBlock, callee); 561 558 if (shouldShowDisassemblyFor(callerCodeBlock)) 562 559 dataLog("Linking call in ", *callerCodeBlock, " at ", callLinkInfo.codeOrigin(), " to ", pointerDump(calleeCodeBlock), ", entrypoint at ", codePtr, "\n"); … … 875 872 toCString(*callerCodeBlock).data(), callLinkInfo.callReturnLocation().labelAtOffset(0).executableAddress(), 876 873 toCString(listDump(callCases)).data())), 877 *vm, callerCodeBlock ->ownerExecutable(), exec->callerFrame(), callLinkInfo, callCases,874 *vm, callerCodeBlock, exec->callerFrame(), callLinkInfo, callCases, 878 875 WTF::move(fastCounts))); 879 876 -
trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
r190546 r190589 577 577 && !structure->typeInfo().prohibitsPropertyCaching() 578 578 && !structure->typeInfo().newImpurePropertyFiresWatchpoints()) { 579 vm.heap.writeBarrier(codeBlock ->ownerExecutable());579 vm.heap.writeBarrier(codeBlock); 580 580 581 581 ConcurrentJITLocker locker(codeBlock->m_lock); … … 642 642 && baseCell == slot.base()) { 643 643 644 vm.heap.writeBarrier(codeBlock ->ownerExecutable());644 vm.heap.writeBarrier(codeBlock); 645 645 646 646 if (slot.type() == PutPropertySlot::NewProperty) { … … 659 659 ASSERT(chain); 660 660 pc[7].u.structureChain.set( 661 vm, codeBlock ->ownerExecutable(), chain);661 vm, codeBlock, chain); 662 662 } 663 663 pc[8].u.putByIdFlags = static_cast<PutByIdFlags>( … … 1191 1191 if (callLinkInfo->isOnList()) 1192 1192 callLinkInfo->remove(); 1193 callLinkInfo->callee.set(vm, callerCodeBlock ->ownerExecutable(), callee);1194 callLinkInfo->lastSeenCallee.set(vm, callerCodeBlock ->ownerExecutable(), callee);1193 callLinkInfo->callee.set(vm, callerCodeBlock, callee); 1194 callLinkInfo->lastSeenCallee.set(vm, callerCodeBlock, callee); 1195 1195 callLinkInfo->machineCodeTarget = codePtr; 1196 1196 if (codeBlock) -
trunk/Source/JavaScriptCore/profiler/ProfilerOriginStack.cpp
r190546 r190589 53 53 for (unsigned i = 1; i < stack.size(); ++i) { 54 54 append(Origin( 55 database.ensureBytecodesFor(stack[i].inlineCallFrame->baselineCodeBlock ()),55 database.ensureBytecodesFor(stack[i].inlineCallFrame->baselineCodeBlock.get()), 56 56 stack[i].bytecodeIndex)); 57 57 } -
trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp
r190546 r190589 232 232 auto& cacheWriteBarrier = pc[4].u.jsCell; 233 233 if (!cacheWriteBarrier) 234 cacheWriteBarrier.set(exec->vm(), exec->codeBlock() ->ownerExecutable(), constructor);234 cacheWriteBarrier.set(exec->vm(), exec->codeBlock(), constructor); 235 235 else if (cacheWriteBarrier.unvalidatedGet() != JSCell::seenMultipleCalleeObjects() && cacheWriteBarrier.get() != constructor) 236 236 cacheWriteBarrier.setWithoutWriteBarrier(JSCell::seenMultipleCalleeObjects()); … … 251 251 if (otherStructure) 252 252 pc[3].u.toThisStatus = ToThisConflicted; 253 pc[2].u.structure.set(vm, exec->codeBlock() ->ownerExecutable(), myStructure);253 pc[2].u.structure.set(vm, exec->codeBlock(), myStructure); 254 254 } 255 255 } else { … … 527 527 { 528 528 BEGIN(); 529 ExecutableBase* ownerExecutable = exec->codeBlock()->ownerExecutable();530 Heap::heap( ownerExecutable)->writeBarrier(ownerExecutable);529 CodeBlock* codeBlock = exec->codeBlock(); 530 Heap::heap(codeBlock)->writeBarrier(codeBlock); 531 531 END(); 532 532 } -
trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.h
r190546 r190589 130 130 131 131 ConcurrentJITLocker locker(codeBlock->m_lock); 132 pc[5].u.structure.set(exec->vm(), codeBlock ->ownerExecutable(), scope->structure());132 pc[5].u.structure.set(exec->vm(), codeBlock, scope->structure()); 133 133 pc[6].u.operand = slot.cachedOffset(); 134 134 } … … 163 163 { 164 164 ConcurrentJITLocker locker(codeBlock->m_lock); 165 pc[5].u.structure.set(exec->vm(), codeBlock ->ownerExecutable(), structure);165 pc[5].u.structure.set(exec->vm(), codeBlock, structure); 166 166 pc[6].u.operand = slot.cachedOffset(); 167 167 } -
trunk/Source/JavaScriptCore/runtime/Executable.cpp
r190546 r190589 61 61 m_numParametersForCall = NUM_PARAMETERS_NOT_COMPILED; 62 62 m_numParametersForConstruct = NUM_PARAMETERS_NOT_COMPILED; 63 64 if (classInfo() == FunctionExecutable::info()) { 65 FunctionExecutable* executable = jsCast<FunctionExecutable*>(this); 66 executable->m_codeBlockForCall.clear(); 67 executable->m_codeBlockForConstruct.clear(); 68 return; 69 } 70 71 if (classInfo() == EvalExecutable::info()) { 72 EvalExecutable* executable = jsCast<EvalExecutable*>(this); 73 executable->m_evalCodeBlock.clear(); 74 executable->m_unlinkedEvalCodeBlock.clear(); 75 return; 76 } 77 78 if (classInfo() == ProgramExecutable::info()) { 79 ProgramExecutable* executable = jsCast<ProgramExecutable*>(this); 80 executable->m_programCodeBlock.clear(); 81 executable->m_unlinkedProgramCodeBlock.clear(); 82 return; 83 } 84 85 if (classInfo() == ModuleProgramExecutable::info()) { 86 ModuleProgramExecutable* executable = jsCast<ModuleProgramExecutable*>(this); 87 executable->m_moduleProgramCodeBlock.clear(); 88 executable->m_unlinkedModuleProgramCodeBlock.clear(); 89 executable->m_moduleEnvironmentSymbolTable.clear(); 90 return; 91 } 92 93 #if ENABLE(WEBASSEMBLY) 94 if (classInfo() == WebAssemblyExecutable::info()) { 95 WebAssemblyExecutable* executable = jsCast<WebAssemblyExecutable*>(this); 96 executable->m_codeBlockForCall.clear(); 97 return; 98 } 99 #endif 100 101 ASSERT(classInfo() == NativeExecutable::info()); 63 102 } 64 103 … … 124 163 ASSERT(vm.heap.isDeferred()); 125 164 126 RefPtr<CodeBlock> oldCodeBlock;165 CodeBlock* oldCodeBlock = nullptr; 127 166 128 167 switch (codeType) { … … 133 172 ASSERT(kind == CodeForCall); 134 173 135 oldCodeBlock = executable->m_programCodeBlock ;136 executable->m_programCodeBlock = codeBlock;174 oldCodeBlock = executable->m_programCodeBlock.get(); 175 executable->m_programCodeBlock.setMayBeNull(vm, this, codeBlock); 137 176 break; 138 177 } … … 144 183 ASSERT(kind == CodeForCall); 145 184 146 oldCodeBlock = executable->m_moduleProgramCodeBlock ;147 executable->m_moduleProgramCodeBlock = codeBlock;185 oldCodeBlock = executable->m_moduleProgramCodeBlock.get(); 186 executable->m_moduleProgramCodeBlock.setMayBeNull(vm, this, codeBlock); 148 187 break; 149 188 } … … 155 194 ASSERT(kind == CodeForCall); 156 195 157 oldCodeBlock = executable->m_evalCodeBlock ;158 executable->m_evalCodeBlock = codeBlock;196 oldCodeBlock = executable->m_evalCodeBlock.get(); 197 executable->m_evalCodeBlock.setMayBeNull(vm, this, codeBlock); 159 198 break; 160 199 } … … 166 205 switch (kind) { 167 206 case CodeForCall: 168 oldCodeBlock = executable->m_codeBlockForCall ;169 executable->m_codeBlockForCall = codeBlock;207 oldCodeBlock = executable->m_codeBlockForCall.get(); 208 executable->m_codeBlockForCall.setMayBeNull(vm, this, codeBlock); 170 209 break; 171 210 case CodeForConstruct: 172 oldCodeBlock = executable->m_codeBlockForConstruct ;173 executable->m_codeBlockForConstruct = codeBlock;211 oldCodeBlock = executable->m_codeBlockForConstruct.get(); 212 executable->m_codeBlockForConstruct.setMayBeNull(vm, this, codeBlock); 174 213 break; 175 214 } … … 211 250 } 212 251 213 RefPtr<CodeBlock>ScriptExecutable::newCodeBlockFor(252 CodeBlock* ScriptExecutable::newCodeBlockFor( 214 253 CodeSpecializationKind kind, JSFunction* function, JSScope* scope, JSObject*& exception) 215 254 { … … 225 264 RELEASE_ASSERT(!executable->m_evalCodeBlock); 226 265 RELEASE_ASSERT(!function); 227 return adoptRef(new EvalCodeBlock(266 return EvalCodeBlock::create(vm, 228 267 executable, executable->m_unlinkedEvalCodeBlock.get(), scope, 229 executable->source().provider()) );268 executable->source().provider()); 230 269 } 231 270 … … 235 274 RELEASE_ASSERT(!executable->m_programCodeBlock); 236 275 RELEASE_ASSERT(!function); 237 return adoptRef(new ProgramCodeBlock(276 return ProgramCodeBlock::create(vm, 238 277 executable, executable->m_unlinkedProgramCodeBlock.get(), scope, 239 executable->source().provider(), executable->source().startColumn()) );278 executable->source().provider(), executable->source().startColumn()); 240 279 } 241 280 … … 245 284 RELEASE_ASSERT(!executable->m_moduleProgramCodeBlock); 246 285 RELEASE_ASSERT(!function); 247 return adoptRef(new ModuleProgramCodeBlock(286 return ModuleProgramCodeBlock::create(vm, 248 287 executable, executable->m_unlinkedModuleProgramCodeBlock.get(), scope, 249 executable->source().provider(), executable->source().startColumn()) );288 executable->source().provider(), executable->source().startColumn()); 250 289 } 251 290 … … 277 316 unsigned startColumn = executable->source().startColumn(); 278 317 279 return adoptRef(new FunctionCodeBlock(280 executable, unlinkedCodeBlock, scope, provider, sourceOffset, startColumn) );281 } 282 283 PassRefPtr<CodeBlock>ScriptExecutable::newReplacementCodeBlockFor(318 return FunctionCodeBlock::create(vm, 319 executable, unlinkedCodeBlock, scope, provider, sourceOffset, startColumn); 320 } 321 322 CodeBlock* ScriptExecutable::newReplacementCodeBlockFor( 284 323 CodeSpecializationKind kind) 285 324 { … … 289 328 EvalCodeBlock* baseline = static_cast<EvalCodeBlock*>( 290 329 executable->m_evalCodeBlock->baselineVersion()); 291 RefPtr<EvalCodeBlock> result = adoptRef(new EvalCodeBlock(292 CodeBlock::CopyParsedBlock, *baseline) );293 result->setAlternative( baseline);330 EvalCodeBlock* result = EvalCodeBlock::create(vm(), 331 CodeBlock::CopyParsedBlock, *baseline); 332 result->setAlternative(*vm(), baseline); 294 333 return result; 295 334 } … … 300 339 ProgramCodeBlock* baseline = static_cast<ProgramCodeBlock*>( 301 340 executable->m_programCodeBlock->baselineVersion()); 302 RefPtr<ProgramCodeBlock> result = adoptRef(new ProgramCodeBlock(303 CodeBlock::CopyParsedBlock, *baseline) );304 result->setAlternative( baseline);341 ProgramCodeBlock* result = ProgramCodeBlock::create(vm(), 342 CodeBlock::CopyParsedBlock, *baseline); 343 result->setAlternative(*vm(), baseline); 305 344 return result; 306 345 } … … 311 350 ModuleProgramCodeBlock* baseline = static_cast<ModuleProgramCodeBlock*>( 312 351 executable->m_moduleProgramCodeBlock->baselineVersion()); 313 RefPtr<ModuleProgramCodeBlock> result = adoptRef(new ModuleProgramCodeBlock(314 CodeBlock::CopyParsedBlock, *baseline) );315 result->setAlternative( baseline);352 ModuleProgramCodeBlock* result = ModuleProgramCodeBlock::create(vm(), 353 CodeBlock::CopyParsedBlock, *baseline); 354 result->setAlternative(*vm(), baseline); 316 355 return result; 317 356 } … … 321 360 FunctionCodeBlock* baseline = static_cast<FunctionCodeBlock*>( 322 361 executable->codeBlockFor(kind)->baselineVersion()); 323 RefPtr<FunctionCodeBlock> result = adoptRef(new FunctionCodeBlock(324 CodeBlock::CopyParsedBlock, *baseline) );325 result->setAlternative( baseline);362 FunctionCodeBlock* result = FunctionCodeBlock::create(vm(), 363 CodeBlock::CopyParsedBlock, *baseline); 364 result->setAlternative(*vm(), baseline); 326 365 return result; 327 366 } … … 351 390 352 391 JSObject* exception = 0; 353 RefPtr<CodeBlock>codeBlock = newCodeBlockFor(kind, function, scope, exception);392 CodeBlock* codeBlock = newCodeBlockFor(kind, function, scope, exception); 354 393 if (!codeBlock) { 355 394 RELEASE_ASSERT(exception); … … 361 400 362 401 if (Options::useLLInt()) 363 setupLLInt(vm, codeBlock .get());402 setupLLInt(vm, codeBlock); 364 403 else 365 setupJIT(vm, codeBlock .get());366 367 installCode(*codeBlock->vm(), codeBlock .get(), codeBlock->codeType(), codeBlock->specializationKind());404 setupJIT(vm, codeBlock); 405 406 installCode(*codeBlock->vm(), codeBlock, codeBlock->codeType(), codeBlock->specializationKind()); 368 407 return 0; 369 408 } … … 503 542 ASSERT_GC_OBJECT_INHERITS(thisObject, info()); 504 543 ScriptExecutable::visitChildren(thisObject, visitor); 544 visitor.append(&thisObject->m_unlinkedEvalCodeBlock); 505 545 if (thisObject->m_evalCodeBlock) 506 thisObject->m_evalCodeBlock->visitAggregate(visitor); 507 visitor.append(&thisObject->m_unlinkedEvalCodeBlock); 508 } 509 510 void EvalExecutable::clearCode() 511 { 512 m_evalCodeBlock = nullptr; 513 m_unlinkedEvalCodeBlock.clear(); 514 Base::clearCode(); 546 thisObject->m_evalCodeBlock->visitWeakly(visitor); 515 547 } 516 548 … … 619 651 visitor.append(&thisObject->m_unlinkedProgramCodeBlock); 620 652 if (thisObject->m_programCodeBlock) 621 thisObject->m_programCodeBlock->visitAggregate(visitor); 622 } 623 624 void ProgramExecutable::clearCode() 625 { 626 m_programCodeBlock = nullptr; 627 m_unlinkedProgramCodeBlock.clear(); 628 Base::clearCode(); 653 thisObject->m_programCodeBlock->visitWeakly(visitor); 629 654 } 630 655 … … 637 662 visitor.append(&thisObject->m_moduleEnvironmentSymbolTable); 638 663 if (thisObject->m_moduleProgramCodeBlock) 639 thisObject->m_moduleProgramCodeBlock->visitAggregate(visitor); 640 } 641 642 void ModuleProgramExecutable::clearCode() 643 { 644 m_moduleProgramCodeBlock = nullptr; 645 m_unlinkedModuleProgramCodeBlock.clear(); 646 m_moduleEnvironmentSymbolTable.clear(); 647 Base::clearCode(); 664 thisObject->m_moduleProgramCodeBlock->visitWeakly(visitor); 648 665 } 649 666 … … 668 685 ScriptExecutable::visitChildren(thisObject, visitor); 669 686 if (thisObject->m_codeBlockForCall) 670 thisObject->m_codeBlockForCall->visit Aggregate(visitor);687 thisObject->m_codeBlockForCall->visitWeakly(visitor); 671 688 if (thisObject->m_codeBlockForConstruct) 672 thisObject->m_codeBlockForConstruct->visit Aggregate(visitor);689 thisObject->m_codeBlockForConstruct->visitWeakly(visitor); 673 690 visitor.append(&thisObject->m_unlinkedExecutable); 674 691 visitor.append(&thisObject->m_singletonFunction); 675 }676 677 void FunctionExecutable::clearCode()678 {679 m_codeBlockForCall = nullptr;680 m_codeBlockForConstruct = nullptr;681 Base::clearCode();682 692 } 683 693 … … 717 727 ExecutableBase::visitChildren(thisObject, visitor); 718 728 if (thisObject->m_codeBlockForCall) 719 thisObject->m_codeBlockForCall->visit Aggregate(visitor);729 thisObject->m_codeBlockForCall->visitWeakly(visitor); 720 730 visitor.append(&thisObject->m_module); 721 }722 723 void WebAssemblyExecutable::clearCode()724 {725 m_codeBlockForCall = nullptr;726 Base::clearCode();727 731 } 728 732 … … 735 739 DeferGC deferGC(vm.heap); 736 740 737 RefPtr<WebAssemblyCodeBlock> codeBlock = adoptRef(new WebAssemblyCodeBlock(738 this, vm,exec->lexicalGlobalObject()));739 740 WASMFunctionParser::compile(vm, codeBlock .get(), m_module.get(), m_source, m_functionIndex);741 WebAssemblyCodeBlock* codeBlock = WebAssemblyCodeBlock::create(vm, 742 this, exec->lexicalGlobalObject())); 743 744 WASMFunctionParser::compile(vm, codeBlock, m_module.get(), m_source, m_functionIndex); 741 745 742 746 m_jitCodeForCall = codeBlock->jitCode(); … … 744 748 m_numParametersForCall = codeBlock->numParameters(); 745 749 746 m_codeBlockForCall = codeBlock;750 m_codeBlockForCall.set(vm, this, codeBlock); 747 751 748 752 Heap::heap(this)->writeBarrier(this); -
trunk/Source/JavaScriptCore/runtime/Executable.h
r190546 r190589 140 140 141 141 public: 142 static void clearCodeVirtual(ExecutableBase*);143 144 142 PassRefPtr<JITCode> generatedJITCodeForCall() 145 143 { … … 307 305 308 306 private: 307 friend class ExecutableBase; 308 309 309 NativeExecutable(VM& vm, NativeFunction function, NativeFunction constructor) 310 310 : ExecutableBase(vm, vm.nativeExecutableStructure.get(), NUM_PARAMETERS_IS_HOST) … … 377 377 void installCode(CodeBlock*); 378 378 void installCode(VM&, CodeBlock*, CodeType, CodeSpecializationKind); 379 RefPtr<CodeBlock>newCodeBlockFor(CodeSpecializationKind, JSFunction*, JSScope*, JSObject*& exception);380 PassRefPtr<CodeBlock>newReplacementCodeBlockFor(CodeSpecializationKind);379 CodeBlock* newCodeBlockFor(CodeSpecializationKind, JSFunction*, JSScope*, JSObject*& exception); 380 CodeBlock* newReplacementCodeBlockFor(CodeSpecializationKind); 381 381 382 382 JSObject* prepareForExecution(ExecState* exec, JSFunction* function, JSScope* scope, CodeSpecializationKind kind) … … 390 390 391 391 private: 392 friend class ExecutableBase; 392 393 JSObject* prepareForExecutionImpl(ExecState*, JSFunction*, JSScope*, CodeSpecializationKind); 393 394 … … 448 449 DECLARE_INFO; 449 450 450 void clearCode();451 452 451 ExecutableInfo executableInfo() const { return ExecutableInfo(needsActivation(), usesEval(), isStrictMode(), false, false, ConstructorKind::None, false); } 453 452 … … 456 455 457 456 private: 457 friend class ExecutableBase; 458 458 friend class ScriptExecutable; 459 459 EvalExecutable(ExecState*, const SourceCode&, bool); … … 461 461 static void visitChildren(JSCell*, SlotVisitor&); 462 462 463 RefPtr<EvalCodeBlock> m_evalCodeBlock;463 WriteBarrier<EvalCodeBlock> m_evalCodeBlock; 464 464 WriteBarrier<UnlinkedEvalCodeBlock> m_unlinkedEvalCodeBlock; 465 465 }; … … 502 502 DECLARE_INFO; 503 503 504 void clearCode();505 506 504 ExecutableInfo executableInfo() const { return ExecutableInfo(needsActivation(), usesEval(), isStrictMode(), false, false, ConstructorKind::None, false); } 507 505 508 506 private: 507 friend class ExecutableBase; 509 508 friend class ScriptExecutable; 510 509 … … 514 513 515 514 WriteBarrier<UnlinkedProgramCodeBlock> m_unlinkedProgramCodeBlock; 516 RefPtr<ProgramCodeBlock> m_programCodeBlock;515 WriteBarrier<ProgramCodeBlock> m_programCodeBlock; 517 516 }; 518 517 … … 544 543 DECLARE_INFO; 545 544 546 void clearCode();547 548 545 ExecutableInfo executableInfo() const { return ExecutableInfo(needsActivation(), usesEval(), isStrictMode(), false, false, ConstructorKind::None, false); } 549 546 UnlinkedModuleProgramCodeBlock* unlinkedModuleProgramCodeBlock() { return m_unlinkedModuleProgramCodeBlock.get(); } … … 552 549 553 550 private: 551 friend class ExecutableBase; 554 552 friend class ScriptExecutable; 555 553 … … 560 558 WriteBarrier<UnlinkedModuleProgramCodeBlock> m_unlinkedModuleProgramCodeBlock; 561 559 WriteBarrier<SymbolTable> m_moduleEnvironmentSymbolTable; 562 RefPtr<ModuleProgramCodeBlock> m_moduleProgramCodeBlock;560 WriteBarrier<ModuleProgramCodeBlock> m_moduleProgramCodeBlock; 563 561 }; 564 562 … … 601 599 bool isGeneratedForCall() const 602 600 { 603 return m_codeBlockForCall;601 return !!m_codeBlockForCall; 604 602 } 605 603 … … 611 609 bool isGeneratedForConstruct() const 612 610 { 613 return m_codeBlockForConstruct ;611 return m_codeBlockForConstruct.get(); 614 612 } 615 613 … … 677 675 DECLARE_INFO; 678 676 679 void clearCode();680 681 677 InferredValue* singletonFunction() { return m_singletonFunction.get(); } 682 678 683 679 private: 680 friend class ExecutableBase; 684 681 FunctionExecutable( 685 682 VM&, const SourceCode&, UnlinkedFunctionExecutable*, unsigned firstLine, … … 691 688 692 689 WriteBarrier<UnlinkedFunctionExecutable> m_unlinkedExecutable; 693 RefPtr<FunctionCodeBlock> m_codeBlockForCall;694 RefPtr<FunctionCodeBlock> m_codeBlockForConstruct;690 WriteBarrier<FunctionCodeBlock> m_codeBlockForCall; 691 WriteBarrier<FunctionCodeBlock> m_codeBlockForConstruct; 695 692 RefPtr<TypeSet> m_returnStatementTypeSet; 696 693 unsigned m_parametersStartOffset; … … 720 717 DECLARE_INFO; 721 718 722 void clearCode();723 724 719 void prepareForExecution(ExecState*); 725 720 … … 730 725 731 726 private: 727 friend class ExecutableBase; 732 728 WebAssemblyExecutable(VM&, const SourceCode&, JSWASMModule*, unsigned functionIndex); 733 729 … … 738 734 unsigned m_functionIndex; 739 735 740 RefPtr<WebAssemblyCodeBlock> m_codeBlockForCall;736 WriteBarrier<WebAssemblyCodeBlock> m_codeBlockForCall; 741 737 }; 742 738 #endif 743 739 744 inline void ExecutableBase::clearCodeVirtual(ExecutableBase* executable) 745 { 746 switch (executable->type()) { 747 case EvalExecutableType: 748 return jsCast<EvalExecutable*>(executable)->clearCode(); 749 case ProgramExecutableType: 750 return jsCast<ProgramExecutable*>(executable)->clearCode(); 751 case FunctionExecutableType: 752 return jsCast<FunctionExecutable*>(executable)->clearCode(); 753 #if ENABLE(WEBASSEMBLY) 754 case WebAssemblyExecutableType: 755 return jsCast<WebAssemblyExecutable*>(executable)->clearCode(); 756 #endif 757 case ModuleProgramExecutableType: 758 return jsCast<ModuleProgramExecutable*>(executable)->clearCode(); 759 default: 760 return jsCast<NativeExecutable*>(executable)->clearCode(); 761 } 762 } 763 764 } 765 766 #endif 740 } // namespace JSC 741 742 #endif // Executable_h -
trunk/Source/JavaScriptCore/runtime/VM.cpp
r190563 r190589 248 248 promiseDeferredStructure.set(*this, JSPromiseDeferred::createStructure(*this, 0, jsNull())); 249 249 internalPromiseDeferredStructure.set(*this, JSInternalPromiseDeferred::createStructure(*this, 0, jsNull())); 250 programCodeBlockStructure.set(*this, ProgramCodeBlock::createStructure(*this, 0, jsNull())); 251 moduleProgramCodeBlockStructure.set(*this, ModuleProgramCodeBlock::createStructure(*this, 0, jsNull())); 252 evalCodeBlockStructure.set(*this, EvalCodeBlock::createStructure(*this, 0, jsNull())); 253 functionCodeBlockStructure.set(*this, FunctionCodeBlock::createStructure(*this, 0, jsNull())); 254 #if ENABLE(WEBASSEMBLY) 255 webAssemblyCodeBlockStructure.set(*this, WebAssemblyCodeBlock::createStructure(*this, 0, jsNull())); 256 #endif 257 250 258 iterationTerminator.set(*this, JSFinalObject::create(*this, JSFinalObject::createStructure(*this, 0, jsNull(), 1))); 251 259 nativeStdFunctionCellStructure.set(*this, NativeStdFunctionCell::createStructure(*this, 0, jsNull())); -
trunk/Source/JavaScriptCore/runtime/VM.h
r190563 r190589 310 310 Strong<Structure> internalPromiseDeferredStructure; 311 311 Strong<Structure> nativeStdFunctionCellStructure; 312 Strong<Structure> programCodeBlockStructure; 313 Strong<Structure> moduleProgramCodeBlockStructure; 314 Strong<Structure> evalCodeBlockStructure; 315 Strong<Structure> functionCodeBlockStructure; 316 Strong<Structure> webAssemblyCodeBlockStructure; 317 312 318 Strong<JSCell> iterationTerminator; 313 319 Strong<JSCell> emptyPropertyNameEnumerator;
Note:
See TracChangeset
for help on using the changeset viewer.