Changeset 244238 in webkit
- Timestamp:
- Apr 12, 2019 8:04:18 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r244211 r244238 1 2019-04-12 Saam barati <sbarati@apple.com> 2 3 r244079 logically broke shouldSpeculateInt52 4 https://bugs.webkit.org/show_bug.cgi?id=196884 5 6 Reviewed by Yusuke Suzuki. 7 8 * microbenchmarks/int52-rand-function.js: Added. 9 (Math.random): 10 1 11 2019-04-11 Yusuke Suzuki <ysuzuki@apple.com> 2 12 -
trunk/Source/JavaScriptCore/ChangeLog
r244237 r244238 1 2019-04-12 Saam barati <sbarati@apple.com> 2 3 r244079 logically broke shouldSpeculateInt52 4 https://bugs.webkit.org/show_bug.cgi?id=196884 5 6 Reviewed by Yusuke Suzuki. 7 8 In r244079, I changed shouldSpeculateInt52 to only return true 9 when the prediction is isAnyInt52Speculation(). However, it was 10 wrong to not to include SpecInt32 in this for two reasons: 11 12 1. We diligently write code that first checks if we should speculate Int32. 13 For example: 14 if (shouldSpeculateInt32()) ... 15 else if (shouldSpeculateInt52()) ... 16 17 It would be wrong not to fall back to Int52 if we're dealing with the union of 18 Int32 and Int52. 19 20 It would be a performance mistake to not include Int32 here because 21 data flow can easily tell us that we have variables that are the union 22 of Int32 and Int52 values. It's better to speculate Int52 than Double 23 in that situation. 24 25 2. We also write code where we ask if the inputs can be Int52, e.g, if 26 we know via profiling that an Add overflows, we may not emit an Int32 add. 27 However, we only emit such an add if both inputs can be Int52, and Int32 28 can trivially become Int52. 29 30 This patch recovers the 0.5-1% regression r244079 caused on JetStream 2. 31 32 * bytecode/SpeculatedType.h: 33 (JSC::isInt32SpeculationForArithmetic): 34 (JSC::isInt32OrBooleanSpeculationForArithmetic): 35 (JSC::isInt32OrInt52Speculation): 36 * dfg/DFGFixupPhase.cpp: 37 (JSC::DFG::FixupPhase::observeUseKindOnNode): 38 * dfg/DFGNode.h: 39 (JSC::DFG::Node::shouldSpeculateInt52): 40 * dfg/DFGPredictionPropagationPhase.cpp: 41 * dfg/DFGVariableAccessData.cpp: 42 (JSC::DFG::VariableAccessData::couldRepresentInt52Impl): 43 1 44 2019-04-12 Saam barati <sbarati@apple.com> 2 45 -
trunk/Source/JavaScriptCore/bytecode/SpeculatedType.h
r244079 r244238 343 343 inline bool isInt32SpeculationForArithmetic(SpeculatedType value) 344 344 { 345 return !(value & (SpecFullDouble | Spec Int52Any));345 return !(value & (SpecFullDouble | SpecNonInt32AsInt52)); 346 346 } 347 347 348 348 inline bool isInt32OrBooleanSpeculationForArithmetic(SpeculatedType value) 349 349 { 350 return !(value & (SpecFullDouble | Spec Int52Any));350 return !(value & (SpecFullDouble | SpecNonInt32AsInt52)); 351 351 } 352 352 … … 359 359 { 360 360 return !!value && (value & SpecInt52Any) == value; 361 } 362 363 inline bool isInt32OrInt52Speculation(SpeculatedType value) 364 { 365 return !!value && (value & (SpecInt32Only | SpecInt52Any)) == value; 361 366 } 362 367 -
trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
r244193 r244238 3225 3225 break; 3226 3226 case Int52RepUse: 3227 if ( isAnyInt52Speculation(variable->prediction()))3227 if (!isInt32Speculation(variable->prediction()) && isInt32OrInt52Speculation(variable->prediction())) 3228 3228 m_profitabilityChanged |= variable->mergeIsProfitableToUnbox(true); 3229 3229 break; -
trunk/Source/JavaScriptCore/dfg/DFGNode.h
r244193 r244238 2349 2349 bool shouldSpeculateInt52() 2350 2350 { 2351 return enableInt52() && isAnyInt52Speculation(prediction()); 2351 // We have to include SpecInt32Only here for two reasons: 2352 // 1. We diligently write code that first checks if we should speculate Int32. 2353 // For example: 2354 // if (shouldSpeculateInt32()) ... 2355 // else if (shouldSpeculateInt52()) ... 2356 // This means we it's totally valid to speculate Int52 when we're dealing 2357 // with a type that's the union of Int32 and Int52. 2358 // 2359 // It would be a performance mistake to not include Int32 here because we obviously 2360 // have variables that are the union of Int32 and Int52 values, and it's better 2361 // to speculate Int52 than double in that situation. 2362 // 2363 // 2. We also write code where we ask if the inputs can be Int52, like if 2364 // we know via profiling that an Add overflows, we may not emit an Int32 add. 2365 // However, we only emit such an add if both inputs can be Int52, and Int32 2366 // can trivially become Int52. 2367 // 2368 return enableInt52() && isInt32OrInt52Speculation(prediction()); 2352 2369 } 2353 2370 -
trunk/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp
r244193 r244238 643 643 if (isDoubleSpeculation(prediction)) 644 644 node->variableAccessData()->vote(VoteDouble, weight); 645 else if (!isFullNumberSpeculation(prediction) 646 || isInt32Speculation(prediction) || isAnyInt52Speculation(prediction)) 645 else if (!isFullNumberSpeculation(prediction) || isInt32OrInt52Speculation(prediction)) 647 646 node->variableAccessData()->vote(VoteValue, weight); 648 647 break; … … 735 734 switch (m_currentNode->op()) { 736 735 case JSConstant: { 737 setPrediction(speculationFromValue(m_currentNode->asJSValue())); 736 SpeculatedType type = speculationFromValue(m_currentNode->asJSValue()); 737 if (type == SpecAnyIntAsDouble && enableInt52()) 738 type = int52AwareSpeculationFromValue(m_currentNode->asJSValue()); 739 setPrediction(type); 738 740 break; 739 741 } -
trunk/Source/JavaScriptCore/dfg/DFGVariableAccessData.cpp
r244079 r244238 182 182 // The argument-aware prediction -- which merges all of an (inlined or machine) 183 183 // argument's variable access datas' predictions -- must possibly be Int52Any. 184 return is AnyInt52Speculation(argumentAwarePrediction());184 return isInt32OrInt52Speculation(argumentAwarePrediction()); 185 185 } 186 186
Note: See TracChangeset
for help on using the changeset viewer.