|
| 1 | +2019-04-09 Saam barati <sbarati@apple.com> |
| 2 | + |
| 3 | + Clean up Int52 code and some bugs in it |
| 4 | + https://bugs.webkit.org/show_bug.cgi?id=196639 |
| 5 | + <rdar://problem/49515757> |
| 6 | + |
| 7 | + Reviewed by Yusuke Suzuki. |
| 8 | + |
| 9 | + This patch fixes bugs in our Int52 code. The primary change in this patch is |
| 10 | + adopting a segregated type lattice for Int52. Previously, for Int52 values, |
| 11 | + we represented them with SpecInt32Only and SpecInt52Only. For an Int52, |
| 12 | + SpecInt32Only meant that the value is in int32 range. And SpecInt52Only meant |
| 13 | + that the is outside of the int32 range. |
| 14 | + |
| 15 | + However, this got confusing because we reused SpecInt32Only both for JSValue |
| 16 | + representations and Int52 representations. This actually lead to some bugs. |
| 17 | + |
| 18 | + 1. It's possible that roundtripping through Int52 representation would say |
| 19 | + it produces the wrong type. For example, consider this program and how we |
| 20 | + used to annotate types in AI: |
| 21 | + a: JSConstant(10.0) => m_type is SpecAnyIntAsDouble |
| 22 | + b: Int52Rep(@a) => m_type is SpecInt52Only |
| 23 | + c: ValueRep(@b) => m_type is SpecAnyIntAsDouble |
| 24 | + |
| 25 | + In AI, for the above program, we'd say that @c produces SpecAnyIntAsDouble. |
| 26 | + However, the execution semantics are such that it'd actually produce a boxed |
| 27 | + Int32. This patch fixes the bug where we'd say that Int52Rep over SpecAnyIntAsDouble |
| 28 | + would produce SpecInt52Only. This is clearly wrong, as SpecAnyIntAsDouble can |
| 29 | + mean an int value in either int32 or int52 range. |
| 30 | + |
| 31 | + 2. AsbstractValue::validateTypeAcceptingBoxedInt52 was wrong in how it |
| 32 | + accepted Int52 values. It was wrong in two different ways: |
| 33 | + a: If the AbstractValue's type was SpecInt52Only, and the incoming value |
| 34 | + was a boxed double, but represented a value in int32 range, the incoming |
| 35 | + value would incorrectly validate as being acceptable. However, we should |
| 36 | + have rejected this value. |
| 37 | + b: If the AbstractValue's type was SpecInt32Only, and the incoming value |
| 38 | + was an Int32 boxed in a double, this would not validate, even though |
| 39 | + it should have validated. |
| 40 | + |
| 41 | + Solving 2 was easiest if we segregated out the Int52 type into its own |
| 42 | + lattice. This patch makes a new Int52 lattice, which is composed of |
| 43 | + SpecInt32AsInt52 and SpecNonInt32AsInt52. |
| 44 | + |
| 45 | + The conversion rules are now really simple. |
| 46 | + |
| 47 | + Int52 rep => JSValue rep |
| 48 | + SpecInt32AsInt52 => SpecInt32Only |
| 49 | + SpecNonInt32AsInt52 => SpecAnyIntAsDouble |
| 50 | + |
| 51 | + JSValue rep => Int52 rep |
| 52 | + SpecInt32Only => SpecInt32AsInt52 |
| 53 | + SpecAnyIntAsDouble => SpecInt52Any |
| 54 | + |
| 55 | + With these rules, the program in (1) will now correctly report that @c |
| 56 | + returns SpecInt32Only | SpecAnyIntAsDouble. |
| 57 | + |
| 58 | + * bytecode/SpeculatedType.cpp: |
| 59 | + (JSC::dumpSpeculation): |
| 60 | + (JSC::speculationToAbbreviatedString): |
| 61 | + (JSC::int52AwareSpeculationFromValue): |
| 62 | + (JSC::leastUpperBoundOfStrictlyEquivalentSpeculations): |
| 63 | + (JSC::speculationFromString): |
| 64 | + * bytecode/SpeculatedType.h: |
| 65 | + (JSC::isInt32SpeculationForArithmetic): |
| 66 | + (JSC::isInt32OrBooleanSpeculationForArithmetic): |
| 67 | + (JSC::isAnyInt52Speculation): |
| 68 | + (JSC::isIntAnyFormat): |
| 69 | + (JSC::isInt52Speculation): Deleted. |
| 70 | + (JSC::isAnyIntSpeculation): Deleted. |
| 71 | + * dfg/DFGAbstractInterpreterInlines.h: |
| 72 | + (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): |
| 73 | + * dfg/DFGAbstractValue.cpp: |
| 74 | + (JSC::DFG::AbstractValue::fixTypeForRepresentation): |
| 75 | + (JSC::DFG::AbstractValue::checkConsistency const): |
| 76 | + * dfg/DFGAbstractValue.h: |
| 77 | + (JSC::DFG::AbstractValue::isInt52Any const): |
| 78 | + (JSC::DFG::AbstractValue::validateTypeAcceptingBoxedInt52 const): |
| 79 | + * dfg/DFGFixupPhase.cpp: |
| 80 | + (JSC::DFG::FixupPhase::fixupArithMul): |
| 81 | + (JSC::DFG::FixupPhase::fixupNode): |
| 82 | + (JSC::DFG::FixupPhase::fixupGetPrototypeOf): |
| 83 | + (JSC::DFG::FixupPhase::fixupToThis): |
| 84 | + (JSC::DFG::FixupPhase::fixupToStringOrCallStringConstructor): |
| 85 | + (JSC::DFG::FixupPhase::observeUseKindOnNode): |
| 86 | + (JSC::DFG::FixupPhase::fixIntConvertingEdge): |
| 87 | + (JSC::DFG::FixupPhase::attemptToMakeIntegerAdd): |
| 88 | + (JSC::DFG::FixupPhase::fixupCompareStrictEqAndSameValue): |
| 89 | + (JSC::DFG::FixupPhase::fixupChecksInBlock): |
| 90 | + * dfg/DFGGraph.h: |
| 91 | + (JSC::DFG::Graph::addShouldSpeculateInt52): |
| 92 | + (JSC::DFG::Graph::binaryArithShouldSpeculateInt52): |
| 93 | + (JSC::DFG::Graph::unaryArithShouldSpeculateInt52): |
| 94 | + (JSC::DFG::Graph::addShouldSpeculateAnyInt): Deleted. |
| 95 | + (JSC::DFG::Graph::binaryArithShouldSpeculateAnyInt): Deleted. |
| 96 | + (JSC::DFG::Graph::unaryArithShouldSpeculateAnyInt): Deleted. |
| 97 | + * dfg/DFGNode.h: |
| 98 | + (JSC::DFG::Node::shouldSpeculateInt52): |
| 99 | + (JSC::DFG::Node::shouldSpeculateAnyInt): Deleted. |
| 100 | + * dfg/DFGPredictionPropagationPhase.cpp: |
| 101 | + * dfg/DFGSpeculativeJIT.cpp: |
| 102 | + (JSC::DFG::SpeculativeJIT::setIntTypedArrayLoadResult): |
| 103 | + (JSC::DFG::SpeculativeJIT::compileArithAdd): |
| 104 | + (JSC::DFG::SpeculativeJIT::compileArithSub): |
| 105 | + (JSC::DFG::SpeculativeJIT::compileArithNegate): |
| 106 | + * dfg/DFGSpeculativeJIT64.cpp: |
| 107 | + (JSC::DFG::SpeculativeJIT::fillSpeculateInt32Internal): |
| 108 | + (JSC::DFG::SpeculativeJIT::fillSpeculateInt52): |
| 109 | + * dfg/DFGUseKind.h: |
| 110 | + (JSC::DFG::typeFilterFor): |
| 111 | + * dfg/DFGVariableAccessData.cpp: |
| 112 | + (JSC::DFG::VariableAccessData::makePredictionForDoubleFormat): |
| 113 | + (JSC::DFG::VariableAccessData::couldRepresentInt52Impl): |
| 114 | + * ftl/FTLLowerDFGToB3.cpp: |
| 115 | + (JSC::FTL::DFG::LowerDFGToB3::compileArithAddOrSub): |
| 116 | + (JSC::FTL::DFG::LowerDFGToB3::compileArithNegate): |
| 117 | + (JSC::FTL::DFG::LowerDFGToB3::setIntTypedArrayLoadResult): |
| 118 | + |
1 | 119 | 2019-04-09 Tadeu Zagallo <tzagallo@apple.com> |
2 | 120 |
|
3 | 121 | ASSERTION FAILED: !scope.exception() || !hasProperty in JSObject::get |
|
0 commit comments