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 6381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6392 SetFlag(kUseGVN); | 6392 SetFlag(kUseGVN); |
6393 SetDependsOnFlag(kCalls); | 6393 SetDependsOnFlag(kCalls); |
6394 } | 6394 } |
6395 }; | 6395 }; |
6396 | 6396 |
6397 class ArrayInstructionInterface { | 6397 class ArrayInstructionInterface { |
6398 public: | 6398 public: |
6399 virtual HValue* GetKey() = 0; | 6399 virtual HValue* GetKey() = 0; |
6400 virtual void SetKey(HValue* key) = 0; | 6400 virtual void SetKey(HValue* key) = 0; |
6401 virtual ElementsKind elements_kind() const = 0; | 6401 virtual ElementsKind elements_kind() const = 0; |
6402 virtual void IncreaseBaseOffset(uint32_t base_offset) = 0; | 6402 // increase_by_value should be non-negative |
6403 virtual int MaxBaseOffsetBits() = 0; | 6403 virtual bool CanIncreaseBaseOffset(int32_t increase_by_value) = 0; |
| 6404 virtual void IncreaseBaseOffset(int32_t increase_by_value) = 0; |
6404 virtual bool IsDehoisted() = 0; | 6405 virtual bool IsDehoisted() = 0; |
6405 virtual void SetDehoisted(bool is_dehoisted) = 0; | 6406 virtual void SetDehoisted(bool is_dehoisted) = 0; |
6406 virtual ~ArrayInstructionInterface() { } | 6407 virtual ~ArrayInstructionInterface() { } |
6407 | 6408 |
6408 static Representation KeyedAccessIndexRequirement(Representation r) { | 6409 static Representation KeyedAccessIndexRequirement(Representation r) { |
6409 return r.IsInteger32() || SmiValuesAre32Bits() | 6410 return r.IsInteger32() || SmiValuesAre32Bits() |
6410 ? Representation::Integer32() : Representation::Smi(); | 6411 ? Representation::Integer32() : Representation::Smi(); |
6411 } | 6412 } |
6412 }; | 6413 }; |
6413 | 6414 |
(...skipping 25 matching lines...) Expand all Loading... |
6439 bool is_typed_elements() const { | 6440 bool is_typed_elements() const { |
6440 return is_external() || is_fixed_typed_array(); | 6441 return is_external() || is_fixed_typed_array(); |
6441 } | 6442 } |
6442 HValue* elements() { return OperandAt(0); } | 6443 HValue* elements() { return OperandAt(0); } |
6443 HValue* key() { return OperandAt(1); } | 6444 HValue* key() { return OperandAt(1); } |
6444 HValue* dependency() { | 6445 HValue* dependency() { |
6445 ASSERT(HasDependency()); | 6446 ASSERT(HasDependency()); |
6446 return OperandAt(2); | 6447 return OperandAt(2); |
6447 } | 6448 } |
6448 bool HasDependency() const { return OperandAt(0) != OperandAt(2); } | 6449 bool HasDependency() const { return OperandAt(0) != OperandAt(2); } |
6449 uint32_t base_offset() { return BaseOffsetField::decode(bit_field_); } | 6450 uint32_t base_offset() { |
6450 void IncreaseBaseOffset(uint32_t base_offset) { | 6451 int32_t base_offset_value = BaseOffsetField::decode(bit_field_); |
6451 base_offset += BaseOffsetField::decode(bit_field_); | 6452 ASSERT(base_offset_value >= 0); |
6452 bit_field_ = BaseOffsetField::update(bit_field_, base_offset); | 6453 return static_cast<uint32_t>(base_offset_value); |
6453 } | 6454 } |
6454 virtual int MaxBaseOffsetBits() { | 6455 bool CanIncreaseBaseOffset(int32_t increase_by_value) { |
6455 return kBitsForBaseOffset; | 6456 ASSERT(increase_by_value >= 0); |
| 6457 int32_t new_value = BaseOffsetField::decode(bit_field_) + increase_by_value; |
| 6458 return (new_value >= 0 || BaseOffsetField::is_valid(new_value)); |
| 6459 } |
| 6460 void IncreaseBaseOffset(int32_t increase_by_value) { |
| 6461 ASSERT(increase_by_value >= 0); |
| 6462 increase_by_value += BaseOffsetField::decode(bit_field_); |
| 6463 bit_field_ = BaseOffsetField::update(bit_field_, increase_by_value); |
6456 } | 6464 } |
6457 HValue* GetKey() { return key(); } | 6465 HValue* GetKey() { return key(); } |
6458 void SetKey(HValue* key) { SetOperandAt(1, key); } | 6466 void SetKey(HValue* key) { SetOperandAt(1, key); } |
6459 bool IsDehoisted() { return IsDehoistedField::decode(bit_field_); } | 6467 bool IsDehoisted() { return IsDehoistedField::decode(bit_field_); } |
6460 void SetDehoisted(bool is_dehoisted) { | 6468 void SetDehoisted(bool is_dehoisted) { |
6461 bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted); | 6469 bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted); |
6462 } | 6470 } |
6463 ElementsKind elements_kind() const { | 6471 ElementsKind elements_kind() const { |
6464 return ElementsKindField::decode(bit_field_); | 6472 return ElementsKindField::decode(bit_field_); |
6465 } | 6473 } |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6595 STATIC_ASSERT((kBitsForElementsKind + kBitsForBaseOffset + | 6603 STATIC_ASSERT((kBitsForElementsKind + kBitsForBaseOffset + |
6596 kBitsForIsDehoisted) <= sizeof(uint32_t)*8); | 6604 kBitsForIsDehoisted) <= sizeof(uint32_t)*8); |
6597 STATIC_ASSERT(kElementsKindCount <= (1 << kBitsForElementsKind)); | 6605 STATIC_ASSERT(kElementsKindCount <= (1 << kBitsForElementsKind)); |
6598 class ElementsKindField: | 6606 class ElementsKindField: |
6599 public BitField<ElementsKind, kStartElementsKind, kBitsForElementsKind> | 6607 public BitField<ElementsKind, kStartElementsKind, kBitsForElementsKind> |
6600 {}; // NOLINT | 6608 {}; // NOLINT |
6601 class HoleModeField: | 6609 class HoleModeField: |
6602 public BitField<LoadKeyedHoleMode, kStartHoleMode, kBitsForHoleMode> | 6610 public BitField<LoadKeyedHoleMode, kStartHoleMode, kBitsForHoleMode> |
6603 {}; // NOLINT | 6611 {}; // NOLINT |
6604 class BaseOffsetField: | 6612 class BaseOffsetField: |
6605 public BitField<uint32_t, kStartBaseOffset, kBitsForBaseOffset> | 6613 public BitField<int32_t, kStartBaseOffset, kBitsForBaseOffset> |
6606 {}; // NOLINT | 6614 {}; // NOLINT |
6607 class IsDehoistedField: | 6615 class IsDehoistedField: |
6608 public BitField<bool, kStartIsDehoisted, kBitsForIsDehoisted> | 6616 public BitField<bool, kStartIsDehoisted, kBitsForIsDehoisted> |
6609 {}; // NOLINT | 6617 {}; // NOLINT |
6610 uint32_t bit_field_; | 6618 uint32_t bit_field_; |
6611 }; | 6619 }; |
6612 | 6620 |
6613 | 6621 |
6614 class HLoadKeyedGeneric V8_FINAL : public HTemplateInstruction<3> { | 6622 class HLoadKeyedGeneric V8_FINAL : public HTemplateInstruction<3> { |
6615 public: | 6623 public: |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6909 } | 6917 } |
6910 | 6918 |
6911 HValue* elements() const { return OperandAt(0); } | 6919 HValue* elements() const { return OperandAt(0); } |
6912 HValue* key() const { return OperandAt(1); } | 6920 HValue* key() const { return OperandAt(1); } |
6913 HValue* value() const { return OperandAt(2); } | 6921 HValue* value() const { return OperandAt(2); } |
6914 bool value_is_smi() const { | 6922 bool value_is_smi() const { |
6915 return IsFastSmiElementsKind(elements_kind_); | 6923 return IsFastSmiElementsKind(elements_kind_); |
6916 } | 6924 } |
6917 StoreFieldOrKeyedMode store_mode() const { return store_mode_; } | 6925 StoreFieldOrKeyedMode store_mode() const { return store_mode_; } |
6918 ElementsKind elements_kind() const { return elements_kind_; } | 6926 ElementsKind elements_kind() const { return elements_kind_; } |
6919 uint32_t base_offset() { return base_offset_; } | 6927 uint32_t base_offset() { |
6920 void IncreaseBaseOffset(uint32_t base_offset) { | 6928 ASSERT(base_offset_ >= 0); |
6921 base_offset_ += base_offset; | 6929 return static_cast<uint32_t>(base_offset_); |
6922 } | 6930 } |
6923 virtual int MaxBaseOffsetBits() { | 6931 bool CanIncreaseBaseOffset(int32_t increase_by_value) { |
6924 return 31 - ElementsKindToShiftSize(elements_kind_); | 6932 ASSERT(increase_by_value >= 0); |
| 6933 // Guard against overflow |
| 6934 return (increase_by_value + base_offset_) >= 0; |
| 6935 } |
| 6936 void IncreaseBaseOffset(int32_t increase_by_value) { |
| 6937 ASSERT(increase_by_value >= 0); |
| 6938 base_offset_ += increase_by_value; |
6925 } | 6939 } |
6926 HValue* GetKey() { return key(); } | 6940 HValue* GetKey() { return key(); } |
6927 void SetKey(HValue* key) { SetOperandAt(1, key); } | 6941 void SetKey(HValue* key) { SetOperandAt(1, key); } |
6928 bool IsDehoisted() { return is_dehoisted_; } | 6942 bool IsDehoisted() { return is_dehoisted_; } |
6929 void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } | 6943 void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } |
6930 bool IsUninitialized() { return is_uninitialized_; } | 6944 bool IsUninitialized() { return is_uninitialized_; } |
6931 void SetUninitialized(bool is_uninitialized) { | 6945 void SetUninitialized(bool is_uninitialized) { |
6932 is_uninitialized_ = is_uninitialized; | 6946 is_uninitialized_ = is_uninitialized; |
6933 } | 6947 } |
6934 | 6948 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7005 // EXTERNAL_{UNSIGNED_,}{BYTE,SHORT,INT}_ELEMENTS are truncating. | 7019 // EXTERNAL_{UNSIGNED_,}{BYTE,SHORT,INT}_ELEMENTS are truncating. |
7006 if ((elements_kind >= EXTERNAL_INT8_ELEMENTS && | 7020 if ((elements_kind >= EXTERNAL_INT8_ELEMENTS && |
7007 elements_kind <= EXTERNAL_UINT32_ELEMENTS) || | 7021 elements_kind <= EXTERNAL_UINT32_ELEMENTS) || |
7008 (elements_kind >= UINT8_ELEMENTS && | 7022 (elements_kind >= UINT8_ELEMENTS && |
7009 elements_kind <= INT32_ELEMENTS)) { | 7023 elements_kind <= INT32_ELEMENTS)) { |
7010 SetFlag(kTruncatingToInt32); | 7024 SetFlag(kTruncatingToInt32); |
7011 } | 7025 } |
7012 } | 7026 } |
7013 | 7027 |
7014 ElementsKind elements_kind_; | 7028 ElementsKind elements_kind_; |
7015 uint32_t base_offset_; | 7029 int32_t base_offset_; |
7016 bool is_dehoisted_ : 1; | 7030 bool is_dehoisted_ : 1; |
7017 bool is_uninitialized_ : 1; | 7031 bool is_uninitialized_ : 1; |
7018 StoreFieldOrKeyedMode store_mode_: 1; | 7032 StoreFieldOrKeyedMode store_mode_: 1; |
7019 HValue* dominator_; | 7033 HValue* dominator_; |
7020 }; | 7034 }; |
7021 | 7035 |
7022 | 7036 |
7023 class HStoreKeyedGeneric V8_FINAL : public HTemplateInstruction<4> { | 7037 class HStoreKeyedGeneric V8_FINAL : public HTemplateInstruction<4> { |
7024 public: | 7038 public: |
7025 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HStoreKeyedGeneric, HValue*, | 7039 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HStoreKeyedGeneric, HValue*, |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7701 virtual bool IsDeletable() const V8_OVERRIDE { return true; } | 7715 virtual bool IsDeletable() const V8_OVERRIDE { return true; } |
7702 }; | 7716 }; |
7703 | 7717 |
7704 | 7718 |
7705 #undef DECLARE_INSTRUCTION | 7719 #undef DECLARE_INSTRUCTION |
7706 #undef DECLARE_CONCRETE_INSTRUCTION | 7720 #undef DECLARE_CONCRETE_INSTRUCTION |
7707 | 7721 |
7708 } } // namespace v8::internal | 7722 } } // namespace v8::internal |
7709 | 7723 |
7710 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 7724 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |