OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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-stubs.h" | 5 #include "src/code-stubs.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 3620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3631 assembler->Return(var_len.value()); | 3631 assembler->Return(var_len.value()); |
3632 | 3632 |
3633 assembler->Bind(&return_two53minus1); | 3633 assembler->Bind(&return_two53minus1); |
3634 assembler->Return(assembler->NumberConstant(kMaxSafeInteger)); | 3634 assembler->Return(assembler->NumberConstant(kMaxSafeInteger)); |
3635 | 3635 |
3636 assembler->Bind(&return_zero); | 3636 assembler->Bind(&return_zero); |
3637 assembler->Return(assembler->SmiConstant(Smi::FromInt(0))); | 3637 assembler->Return(assembler->SmiConstant(Smi::FromInt(0))); |
3638 } | 3638 } |
3639 } | 3639 } |
3640 | 3640 |
3641 void ToBooleanStub::GenerateAssembly(CodeStubAssembler* assembler) const { | 3641 // static |
| 3642 compiler::Node* ToBooleanStub::Generate(CodeStubAssembler* assembler, |
| 3643 compiler::Node* value, |
| 3644 compiler::Node* context) { |
3642 typedef compiler::Node Node; | 3645 typedef compiler::Node Node; |
3643 typedef CodeStubAssembler::Label Label; | 3646 typedef CodeStubAssembler::Label Label; |
| 3647 typedef CodeStubAssembler::Variable Variable; |
3644 | 3648 |
3645 Node* value = assembler->Parameter(0); | 3649 Variable result(assembler, MachineRepresentation::kTagged); |
3646 Label if_valueissmi(assembler), if_valueisnotsmi(assembler), | 3650 Label if_valueissmi(assembler), if_valueisnotsmi(assembler), |
3647 return_true(assembler), return_false(assembler); | 3651 return_true(assembler), return_false(assembler), end(assembler); |
3648 | 3652 |
3649 // Check if {value} is a Smi or a HeapObject. | 3653 // Check if {value} is a Smi or a HeapObject. |
3650 assembler->Branch(assembler->WordIsSmi(value), &if_valueissmi, | 3654 assembler->Branch(assembler->WordIsSmi(value), &if_valueissmi, |
3651 &if_valueisnotsmi); | 3655 &if_valueisnotsmi); |
3652 | 3656 |
3653 assembler->Bind(&if_valueissmi); | 3657 assembler->Bind(&if_valueissmi); |
3654 { | 3658 { |
3655 // The {value} is a Smi, only need to check against zero. | 3659 // The {value} is a Smi, only need to check against zero. |
3656 assembler->Branch(assembler->SmiEqual(value, assembler->SmiConstant(0)), | 3660 assembler->Branch(assembler->SmiEqual(value, assembler->SmiConstant(0)), |
3657 &return_false, &return_true); | 3661 &return_false, &return_true); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3715 assembler->Branch(assembler->Float64LessThan( | 3719 assembler->Branch(assembler->Float64LessThan( |
3716 value_value, assembler->Float64Constant(0.0)), | 3720 value_value, assembler->Float64Constant(0.0)), |
3717 &return_true, &return_false); | 3721 &return_true, &return_false); |
3718 } | 3722 } |
3719 | 3723 |
3720 assembler->Bind(&if_valueisoddball); | 3724 assembler->Bind(&if_valueisoddball); |
3721 { | 3725 { |
3722 // The {value} is an Oddball, and every Oddball knows its boolean value. | 3726 // The {value} is an Oddball, and every Oddball knows its boolean value. |
3723 Node* value_toboolean = | 3727 Node* value_toboolean = |
3724 assembler->LoadObjectField(value, Oddball::kToBooleanOffset); | 3728 assembler->LoadObjectField(value, Oddball::kToBooleanOffset); |
3725 assembler->Return(value_toboolean); | 3729 result.Bind(value_toboolean); |
| 3730 assembler->Goto(&end); |
3726 } | 3731 } |
3727 | 3732 |
3728 assembler->Bind(&if_valueisother); | 3733 assembler->Bind(&if_valueisother); |
3729 { | 3734 { |
3730 Node* value_map_bitfield = assembler->Load( | 3735 Node* value_map_bitfield = assembler->Load( |
3731 MachineType::Uint8(), value_map, | 3736 MachineType::Uint8(), value_map, |
3732 assembler->IntPtrConstant(Map::kBitFieldOffset - kHeapObjectTag)); | 3737 assembler->IntPtrConstant(Map::kBitFieldOffset - kHeapObjectTag)); |
3733 Node* value_map_undetectable = assembler->Word32And( | 3738 Node* value_map_undetectable = assembler->Word32And( |
3734 value_map_bitfield, | 3739 value_map_bitfield, |
3735 assembler->Int32Constant(1 << Map::kIsUndetectable)); | 3740 assembler->Int32Constant(1 << Map::kIsUndetectable)); |
3736 | 3741 |
3737 // Check if the {value} is undetectable. | 3742 // Check if the {value} is undetectable. |
3738 assembler->Branch(assembler->Word32Equal(value_map_undetectable, | 3743 assembler->Branch(assembler->Word32Equal(value_map_undetectable, |
3739 assembler->Int32Constant(0)), | 3744 assembler->Int32Constant(0)), |
3740 &return_true, &return_false); | 3745 &return_true, &return_false); |
3741 } | 3746 } |
3742 } | 3747 } |
| 3748 |
3743 assembler->Bind(&return_false); | 3749 assembler->Bind(&return_false); |
3744 assembler->Return(assembler->BooleanConstant(false)); | 3750 { |
| 3751 result.Bind(assembler->BooleanConstant(false)); |
| 3752 assembler->Goto(&end); |
| 3753 } |
3745 | 3754 |
3746 assembler->Bind(&return_true); | 3755 assembler->Bind(&return_true); |
3747 assembler->Return(assembler->BooleanConstant(true)); | 3756 { |
| 3757 result.Bind(assembler->BooleanConstant(true)); |
| 3758 assembler->Goto(&end); |
| 3759 } |
| 3760 |
| 3761 assembler->Bind(&end); |
| 3762 return result.value(); |
3748 } | 3763 } |
3749 | 3764 |
3750 void ToIntegerStub::GenerateAssembly(CodeStubAssembler* assembler) const { | 3765 void ToIntegerStub::GenerateAssembly(CodeStubAssembler* assembler) const { |
3751 typedef CodeStubAssembler::Label Label; | 3766 typedef CodeStubAssembler::Label Label; |
3752 typedef compiler::Node Node; | 3767 typedef compiler::Node Node; |
3753 typedef CodeStubAssembler::Variable Variable; | 3768 typedef CodeStubAssembler::Variable Variable; |
3754 | 3769 |
3755 Node* context = assembler->Parameter(1); | 3770 Node* context = assembler->Parameter(1); |
3756 | 3771 |
3757 // We might need to loop once for ToNumber conversion. | 3772 // We might need to loop once for ToNumber conversion. |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4533 if (type->Is(Type::UntaggedPointer())) { | 4548 if (type->Is(Type::UntaggedPointer())) { |
4534 return Representation::External(); | 4549 return Representation::External(); |
4535 } | 4550 } |
4536 | 4551 |
4537 DCHECK(!type->Is(Type::Untagged())); | 4552 DCHECK(!type->Is(Type::Untagged())); |
4538 return Representation::Tagged(); | 4553 return Representation::Tagged(); |
4539 } | 4554 } |
4540 | 4555 |
4541 } // namespace internal | 4556 } // namespace internal |
4542 } // namespace v8 | 4557 } // namespace v8 |
OLD | NEW |