| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/builtins/builtins-utils.h" | 5 #include "src/builtins/builtins-utils.h" |
| 6 #include "src/builtins/builtins.h" | 6 #include "src/builtins/builtins.h" |
| 7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 #include "src/code-stub-assembler.h" | 8 #include "src/code-stub-assembler.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1221 Bind(÷nd_is_smi); | 1221 Bind(÷nd_is_smi); |
| 1222 { | 1222 { |
| 1223 Label divisor_is_smi(this), divisor_is_not_smi(this); | 1223 Label divisor_is_smi(this), divisor_is_not_smi(this); |
| 1224 Branch(TaggedIsSmi(divisor), &divisor_is_smi, &divisor_is_not_smi); | 1224 Branch(TaggedIsSmi(divisor), &divisor_is_smi, &divisor_is_not_smi); |
| 1225 | 1225 |
| 1226 Bind(&divisor_is_smi); | 1226 Bind(&divisor_is_smi); |
| 1227 { | 1227 { |
| 1228 Label bailout(this); | 1228 Label bailout(this); |
| 1229 | 1229 |
| 1230 // Do floating point division if {divisor} is zero. | 1230 // Do floating point division if {divisor} is zero. |
| 1231 GotoIf(WordEqual(divisor, IntPtrConstant(0)), &bailout); | 1231 GotoIf(SmiEqual(divisor, SmiConstant(0)), &bailout); |
| 1232 | 1232 |
| 1233 // Do floating point division {dividend} is zero and {divisor} is | 1233 // Do floating point division {dividend} is zero and {divisor} is |
| 1234 // negative. | 1234 // negative. |
| 1235 Label dividend_is_zero(this), dividend_is_not_zero(this); | 1235 Label dividend_is_zero(this), dividend_is_not_zero(this); |
| 1236 Branch(WordEqual(dividend, IntPtrConstant(0)), ÷nd_is_zero, | 1236 Branch(SmiEqual(dividend, SmiConstant(0)), ÷nd_is_zero, |
| 1237 ÷nd_is_not_zero); | 1237 ÷nd_is_not_zero); |
| 1238 | 1238 |
| 1239 Bind(÷nd_is_zero); | 1239 Bind(÷nd_is_zero); |
| 1240 { | 1240 { |
| 1241 GotoIf(IntPtrLessThan(divisor, IntPtrConstant(0)), &bailout); | 1241 GotoIf(SmiLessThan(divisor, SmiConstant(0)), &bailout); |
| 1242 Goto(÷nd_is_not_zero); | 1242 Goto(÷nd_is_not_zero); |
| 1243 } | 1243 } |
| 1244 Bind(÷nd_is_not_zero); | 1244 Bind(÷nd_is_not_zero); |
| 1245 | 1245 |
| 1246 Node* untagged_divisor = SmiUntag(divisor); | 1246 Node* untagged_divisor = SmiToWord32(divisor); |
| 1247 Node* untagged_dividend = SmiUntag(dividend); | 1247 Node* untagged_dividend = SmiToWord32(dividend); |
| 1248 | 1248 |
| 1249 // Do floating point division if {dividend} is kMinInt (or kMinInt - 1 | 1249 // Do floating point division if {dividend} is kMinInt (or kMinInt - 1 |
| 1250 // if the Smi size is 31) and {divisor} is -1. | 1250 // if the Smi size is 31) and {divisor} is -1. |
| 1251 Label divisor_is_minus_one(this), divisor_is_not_minus_one(this); | 1251 Label divisor_is_minus_one(this), divisor_is_not_minus_one(this); |
| 1252 Branch(Word32Equal(untagged_divisor, Int32Constant(-1)), | 1252 Branch(Word32Equal(untagged_divisor, Int32Constant(-1)), |
| 1253 &divisor_is_minus_one, &divisor_is_not_minus_one); | 1253 &divisor_is_minus_one, &divisor_is_not_minus_one); |
| 1254 | 1254 |
| 1255 Bind(&divisor_is_minus_one); | 1255 Bind(&divisor_is_minus_one); |
| 1256 { | 1256 { |
| 1257 GotoIf( | 1257 GotoIf( |
| 1258 Word32Equal(untagged_dividend, | 1258 Word32Equal(untagged_dividend, |
| 1259 Int32Constant(kSmiValueSize == 32 ? kMinInt | 1259 Int32Constant(kSmiValueSize == 32 ? kMinInt |
| 1260 : (kMinInt >> 1))), | 1260 : (kMinInt >> 1))), |
| 1261 &bailout); | 1261 &bailout); |
| 1262 Goto(&divisor_is_not_minus_one); | 1262 Goto(&divisor_is_not_minus_one); |
| 1263 } | 1263 } |
| 1264 Bind(&divisor_is_not_minus_one); | 1264 Bind(&divisor_is_not_minus_one); |
| 1265 | 1265 |
| 1266 // TODO(epertoso): consider adding a machine instruction that returns | 1266 // TODO(epertoso): consider adding a machine instruction that returns |
| 1267 // both the result and the remainder. | 1267 // both the result and the remainder. |
| 1268 Node* untagged_result = Int32Div(untagged_dividend, untagged_divisor); | 1268 Node* untagged_result = Int32Div(untagged_dividend, untagged_divisor); |
| 1269 Node* truncated = Int32Mul(untagged_result, untagged_divisor); | 1269 Node* truncated = Int32Mul(untagged_result, untagged_divisor); |
| 1270 // Do floating point division if the remainder is not 0. | 1270 // Do floating point division if the remainder is not 0. |
| 1271 GotoIf(Word32NotEqual(untagged_dividend, truncated), &bailout); | 1271 GotoIf(Word32NotEqual(untagged_dividend, truncated), &bailout); |
| 1272 var_result.Bind(SmiTag(untagged_result)); | 1272 var_result.Bind(SmiFromWord32(untagged_result)); |
| 1273 Goto(&end); | 1273 Goto(&end); |
| 1274 | 1274 |
| 1275 // Bailout: convert {dividend} and {divisor} to double and do double | 1275 // Bailout: convert {dividend} and {divisor} to double and do double |
| 1276 // division. | 1276 // division. |
| 1277 Bind(&bailout); | 1277 Bind(&bailout); |
| 1278 { | 1278 { |
| 1279 var_dividend_float64.Bind(SmiToFloat64(dividend)); | 1279 var_dividend_float64.Bind(SmiToFloat64(dividend)); |
| 1280 var_divisor_float64.Bind(SmiToFloat64(divisor)); | 1280 var_divisor_float64.Bind(SmiToFloat64(divisor)); |
| 1281 Goto(&do_fdiv); | 1281 Goto(&do_fdiv); |
| 1282 } | 1282 } |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1606 TF_BUILTIN(StrictNotEqual, CodeStubAssembler) { | 1606 TF_BUILTIN(StrictNotEqual, CodeStubAssembler) { |
| 1607 Node* lhs = Parameter(0); | 1607 Node* lhs = Parameter(0); |
| 1608 Node* rhs = Parameter(1); | 1608 Node* rhs = Parameter(1); |
| 1609 Node* context = Parameter(2); | 1609 Node* context = Parameter(2); |
| 1610 | 1610 |
| 1611 Return(StrictEqual(kNegateResult, lhs, rhs, context)); | 1611 Return(StrictEqual(kNegateResult, lhs, rhs, context)); |
| 1612 } | 1612 } |
| 1613 | 1613 |
| 1614 } // namespace internal | 1614 } // namespace internal |
| 1615 } // namespace v8 | 1615 } // namespace v8 |
| OLD | NEW |