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 6386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6397 SetFlag(kUseGVN); | 6397 SetFlag(kUseGVN); |
6398 SetDependsOnFlag(kCalls); | 6398 SetDependsOnFlag(kCalls); |
6399 } | 6399 } |
6400 }; | 6400 }; |
6401 | 6401 |
6402 class ArrayInstructionInterface { | 6402 class ArrayInstructionInterface { |
6403 public: | 6403 public: |
6404 virtual HValue* GetKey() = 0; | 6404 virtual HValue* GetKey() = 0; |
6405 virtual void SetKey(HValue* key) = 0; | 6405 virtual void SetKey(HValue* key) = 0; |
6406 virtual ElementsKind elements_kind() const = 0; | 6406 virtual ElementsKind elements_kind() const = 0; |
6407 // increase_by_value should be non-negative | 6407 virtual void IncreaseBaseOffset(uint32_t base_offset) = 0; |
6408 virtual bool CanIncreaseBaseOffset(int32_t increase_by_value) = 0; | 6408 virtual int MaxBaseOffsetBits() = 0; |
6409 virtual void IncreaseBaseOffset(int32_t increase_by_value) = 0; | |
6410 virtual bool IsDehoisted() = 0; | 6409 virtual bool IsDehoisted() = 0; |
6411 virtual void SetDehoisted(bool is_dehoisted) = 0; | 6410 virtual void SetDehoisted(bool is_dehoisted) = 0; |
6412 virtual ~ArrayInstructionInterface() { } | 6411 virtual ~ArrayInstructionInterface() { } |
6413 | 6412 |
6414 static Representation KeyedAccessIndexRequirement(Representation r) { | 6413 static Representation KeyedAccessIndexRequirement(Representation r) { |
6415 return r.IsInteger32() || SmiValuesAre32Bits() | 6414 return r.IsInteger32() || SmiValuesAre32Bits() |
6416 ? Representation::Integer32() : Representation::Smi(); | 6415 ? Representation::Integer32() : Representation::Smi(); |
6417 } | 6416 } |
6418 }; | 6417 }; |
6419 | 6418 |
(...skipping 25 matching lines...) Expand all Loading... |
6445 bool is_typed_elements() const { | 6444 bool is_typed_elements() const { |
6446 return is_external() || is_fixed_typed_array(); | 6445 return is_external() || is_fixed_typed_array(); |
6447 } | 6446 } |
6448 HValue* elements() { return OperandAt(0); } | 6447 HValue* elements() { return OperandAt(0); } |
6449 HValue* key() { return OperandAt(1); } | 6448 HValue* key() { return OperandAt(1); } |
6450 HValue* dependency() { | 6449 HValue* dependency() { |
6451 ASSERT(HasDependency()); | 6450 ASSERT(HasDependency()); |
6452 return OperandAt(2); | 6451 return OperandAt(2); |
6453 } | 6452 } |
6454 bool HasDependency() const { return OperandAt(0) != OperandAt(2); } | 6453 bool HasDependency() const { return OperandAt(0) != OperandAt(2); } |
6455 uint32_t base_offset() { | 6454 uint32_t base_offset() { return BaseOffsetField::decode(bit_field_); } |
6456 int32_t base_offset_value = BaseOffsetField::decode(bit_field_); | 6455 void IncreaseBaseOffset(uint32_t base_offset) { |
6457 ASSERT(base_offset_value >= 0); | 6456 base_offset += BaseOffsetField::decode(bit_field_); |
6458 return static_cast<uint32_t>(base_offset_value); | 6457 bit_field_ = BaseOffsetField::update(bit_field_, base_offset); |
6459 } | 6458 } |
6460 bool CanIncreaseBaseOffset(int32_t increase_by_value) { | 6459 virtual int MaxBaseOffsetBits() { |
6461 ASSERT(increase_by_value >= 0); | 6460 return kBitsForBaseOffset; |
6462 int32_t new_value = BaseOffsetField::decode(bit_field_) + increase_by_value; | |
6463 return (new_value >= 0 && BaseOffsetField::is_valid(new_value)); | |
6464 } | |
6465 void IncreaseBaseOffset(int32_t increase_by_value) { | |
6466 ASSERT(increase_by_value >= 0); | |
6467 increase_by_value += BaseOffsetField::decode(bit_field_); | |
6468 bit_field_ = BaseOffsetField::update(bit_field_, increase_by_value); | |
6469 } | 6461 } |
6470 HValue* GetKey() { return key(); } | 6462 HValue* GetKey() { return key(); } |
6471 void SetKey(HValue* key) { SetOperandAt(1, key); } | 6463 void SetKey(HValue* key) { SetOperandAt(1, key); } |
6472 bool IsDehoisted() { return IsDehoistedField::decode(bit_field_); } | 6464 bool IsDehoisted() { return IsDehoistedField::decode(bit_field_); } |
6473 void SetDehoisted(bool is_dehoisted) { | 6465 void SetDehoisted(bool is_dehoisted) { |
6474 bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted); | 6466 bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted); |
6475 } | 6467 } |
6476 ElementsKind elements_kind() const { | 6468 ElementsKind elements_kind() const { |
6477 return ElementsKindField::decode(bit_field_); | 6469 return ElementsKindField::decode(bit_field_); |
6478 } | 6470 } |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6608 STATIC_ASSERT((kBitsForElementsKind + kBitsForBaseOffset + | 6600 STATIC_ASSERT((kBitsForElementsKind + kBitsForBaseOffset + |
6609 kBitsForIsDehoisted) <= sizeof(uint32_t)*8); | 6601 kBitsForIsDehoisted) <= sizeof(uint32_t)*8); |
6610 STATIC_ASSERT(kElementsKindCount <= (1 << kBitsForElementsKind)); | 6602 STATIC_ASSERT(kElementsKindCount <= (1 << kBitsForElementsKind)); |
6611 class ElementsKindField: | 6603 class ElementsKindField: |
6612 public BitField<ElementsKind, kStartElementsKind, kBitsForElementsKind> | 6604 public BitField<ElementsKind, kStartElementsKind, kBitsForElementsKind> |
6613 {}; // NOLINT | 6605 {}; // NOLINT |
6614 class HoleModeField: | 6606 class HoleModeField: |
6615 public BitField<LoadKeyedHoleMode, kStartHoleMode, kBitsForHoleMode> | 6607 public BitField<LoadKeyedHoleMode, kStartHoleMode, kBitsForHoleMode> |
6616 {}; // NOLINT | 6608 {}; // NOLINT |
6617 class BaseOffsetField: | 6609 class BaseOffsetField: |
6618 public BitField<int32_t, kStartBaseOffset, kBitsForBaseOffset> | 6610 public BitField<uint32_t, kStartBaseOffset, kBitsForBaseOffset> |
6619 {}; // NOLINT | 6611 {}; // NOLINT |
6620 class IsDehoistedField: | 6612 class IsDehoistedField: |
6621 public BitField<bool, kStartIsDehoisted, kBitsForIsDehoisted> | 6613 public BitField<bool, kStartIsDehoisted, kBitsForIsDehoisted> |
6622 {}; // NOLINT | 6614 {}; // NOLINT |
6623 uint32_t bit_field_; | 6615 uint32_t bit_field_; |
6624 }; | 6616 }; |
6625 | 6617 |
6626 | 6618 |
6627 class HLoadKeyedGeneric V8_FINAL : public HTemplateInstruction<3> { | 6619 class HLoadKeyedGeneric V8_FINAL : public HTemplateInstruction<3> { |
6628 public: | 6620 public: |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6922 } | 6914 } |
6923 | 6915 |
6924 HValue* elements() const { return OperandAt(0); } | 6916 HValue* elements() const { return OperandAt(0); } |
6925 HValue* key() const { return OperandAt(1); } | 6917 HValue* key() const { return OperandAt(1); } |
6926 HValue* value() const { return OperandAt(2); } | 6918 HValue* value() const { return OperandAt(2); } |
6927 bool value_is_smi() const { | 6919 bool value_is_smi() const { |
6928 return IsFastSmiElementsKind(elements_kind_); | 6920 return IsFastSmiElementsKind(elements_kind_); |
6929 } | 6921 } |
6930 StoreFieldOrKeyedMode store_mode() const { return store_mode_; } | 6922 StoreFieldOrKeyedMode store_mode() const { return store_mode_; } |
6931 ElementsKind elements_kind() const { return elements_kind_; } | 6923 ElementsKind elements_kind() const { return elements_kind_; } |
6932 uint32_t base_offset() { | 6924 uint32_t base_offset() { return base_offset_; } |
6933 ASSERT(base_offset_ >= 0); | 6925 void IncreaseBaseOffset(uint32_t base_offset) { |
6934 return static_cast<uint32_t>(base_offset_); | 6926 base_offset_ += base_offset; |
6935 } | 6927 } |
6936 bool CanIncreaseBaseOffset(int32_t increase_by_value) { | 6928 virtual int MaxBaseOffsetBits() { |
6937 ASSERT(increase_by_value >= 0); | 6929 return 31 - ElementsKindToShiftSize(elements_kind_); |
6938 // Guard against overflow | |
6939 return (increase_by_value + base_offset_) >= 0; | |
6940 } | |
6941 void IncreaseBaseOffset(int32_t increase_by_value) { | |
6942 ASSERT(increase_by_value >= 0); | |
6943 base_offset_ += increase_by_value; | |
6944 } | 6930 } |
6945 HValue* GetKey() { return key(); } | 6931 HValue* GetKey() { return key(); } |
6946 void SetKey(HValue* key) { SetOperandAt(1, key); } | 6932 void SetKey(HValue* key) { SetOperandAt(1, key); } |
6947 bool IsDehoisted() { return is_dehoisted_; } | 6933 bool IsDehoisted() { return is_dehoisted_; } |
6948 void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } | 6934 void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } |
6949 bool IsUninitialized() { return is_uninitialized_; } | 6935 bool IsUninitialized() { return is_uninitialized_; } |
6950 void SetUninitialized(bool is_uninitialized) { | 6936 void SetUninitialized(bool is_uninitialized) { |
6951 is_uninitialized_ = is_uninitialized; | 6937 is_uninitialized_ = is_uninitialized; |
6952 } | 6938 } |
6953 | 6939 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7024 // EXTERNAL_{UNSIGNED_,}{BYTE,SHORT,INT}_ELEMENTS are truncating. | 7010 // EXTERNAL_{UNSIGNED_,}{BYTE,SHORT,INT}_ELEMENTS are truncating. |
7025 if ((elements_kind >= EXTERNAL_INT8_ELEMENTS && | 7011 if ((elements_kind >= EXTERNAL_INT8_ELEMENTS && |
7026 elements_kind <= EXTERNAL_UINT32_ELEMENTS) || | 7012 elements_kind <= EXTERNAL_UINT32_ELEMENTS) || |
7027 (elements_kind >= UINT8_ELEMENTS && | 7013 (elements_kind >= UINT8_ELEMENTS && |
7028 elements_kind <= INT32_ELEMENTS)) { | 7014 elements_kind <= INT32_ELEMENTS)) { |
7029 SetFlag(kTruncatingToInt32); | 7015 SetFlag(kTruncatingToInt32); |
7030 } | 7016 } |
7031 } | 7017 } |
7032 | 7018 |
7033 ElementsKind elements_kind_; | 7019 ElementsKind elements_kind_; |
7034 int32_t base_offset_; | 7020 uint32_t base_offset_; |
7035 bool is_dehoisted_ : 1; | 7021 bool is_dehoisted_ : 1; |
7036 bool is_uninitialized_ : 1; | 7022 bool is_uninitialized_ : 1; |
7037 StoreFieldOrKeyedMode store_mode_: 1; | 7023 StoreFieldOrKeyedMode store_mode_: 1; |
7038 HValue* dominator_; | 7024 HValue* dominator_; |
7039 }; | 7025 }; |
7040 | 7026 |
7041 | 7027 |
7042 class HStoreKeyedGeneric V8_FINAL : public HTemplateInstruction<4> { | 7028 class HStoreKeyedGeneric V8_FINAL : public HTemplateInstruction<4> { |
7043 public: | 7029 public: |
7044 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HStoreKeyedGeneric, HValue*, | 7030 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HStoreKeyedGeneric, HValue*, |
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7771 }; | 7757 }; |
7772 | 7758 |
7773 | 7759 |
7774 | 7760 |
7775 #undef DECLARE_INSTRUCTION | 7761 #undef DECLARE_INSTRUCTION |
7776 #undef DECLARE_CONCRETE_INSTRUCTION | 7762 #undef DECLARE_CONCRETE_INSTRUCTION |
7777 | 7763 |
7778 } } // namespace v8::internal | 7764 } } // namespace v8::internal |
7779 | 7765 |
7780 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 7766 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |