Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: src/hydrogen-instructions.h

Issue 1100083002: Don't MISS if you read the hole from certain FastHoley arrays. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: With ports and test. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 6438 matching lines...) Expand 10 before | Expand all | Expand 10 after
6449 return r.IsInteger32() || SmiValuesAre32Bits() 6449 return r.IsInteger32() || SmiValuesAre32Bits()
6450 ? Representation::Integer32() : Representation::Smi(); 6450 ? Representation::Integer32() : Representation::Smi();
6451 } 6451 }
6452 }; 6452 };
6453 6453
6454 6454
6455 static const int kDefaultKeyedHeaderOffsetSentinel = -1; 6455 static const int kDefaultKeyedHeaderOffsetSentinel = -1;
6456 6456
6457 enum LoadKeyedHoleMode { 6457 enum LoadKeyedHoleMode {
6458 NEVER_RETURN_HOLE, 6458 NEVER_RETURN_HOLE,
6459 ALLOW_RETURN_HOLE 6459 ALLOW_RETURN_HOLE,
6460 CONVERT_HOLE_TO_UNDEFINED
6460 }; 6461 };
6461 6462
6462 6463
6463 class HLoadKeyed final : public HTemplateInstruction<3>, 6464 class HLoadKeyed final : public HTemplateInstruction<3>,
6464 public ArrayInstructionInterface { 6465 public ArrayInstructionInterface {
6465 public: 6466 public:
6466 DECLARE_INSTRUCTION_FACTORY_P4(HLoadKeyed, HValue*, HValue*, HValue*, 6467 DECLARE_INSTRUCTION_FACTORY_P4(HLoadKeyed, HValue*, HValue*, HValue*,
6467 ElementsKind); 6468 ElementsKind);
6468 DECLARE_INSTRUCTION_FACTORY_P5(HLoadKeyed, HValue*, HValue*, HValue*, 6469 DECLARE_INSTRUCTION_FACTORY_P5(HLoadKeyed, HValue*, HValue*, HValue*,
6469 ElementsKind, LoadKeyedHoleMode); 6470 ElementsKind, LoadKeyedHoleMode);
(...skipping 13 matching lines...) Expand all
6483 HValue* key() const { return OperandAt(1); } 6484 HValue* key() const { return OperandAt(1); }
6484 HValue* dependency() const { 6485 HValue* dependency() const {
6485 DCHECK(HasDependency()); 6486 DCHECK(HasDependency());
6486 return OperandAt(2); 6487 return OperandAt(2);
6487 } 6488 }
6488 bool HasDependency() const { return OperandAt(0) != OperandAt(2); } 6489 bool HasDependency() const { return OperandAt(0) != OperandAt(2); }
6489 uint32_t base_offset() const { return BaseOffsetField::decode(bit_field_); } 6490 uint32_t base_offset() const { return BaseOffsetField::decode(bit_field_); }
6490 bool TryIncreaseBaseOffset(uint32_t increase_by_value) override; 6491 bool TryIncreaseBaseOffset(uint32_t increase_by_value) override;
6491 HValue* GetKey() override { return key(); } 6492 HValue* GetKey() override { return key(); }
6492 void SetKey(HValue* key) override { SetOperandAt(1, key); } 6493 void SetKey(HValue* key) override { SetOperandAt(1, key); }
6493 bool IsDehoisted() const override { 6494 bool IsDehoisted() const override { return dehoisted_; }
6494 return IsDehoistedField::decode(bit_field_); 6495 void SetDehoisted(bool is_dehoisted) override { dehoisted_ = is_dehoisted; }
6495 }
6496 void SetDehoisted(bool is_dehoisted) override {
6497 bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted);
6498 }
6499 ElementsKind elements_kind() const override { 6496 ElementsKind elements_kind() const override {
6500 return ElementsKindField::decode(bit_field_); 6497 return ElementsKindField::decode(bit_field_);
6501 } 6498 }
6502 LoadKeyedHoleMode hole_mode() const { 6499 LoadKeyedHoleMode hole_mode() const {
6503 return HoleModeField::decode(bit_field_); 6500 return HoleModeField::decode(bit_field_);
6504 } 6501 }
6505 6502
6506 Representation RequiredInputRepresentation(int index) override { 6503 Representation RequiredInputRepresentation(int index) override {
6507 // kind_fast: tagged[int32] (none) 6504 // kind_fast: tagged[int32] (none)
6508 // kind_double: tagged[int32] (none) 6505 // kind_double: tagged[int32] (none)
(...skipping 27 matching lines...) Expand all
6536 protected: 6533 protected:
6537 bool DataEquals(HValue* other) override { 6534 bool DataEquals(HValue* other) override {
6538 if (!other->IsLoadKeyed()) return false; 6535 if (!other->IsLoadKeyed()) return false;
6539 HLoadKeyed* other_load = HLoadKeyed::cast(other); 6536 HLoadKeyed* other_load = HLoadKeyed::cast(other);
6540 6537
6541 if (base_offset() != other_load->base_offset()) return false; 6538 if (base_offset() != other_load->base_offset()) return false;
6542 return elements_kind() == other_load->elements_kind(); 6539 return elements_kind() == other_load->elements_kind();
6543 } 6540 }
6544 6541
6545 private: 6542 private:
6546 HLoadKeyed(HValue* obj, 6543 HLoadKeyed(HValue* obj, HValue* key, HValue* dependency,
6547 HValue* key,
6548 HValue* dependency,
6549 ElementsKind elements_kind, 6544 ElementsKind elements_kind,
6550 LoadKeyedHoleMode mode = NEVER_RETURN_HOLE, 6545 LoadKeyedHoleMode mode = NEVER_RETURN_HOLE,
6551 int offset = kDefaultKeyedHeaderOffsetSentinel) 6546 int offset = kDefaultKeyedHeaderOffsetSentinel)
6552 : bit_field_(0) { 6547 : bit_field_(0), dehoisted_(false) {
6553 offset = offset == kDefaultKeyedHeaderOffsetSentinel 6548 offset = offset == kDefaultKeyedHeaderOffsetSentinel
6554 ? GetDefaultHeaderSizeForElementsKind(elements_kind) 6549 ? GetDefaultHeaderSizeForElementsKind(elements_kind)
6555 : offset; 6550 : offset;
6556 bit_field_ = ElementsKindField::encode(elements_kind) | 6551 bit_field_ = ElementsKindField::encode(elements_kind) |
6557 HoleModeField::encode(mode) | 6552 HoleModeField::encode(mode) |
6558 BaseOffsetField::encode(offset); 6553 BaseOffsetField::encode(offset);
6559 6554
6560 SetOperandAt(0, obj); 6555 SetOperandAt(0, obj);
6561 SetOperandAt(1, key); 6556 SetOperandAt(1, key);
6562 SetOperandAt(2, dependency != NULL ? dependency : obj); 6557 SetOperandAt(2, dependency != NULL ? dependency : obj);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
6608 } 6603 }
6609 6604
6610 SetFlag(kUseGVN); 6605 SetFlag(kUseGVN);
6611 } 6606 }
6612 6607
6613 bool IsDeletable() const override { return !RequiresHoleCheck(); } 6608 bool IsDeletable() const override { return !RequiresHoleCheck(); }
6614 6609
6615 // Establish some checks around our packed fields 6610 // Establish some checks around our packed fields
6616 enum LoadKeyedBits { 6611 enum LoadKeyedBits {
6617 kBitsForElementsKind = 5, 6612 kBitsForElementsKind = 5,
6618 kBitsForHoleMode = 1, 6613 kBitsForHoleMode = 2,
6619 kBitsForBaseOffset = 25, 6614 kBitsForBaseOffset = 25,
Jakob Kummerow 2015/04/23 13:40:00 I think instead of moving |dehoisted| out of this
mvstanton 2015/04/27 07:57:12 Okay, this is done. I was just being cautious (at
6620 kBitsForIsDehoisted = 1,
6621 6615
6622 kStartElementsKind = 0, 6616 kStartElementsKind = 0,
6623 kStartHoleMode = kStartElementsKind + kBitsForElementsKind, 6617 kStartHoleMode = kStartElementsKind + kBitsForElementsKind,
6624 kStartBaseOffset = kStartHoleMode + kBitsForHoleMode, 6618 kStartBaseOffset = kStartHoleMode + kBitsForHoleMode,
6625 kStartIsDehoisted = kStartBaseOffset + kBitsForBaseOffset
6626 }; 6619 };
6627 6620
6628 STATIC_ASSERT((kBitsForElementsKind + kBitsForHoleMode + kBitsForBaseOffset + 6621 STATIC_ASSERT((kBitsForElementsKind + kBitsForHoleMode +
6629 kBitsForIsDehoisted) <= sizeof(uint32_t) * 8); 6622 kBitsForBaseOffset) <= sizeof(uint32_t) * 8);
6630 STATIC_ASSERT(kElementsKindCount <= (1 << kBitsForElementsKind)); 6623 STATIC_ASSERT(kElementsKindCount <= (1 << kBitsForElementsKind));
6631 class ElementsKindField: 6624 class ElementsKindField:
6632 public BitField<ElementsKind, kStartElementsKind, kBitsForElementsKind> 6625 public BitField<ElementsKind, kStartElementsKind, kBitsForElementsKind>
6633 {}; // NOLINT 6626 {}; // NOLINT
6634 class HoleModeField: 6627 class HoleModeField:
6635 public BitField<LoadKeyedHoleMode, kStartHoleMode, kBitsForHoleMode> 6628 public BitField<LoadKeyedHoleMode, kStartHoleMode, kBitsForHoleMode>
6636 {}; // NOLINT 6629 {}; // NOLINT
6637 class BaseOffsetField: 6630 class BaseOffsetField:
6638 public BitField<uint32_t, kStartBaseOffset, kBitsForBaseOffset> 6631 public BitField<uint32_t, kStartBaseOffset, kBitsForBaseOffset>
6639 {}; // NOLINT 6632 {}; // NOLINT
6640 class IsDehoistedField:
6641 public BitField<bool, kStartIsDehoisted, kBitsForIsDehoisted>
6642 {}; // NOLINT
6643 uint32_t bit_field_; 6633 uint32_t bit_field_;
6634 bool dehoisted_;
6644 }; 6635 };
6645 6636
6646 6637
6647 class HLoadKeyedGeneric final : public HTemplateInstruction<3> { 6638 class HLoadKeyedGeneric final : public HTemplateInstruction<3> {
6648 public: 6639 public:
6649 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P3(HLoadKeyedGeneric, HValue*, 6640 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P3(HLoadKeyedGeneric, HValue*,
6650 HValue*, InlineCacheState); 6641 HValue*, InlineCacheState);
6651 HValue* object() const { return OperandAt(0); } 6642 HValue* object() const { return OperandAt(0); }
6652 HValue* key() const { return OperandAt(1); } 6643 HValue* key() const { return OperandAt(1); }
6653 HValue* context() const { return OperandAt(2); } 6644 HValue* context() const { return OperandAt(2); }
(...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after
7819 }; 7810 };
7820 7811
7821 7812
7822 7813
7823 #undef DECLARE_INSTRUCTION 7814 #undef DECLARE_INSTRUCTION
7824 #undef DECLARE_CONCRETE_INSTRUCTION 7815 #undef DECLARE_CONCRETE_INSTRUCTION
7825 7816
7826 } } // namespace v8::internal 7817 } } // namespace v8::internal
7827 7818
7828 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 7819 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698