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

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

Issue 295743002: Refactor transitioning stores. (Closed) Base URL: git@github.com:v8/v8.git@master
Patch Set: Created 6 years, 7 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
« no previous file with comments | « src/hydrogen-escape-analysis.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "v8.h" 8 #include "v8.h"
9 9
10 #include "allocation.h" 10 #include "allocation.h"
(...skipping 6638 matching lines...) Expand 10 before | Expand all | Expand 10 after
6649 // initialized or not. 6649 // initialized or not.
6650 enum StoreFieldOrKeyedMode { 6650 enum StoreFieldOrKeyedMode {
6651 // The entry could be either previously initialized or not. 6651 // The entry could be either previously initialized or not.
6652 INITIALIZING_STORE, 6652 INITIALIZING_STORE,
6653 // At the time of this store it is guaranteed that the entry is already 6653 // At the time of this store it is guaranteed that the entry is already
6654 // initialized. 6654 // initialized.
6655 STORE_TO_INITIALIZED_ENTRY 6655 STORE_TO_INITIALIZED_ENTRY
6656 }; 6656 };
6657 6657
6658 6658
6659 class HStoreNamedField V8_FINAL : public HTemplateInstruction<3> { 6659 class HStoreNamedField V8_FINAL : public HTemplateInstruction<2> {
6660 public: 6660 public:
6661 DECLARE_INSTRUCTION_FACTORY_P3(HStoreNamedField, HValue*, 6661 DECLARE_INSTRUCTION_FACTORY_P3(HStoreNamedField, HValue*,
6662 HObjectAccess, HValue*); 6662 HObjectAccess, HValue*);
6663 DECLARE_INSTRUCTION_FACTORY_P4(HStoreNamedField, HValue*, 6663 DECLARE_INSTRUCTION_FACTORY_P4(HStoreNamedField, HValue*,
6664 HObjectAccess, HValue*, StoreFieldOrKeyedMode); 6664 HObjectAccess, HValue*, StoreFieldOrKeyedMode);
6665 6665
6666 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField) 6666 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField)
6667 6667
6668 virtual bool HasEscapingOperandAt(int index) V8_OVERRIDE { 6668 virtual bool HasEscapingOperandAt(int index) V8_OVERRIDE {
6669 return index == 1; 6669 return index == 1;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
6704 } 6704 }
6705 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; 6705 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
6706 6706
6707 void SkipWriteBarrier() { write_barrier_mode_ = SKIP_WRITE_BARRIER; } 6707 void SkipWriteBarrier() { write_barrier_mode_ = SKIP_WRITE_BARRIER; }
6708 bool IsSkipWriteBarrier() const { 6708 bool IsSkipWriteBarrier() const {
6709 return write_barrier_mode_ == SKIP_WRITE_BARRIER; 6709 return write_barrier_mode_ == SKIP_WRITE_BARRIER;
6710 } 6710 }
6711 6711
6712 HValue* object() const { return OperandAt(0); } 6712 HValue* object() const { return OperandAt(0); }
6713 HValue* value() const { return OperandAt(1); } 6713 HValue* value() const { return OperandAt(1); }
6714 HValue* transition() const { return OperandAt(2); }
6715 6714
6716 HObjectAccess access() const { return access_; } 6715 HObjectAccess access() const { return access_; }
6717 HValue* new_space_dominator() const { return new_space_dominator_; } 6716 HValue* new_space_dominator() const { return new_space_dominator_; }
6718 bool has_transition() const { return has_transition_; }
6719 StoreFieldOrKeyedMode store_mode() const { return store_mode_; } 6717 StoreFieldOrKeyedMode store_mode() const { return store_mode_; }
6720 6718
6721 Handle<Map> transition_map() const {
6722 if (has_transition()) {
6723 return Handle<Map>::cast(
6724 HConstant::cast(transition())->handle(Isolate::Current()));
6725 } else {
6726 return Handle<Map>();
6727 }
6728 }
6729
6730 void SetTransition(HConstant* transition) {
6731 ASSERT(!has_transition()); // Only set once.
6732 SetOperandAt(2, transition);
6733 has_transition_ = true;
6734 }
6735
6736 bool NeedsWriteBarrier() { 6719 bool NeedsWriteBarrier() {
6737 ASSERT(!field_representation().IsDouble() || !has_transition());
6738 if (IsSkipWriteBarrier()) return false; 6720 if (IsSkipWriteBarrier()) return false;
6739 if (field_representation().IsDouble()) return false; 6721 if (field_representation().IsDouble()) return false;
6740 if (field_representation().IsSmi()) return false; 6722 if (field_representation().IsSmi()) return false;
6741 if (field_representation().IsInteger32()) return false; 6723 if (field_representation().IsInteger32()) return false;
6742 if (field_representation().IsExternal()) return false; 6724 if (field_representation().IsExternal()) return false;
6743 return StoringValueNeedsWriteBarrier(value()) && 6725 return StoringValueNeedsWriteBarrier(value()) &&
6744 ReceiverObjectNeedsWriteBarrier(object(), value(), 6726 ReceiverObjectNeedsWriteBarrier(object(), value(),
6745 new_space_dominator()); 6727 new_space_dominator());
6746 } 6728 }
6747 6729
6748 bool NeedsWriteBarrierForMap() {
6749 if (IsSkipWriteBarrier()) return false;
6750 return ReceiverObjectNeedsWriteBarrier(object(), transition(),
6751 new_space_dominator());
6752 }
6753
6754 Representation field_representation() const { 6730 Representation field_representation() const {
6755 return access_.representation(); 6731 return access_.representation();
6756 } 6732 }
6757 6733
6758 void UpdateValue(HValue* value) { 6734 void UpdateValue(HValue* value) {
6759 SetOperandAt(1, value); 6735 SetOperandAt(1, value);
6760 } 6736 }
6761 6737
6762 private: 6738 private:
6763 HStoreNamedField(HValue* obj, 6739 HStoreNamedField(HValue* obj,
6764 HObjectAccess access, 6740 HObjectAccess access,
6765 HValue* val, 6741 HValue* val,
6766 StoreFieldOrKeyedMode store_mode = INITIALIZING_STORE) 6742 StoreFieldOrKeyedMode store_mode = INITIALIZING_STORE)
6767 : access_(access), 6743 : access_(access),
6768 new_space_dominator_(NULL), 6744 new_space_dominator_(NULL),
6769 write_barrier_mode_(UPDATE_WRITE_BARRIER), 6745 write_barrier_mode_(UPDATE_WRITE_BARRIER),
6770 has_transition_(false),
6771 store_mode_(store_mode) { 6746 store_mode_(store_mode) {
6772 // Stores to a non existing in-object property are allowed only to the 6747 // Stores to a non existing in-object property are allowed only to the
6773 // newly allocated objects (via HAllocate or HInnerAllocatedObject). 6748 // newly allocated objects (via HAllocate or HInnerAllocatedObject).
6774 ASSERT(!access.IsInobject() || access.existing_inobject_property() || 6749 ASSERT(!access.IsInobject() || access.existing_inobject_property() ||
6775 obj->IsAllocate() || obj->IsInnerAllocatedObject()); 6750 obj->IsAllocate() || obj->IsInnerAllocatedObject());
6776 SetOperandAt(0, obj); 6751 SetOperandAt(0, obj);
6777 SetOperandAt(1, val); 6752 SetOperandAt(1, val);
6778 SetOperandAt(2, obj);
6779 access.SetGVNFlags(this, STORE); 6753 access.SetGVNFlags(this, STORE);
6780 } 6754 }
6781 6755
6782 HObjectAccess access_; 6756 HObjectAccess access_;
6783 HValue* new_space_dominator_; 6757 HValue* new_space_dominator_;
6784 WriteBarrierMode write_barrier_mode_ : 1; 6758 WriteBarrierMode write_barrier_mode_ : 1;
6785 bool has_transition_ : 1;
6786 StoreFieldOrKeyedMode store_mode_ : 1; 6759 StoreFieldOrKeyedMode store_mode_ : 1;
6787 }; 6760 };
6788 6761
6789 6762
6790 class HStoreNamedGeneric V8_FINAL : public HTemplateInstruction<3> { 6763 class HStoreNamedGeneric V8_FINAL : public HTemplateInstruction<3> {
6791 public: 6764 public:
6792 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HStoreNamedGeneric, HValue*, 6765 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HStoreNamedGeneric, HValue*,
6793 Handle<String>, HValue*, 6766 Handle<String>, HValue*,
6794 StrictMode); 6767 StrictMode);
6795 HValue* object() { return OperandAt(0); } 6768 HValue* object() { return OperandAt(0); }
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
7719 virtual bool IsDeletable() const V8_OVERRIDE { return true; } 7692 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
7720 }; 7693 };
7721 7694
7722 7695
7723 #undef DECLARE_INSTRUCTION 7696 #undef DECLARE_INSTRUCTION
7724 #undef DECLARE_CONCRETE_INSTRUCTION 7697 #undef DECLARE_CONCRETE_INSTRUCTION
7725 7698
7726 } } // namespace v8::internal 7699 } } // namespace v8::internal
7727 7700
7728 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 7701 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen-escape-analysis.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698