| 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 #include "src/code-stub-assembler.h" | 4 #include "src/code-stub-assembler.h" |
| 5 #include "src/code-factory.h" | 5 #include "src/code-factory.h" |
| 6 #include "src/frames-inl.h" | 6 #include "src/frames-inl.h" |
| 7 #include "src/frames.h" | 7 #include "src/frames.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 } | 424 } |
| 425 return BitcastWordToTaggedSigned(WordShl(value, SmiShiftBitsConstant())); | 425 return BitcastWordToTaggedSigned(WordShl(value, SmiShiftBitsConstant())); |
| 426 } | 426 } |
| 427 | 427 |
| 428 Node* CodeStubAssembler::SmiUntag(Node* value) { | 428 Node* CodeStubAssembler::SmiUntag(Node* value) { |
| 429 return WordSar(BitcastTaggedToWord(value), SmiShiftBitsConstant()); | 429 return WordSar(BitcastTaggedToWord(value), SmiShiftBitsConstant()); |
| 430 } | 430 } |
| 431 | 431 |
| 432 Node* CodeStubAssembler::SmiToWord32(Node* value) { | 432 Node* CodeStubAssembler::SmiToWord32(Node* value) { |
| 433 Node* result = SmiUntag(value); | 433 Node* result = SmiUntag(value); |
| 434 if (Is64()) { | 434 return TruncateWordToWord32(result); |
| 435 result = TruncateInt64ToInt32(result); | |
| 436 } | |
| 437 return result; | |
| 438 } | 435 } |
| 439 | 436 |
| 440 Node* CodeStubAssembler::SmiToFloat64(Node* value) { | 437 Node* CodeStubAssembler::SmiToFloat64(Node* value) { |
| 441 return ChangeInt32ToFloat64(SmiToWord32(value)); | 438 return ChangeInt32ToFloat64(SmiToWord32(value)); |
| 442 } | 439 } |
| 443 | 440 |
| 444 Node* CodeStubAssembler::SmiAdd(Node* a, Node* b) { | 441 Node* CodeStubAssembler::SmiAdd(Node* a, Node* b) { |
| 445 return BitcastWordToTaggedSigned( | 442 return BitcastWordToTaggedSigned( |
| 446 IntPtrAdd(BitcastTaggedToWord(a), BitcastTaggedToWord(b))); | 443 IntPtrAdd(BitcastTaggedToWord(a), BitcastTaggedToWord(b))); |
| 447 } | 444 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 Node* value = Float64Mul(var_lhs_float64.value(), var_rhs_float64.value()); | 598 Node* value = Float64Mul(var_lhs_float64.value(), var_rhs_float64.value()); |
| 602 Node* result = AllocateHeapNumberWithValue(value); | 599 Node* result = AllocateHeapNumberWithValue(value); |
| 603 var_result.Bind(result); | 600 var_result.Bind(result); |
| 604 Goto(&return_result); | 601 Goto(&return_result); |
| 605 } | 602 } |
| 606 | 603 |
| 607 Bind(&return_result); | 604 Bind(&return_result); |
| 608 return var_result.value(); | 605 return var_result.value(); |
| 609 } | 606 } |
| 610 | 607 |
| 608 Node* CodeStubAssembler::TruncateWordToWord32(Node* value) { |
| 609 if (Is64()) { |
| 610 return TruncateInt64ToInt32(value); |
| 611 } |
| 612 return value; |
| 613 } |
| 614 |
| 611 Node* CodeStubAssembler::TaggedIsSmi(Node* a) { | 615 Node* CodeStubAssembler::TaggedIsSmi(Node* a) { |
| 612 return WordEqual(WordAnd(BitcastTaggedToWord(a), IntPtrConstant(kSmiTagMask)), | 616 return WordEqual(WordAnd(BitcastTaggedToWord(a), IntPtrConstant(kSmiTagMask)), |
| 613 IntPtrConstant(0)); | 617 IntPtrConstant(0)); |
| 614 } | 618 } |
| 615 | 619 |
| 616 Node* CodeStubAssembler::TaggedIsNotSmi(Node* a) { | 620 Node* CodeStubAssembler::TaggedIsNotSmi(Node* a) { |
| 617 return WordNotEqual( | 621 return WordNotEqual( |
| 618 WordAnd(BitcastTaggedToWord(a), IntPtrConstant(kSmiTagMask)), | 622 WordAnd(BitcastTaggedToWord(a), IntPtrConstant(kSmiTagMask)), |
| 619 IntPtrConstant(0)); | 623 IntPtrConstant(0)); |
| 620 } | 624 } |
| (...skipping 2001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2622 Branch(overflow, &if_overflow, &if_notoverflow); | 2626 Branch(overflow, &if_overflow, &if_notoverflow); |
| 2623 Bind(&if_overflow); | 2627 Bind(&if_overflow); |
| 2624 { | 2628 { |
| 2625 Node* value64 = ChangeInt32ToFloat64(value); | 2629 Node* value64 = ChangeInt32ToFloat64(value); |
| 2626 Node* result = AllocateHeapNumberWithValue(value64); | 2630 Node* result = AllocateHeapNumberWithValue(value64); |
| 2627 var_result.Bind(result); | 2631 var_result.Bind(result); |
| 2628 } | 2632 } |
| 2629 Goto(&if_join); | 2633 Goto(&if_join); |
| 2630 Bind(&if_notoverflow); | 2634 Bind(&if_notoverflow); |
| 2631 { | 2635 { |
| 2632 Node* result = Projection(0, pair); | 2636 Node* result = BitcastWordToTaggedSigned(Projection(0, pair)); |
| 2633 var_result.Bind(result); | 2637 var_result.Bind(result); |
| 2634 } | 2638 } |
| 2635 Goto(&if_join); | 2639 Goto(&if_join); |
| 2636 Bind(&if_join); | 2640 Bind(&if_join); |
| 2637 return var_result.value(); | 2641 return var_result.value(); |
| 2638 } | 2642 } |
| 2639 | 2643 |
| 2640 Node* CodeStubAssembler::ChangeUint32ToTagged(Node* value) { | 2644 Node* CodeStubAssembler::ChangeUint32ToTagged(Node* value) { |
| 2641 Label if_overflow(this, Label::kDeferred), if_not_overflow(this), | 2645 Label if_overflow(this, Label::kDeferred), if_not_overflow(this), |
| 2642 if_join(this); | 2646 if_join(this); |
| 2643 Variable var_result(this, MachineRepresentation::kTagged); | 2647 Variable var_result(this, MachineRepresentation::kTagged); |
| 2644 // If {value} > 2^31 - 1, we need to store it in a HeapNumber. | 2648 // If {value} > 2^31 - 1, we need to store it in a HeapNumber. |
| 2645 Branch(Uint32LessThan(Int32Constant(Smi::kMaxValue), value), &if_overflow, | 2649 Branch(Uint32LessThan(Int32Constant(Smi::kMaxValue), value), &if_overflow, |
| 2646 &if_not_overflow); | 2650 &if_not_overflow); |
| 2647 | 2651 |
| 2648 Bind(&if_not_overflow); | 2652 Bind(&if_not_overflow); |
| 2649 { | 2653 { |
| 2650 if (Is64()) { | 2654 if (Is64()) { |
| 2651 var_result.Bind(SmiTag(ChangeUint32ToUint64(value))); | 2655 var_result.Bind(SmiTag(ChangeUint32ToUint64(value))); |
| 2652 } else { | 2656 } else { |
| 2653 // If tagging {value} results in an overflow, we need to use a HeapNumber | 2657 // If tagging {value} results in an overflow, we need to use a HeapNumber |
| 2654 // to represent it. | 2658 // to represent it. |
| 2655 Node* pair = Int32AddWithOverflow(value, value); | 2659 Node* pair = Int32AddWithOverflow(value, value); |
| 2656 Node* overflow = Projection(1, pair); | 2660 Node* overflow = Projection(1, pair); |
| 2657 GotoIf(overflow, &if_overflow); | 2661 GotoIf(overflow, &if_overflow); |
| 2658 | 2662 |
| 2659 Node* result = Projection(0, pair); | 2663 Node* result = BitcastWordToTaggedSigned(Projection(0, pair)); |
| 2660 var_result.Bind(result); | 2664 var_result.Bind(result); |
| 2661 } | 2665 } |
| 2662 } | 2666 } |
| 2663 Goto(&if_join); | 2667 Goto(&if_join); |
| 2664 | 2668 |
| 2665 Bind(&if_overflow); | 2669 Bind(&if_overflow); |
| 2666 { | 2670 { |
| 2667 Node* float64_value = ChangeUint32ToFloat64(value); | 2671 Node* float64_value = ChangeUint32ToFloat64(value); |
| 2668 var_result.Bind(AllocateHeapNumberWithValue(float64_value)); | 2672 var_result.Bind(AllocateHeapNumberWithValue(float64_value)); |
| 2669 } | 2673 } |
| (...skipping 1785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4455 } | 4459 } |
| 4456 | 4460 |
| 4457 // Instantiate template methods to workaround GCC compilation issue. | 4461 // Instantiate template methods to workaround GCC compilation issue. |
| 4458 template void CodeStubAssembler::NameDictionaryLookup<NameDictionary>( | 4462 template void CodeStubAssembler::NameDictionaryLookup<NameDictionary>( |
| 4459 Node*, Node*, Label*, Variable*, Label*, int, LookupMode); | 4463 Node*, Node*, Label*, Variable*, Label*, int, LookupMode); |
| 4460 template void CodeStubAssembler::NameDictionaryLookup<GlobalDictionary>( | 4464 template void CodeStubAssembler::NameDictionaryLookup<GlobalDictionary>( |
| 4461 Node*, Node*, Label*, Variable*, Label*, int, LookupMode); | 4465 Node*, Node*, Label*, Variable*, Label*, int, LookupMode); |
| 4462 | 4466 |
| 4463 Node* CodeStubAssembler::ComputeIntegerHash(Node* key, Node* seed) { | 4467 Node* CodeStubAssembler::ComputeIntegerHash(Node* key, Node* seed) { |
| 4464 // See v8::internal::ComputeIntegerHash() | 4468 // See v8::internal::ComputeIntegerHash() |
| 4465 Node* hash = key; | 4469 Node* hash = TruncateWordToWord32(key); |
| 4466 hash = Word32Xor(hash, seed); | 4470 hash = Word32Xor(hash, seed); |
| 4467 hash = Int32Add(Word32Xor(hash, Int32Constant(0xffffffff)), | 4471 hash = Int32Add(Word32Xor(hash, Int32Constant(0xffffffff)), |
| 4468 Word32Shl(hash, Int32Constant(15))); | 4472 Word32Shl(hash, Int32Constant(15))); |
| 4469 hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(12))); | 4473 hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(12))); |
| 4470 hash = Int32Add(hash, Word32Shl(hash, Int32Constant(2))); | 4474 hash = Int32Add(hash, Word32Shl(hash, Int32Constant(2))); |
| 4471 hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(4))); | 4475 hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(4))); |
| 4472 hash = Int32Mul(hash, Int32Constant(2057)); | 4476 hash = Int32Mul(hash, Int32Constant(2057)); |
| 4473 hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(16))); | 4477 hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(16))); |
| 4474 return Word32And(hash, Int32Constant(0x3fffffff)); | 4478 return Word32And(hash, Int32Constant(0x3fffffff)); |
| 4475 } | 4479 } |
| (...skipping 3746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8222 | 8226 |
| 8223 Node* CodeStubAssembler::IsDebugActive() { | 8227 Node* CodeStubAssembler::IsDebugActive() { |
| 8224 Node* is_debug_active = Load( | 8228 Node* is_debug_active = Load( |
| 8225 MachineType::Uint8(), | 8229 MachineType::Uint8(), |
| 8226 ExternalConstant(ExternalReference::debug_is_active_address(isolate()))); | 8230 ExternalConstant(ExternalReference::debug_is_active_address(isolate()))); |
| 8227 return WordNotEqual(is_debug_active, Int32Constant(0)); | 8231 return WordNotEqual(is_debug_active, Int32Constant(0)); |
| 8228 } | 8232 } |
| 8229 | 8233 |
| 8230 } // namespace internal | 8234 } // namespace internal |
| 8231 } // namespace v8 | 8235 } // namespace v8 |
| OLD | NEW |