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/code-stub-assembler.h" | 5 #include "src/code-stub-assembler.h" |
6 #include "src/code-factory.h" | 6 #include "src/code-factory.h" |
7 #include "src/frames-inl.h" | 7 #include "src/frames-inl.h" |
8 #include "src/frames.h" | 8 #include "src/frames.h" |
9 #include "src/ic/stub-cache.h" | 9 #include "src/ic/stub-cache.h" |
10 | 10 |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 Goto(&return_result); | 394 Goto(&return_result); |
395 | 395 |
396 Bind(&return_nan); | 396 Bind(&return_nan); |
397 var_result.Bind(NanConstant()); | 397 var_result.Bind(NanConstant()); |
398 Goto(&return_result); | 398 Goto(&return_result); |
399 | 399 |
400 Bind(&return_result); | 400 Bind(&return_result); |
401 return var_result.value(); | 401 return var_result.value(); |
402 } | 402 } |
403 | 403 |
| 404 Node* CodeStubAssembler::SmiMul(Node* a, Node* b) { |
| 405 Variable var_result(this, MachineRepresentation::kTagged); |
| 406 Variable var_lhs_float64(this, MachineRepresentation::kFloat64), |
| 407 var_rhs_float64(this, MachineRepresentation::kFloat64); |
| 408 Label return_result(this, &var_result); |
| 409 |
| 410 // Both {a} and {b} are Smis. Convert them to integers and multiply. |
| 411 Node* lhs32 = SmiToWord32(a); |
| 412 Node* rhs32 = SmiToWord32(b); |
| 413 Node* pair = Int32MulWithOverflow(lhs32, rhs32); |
| 414 |
| 415 Node* overflow = Projection(1, pair); |
| 416 |
| 417 // Check if the multiplication overflowed. |
| 418 Label if_overflow(this, Label::kDeferred), if_notoverflow(this); |
| 419 Branch(overflow, &if_overflow, &if_notoverflow); |
| 420 Bind(&if_notoverflow); |
| 421 { |
| 422 // If the answer is zero, we may need to return -0.0, depending on the |
| 423 // input. |
| 424 Label answer_zero(this), answer_not_zero(this); |
| 425 Node* answer = Projection(0, pair); |
| 426 Node* zero = Int32Constant(0); |
| 427 Branch(WordEqual(answer, zero), &answer_zero, &answer_not_zero); |
| 428 Bind(&answer_not_zero); |
| 429 { |
| 430 var_result.Bind(ChangeInt32ToTagged(answer)); |
| 431 Goto(&return_result); |
| 432 } |
| 433 Bind(&answer_zero); |
| 434 { |
| 435 Node* or_result = Word32Or(lhs32, rhs32); |
| 436 Label if_should_be_negative_zero(this), if_should_be_zero(this); |
| 437 Branch(Int32LessThan(or_result, zero), &if_should_be_negative_zero, |
| 438 &if_should_be_zero); |
| 439 Bind(&if_should_be_negative_zero); |
| 440 { |
| 441 var_result.Bind(MinusZeroConstant()); |
| 442 Goto(&return_result); |
| 443 } |
| 444 Bind(&if_should_be_zero); |
| 445 { |
| 446 var_result.Bind(zero); |
| 447 Goto(&return_result); |
| 448 } |
| 449 } |
| 450 } |
| 451 Bind(&if_overflow); |
| 452 { |
| 453 var_lhs_float64.Bind(SmiToFloat64(a)); |
| 454 var_rhs_float64.Bind(SmiToFloat64(b)); |
| 455 Node* value = Float64Mul(var_lhs_float64.value(), var_rhs_float64.value()); |
| 456 Node* result = ChangeFloat64ToTagged(value); |
| 457 var_result.Bind(result); |
| 458 Goto(&return_result); |
| 459 } |
| 460 |
| 461 Bind(&return_result); |
| 462 return var_result.value(); |
| 463 } |
| 464 |
404 Node* CodeStubAssembler::WordIsSmi(Node* a) { | 465 Node* CodeStubAssembler::WordIsSmi(Node* a) { |
405 return WordEqual(WordAnd(a, IntPtrConstant(kSmiTagMask)), IntPtrConstant(0)); | 466 return WordEqual(WordAnd(a, IntPtrConstant(kSmiTagMask)), IntPtrConstant(0)); |
406 } | 467 } |
407 | 468 |
408 Node* CodeStubAssembler::WordIsPositiveSmi(Node* a) { | 469 Node* CodeStubAssembler::WordIsPositiveSmi(Node* a) { |
409 return WordEqual(WordAnd(a, IntPtrConstant(kSmiTagMask | kSmiSignMask)), | 470 return WordEqual(WordAnd(a, IntPtrConstant(kSmiTagMask | kSmiSignMask)), |
410 IntPtrConstant(0)); | 471 IntPtrConstant(0)); |
411 } | 472 } |
412 | 473 |
413 Node* CodeStubAssembler::AllocateRawUnaligned(Node* size_in_bytes, | 474 Node* CodeStubAssembler::AllocateRawUnaligned(Node* size_in_bytes, |
(...skipping 2530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2944 } | 3005 } |
2945 Bind(&miss); | 3006 Bind(&miss); |
2946 { | 3007 { |
2947 TailCallRuntime(Runtime::kLoadGlobalIC_Miss, p->context, p->slot, | 3008 TailCallRuntime(Runtime::kLoadGlobalIC_Miss, p->context, p->slot, |
2948 p->vector); | 3009 p->vector); |
2949 } | 3010 } |
2950 } | 3011 } |
2951 | 3012 |
2952 } // namespace internal | 3013 } // namespace internal |
2953 } // namespace v8 | 3014 } // namespace v8 |
OLD | NEW |