@@ -16,90 +16,6 @@ namespace internal {
1616// -----------------------------------------------------------------------------
1717// ES6 section 20.2.2 Function Properties of the Math Object
1818
19- // ES6 #sec-math.abs
20- TF_BUILTIN (MathAbs, CodeStubAssembler) {
21- TNode<Context> context = CAST (Parameter (Descriptor::kContext ));
22-
23- // We might need to loop once for ToNumber conversion.
24- TVARIABLE (Object, var_x);
25- Label loop (this , &var_x);
26- var_x = CAST (Parameter (Descriptor::kX ));
27- Goto (&loop);
28- BIND (&loop);
29- {
30- // Load the current {x} value.
31- TNode<Object> x = var_x.value ();
32-
33- // Check if {x} is a Smi or a HeapObject.
34- Label if_xissmi (this ), if_xisnotsmi (this );
35- Branch (TaggedIsSmi (x), &if_xissmi, &if_xisnotsmi);
36-
37- BIND (&if_xissmi);
38- {
39- TNode<Smi> x_smi = CAST (x);
40- Label if_overflow (this , Label::kDeferred );
41-
42- // check if support abs function
43- if (IsIntPtrAbsWithOverflowSupported ()) {
44- TNode<PairT<IntPtrT, BoolT>> pair =
45- IntPtrAbsWithOverflow (BitcastTaggedToWordForTagAndSmiBits (x_smi));
46- TNode<BoolT> overflow = Projection<1 >(pair);
47- GotoIf (overflow, &if_overflow);
48-
49- // There is a Smi representation for negated {x}.
50- TNode<IntPtrT> result = Projection<0 >(pair);
51- Return (BitcastWordToTagged (result));
52-
53- } else {
54- // Check if {x} is already positive.
55- Label if_xispositive (this ), if_xisnotpositive (this );
56- BranchIfSmiLessThanOrEqual (SmiConstant (0 ), x_smi, &if_xispositive,
57- &if_xisnotpositive);
58-
59- BIND (&if_xispositive);
60- {
61- // Just return the input {x}.
62- Return (x_smi);
63- }
64-
65- BIND (&if_xisnotpositive);
66- {
67- // Try to negate the {x} value.
68- TNode<Smi> result = TrySmiSub (SmiConstant (0 ), x_smi, &if_overflow);
69- Return (result);
70- }
71- }
72-
73- BIND (&if_overflow);
74- { Return (NumberConstant (0.0 - Smi::kMinValue )); }
75- }
76-
77- BIND (&if_xisnotsmi);
78- {
79- // Check if {x} is a HeapNumber.
80- Label if_xisheapnumber (this ), if_xisnotheapnumber (this , Label::kDeferred );
81- TNode<HeapObject> x_heap_object = CAST (x);
82- Branch (IsHeapNumber (x_heap_object), &if_xisheapnumber,
83- &if_xisnotheapnumber);
84-
85- BIND (&if_xisheapnumber);
86- {
87- TNode<Float64T> x_value = LoadHeapNumberValue (x_heap_object);
88- TNode<Float64T> value = Float64Abs (x_value);
89- TNode<HeapNumber> result = AllocateHeapNumberWithValue (value);
90- Return (result);
91- }
92-
93- BIND (&if_xisnotheapnumber);
94- {
95- // Need to convert {x} to a Number first.
96- var_x = CallBuiltin (Builtins::kNonNumberToNumber , context, x);
97- Goto (&loop);
98- }
99- }
100- }
101- }
102-
10319void MathBuiltinsAssembler::MathRoundingOperation (
10420 TNode<Context> context, TNode<Object> x,
10521 TNode<Float64T> (CodeStubAssembler::*float64op)(SloppyTNode<Float64T>)) {
@@ -180,18 +96,6 @@ TF_BUILTIN(MathFloor, MathBuiltinsAssembler) {
18096 MathRoundingOperation (context, x, &CodeStubAssembler::Float64Floor);
18197}
18298
183- // ES6 #sec-math.imul
184- TF_BUILTIN (MathImul, CodeStubAssembler) {
185- TNode<Context> context = CAST (Parameter (Descriptor::kContext ));
186- TNode<Object> x = CAST (Parameter (Descriptor::kX ));
187- TNode<Object> y = CAST (Parameter (Descriptor::kY ));
188- TNode<Word32T> x_value = TruncateTaggedToWord32 (context, x);
189- TNode<Word32T> y_value = TruncateTaggedToWord32 (context, y);
190- TNode<Int32T> value = Signed (Int32Mul (x_value, y_value));
191- TNode<Number> result = ChangeInt32ToTagged (value);
192- Return (result);
193- }
194-
19599TNode<Number> MathBuiltinsAssembler::MathPow (TNode<Context> context,
196100 TNode<Object> base,
197101 TNode<Object> exponent) {
0 commit comments