Changeset 252502 in webkit
- Timestamp:
- Nov 15, 2019 2:10:07 PM (5 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r252479 r252502 1 2019-11-15 Mark Lam <mark.lam@apple.com> 2 3 Rename InPlaceAbstractState's m_foundConstant to m_shouldTryConstantFolding. 4 https://bugs.webkit.org/show_bug.cgi?id=204244 5 6 Reviewed by Saam Barati. 7 8 m_shouldTryConstantFolding is a more accurate description of what this flag really 9 means i.e. that the AbstractInterpreter thinks that we may benefit from constant 10 folding, and therefore, should attempt it. It doesn't always mean that it found 11 constants to be folded. It also doesn't guarantee that the constant folding phase 12 will succeed in folding any constants. 13 14 * dfg/DFGAbstractInterpreter.h: 15 (JSC::DFG::AbstractInterpreter::setConstant): 16 * dfg/DFGAbstractInterpreterInlines.h: 17 (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): 18 * dfg/DFGAtTailAbstractState.h: 19 (JSC::DFG::AtTailAbstractState::setShouldTryConstantFolding): 20 (JSC::DFG::AtTailAbstractState::setFoundConstants): Deleted. 21 * dfg/DFGBasicBlock.cpp: 22 (JSC::DFG::BasicBlock::BasicBlock): 23 * dfg/DFGBasicBlock.h: 24 * dfg/DFGConstantFoldingPhase.cpp: 25 (JSC::DFG::ConstantFoldingPhase::run): 26 * dfg/DFGInPlaceAbstractState.cpp: 27 (JSC::DFG::InPlaceAbstractState::beginBasicBlock): 28 (JSC::DFG::InPlaceAbstractState::initialize): 29 (JSC::DFG::InPlaceAbstractState::endBasicBlock): 30 * dfg/DFGInPlaceAbstractState.h: 31 (JSC::DFG::InPlaceAbstractState::setShouldTryConstantFolding): 32 (JSC::DFG::InPlaceAbstractState::setFoundConstants): Deleted. 33 1 34 2019-11-14 Saam Barati <sbarati@apple.com> 2 35 -
trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreter.h
r248546 r252502 248 248 { 249 249 setBuiltInConstant(node, value); 250 m_state.set FoundConstants(true);250 m_state.setShouldTryConstantFolding(true); 251 251 } 252 252 -
trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h
r252416 r252502 370 370 setForNode(node, forNode(node->child1())); 371 371 if (forNode(node).value()) 372 m_state.set FoundConstants(true);372 m_state.setShouldTryConstantFolding(true); 373 373 break; 374 374 } … … 386 386 DFG_ASSERT(m_graph, node, value.isType(typeFilterFor(variableAccessData->flushFormat()))); 387 387 if (value.value()) 388 m_state.set FoundConstants(true);388 m_state.setShouldTryConstantFolding(true); 389 389 setForNode(node, value); 390 390 break; … … 397 397 DFG_ASSERT(m_graph, node, value.isType(typeFilterFor(data->format))); 398 398 if (value.value()) 399 m_state.set FoundConstants(true);399 m_state.setShouldTryConstantFolding(true); 400 400 setForNode(node, value); 401 401 break; … … 598 598 value = forNode(node->child1()); 599 599 if (node->child1().useKind() == UntypedUse && !(value.m_type & ~SpecBoolean)) 600 m_state.set FoundConstants(true);600 m_state.setShouldTryConstantFolding(true); 601 601 if (value.m_type & SpecBoolean) { 602 602 value.merge(SpecBoolInt32); … … 820 820 821 821 if (numberOfRemovedChildren) 822 m_state.set FoundConstants(true);822 m_state.setShouldTryConstantFolding(true); 823 823 setForNode(node, m_vm.stringStructure.get()); 824 824 break; … … 1272 1272 SpeculatedType typeMaybeNormalized = (SpecFullNumber & ~SpecInt32Only); 1273 1273 if (!(forNode(node->child1()).m_type & typeMaybeNormalized)) { 1274 m_state.set FoundConstants(true);1274 m_state.setShouldTryConstantFolding(true); 1275 1275 forNode(node) = forNode(node->child1()); 1276 1276 break; … … 1904 1904 1905 1905 if (isNonStringCellConstant(left) || isNonStringCellConstant(right)) { 1906 m_state.set FoundConstants(true);1906 m_state.setShouldTryConstantFolding(true); 1907 1907 setNonCellTypeForNode(node, SpecBoolean); 1908 1908 break; … … 2335 2335 setForNode(node, m_state.operand( 2336 2336 virtualRegisterForArgument(argumentIndex + 1) + inlineCallFrame->stackOffset)); 2337 m_state.set FoundConstants(true);2337 m_state.setShouldTryConstantFolding(true); 2338 2338 break; 2339 2339 } … … 2341 2341 if (argumentIndex < m_state.numberOfArguments() - 1) { 2342 2342 setForNode(node, m_state.argument(argumentIndex + 1)); 2343 m_state.set FoundConstants(true);2343 m_state.setShouldTryConstantFolding(true); 2344 2344 break; 2345 2345 } … … 2362 2362 2363 2363 if (result.value()) 2364 m_state.set FoundConstants(true);2364 m_state.setShouldTryConstantFolding(true); 2365 2365 2366 2366 setForNode(node, result); … … 2480 2480 2481 2481 if (!(forNode(node->child1()).m_type & ~(SpecFullNumber | SpecBoolean | SpecString | SpecSymbol | SpecBigInt))) { 2482 m_state.set FoundConstants(true);2482 m_state.setShouldTryConstantFolding(true); 2483 2483 didFoldClobberWorld(); 2484 2484 setForNode(node, forNode(node->child1())); … … 2503 2503 2504 2504 if (!(forNode(node->child1()).m_type & ~SpecBytecodeNumber)) { 2505 m_state.set FoundConstants(true);2505 m_state.setShouldTryConstantFolding(true); 2506 2506 didFoldClobberWorld(); 2507 2507 setForNode(node, forNode(node->child1())); … … 2541 2541 int32_t radix = radixValue.asInt32(); 2542 2542 if (2 <= radix && radix <= 36) { 2543 m_state.set FoundConstants(true);2543 m_state.setShouldTryConstantFolding(true); 2544 2544 didFoldClobberWorld(); 2545 2545 setForNode(node, m_graph.m_vm.stringStructure.get()); … … 2642 2642 switch (result) { 2643 2643 case ToThisResult::Identity: 2644 m_state.set FoundConstants(true);2644 m_state.setShouldTryConstantFolding(true); 2645 2645 destination = source; 2646 2646 break; … … 2649 2649 break; 2650 2650 case ToThisResult::GlobalThis: 2651 m_state.set FoundConstants(true);2651 m_state.setShouldTryConstantFolding(true); 2652 2652 destination.setType(m_graph, SpecObject); 2653 2653 break; … … 2672 2672 m_graph.freeze(rareData); 2673 2673 m_graph.watchpoints().addLazily(rareData->allocationProfileWatchpointSet()); 2674 m_state.set FoundConstants(true);2674 m_state.setShouldTryConstantFolding(true); 2675 2675 didFoldClobberWorld(); 2676 2676 setForNode(node, structure); … … 2690 2690 if (JSValue base = forNode(node->child1()).m_value) { 2691 2691 if (base == (node->isInternalPromise() ? globalObject->internalPromiseConstructor() : globalObject->promiseConstructor())) { 2692 m_state.set FoundConstants(true);2692 m_state.setShouldTryConstantFolding(true); 2693 2693 didFoldClobberWorld(); 2694 2694 setForNode(node, node->isInternalPromise() ? globalObject->internalPromiseStructure() : globalObject->promiseStructure()); … … 2705 2705 m_graph.freeze(rareData); 2706 2706 m_graph.watchpoints().addLazily(rareData->allocationProfileWatchpointSet()); 2707 m_state.set FoundConstants(true);2707 m_state.setShouldTryConstantFolding(true); 2708 2708 didFoldClobberWorld(); 2709 2709 setForNode(node, structure); … … 2734 2734 m_graph.freeze(rareData); 2735 2735 m_graph.watchpoints().addLazily(rareData->allocationProfileWatchpointSet()); 2736 m_state.set FoundConstants(true);2736 m_state.setShouldTryConstantFolding(true); 2737 2737 didFoldClobberWorld(); 2738 2738 setForNode(node, structure); … … 2791 2791 2792 2792 if (structure) { 2793 m_state.set FoundConstants(true);2793 m_state.setShouldTryConstantFolding(true); 2794 2794 if (node->child1().useKind() == UntypedUse) 2795 2795 didFoldClobberWorld(); … … 2812 2812 if (!!rareData->cachedOwnKeysConcurrently()) { 2813 2813 if (m_graph.isWatchingHavingABadTimeWatchpoint(node)) { 2814 m_state.set FoundConstants(true);2814 m_state.setShouldTryConstantFolding(true); 2815 2815 didFoldClobberWorld(); 2816 2816 setTypeForNode(node, SpecArray); … … 2833 2833 2834 2834 if (!(source.m_type & ~SpecObject)) { 2835 m_state.set FoundConstants(true);2835 m_state.setShouldTryConstantFolding(true); 2836 2836 if (node->op() == ToObject) 2837 2837 didFoldClobberWorld(); … … 3092 3092 } 3093 3093 3094 m_state.set FoundConstants(true);3094 m_state.setShouldTryConstantFolding(true); 3095 3095 didFoldClobberWorld(); 3096 3096 forNode(node) = result; … … 3145 3145 3146 3146 if (value.m_structure.isSubsetOf(set)) 3147 m_state.set FoundConstants(true);3147 m_state.setShouldTryConstantFolding(true); 3148 3148 3149 3149 SpeculatedType admittedTypes = SpecNone; … … 3170 3170 bool mayBeEmpty = value.m_type & SpecEmpty; 3171 3171 if (!mayBeEmpty) 3172 m_state.set FoundConstants(true);3172 m_state.setShouldTryConstantFolding(true); 3173 3173 3174 3174 SpeculatedType admittedTypes = mayBeEmpty ? SpecEmpty : SpecNone; … … 3187 3187 if (Structure* structure = jsDynamicCast<Structure*>(m_vm, value.value())) { 3188 3188 if (set.contains(m_graph.registerStructure(structure))) { 3189 m_state.set FoundConstants(true);3189 m_state.setShouldTryConstantFolding(true); 3190 3190 break; 3191 3191 } … … 3207 3207 }); 3208 3208 if (allGood) { 3209 m_state.set FoundConstants(true);3209 m_state.setShouldTryConstantFolding(true); 3210 3210 break; 3211 3211 } … … 3225 3225 if (forNode(node->child1()).m_structure.onlyStructure() == node->transition()->next) { 3226 3226 didFoldClobberStructures(); 3227 m_state.set FoundConstants(true);3227 m_state.setShouldTryConstantFolding(true); 3228 3228 } else { 3229 3229 observeTransition( … … 3250 3250 if (constant) { 3251 3251 if (constant.isCell() && constant.asCell()->inherits(m_vm, node->classInfo())) { 3252 m_state.set FoundConstants(true);3252 m_state.setShouldTryConstantFolding(true); 3253 3253 ASSERT(constant); 3254 3254 break; … … 3259 3259 3260 3260 if (value.m_structure.isSubClassOf(node->classInfo())) 3261 m_state.set FoundConstants(true);3261 m_state.setShouldTryConstantFolding(true); 3262 3262 3263 3263 filterClassInfo(value, node->classInfo()); … … 3284 3284 case CheckArray: { 3285 3285 if (node->arrayMode().alreadyChecked(m_graph, node, forNode(node->child1()))) { 3286 m_state.set FoundConstants(true);3286 m_state.setShouldTryConstantFolding(true); 3287 3287 break; 3288 3288 } … … 3344 3344 if (node->arrayMode().alreadyChecked(m_graph, node, forNode(node->child1()))) { 3345 3345 didFoldClobberStructures(); 3346 m_state.set FoundConstants(true);3346 m_state.setShouldTryConstantFolding(true); 3347 3347 break; 3348 3348 } … … 3355 3355 AbstractValue& value = forNode(node->child1()); 3356 3356 if (value.m_structure.isSubsetOf(RegisteredStructureSet(node->structure()))) 3357 m_state.set FoundConstants(true);3357 m_state.setShouldTryConstantFolding(true); 3358 3358 clobberStructures(); 3359 3359 … … 3392 3392 forNode(node->child1()).m_value, node->arrayMode()); 3393 3393 if (view) 3394 m_state.set FoundConstants(true);3394 m_state.setShouldTryConstantFolding(true); 3395 3395 clearForNode(node); 3396 3396 break; … … 3483 3483 setForNode(node, value); 3484 3484 if (value.m_value) 3485 m_state.set FoundConstants(true);3485 m_state.setShouldTryConstantFolding(true); 3486 3486 break; 3487 3487 } … … 3510 3510 // realize it. This is the case here. 3511 3511 3512 // Ordinarily you have to be careful with calling set FoundConstants()3512 // Ordinarily you have to be careful with calling setShouldTryConstantFolding() 3513 3513 // because of the effect on compile times, but this node is FTL-only. 3514 m_state.set FoundConstants(true);3514 m_state.setShouldTryConstantFolding(true); 3515 3515 3516 3516 AbstractValue base = forNode(node->child1()); … … 3556 3556 TransitionVector transitions; 3557 3557 3558 // Ordinarily you have to be careful with calling set FoundConstants()3558 // Ordinarily you have to be careful with calling setShouldTryConstantFolding() 3559 3559 // because of the effect on compile times, but this node is FTL-only. 3560 m_state.set FoundConstants(true);3560 m_state.setShouldTryConstantFolding(true); 3561 3561 3562 3562 AbstractValue base = forNode(node->child1()); … … 3620 3620 JSValue value = forNode(node->child1()).value(); 3621 3621 if (value == node->cellOperand()->value()) { 3622 m_state.set FoundConstants(true);3622 m_state.setShouldTryConstantFolding(true); 3623 3623 ASSERT(value); 3624 3624 break; … … 3632 3632 AbstractValue& value = forNode(node->child1()); 3633 3633 if (!(value.m_type & SpecEmpty)) { 3634 m_state.set FoundConstants(true);3634 m_state.setShouldTryConstantFolding(true); 3635 3635 break; 3636 3636 } … … 3649 3649 ASSERT(childConstant.isString()); 3650 3650 if (asString(childConstant)->tryGetValueImpl() == uid) { 3651 m_state.set FoundConstants(true);3651 m_state.setShouldTryConstantFolding(true); 3652 3652 break; 3653 3653 } … … 3662 3662 JSValue right = forNode(node->child2()).value(); 3663 3663 if (left && right && left.isInt32() && right.isInt32() && static_cast<uint32_t>(left.asInt32()) < static_cast<uint32_t>(right.asInt32())) 3664 m_state.set FoundConstants(true);3664 m_state.setShouldTryConstantFolding(true); 3665 3665 3666 3666 // We claim we result in Int32. It's not really important what our result is (though we … … 3704 3704 3705 3705 if (status.numVariants() == 1 || m_graph.m_plan.isFTL()) 3706 m_state.set FoundConstants(true);3706 m_state.setShouldTryConstantFolding(true); 3707 3707 3708 3708 didFoldClobberWorld(); … … 3753 3753 const StringImpl* impl = string->tryGetValueImpl(); 3754 3754 if (impl && impl->isAtom()) 3755 m_state.set FoundConstants(true);3755 m_state.setShouldTryConstantFolding(true); 3756 3756 } 3757 3757 } … … 3878 3878 RegisteredStructure structure = variant.structure; 3879 3879 if (!base.contains(structure)) { 3880 m_state.set FoundConstants(true);3880 m_state.setShouldTryConstantFolding(true); 3881 3881 continue; 3882 3882 } … … 3910 3910 // constant, in which case we'd like to know. 3911 3911 if (forNode(node).m_value) 3912 m_state.set FoundConstants(true);3912 m_state.setShouldTryConstantFolding(true); 3913 3913 break; 3914 3914 … … 3988 3988 if (bits == ImplementsDefaultHasInstance) { 3989 3989 if (abstractValue.m_type == SpecFunctionWithDefaultHasInstance) { 3990 m_state.set FoundConstants(true);3990 m_state.setShouldTryConstantFolding(true); 3991 3991 break; 3992 3992 } … … 3999 3999 // object's lifetime. 4000 4000 if ((value.asCell()->inlineTypeFlags() & bits) == bits) { 4001 m_state.set FoundConstants(true);4001 m_state.setShouldTryConstantFolding(true); 4002 4002 break; 4003 4003 } … … 4011 4011 }); 4012 4012 if (ok) { 4013 m_state.set FoundConstants(true);4013 m_state.setShouldTryConstantFolding(true); 4014 4014 break; 4015 4015 } … … 4030 4030 if (radix.isNumber() 4031 4031 && (radix.asNumber() == 0 || radix.asNumber() == 10)) { 4032 m_state.set FoundConstants(true);4032 m_state.setShouldTryConstantFolding(true); 4033 4033 if (node->child1().useKind() == UntypedUse) 4034 4034 didFoldClobberWorld(); … … 4062 4062 return; 4063 4063 if (edge.isProved() || edge.willNotHaveCheck()) 4064 m_state.set FoundConstants(true);4064 m_state.setShouldTryConstantFolding(true); 4065 4065 }); 4066 4066 break; -
trunk/Source/JavaScriptCore/dfg/DFGAtTailAbstractState.h
r231607 r252502 166 166 void setIsValid(bool isValid) { m_block->cfaDidFinish = isValid; } 167 167 void setBranchDirection(BranchDirection) { } 168 void set FoundConstants(bool) { }168 void setShouldTryConstantFolding(bool) { } 169 169 170 170 void trustEdgeProofs() { m_trustEdgeProofs = true; } -
trunk/Source/JavaScriptCore/dfg/DFGBasicBlock.cpp
r251468 r252502 41 41 , cfaHasVisited(false) 42 42 , cfaShouldRevisit(false) 43 , cfaFoundConstants(false)44 43 , cfaDidFinish(true) 45 44 , intersectionOfCFAHasVisited(true) -
trunk/Source/JavaScriptCore/dfg/DFGBasicBlock.h
r251468 r252502 188 188 bool cfaHasVisited; 189 189 bool cfaShouldRevisit; 190 bool cfa FoundConstants;190 bool cfaThinksShouldTryConstantFolding { false }; 191 191 bool cfaDidFinish; 192 192 bool intersectionOfCFAHasVisited; -
trunk/Source/JavaScriptCore/dfg/DFGConstantFoldingPhase.cpp
r250630 r252502 59 59 60 60 for (BasicBlock* block : m_graph.blocksInNaturalOrder()) { 61 if (block->cfa FoundConstants)61 if (block->cfaThinksShouldTryConstantFolding) 62 62 changed |= foldConstants(block); 63 63 } -
trunk/Source/JavaScriptCore/dfg/DFGInPlaceAbstractState.cpp
r250005 r252502 85 85 basicBlock->cfaHasVisited = true; 86 86 m_isValid = true; 87 m_ foundConstants= false;87 m_shouldTryConstantFolding = false; 88 88 m_branchDirection = InvalidBranchDirection; 89 89 m_structureClobberState = basicBlock->cfaStructureClobberStateAtHead; … … 115 115 entrypoint->cfaShouldRevisit = true; 116 116 entrypoint->cfaHasVisited = false; 117 entrypoint->cfa FoundConstants= false;117 entrypoint->cfaThinksShouldTryConstantFolding = false; 118 118 entrypoint->cfaStructureClobberStateAtHead = StructuresAreWatched; 119 119 entrypoint->cfaStructureClobberStateAtTail = StructuresAreWatched; … … 173 173 block->cfaShouldRevisit = false; 174 174 block->cfaHasVisited = false; 175 block->cfa FoundConstants= false;175 block->cfaThinksShouldTryConstantFolding = false; 176 176 block->cfaStructureClobberStateAtHead = StructuresAreWatched; 177 177 block->cfaStructureClobberStateAtTail = StructuresAreWatched; … … 203 203 BasicBlock* block = m_block; // Save the block for successor merging. 204 204 205 block->cfa FoundConstants = m_foundConstants;205 block->cfaThinksShouldTryConstantFolding = m_shouldTryConstantFolding; 206 206 block->cfaDidFinish = m_isValid; 207 207 block->cfaBranchDirection = m_branchDirection; -
trunk/Source/JavaScriptCore/dfg/DFGInPlaceAbstractState.h
r231660 r252502 258 258 // https://bugs.webkit.org/show_bug.cgi?id=133947 259 259 // So, we should probably keep this method. 260 void set FoundConstants(bool foundConstants) { m_foundConstants = foundConstants; }260 void setShouldTryConstantFolding(bool tryConstantFolding) { m_shouldTryConstantFolding = tryConstantFolding; } 261 261 262 262 void setProofStatus(Edge& edge, ProofStatus status) … … 283 283 FastBitVector m_activeVariables; 284 284 BasicBlock* m_block; 285 286 bool m_ foundConstants;287 285 286 bool m_shouldTryConstantFolding; 287 288 288 bool m_isValid; 289 289 AbstractInterpreterClobberState m_clobberState;
Note: See TracChangeset
for help on using the changeset viewer.