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 <cstring> | 8 #include <cstring> |
9 #include <iosfwd> | 9 #include <iosfwd> |
10 | 10 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 V(InvokeFunction) \ | 110 V(InvokeFunction) \ |
111 V(IsConstructCallAndBranch) \ | 111 V(IsConstructCallAndBranch) \ |
112 V(IsObjectAndBranch) \ | 112 V(IsObjectAndBranch) \ |
113 V(IsStringAndBranch) \ | 113 V(IsStringAndBranch) \ |
114 V(IsSmiAndBranch) \ | 114 V(IsSmiAndBranch) \ |
115 V(IsUndetectableAndBranch) \ | 115 V(IsUndetectableAndBranch) \ |
116 V(LeaveInlined) \ | 116 V(LeaveInlined) \ |
117 V(LoadContextSlot) \ | 117 V(LoadContextSlot) \ |
118 V(LoadFieldByIndex) \ | 118 V(LoadFieldByIndex) \ |
119 V(LoadFunctionPrototype) \ | 119 V(LoadFunctionPrototype) \ |
120 V(LoadGlobalCell) \ | |
121 V(LoadGlobalGeneric) \ | 120 V(LoadGlobalGeneric) \ |
122 V(LoadKeyed) \ | 121 V(LoadKeyed) \ |
123 V(LoadKeyedGeneric) \ | 122 V(LoadKeyedGeneric) \ |
124 V(LoadNamedField) \ | 123 V(LoadNamedField) \ |
125 V(LoadNamedGeneric) \ | 124 V(LoadNamedGeneric) \ |
126 V(LoadRoot) \ | 125 V(LoadRoot) \ |
127 V(MapEnumLength) \ | 126 V(MapEnumLength) \ |
128 V(MathFloorOfDiv) \ | 127 V(MathFloorOfDiv) \ |
129 V(MathMinMax) \ | 128 V(MathMinMax) \ |
130 V(Mod) \ | 129 V(Mod) \ |
131 V(Mul) \ | 130 V(Mul) \ |
132 V(OsrEntry) \ | 131 V(OsrEntry) \ |
133 V(Parameter) \ | 132 V(Parameter) \ |
134 V(Power) \ | 133 V(Power) \ |
135 V(PushArguments) \ | 134 V(PushArguments) \ |
136 V(RegExpLiteral) \ | 135 V(RegExpLiteral) \ |
137 V(Return) \ | 136 V(Return) \ |
138 V(Ror) \ | 137 V(Ror) \ |
139 V(Sar) \ | 138 V(Sar) \ |
140 V(SeqStringGetChar) \ | 139 V(SeqStringGetChar) \ |
141 V(SeqStringSetChar) \ | 140 V(SeqStringSetChar) \ |
142 V(Shl) \ | 141 V(Shl) \ |
143 V(Shr) \ | 142 V(Shr) \ |
144 V(Simulate) \ | 143 V(Simulate) \ |
145 V(StackCheck) \ | 144 V(StackCheck) \ |
146 V(StoreCodeEntry) \ | 145 V(StoreCodeEntry) \ |
147 V(StoreContextSlot) \ | 146 V(StoreContextSlot) \ |
148 V(StoreFrameContext) \ | 147 V(StoreFrameContext) \ |
149 V(StoreGlobalCell) \ | |
150 V(StoreKeyed) \ | 148 V(StoreKeyed) \ |
151 V(StoreKeyedGeneric) \ | 149 V(StoreKeyedGeneric) \ |
152 V(StoreNamedField) \ | 150 V(StoreNamedField) \ |
153 V(StoreNamedGeneric) \ | 151 V(StoreNamedGeneric) \ |
154 V(StringAdd) \ | 152 V(StringAdd) \ |
155 V(StringCharCodeAt) \ | 153 V(StringCharCodeAt) \ |
156 V(StringCharFromCode) \ | 154 V(StringCharFromCode) \ |
157 V(StringCompareAndBranch) \ | 155 V(StringCompareAndBranch) \ |
158 V(Sub) \ | 156 V(Sub) \ |
159 V(TailCallThroughMegamorphicCache) \ | 157 V(TailCallThroughMegamorphicCache) \ |
(...skipping 3334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3494 } | 3492 } |
3495 | 3493 |
3496 bool NotInNewSpace() const { | 3494 bool NotInNewSpace() const { |
3497 return IsNotInNewSpaceField::decode(bit_field_); | 3495 return IsNotInNewSpaceField::decode(bit_field_); |
3498 } | 3496 } |
3499 | 3497 |
3500 bool ImmortalImmovable() const; | 3498 bool ImmortalImmovable() const; |
3501 | 3499 |
3502 bool IsCell() const { | 3500 bool IsCell() const { |
3503 InstanceType instance_type = GetInstanceType(); | 3501 InstanceType instance_type = GetInstanceType(); |
3504 return instance_type == CELL_TYPE || instance_type == PROPERTY_CELL_TYPE; | 3502 return instance_type == CELL_TYPE; |
3505 } | 3503 } |
3506 | 3504 |
3507 Representation RequiredInputRepresentation(int index) OVERRIDE { | 3505 Representation RequiredInputRepresentation(int index) OVERRIDE { |
3508 return Representation::None(); | 3506 return Representation::None(); |
3509 } | 3507 } |
3510 | 3508 |
3511 Representation KnownOptimalRepresentation() OVERRIDE { | 3509 Representation KnownOptimalRepresentation() OVERRIDE { |
3512 if (HasSmiValue() && SmiValuesAre31Bits()) return Representation::Smi(); | 3510 if (HasSmiValue() && SmiValuesAre31Bits()) return Representation::Smi(); |
3513 if (HasInteger32Value()) return Representation::Integer32(); | 3511 if (HasInteger32Value()) return Representation::Integer32(); |
3514 if (HasNumberValue()) return Representation::Double(); | 3512 if (HasNumberValue()) return Representation::Double(); |
(...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5407 incoming_value_(NULL) { | 5405 incoming_value_(NULL) { |
5408 set_representation(Representation::Tagged()); | 5406 set_representation(Representation::Tagged()); |
5409 } | 5407 } |
5410 | 5408 |
5411 HEnvironment* environment_; | 5409 HEnvironment* environment_; |
5412 int index_; | 5410 int index_; |
5413 HPhi* incoming_value_; | 5411 HPhi* incoming_value_; |
5414 }; | 5412 }; |
5415 | 5413 |
5416 | 5414 |
5417 class HLoadGlobalCell FINAL : public HTemplateInstruction<0> { | |
5418 public: | |
5419 DECLARE_INSTRUCTION_FACTORY_P2(HLoadGlobalCell, Handle<Cell>, | |
5420 PropertyDetails); | |
5421 | |
5422 Unique<Cell> cell() const { return cell_; } | |
5423 // TODO(dcarney): remove this. | |
5424 bool RequiresHoleCheck() const { return false; } | |
5425 | |
5426 std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT | |
5427 | |
5428 intptr_t Hashcode() OVERRIDE { return cell_.Hashcode(); } | |
5429 | |
5430 void FinalizeUniqueness() OVERRIDE { cell_ = Unique<Cell>(cell_.handle()); } | |
5431 | |
5432 Representation RequiredInputRepresentation(int index) OVERRIDE { | |
5433 return Representation::None(); | |
5434 } | |
5435 | |
5436 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell) | |
5437 | |
5438 protected: | |
5439 bool DataEquals(HValue* other) OVERRIDE { | |
5440 return cell_ == HLoadGlobalCell::cast(other)->cell_; | |
5441 } | |
5442 | |
5443 private: | |
5444 HLoadGlobalCell(Handle<Cell> cell, PropertyDetails details) | |
5445 : cell_(Unique<Cell>::CreateUninitialized(cell)), details_(details) { | |
5446 set_representation(Representation::Tagged()); | |
5447 SetFlag(kUseGVN); | |
5448 SetDependsOnFlag(kGlobalVars); | |
5449 } | |
5450 | |
5451 bool IsDeletable() const OVERRIDE { return true; } | |
5452 | |
5453 Unique<Cell> cell_; | |
5454 PropertyDetails details_; | |
5455 }; | |
5456 | |
5457 | |
5458 class HLoadGlobalGeneric FINAL : public HTemplateInstruction<2> { | 5415 class HLoadGlobalGeneric FINAL : public HTemplateInstruction<2> { |
5459 public: | 5416 public: |
5460 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P3(HLoadGlobalGeneric, HValue*, | 5417 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P3(HLoadGlobalGeneric, HValue*, |
5461 Handle<String>, bool); | 5418 Handle<String>, bool); |
5462 | 5419 |
5463 HValue* context() { return OperandAt(0); } | 5420 HValue* context() { return OperandAt(0); } |
5464 HValue* global_object() { return OperandAt(1); } | 5421 HValue* global_object() { return OperandAt(1); } |
5465 Handle<String> name() const { return name_; } | 5422 Handle<String> name() const { return name_; } |
5466 bool for_typeof() const { return for_typeof_; } | 5423 bool for_typeof() const { return for_typeof_; } |
5467 FeedbackVectorICSlot slot() const { return slot_; } | 5424 FeedbackVectorICSlot slot() const { return slot_; } |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5799 } | 5756 } |
5800 if (object == dominator && | 5757 if (object == dominator && |
5801 object->IsAllocate() && | 5758 object->IsAllocate() && |
5802 HAllocate::cast(object)->IsNewSpaceAllocation()) { | 5759 HAllocate::cast(object)->IsNewSpaceAllocation()) { |
5803 return kPointersToHereAreAlwaysInteresting; | 5760 return kPointersToHereAreAlwaysInteresting; |
5804 } | 5761 } |
5805 return kPointersToHereMaybeInteresting; | 5762 return kPointersToHereMaybeInteresting; |
5806 } | 5763 } |
5807 | 5764 |
5808 | 5765 |
5809 class HStoreGlobalCell FINAL : public HUnaryOperation { | |
5810 public: | |
5811 DECLARE_INSTRUCTION_FACTORY_P3(HStoreGlobalCell, HValue*, | |
5812 Handle<PropertyCell>, PropertyDetails); | |
5813 | |
5814 Unique<PropertyCell> cell() const { return cell_; } | |
5815 // TODO(dcarney): remove | |
5816 bool RequiresHoleCheck() const { return false; } | |
5817 bool NeedsWriteBarrier() { | |
5818 return StoringValueNeedsWriteBarrier(value()); | |
5819 } | |
5820 | |
5821 void FinalizeUniqueness() OVERRIDE { | |
5822 cell_ = Unique<PropertyCell>(cell_.handle()); | |
5823 } | |
5824 | |
5825 Representation RequiredInputRepresentation(int index) OVERRIDE { | |
5826 return Representation::Tagged(); | |
5827 } | |
5828 std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT | |
5829 | |
5830 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell) | |
5831 | |
5832 private: | |
5833 HStoreGlobalCell(HValue* value, | |
5834 Handle<PropertyCell> cell, | |
5835 PropertyDetails details) | |
5836 : HUnaryOperation(value), | |
5837 cell_(Unique<PropertyCell>::CreateUninitialized(cell)), | |
5838 details_(details) { | |
5839 SetChangesFlag(kGlobalVars); | |
5840 } | |
5841 | |
5842 Unique<PropertyCell> cell_; | |
5843 PropertyDetails details_; | |
5844 }; | |
5845 | |
5846 | |
5847 class HLoadContextSlot FINAL : public HUnaryOperation { | 5766 class HLoadContextSlot FINAL : public HUnaryOperation { |
5848 public: | 5767 public: |
5849 enum Mode { | 5768 enum Mode { |
5850 // Perform a normal load of the context slot without checking its value. | 5769 // Perform a normal load of the context slot without checking its value. |
5851 kNoCheck, | 5770 kNoCheck, |
5852 // Load and check the value of the context slot. Deoptimize if it's the | 5771 // Load and check the value of the context slot. Deoptimize if it's the |
5853 // hole value. This is used for checking for loading of uninitialized | 5772 // hole value. This is used for checking for loading of uninitialized |
5854 // harmony bindings where we deoptimize into full-codegen generated code | 5773 // harmony bindings where we deoptimize into full-codegen generated code |
5855 // which will subsequently throw a reference error. | 5774 // which will subsequently throw a reference error. |
5856 kCheckDeoptimize, | 5775 kCheckDeoptimize, |
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6927 } | 6846 } |
6928 } | 6847 } |
6929 | 6848 |
6930 void SetTransition(HConstant* transition) { | 6849 void SetTransition(HConstant* transition) { |
6931 DCHECK(!has_transition()); // Only set once. | 6850 DCHECK(!has_transition()); // Only set once. |
6932 SetOperandAt(2, transition); | 6851 SetOperandAt(2, transition); |
6933 bit_field_ = HasTransitionField::update(bit_field_, true); | 6852 bit_field_ = HasTransitionField::update(bit_field_, true); |
6934 SetChangesFlag(kMaps); | 6853 SetChangesFlag(kMaps); |
6935 } | 6854 } |
6936 | 6855 |
6937 void MarkReceiverAsCell() { | |
6938 bit_field_ = ReceiverIsCellField::update(bit_field_, true); | |
6939 } | |
6940 | |
6941 bool receiver_is_cell() const { | |
6942 return ReceiverIsCellField::decode(bit_field_); | |
6943 } | |
6944 | |
6945 bool NeedsWriteBarrier() const { | 6856 bool NeedsWriteBarrier() const { |
6946 DCHECK(!field_representation().IsDouble() || | 6857 DCHECK(!field_representation().IsDouble() || |
6947 (FLAG_unbox_double_fields && access_.IsInobject()) || | 6858 (FLAG_unbox_double_fields && access_.IsInobject()) || |
6948 !has_transition()); | 6859 !has_transition()); |
6949 if (field_representation().IsDouble()) return false; | 6860 if (field_representation().IsDouble()) return false; |
6950 if (field_representation().IsSmi()) return false; | 6861 if (field_representation().IsSmi()) return false; |
6951 if (field_representation().IsInteger32()) return false; | 6862 if (field_representation().IsInteger32()) return false; |
6952 if (field_representation().IsExternal()) return false; | 6863 if (field_representation().IsExternal()) return false; |
6953 if (receiver_is_cell()) return false; | |
6954 return StoringValueNeedsWriteBarrier(value()) && | 6864 return StoringValueNeedsWriteBarrier(value()) && |
6955 ReceiverObjectNeedsWriteBarrier(object(), value(), dominator()); | 6865 ReceiverObjectNeedsWriteBarrier(object(), value(), dominator()); |
6956 } | 6866 } |
6957 | 6867 |
6958 bool NeedsWriteBarrierForMap() { | 6868 bool NeedsWriteBarrierForMap() { |
6959 return ReceiverObjectNeedsWriteBarrier(object(), transition(), | 6869 return ReceiverObjectNeedsWriteBarrier(object(), transition(), |
6960 dominator()); | 6870 dominator()); |
6961 } | 6871 } |
6962 | 6872 |
6963 SmiCheck SmiCheckForWriteBarrier() const { | 6873 SmiCheck SmiCheckForWriteBarrier() const { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7003 DCHECK(!access.IsInobject() || access.existing_inobject_property() || | 6913 DCHECK(!access.IsInobject() || access.existing_inobject_property() || |
7004 obj->IsAllocate() || obj->IsInnerAllocatedObject()); | 6914 obj->IsAllocate() || obj->IsInnerAllocatedObject()); |
7005 SetOperandAt(0, obj); | 6915 SetOperandAt(0, obj); |
7006 SetOperandAt(1, val); | 6916 SetOperandAt(1, val); |
7007 SetOperandAt(2, obj); | 6917 SetOperandAt(2, obj); |
7008 access.SetGVNFlags(this, STORE); | 6918 access.SetGVNFlags(this, STORE); |
7009 } | 6919 } |
7010 | 6920 |
7011 class HasTransitionField : public BitField<bool, 0, 1> {}; | 6921 class HasTransitionField : public BitField<bool, 0, 1> {}; |
7012 class StoreModeField : public BitField<StoreFieldOrKeyedMode, 1, 1> {}; | 6922 class StoreModeField : public BitField<StoreFieldOrKeyedMode, 1, 1> {}; |
7013 class ReceiverIsCellField : public BitField<bool, 2, 1> {}; | |
7014 | 6923 |
7015 HObjectAccess access_; | 6924 HObjectAccess access_; |
7016 HValue* dominator_; | 6925 HValue* dominator_; |
7017 uint32_t bit_field_; | 6926 uint32_t bit_field_; |
7018 }; | 6927 }; |
7019 | 6928 |
7020 | 6929 |
7021 class HStoreNamedGeneric FINAL : public HTemplateInstruction<3> { | 6930 class HStoreNamedGeneric FINAL : public HTemplateInstruction<3> { |
7022 public: | 6931 public: |
7023 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P5(HStoreNamedGeneric, HValue*, | 6932 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P5(HStoreNamedGeneric, HValue*, |
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7979 }; | 7888 }; |
7980 | 7889 |
7981 | 7890 |
7982 | 7891 |
7983 #undef DECLARE_INSTRUCTION | 7892 #undef DECLARE_INSTRUCTION |
7984 #undef DECLARE_CONCRETE_INSTRUCTION | 7893 #undef DECLARE_CONCRETE_INSTRUCTION |
7985 | 7894 |
7986 } } // namespace v8::internal | 7895 } } // namespace v8::internal |
7987 | 7896 |
7988 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 7897 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |