| 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 #ifndef V8_HYDROGEN_INSTRUCTIONS_H_ | 5 #ifndef V8_HYDROGEN_INSTRUCTIONS_H_ |
| 6 #define V8_HYDROGEN_INSTRUCTIONS_H_ | 6 #define V8_HYDROGEN_INSTRUCTIONS_H_ |
| 7 | 7 |
| 8 #include "v8.h" | 8 #include "v8.h" |
| 9 | 9 |
| 10 #include "allocation.h" | 10 #include "allocation.h" |
| (...skipping 2767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2778 | 2778 |
| 2779 const UniqueSet<Map>* maps() const { return maps_; } | 2779 const UniqueSet<Map>* maps() const { return maps_; } |
| 2780 void set_maps(const UniqueSet<Map>* maps) { maps_ = maps; } | 2780 void set_maps(const UniqueSet<Map>* maps) { maps_ = maps; } |
| 2781 | 2781 |
| 2782 bool maps_are_stable() const { return maps_are_stable_; } | 2782 bool maps_are_stable() const { return maps_are_stable_; } |
| 2783 | 2783 |
| 2784 bool HasMigrationTarget() const { return has_migration_target_; } | 2784 bool HasMigrationTarget() const { return has_migration_target_; } |
| 2785 | 2785 |
| 2786 virtual HValue* Canonicalize() V8_OVERRIDE; | 2786 virtual HValue* Canonicalize() V8_OVERRIDE; |
| 2787 | 2787 |
| 2788 static HCheckMaps* CreateAndInsertAfter(Zone* zone, |
| 2789 HValue* value, |
| 2790 Unique<Map> map, |
| 2791 bool map_is_stable, |
| 2792 HInstruction* instr) { |
| 2793 return CreateAndInsertAfter(zone, value, new(zone) UniqueSet<Map>( |
| 2794 map, zone), map_is_stable, instr); |
| 2795 } |
| 2796 |
| 2797 static HCheckMaps* CreateAndInsertAfter(Zone* zone, |
| 2798 HValue* value, |
| 2799 const UniqueSet<Map>* maps, |
| 2800 bool maps_are_stable, |
| 2801 HInstruction* instr) { |
| 2802 return instr->Append(new(zone) HCheckMaps(value, maps, maps_are_stable)); |
| 2803 } |
| 2804 |
| 2788 DECLARE_CONCRETE_INSTRUCTION(CheckMaps) | 2805 DECLARE_CONCRETE_INSTRUCTION(CheckMaps) |
| 2789 | 2806 |
| 2790 protected: | 2807 protected: |
| 2791 virtual bool DataEquals(HValue* other) V8_OVERRIDE { | 2808 virtual bool DataEquals(HValue* other) V8_OVERRIDE { |
| 2792 return this->maps()->Equals(HCheckMaps::cast(other)->maps()); | 2809 return this->maps()->Equals(HCheckMaps::cast(other)->maps()); |
| 2793 } | 2810 } |
| 2794 | 2811 |
| 2795 virtual int RedefinedOperandIndex() { return 0; } | 2812 virtual int RedefinedOperandIndex() { return 0; } |
| 2796 | 2813 |
| 2797 private: | 2814 private: |
| 2798 // Clients should use one of the static New* methods above. | 2815 HCheckMaps(HValue* value, const UniqueSet<Map>* maps, bool maps_are_stable) |
| 2816 : HTemplateInstruction<2>(value->type()), maps_(maps), |
| 2817 has_migration_target_(false), is_stability_check_(false), |
| 2818 maps_are_stable_(maps_are_stable) { |
| 2819 ASSERT_NE(0, maps->size()); |
| 2820 SetOperandAt(0, value); |
| 2821 // Use the object value for the dependency. |
| 2822 SetOperandAt(1, value); |
| 2823 set_representation(Representation::Tagged()); |
| 2824 SetFlag(kUseGVN); |
| 2825 SetDependsOnFlag(kMaps); |
| 2826 SetDependsOnFlag(kElementsKind); |
| 2827 } |
| 2828 |
| 2799 HCheckMaps(HValue* value, const UniqueSet<Map>* maps, HValue* typecheck) | 2829 HCheckMaps(HValue* value, const UniqueSet<Map>* maps, HValue* typecheck) |
| 2800 : HTemplateInstruction<2>(value->type()), maps_(maps), | 2830 : HTemplateInstruction<2>(value->type()), maps_(maps), |
| 2801 has_migration_target_(false), is_stability_check_(false), | 2831 has_migration_target_(false), is_stability_check_(false), |
| 2802 maps_are_stable_(true) { | 2832 maps_are_stable_(true) { |
| 2803 ASSERT_NE(0, maps->size()); | 2833 ASSERT_NE(0, maps->size()); |
| 2804 SetOperandAt(0, value); | 2834 SetOperandAt(0, value); |
| 2805 // Use the object value for the dependency if NULL is passed. | 2835 // Use the object value for the dependency if NULL is passed. |
| 2806 SetOperandAt(1, typecheck ? typecheck : value); | 2836 SetOperandAt(1, typecheck ? typecheck : value); |
| 2807 set_representation(Representation::Tagged()); | 2837 set_representation(Representation::Tagged()); |
| 2808 SetFlag(kUseGVN); | 2838 SetFlag(kUseGVN); |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3456 static HConstant* CreateAndInsertBefore(Zone* zone, | 3486 static HConstant* CreateAndInsertBefore(Zone* zone, |
| 3457 HValue* context, | 3487 HValue* context, |
| 3458 int32_t value, | 3488 int32_t value, |
| 3459 Representation representation, | 3489 Representation representation, |
| 3460 HInstruction* instruction) { | 3490 HInstruction* instruction) { |
| 3461 return instruction->Prepend(HConstant::New( | 3491 return instruction->Prepend(HConstant::New( |
| 3462 zone, context, value, representation)); | 3492 zone, context, value, representation)); |
| 3463 } | 3493 } |
| 3464 | 3494 |
| 3465 static HConstant* CreateAndInsertBefore(Zone* zone, | 3495 static HConstant* CreateAndInsertBefore(Zone* zone, |
| 3466 Unique<Object> unique, | 3496 Unique<Object> object, |
| 3467 bool is_not_in_new_space, | 3497 bool is_not_in_new_space, |
| 3468 HInstruction* instruction) { | 3498 HInstruction* instruction) { |
| 3469 return instruction->Prepend(new(zone) HConstant( | 3499 return instruction->Prepend(new(zone) HConstant( |
| 3470 unique, Representation::Tagged(), HType::Tagged(), | 3500 object, Unique<Map>(Handle<Map>::null()), false, |
| 3471 is_not_in_new_space, false, false, kUnknownInstanceType)); | 3501 Representation::Tagged(), HType::Tagged(), is_not_in_new_space, |
| 3502 false, false, kUnknownInstanceType)); |
| 3472 } | 3503 } |
| 3473 | 3504 |
| 3474 static HConstant* CreateAndInsertAfter(Zone* zone, | 3505 static HConstant* CreateAndInsertAfter(Zone* zone, |
| 3475 Unique<Map> unique, | 3506 Unique<Map> map, |
| 3476 HInstruction* instruction) { | 3507 HInstruction* instruction) { |
| 3477 return instruction->Append(new(zone) HConstant( | 3508 return instruction->Append(new(zone) HConstant( |
| 3478 unique, Representation::Tagged(), HType::Tagged(), | 3509 map, Unique<Map>(Handle<Map>::null()), false, |
| 3479 true, false, false, MAP_TYPE)); | 3510 Representation::Tagged(), HType::Tagged(), true, |
| 3511 false, false, MAP_TYPE)); |
| 3480 } | 3512 } |
| 3481 | 3513 |
| 3482 Handle<Object> handle(Isolate* isolate) { | 3514 Handle<Object> handle(Isolate* isolate) { |
| 3483 if (object_.handle().is_null()) { | 3515 if (object_.handle().is_null()) { |
| 3484 // Default arguments to is_not_in_new_space depend on this heap number | 3516 // Default arguments to is_not_in_new_space depend on this heap number |
| 3485 // to be tenured so that it's guaranteed not to be located in new space. | 3517 // to be tenured so that it's guaranteed not to be located in new space. |
| 3486 object_ = Unique<Object>::CreateUninitialized( | 3518 object_ = Unique<Object>::CreateUninitialized( |
| 3487 isolate->factory()->NewNumber(double_value_, TENURED)); | 3519 isolate->factory()->NewNumber(double_value_, TENURED)); |
| 3488 } | 3520 } |
| 3489 AllowDeferredHandleDereference smi_check; | 3521 AllowDeferredHandleDereference smi_check; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3568 } | 3600 } |
| 3569 ExternalReference ExternalReferenceValue() const { | 3601 ExternalReference ExternalReferenceValue() const { |
| 3570 return external_reference_value_; | 3602 return external_reference_value_; |
| 3571 } | 3603 } |
| 3572 | 3604 |
| 3573 bool HasBooleanValue() const { return type_.IsBoolean(); } | 3605 bool HasBooleanValue() const { return type_.IsBoolean(); } |
| 3574 bool BooleanValue() const { return boolean_value_; } | 3606 bool BooleanValue() const { return boolean_value_; } |
| 3575 bool IsUndetectable() const { return is_undetectable_; } | 3607 bool IsUndetectable() const { return is_undetectable_; } |
| 3576 InstanceType GetInstanceType() const { return instance_type_; } | 3608 InstanceType GetInstanceType() const { return instance_type_; } |
| 3577 | 3609 |
| 3610 bool HasMapValue() const { return instance_type_ == MAP_TYPE; } |
| 3611 Unique<Map> MapValue() const { |
| 3612 ASSERT(HasMapValue()); |
| 3613 return Unique<Map>::cast(GetUnique()); |
| 3614 } |
| 3615 bool HasStableMapValue() const { |
| 3616 ASSERT(HasMapValue()); |
| 3617 return has_stable_map_value_; |
| 3618 } |
| 3619 |
| 3578 bool HasObjectMap() const { return !object_map_.IsNull(); } | 3620 bool HasObjectMap() const { return !object_map_.IsNull(); } |
| 3579 Unique<Map> ObjectMap() const { | 3621 Unique<Map> ObjectMap() const { |
| 3580 ASSERT(HasObjectMap()); | 3622 ASSERT(HasObjectMap()); |
| 3581 return object_map_; | 3623 return object_map_; |
| 3582 } | 3624 } |
| 3583 bool ObjectMapIsStable() const { | |
| 3584 ASSERT(HasObjectMap()); | |
| 3585 return object_map_is_stable_; | |
| 3586 } | |
| 3587 | 3625 |
| 3588 virtual intptr_t Hashcode() V8_OVERRIDE { | 3626 virtual intptr_t Hashcode() V8_OVERRIDE { |
| 3589 if (has_int32_value_) { | 3627 if (has_int32_value_) { |
| 3590 return static_cast<intptr_t>(int32_value_); | 3628 return static_cast<intptr_t>(int32_value_); |
| 3591 } else if (has_double_value_) { | 3629 } else if (has_double_value_) { |
| 3592 return static_cast<intptr_t>(BitCast<int64_t>(double_value_)); | 3630 return static_cast<intptr_t>(BitCast<int64_t>(double_value_)); |
| 3593 } else if (has_external_reference_value_) { | 3631 } else if (has_external_reference_value_) { |
| 3594 return reinterpret_cast<intptr_t>(external_reference_value_.address()); | 3632 return reinterpret_cast<intptr_t>(external_reference_value_.address()); |
| 3595 } else { | 3633 } else { |
| 3596 ASSERT(!object_.handle().is_null()); | 3634 ASSERT(!object_.handle().is_null()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3650 friend class HGraph; | 3688 friend class HGraph; |
| 3651 HConstant(Handle<Object> handle, Representation r = Representation::None()); | 3689 HConstant(Handle<Object> handle, Representation r = Representation::None()); |
| 3652 HConstant(int32_t value, | 3690 HConstant(int32_t value, |
| 3653 Representation r = Representation::None(), | 3691 Representation r = Representation::None(), |
| 3654 bool is_not_in_new_space = true, | 3692 bool is_not_in_new_space = true, |
| 3655 Unique<Object> optional = Unique<Object>(Handle<Object>::null())); | 3693 Unique<Object> optional = Unique<Object>(Handle<Object>::null())); |
| 3656 HConstant(double value, | 3694 HConstant(double value, |
| 3657 Representation r = Representation::None(), | 3695 Representation r = Representation::None(), |
| 3658 bool is_not_in_new_space = true, | 3696 bool is_not_in_new_space = true, |
| 3659 Unique<Object> optional = Unique<Object>(Handle<Object>::null())); | 3697 Unique<Object> optional = Unique<Object>(Handle<Object>::null())); |
| 3660 HConstant(Unique<Object> unique, | 3698 HConstant(Unique<Object> object, |
| 3699 Unique<Map> object_map, |
| 3700 bool has_stable_map_value, |
| 3661 Representation r, | 3701 Representation r, |
| 3662 HType type, | 3702 HType type, |
| 3663 bool is_not_in_new_space, | 3703 bool is_not_in_new_space, |
| 3664 bool boolean_value, | 3704 bool boolean_value, |
| 3665 bool is_undetectable, | 3705 bool is_undetectable, |
| 3666 InstanceType instance_type); | 3706 InstanceType instance_type); |
| 3667 | 3707 |
| 3668 explicit HConstant(ExternalReference reference); | 3708 explicit HConstant(ExternalReference reference); |
| 3669 | 3709 |
| 3670 void Initialize(Representation r); | 3710 void Initialize(Representation r); |
| 3671 | 3711 |
| 3672 virtual bool IsDeletable() const V8_OVERRIDE { return true; } | 3712 virtual bool IsDeletable() const V8_OVERRIDE { return true; } |
| 3673 | 3713 |
| 3674 // If this is a numerical constant, object_ either points to the | 3714 // If this is a numerical constant, object_ either points to the |
| 3675 // HeapObject the constant originated from or is null. If the | 3715 // HeapObject the constant originated from or is null. If the |
| 3676 // constant is non-numeric, object_ always points to a valid | 3716 // constant is non-numeric, object_ always points to a valid |
| 3677 // constant HeapObject. | 3717 // constant HeapObject. |
| 3678 Unique<Object> object_; | 3718 Unique<Object> object_; |
| 3679 | 3719 |
| 3680 // If this is a heap object, this points to the Map of the object. | 3720 // If object_ is a heap object, this points to the stable map of the object. |
| 3681 Unique<Map> object_map_; | 3721 Unique<Map> object_map_; |
| 3682 bool object_map_is_stable_ : 1; | 3722 |
| 3723 // If object_ is a map, this indicates whether the map is stable. |
| 3724 bool has_stable_map_value_ : 1; |
| 3683 | 3725 |
| 3684 // We store the HConstant in the most specific form safely possible. | 3726 // We store the HConstant in the most specific form safely possible. |
| 3685 // The two flags, has_int32_value_ and has_double_value_ tell us if | 3727 // The two flags, has_int32_value_ and has_double_value_ tell us if |
| 3686 // int32_value_ and double_value_ hold valid, safe representations | 3728 // int32_value_ and double_value_ hold valid, safe representations |
| 3687 // of the constant. has_int32_value_ implies has_double_value_ but | 3729 // of the constant. has_int32_value_ implies has_double_value_ but |
| 3688 // not the converse. | 3730 // not the converse. |
| 3689 bool has_smi_value_ : 1; | 3731 bool has_smi_value_ : 1; |
| 3690 bool has_int32_value_ : 1; | 3732 bool has_int32_value_ : 1; |
| 3691 bool has_double_value_ : 1; | 3733 bool has_double_value_ : 1; |
| 3692 bool has_external_reference_value_ : 1; | 3734 bool has_external_reference_value_ : 1; |
| (...skipping 3761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7454 | 7496 |
| 7455 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; | 7497 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; |
| 7456 | 7498 |
| 7457 virtual HType CalculateInferredType() V8_OVERRIDE { | 7499 virtual HType CalculateInferredType() V8_OVERRIDE { |
| 7458 return HType::Tagged(); | 7500 return HType::Tagged(); |
| 7459 } | 7501 } |
| 7460 | 7502 |
| 7461 HValue* value() { return OperandAt(0); } | 7503 HValue* value() { return OperandAt(0); } |
| 7462 HValue* map() { return OperandAt(1); } | 7504 HValue* map() { return OperandAt(1); } |
| 7463 | 7505 |
| 7506 virtual HValue* Canonicalize() V8_OVERRIDE; |
| 7507 |
| 7464 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue) | 7508 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue) |
| 7465 | 7509 |
| 7466 protected: | 7510 protected: |
| 7467 virtual int RedefinedOperandIndex() { return 0; } | 7511 virtual int RedefinedOperandIndex() { return 0; } |
| 7468 | 7512 |
| 7469 virtual bool DataEquals(HValue* other) V8_OVERRIDE { | 7513 virtual bool DataEquals(HValue* other) V8_OVERRIDE { |
| 7470 return true; | 7514 return true; |
| 7471 } | 7515 } |
| 7472 | 7516 |
| 7473 private: | 7517 private: |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7584 virtual bool IsDeletable() const V8_OVERRIDE { return true; } | 7628 virtual bool IsDeletable() const V8_OVERRIDE { return true; } |
| 7585 }; | 7629 }; |
| 7586 | 7630 |
| 7587 | 7631 |
| 7588 #undef DECLARE_INSTRUCTION | 7632 #undef DECLARE_INSTRUCTION |
| 7589 #undef DECLARE_CONCRETE_INSTRUCTION | 7633 #undef DECLARE_CONCRETE_INSTRUCTION |
| 7590 | 7634 |
| 7591 } } // namespace v8::internal | 7635 } } // namespace v8::internal |
| 7592 | 7636 |
| 7593 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 7637 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |