| 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 <cstring> | 8 #include <cstring> |
| 9 #include <iosfwd> | 9 #include <iosfwd> |
| 10 | 10 |
| (...skipping 6443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6454 return r.IsInteger32() || SmiValuesAre32Bits() | 6454 return r.IsInteger32() || SmiValuesAre32Bits() |
| 6455 ? Representation::Integer32() : Representation::Smi(); | 6455 ? Representation::Integer32() : Representation::Smi(); |
| 6456 } | 6456 } |
| 6457 }; | 6457 }; |
| 6458 | 6458 |
| 6459 | 6459 |
| 6460 static const int kDefaultKeyedHeaderOffsetSentinel = -1; | 6460 static const int kDefaultKeyedHeaderOffsetSentinel = -1; |
| 6461 | 6461 |
| 6462 enum LoadKeyedHoleMode { | 6462 enum LoadKeyedHoleMode { |
| 6463 NEVER_RETURN_HOLE, | 6463 NEVER_RETURN_HOLE, |
| 6464 ALLOW_RETURN_HOLE | 6464 ALLOW_RETURN_HOLE, |
| 6465 CONVERT_HOLE_TO_UNDEFINED |
| 6465 }; | 6466 }; |
| 6466 | 6467 |
| 6467 | 6468 |
| 6468 class HLoadKeyed final : public HTemplateInstruction<3>, | 6469 class HLoadKeyed final : public HTemplateInstruction<3>, |
| 6469 public ArrayInstructionInterface { | 6470 public ArrayInstructionInterface { |
| 6470 public: | 6471 public: |
| 6471 DECLARE_INSTRUCTION_FACTORY_P4(HLoadKeyed, HValue*, HValue*, HValue*, | 6472 DECLARE_INSTRUCTION_FACTORY_P4(HLoadKeyed, HValue*, HValue*, HValue*, |
| 6472 ElementsKind); | 6473 ElementsKind); |
| 6473 DECLARE_INSTRUCTION_FACTORY_P5(HLoadKeyed, HValue*, HValue*, HValue*, | 6474 DECLARE_INSTRUCTION_FACTORY_P5(HLoadKeyed, HValue*, HValue*, HValue*, |
| 6474 ElementsKind, LoadKeyedHoleMode); | 6475 ElementsKind, LoadKeyedHoleMode); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6541 protected: | 6542 protected: |
| 6542 bool DataEquals(HValue* other) override { | 6543 bool DataEquals(HValue* other) override { |
| 6543 if (!other->IsLoadKeyed()) return false; | 6544 if (!other->IsLoadKeyed()) return false; |
| 6544 HLoadKeyed* other_load = HLoadKeyed::cast(other); | 6545 HLoadKeyed* other_load = HLoadKeyed::cast(other); |
| 6545 | 6546 |
| 6546 if (base_offset() != other_load->base_offset()) return false; | 6547 if (base_offset() != other_load->base_offset()) return false; |
| 6547 return elements_kind() == other_load->elements_kind(); | 6548 return elements_kind() == other_load->elements_kind(); |
| 6548 } | 6549 } |
| 6549 | 6550 |
| 6550 private: | 6551 private: |
| 6551 HLoadKeyed(HValue* obj, | 6552 HLoadKeyed(HValue* obj, HValue* key, HValue* dependency, |
| 6552 HValue* key, | |
| 6553 HValue* dependency, | |
| 6554 ElementsKind elements_kind, | 6553 ElementsKind elements_kind, |
| 6555 LoadKeyedHoleMode mode = NEVER_RETURN_HOLE, | 6554 LoadKeyedHoleMode mode = NEVER_RETURN_HOLE, |
| 6556 int offset = kDefaultKeyedHeaderOffsetSentinel) | 6555 int offset = kDefaultKeyedHeaderOffsetSentinel) |
| 6557 : bit_field_(0) { | 6556 : bit_field_(0) { |
| 6558 offset = offset == kDefaultKeyedHeaderOffsetSentinel | 6557 offset = offset == kDefaultKeyedHeaderOffsetSentinel |
| 6559 ? GetDefaultHeaderSizeForElementsKind(elements_kind) | 6558 ? GetDefaultHeaderSizeForElementsKind(elements_kind) |
| 6560 : offset; | 6559 : offset; |
| 6561 bit_field_ = ElementsKindField::encode(elements_kind) | | 6560 bit_field_ = ElementsKindField::encode(elements_kind) | |
| 6562 HoleModeField::encode(mode) | | 6561 HoleModeField::encode(mode) | |
| 6563 BaseOffsetField::encode(offset); | 6562 BaseOffsetField::encode(offset); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6613 } | 6612 } |
| 6614 | 6613 |
| 6615 SetFlag(kUseGVN); | 6614 SetFlag(kUseGVN); |
| 6616 } | 6615 } |
| 6617 | 6616 |
| 6618 bool IsDeletable() const override { return !RequiresHoleCheck(); } | 6617 bool IsDeletable() const override { return !RequiresHoleCheck(); } |
| 6619 | 6618 |
| 6620 // Establish some checks around our packed fields | 6619 // Establish some checks around our packed fields |
| 6621 enum LoadKeyedBits { | 6620 enum LoadKeyedBits { |
| 6622 kBitsForElementsKind = 5, | 6621 kBitsForElementsKind = 5, |
| 6623 kBitsForHoleMode = 1, | 6622 kBitsForHoleMode = 2, |
| 6624 kBitsForBaseOffset = 25, | 6623 kBitsForBaseOffset = 24, |
| 6625 kBitsForIsDehoisted = 1, | 6624 kBitsForIsDehoisted = 1, |
| 6626 | 6625 |
| 6627 kStartElementsKind = 0, | 6626 kStartElementsKind = 0, |
| 6628 kStartHoleMode = kStartElementsKind + kBitsForElementsKind, | 6627 kStartHoleMode = kStartElementsKind + kBitsForElementsKind, |
| 6629 kStartBaseOffset = kStartHoleMode + kBitsForHoleMode, | 6628 kStartBaseOffset = kStartHoleMode + kBitsForHoleMode, |
| 6630 kStartIsDehoisted = kStartBaseOffset + kBitsForBaseOffset | 6629 kStartIsDehoisted = kStartBaseOffset + kBitsForBaseOffset |
| 6631 }; | 6630 }; |
| 6632 | 6631 |
| 6633 STATIC_ASSERT((kBitsForElementsKind + kBitsForHoleMode + kBitsForBaseOffset + | 6632 STATIC_ASSERT((kBitsForElementsKind + kBitsForHoleMode + kBitsForBaseOffset + |
| 6634 kBitsForIsDehoisted) <= sizeof(uint32_t) * 8); | 6633 kBitsForIsDehoisted) <= sizeof(uint32_t) * 8); |
| (...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7824 }; | 7823 }; |
| 7825 | 7824 |
| 7826 | 7825 |
| 7827 | 7826 |
| 7828 #undef DECLARE_INSTRUCTION | 7827 #undef DECLARE_INSTRUCTION |
| 7829 #undef DECLARE_CONCRETE_INSTRUCTION | 7828 #undef DECLARE_CONCRETE_INSTRUCTION |
| 7830 | 7829 |
| 7831 } } // namespace v8::internal | 7830 } } // namespace v8::internal |
| 7832 | 7831 |
| 7833 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 7832 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |