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_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ | 5 #ifndef V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ |
6 #define V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ | 6 #define V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ |
7 | 7 |
8 #include <cstring> | 8 #include <cstring> |
9 #include <iosfwd> | 9 #include <iosfwd> |
10 | 10 |
(...skipping 4929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4940 object->IsAllocate() && | 4940 object->IsAllocate() && |
4941 HAllocate::cast(object)->IsNewSpaceAllocation()) { | 4941 HAllocate::cast(object)->IsNewSpaceAllocation()) { |
4942 return kPointersToHereAreAlwaysInteresting; | 4942 return kPointersToHereAreAlwaysInteresting; |
4943 } | 4943 } |
4944 return kPointersToHereMaybeInteresting; | 4944 return kPointersToHereMaybeInteresting; |
4945 } | 4945 } |
4946 | 4946 |
4947 | 4947 |
4948 class HLoadContextSlot final : public HUnaryOperation { | 4948 class HLoadContextSlot final : public HUnaryOperation { |
4949 public: | 4949 public: |
4950 HLoadContextSlot(HValue* context, int slot_index) | 4950 enum Mode { |
4951 : HUnaryOperation(context), slot_index_(slot_index) { | 4951 // Perform a normal load of the context slot without checking its value. |
| 4952 kNoCheck, |
| 4953 // Load and check the value of the context slot. Deoptimize if it's the |
| 4954 // hole value. This is used for checking for loading of uninitialized |
| 4955 // harmony bindings where we deoptimize into full-codegen generated code |
| 4956 // which will subsequently throw a reference error. |
| 4957 kCheckDeoptimize |
| 4958 }; |
| 4959 |
| 4960 HLoadContextSlot(HValue* context, int slot_index, Mode mode) |
| 4961 : HUnaryOperation(context), slot_index_(slot_index), mode_(mode) { |
4952 set_representation(Representation::Tagged()); | 4962 set_representation(Representation::Tagged()); |
4953 SetFlag(kUseGVN); | 4963 SetFlag(kUseGVN); |
4954 SetDependsOnFlag(kContextSlots); | 4964 SetDependsOnFlag(kContextSlots); |
4955 } | 4965 } |
4956 | 4966 |
4957 int slot_index() const { return slot_index_; } | 4967 int slot_index() const { return slot_index_; } |
| 4968 Mode mode() const { return mode_; } |
| 4969 |
| 4970 bool DeoptimizesOnHole() { |
| 4971 return mode_ == kCheckDeoptimize; |
| 4972 } |
| 4973 |
| 4974 bool RequiresHoleCheck() const { |
| 4975 return mode_ != kNoCheck; |
| 4976 } |
4958 | 4977 |
4959 Representation RequiredInputRepresentation(int index) override { | 4978 Representation RequiredInputRepresentation(int index) override { |
4960 return Representation::Tagged(); | 4979 return Representation::Tagged(); |
4961 } | 4980 } |
4962 | 4981 |
4963 std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT | 4982 std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT |
4964 | 4983 |
4965 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot) | 4984 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot) |
4966 | 4985 |
4967 protected: | 4986 protected: |
4968 bool DataEquals(HValue* other) override { | 4987 bool DataEquals(HValue* other) override { |
4969 HLoadContextSlot* b = HLoadContextSlot::cast(other); | 4988 HLoadContextSlot* b = HLoadContextSlot::cast(other); |
4970 return (slot_index() == b->slot_index()); | 4989 return (slot_index() == b->slot_index()); |
4971 } | 4990 } |
4972 | 4991 |
4973 private: | 4992 private: |
4974 bool IsDeletable() const override { return true; } | 4993 bool IsDeletable() const override { return !RequiresHoleCheck(); } |
4975 | 4994 |
4976 int slot_index_; | 4995 int slot_index_; |
| 4996 Mode mode_; |
4977 }; | 4997 }; |
4978 | 4998 |
4979 | 4999 |
4980 class HStoreContextSlot final : public HTemplateInstruction<2> { | 5000 class HStoreContextSlot final : public HTemplateInstruction<2> { |
4981 public: | 5001 public: |
4982 DECLARE_INSTRUCTION_FACTORY_P3(HStoreContextSlot, HValue*, int, HValue*); | 5002 enum Mode { |
| 5003 // Perform a normal store to the context slot without checking its previous |
| 5004 // value. |
| 5005 kNoCheck, |
| 5006 // Check the previous value of the context slot and deoptimize if it's the |
| 5007 // hole value. This is used for checking for assignments to uninitialized |
| 5008 // harmony bindings where we deoptimize into full-codegen generated code |
| 5009 // which will subsequently throw a reference error. |
| 5010 kCheckDeoptimize |
| 5011 }; |
| 5012 |
| 5013 DECLARE_INSTRUCTION_FACTORY_P4(HStoreContextSlot, HValue*, int, |
| 5014 Mode, HValue*); |
4983 | 5015 |
4984 HValue* context() const { return OperandAt(0); } | 5016 HValue* context() const { return OperandAt(0); } |
4985 HValue* value() const { return OperandAt(1); } | 5017 HValue* value() const { return OperandAt(1); } |
4986 int slot_index() const { return slot_index_; } | 5018 int slot_index() const { return slot_index_; } |
| 5019 Mode mode() const { return mode_; } |
4987 | 5020 |
4988 bool NeedsWriteBarrier() { | 5021 bool NeedsWriteBarrier() { |
4989 return StoringValueNeedsWriteBarrier(value()); | 5022 return StoringValueNeedsWriteBarrier(value()); |
4990 } | 5023 } |
4991 | 5024 |
| 5025 bool DeoptimizesOnHole() { |
| 5026 return mode_ == kCheckDeoptimize; |
| 5027 } |
| 5028 |
| 5029 bool RequiresHoleCheck() { |
| 5030 return mode_ != kNoCheck; |
| 5031 } |
| 5032 |
4992 Representation RequiredInputRepresentation(int index) override { | 5033 Representation RequiredInputRepresentation(int index) override { |
4993 return Representation::Tagged(); | 5034 return Representation::Tagged(); |
4994 } | 5035 } |
4995 | 5036 |
4996 std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT | 5037 std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT |
4997 | 5038 |
4998 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot) | 5039 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot) |
4999 | 5040 |
5000 private: | 5041 private: |
5001 HStoreContextSlot(HValue* context, int slot_index, HValue* value) | 5042 HStoreContextSlot(HValue* context, int slot_index, Mode mode, HValue* value) |
5002 : slot_index_(slot_index) { | 5043 : slot_index_(slot_index), mode_(mode) { |
5003 SetOperandAt(0, context); | 5044 SetOperandAt(0, context); |
5004 SetOperandAt(1, value); | 5045 SetOperandAt(1, value); |
5005 SetChangesFlag(kContextSlots); | 5046 SetChangesFlag(kContextSlots); |
5006 } | 5047 } |
5007 | 5048 |
5008 int slot_index_; | 5049 int slot_index_; |
| 5050 Mode mode_; |
5009 }; | 5051 }; |
5010 | 5052 |
5011 | 5053 |
5012 // Represents an access to a portion of an object, such as the map pointer, | 5054 // Represents an access to a portion of an object, such as the map pointer, |
5013 // array elements pointer, etc, but not accesses to array elements themselves. | 5055 // array elements pointer, etc, but not accesses to array elements themselves. |
5014 class HObjectAccess final { | 5056 class HObjectAccess final { |
5015 public: | 5057 public: |
5016 inline bool IsInobject() const { | 5058 inline bool IsInobject() const { |
5017 return portion() != kBackingStore && portion() != kExternalMemory; | 5059 return portion() != kBackingStore && portion() != kExternalMemory; |
5018 } | 5060 } |
(...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6717 bool IsDeletable() const override { return true; } | 6759 bool IsDeletable() const override { return true; } |
6718 }; | 6760 }; |
6719 | 6761 |
6720 #undef DECLARE_INSTRUCTION | 6762 #undef DECLARE_INSTRUCTION |
6721 #undef DECLARE_CONCRETE_INSTRUCTION | 6763 #undef DECLARE_CONCRETE_INSTRUCTION |
6722 | 6764 |
6723 } // namespace internal | 6765 } // namespace internal |
6724 } // namespace v8 | 6766 } // namespace v8 |
6725 | 6767 |
6726 #endif // V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ | 6768 #endif // V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |