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 "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 6423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6434 SetFlag(kUseGVN); | 6434 SetFlag(kUseGVN); |
6435 SetDependsOnFlag(kCalls); | 6435 SetDependsOnFlag(kCalls); |
6436 } | 6436 } |
6437 }; | 6437 }; |
6438 | 6438 |
6439 class ArrayInstructionInterface { | 6439 class ArrayInstructionInterface { |
6440 public: | 6440 public: |
6441 virtual HValue* GetKey() = 0; | 6441 virtual HValue* GetKey() = 0; |
6442 virtual void SetKey(HValue* key) = 0; | 6442 virtual void SetKey(HValue* key) = 0; |
6443 virtual ElementsKind elements_kind() const = 0; | 6443 virtual ElementsKind elements_kind() const = 0; |
6444 virtual void IncreaseBaseOffset(uint32_t base_offset) = 0; | 6444 // TryIncreaseBaseOffset returns false if overflow would result. |
6445 virtual int MaxBaseOffsetBits() = 0; | 6445 virtual bool TryIncreaseBaseOffset(uint32_t increase_by_value) = 0; |
6446 virtual bool IsDehoisted() = 0; | 6446 virtual bool IsDehoisted() = 0; |
6447 virtual void SetDehoisted(bool is_dehoisted) = 0; | 6447 virtual void SetDehoisted(bool is_dehoisted) = 0; |
6448 virtual ~ArrayInstructionInterface() { } | 6448 virtual ~ArrayInstructionInterface() { } |
6449 | 6449 |
6450 static Representation KeyedAccessIndexRequirement(Representation r) { | 6450 static Representation KeyedAccessIndexRequirement(Representation r) { |
6451 return r.IsInteger32() || SmiValuesAre32Bits() | 6451 return r.IsInteger32() || SmiValuesAre32Bits() |
6452 ? Representation::Integer32() : Representation::Smi(); | 6452 ? Representation::Integer32() : Representation::Smi(); |
6453 } | 6453 } |
6454 }; | 6454 }; |
6455 | 6455 |
(...skipping 26 matching lines...) Expand all Loading... |
6482 return is_external() || is_fixed_typed_array(); | 6482 return is_external() || is_fixed_typed_array(); |
6483 } | 6483 } |
6484 HValue* elements() { return OperandAt(0); } | 6484 HValue* elements() { return OperandAt(0); } |
6485 HValue* key() { return OperandAt(1); } | 6485 HValue* key() { return OperandAt(1); } |
6486 HValue* dependency() { | 6486 HValue* dependency() { |
6487 ASSERT(HasDependency()); | 6487 ASSERT(HasDependency()); |
6488 return OperandAt(2); | 6488 return OperandAt(2); |
6489 } | 6489 } |
6490 bool HasDependency() const { return OperandAt(0) != OperandAt(2); } | 6490 bool HasDependency() const { return OperandAt(0) != OperandAt(2); } |
6491 uint32_t base_offset() { return BaseOffsetField::decode(bit_field_); } | 6491 uint32_t base_offset() { return BaseOffsetField::decode(bit_field_); } |
6492 void IncreaseBaseOffset(uint32_t base_offset) { | 6492 bool TryIncreaseBaseOffset(uint32_t increase_by_value) { |
6493 // The base offset is usually simply the size of the array header, except | 6493 // The base offset is usually simply the size of the array header, except |
6494 // with dehoisting adds an addition offset due to a array index key | 6494 // with dehoisting adds an addition offset due to a array index key |
6495 // manipulation, in which case it becomes (array header size + | 6495 // manipulation, in which case it becomes (array header size + |
6496 // constant-offset-from-key * kPointerSize) | 6496 // constant-offset-from-key * kPointerSize) |
6497 base_offset += BaseOffsetField::decode(bit_field_); | 6497 uint32_t base_offset = BaseOffsetField::decode(bit_field_); |
| 6498 if (AdditionOverflows(base_offset, increase_by_value) || |
| 6499 !BaseOffsetField::is_valid(base_offset + increase_by_value)) { |
| 6500 return false; |
| 6501 } |
| 6502 base_offset += increase_by_value; |
6498 bit_field_ = BaseOffsetField::update(bit_field_, base_offset); | 6503 bit_field_ = BaseOffsetField::update(bit_field_, base_offset); |
6499 } | 6504 return true; |
6500 virtual int MaxBaseOffsetBits() { | |
6501 return kBitsForBaseOffset; | |
6502 } | 6505 } |
6503 HValue* GetKey() { return key(); } | 6506 HValue* GetKey() { return key(); } |
6504 void SetKey(HValue* key) { SetOperandAt(1, key); } | 6507 void SetKey(HValue* key) { SetOperandAt(1, key); } |
6505 bool IsDehoisted() { return IsDehoistedField::decode(bit_field_); } | 6508 bool IsDehoisted() { return IsDehoistedField::decode(bit_field_); } |
6506 void SetDehoisted(bool is_dehoisted) { | 6509 void SetDehoisted(bool is_dehoisted) { |
6507 bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted); | 6510 bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted); |
6508 } | 6511 } |
6509 virtual ElementsKind elements_kind() const V8_OVERRIDE { | 6512 virtual ElementsKind elements_kind() const V8_OVERRIDE { |
6510 return ElementsKindField::decode(bit_field_); | 6513 return ElementsKindField::decode(bit_field_); |
6511 } | 6514 } |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6956 | 6959 |
6957 HValue* elements() const { return OperandAt(0); } | 6960 HValue* elements() const { return OperandAt(0); } |
6958 HValue* key() const { return OperandAt(1); } | 6961 HValue* key() const { return OperandAt(1); } |
6959 HValue* value() const { return OperandAt(2); } | 6962 HValue* value() const { return OperandAt(2); } |
6960 bool value_is_smi() const { | 6963 bool value_is_smi() const { |
6961 return IsFastSmiElementsKind(elements_kind_); | 6964 return IsFastSmiElementsKind(elements_kind_); |
6962 } | 6965 } |
6963 StoreFieldOrKeyedMode store_mode() const { return store_mode_; } | 6966 StoreFieldOrKeyedMode store_mode() const { return store_mode_; } |
6964 ElementsKind elements_kind() const { return elements_kind_; } | 6967 ElementsKind elements_kind() const { return elements_kind_; } |
6965 uint32_t base_offset() { return base_offset_; } | 6968 uint32_t base_offset() { return base_offset_; } |
6966 void IncreaseBaseOffset(uint32_t base_offset) { | 6969 bool TryIncreaseBaseOffset(uint32_t increase_by_value) { |
6967 // The base offset is usually simply the size of the array header, except | 6970 // The base offset is usually simply the size of the array header, except |
6968 // with dehoisting adds an addition offset due to a array index key | 6971 // with dehoisting adds an addition offset due to a array index key |
6969 // manipulation, in which case it becomes (array header size + | 6972 // manipulation, in which case it becomes (array header size + |
6970 // constant-offset-from-key * kPointerSize) | 6973 // constant-offset-from-key * kPointerSize) |
6971 base_offset_ += base_offset; | 6974 if (AdditionOverflows(base_offset_, increase_by_value)) return false; |
6972 } | 6975 base_offset_ += increase_by_value; |
6973 virtual int MaxBaseOffsetBits() { | 6976 return true; |
6974 return 31 - ElementsKindToShiftSize(elements_kind_); | |
6975 } | 6977 } |
6976 HValue* GetKey() { return key(); } | 6978 HValue* GetKey() { return key(); } |
6977 void SetKey(HValue* key) { SetOperandAt(1, key); } | 6979 void SetKey(HValue* key) { SetOperandAt(1, key); } |
6978 bool IsDehoisted() { return is_dehoisted_; } | 6980 bool IsDehoisted() { return is_dehoisted_; } |
6979 void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } | 6981 void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } |
6980 bool IsUninitialized() { return is_uninitialized_; } | 6982 bool IsUninitialized() { return is_uninitialized_; } |
6981 void SetUninitialized(bool is_uninitialized) { | 6983 void SetUninitialized(bool is_uninitialized) { |
6982 is_uninitialized_ = is_uninitialized; | 6984 is_uninitialized_ = is_uninitialized; |
6983 } | 6985 } |
6984 | 6986 |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7802 }; | 7804 }; |
7803 | 7805 |
7804 | 7806 |
7805 | 7807 |
7806 #undef DECLARE_INSTRUCTION | 7808 #undef DECLARE_INSTRUCTION |
7807 #undef DECLARE_CONCRETE_INSTRUCTION | 7809 #undef DECLARE_CONCRETE_INSTRUCTION |
7808 | 7810 |
7809 } } // namespace v8::internal | 7811 } } // namespace v8::internal |
7810 | 7812 |
7811 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 7813 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |