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