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

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

Issue 700963002: Replace C++ bitfields with our own BitFields (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fixed AST node field sizes; more scanner fixes; undid hydrogen.h/cc changes Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/heap-snapshot-generator-inl.h ('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 <iosfwd> 8 #include <iosfwd>
9 9
10 #include "src/v8.h" 10 #include "src/v8.h"
(...skipping 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 *block = SuccessorAt(known_successor_index()); 1490 *block = SuccessorAt(known_successor_index());
1491 return true; 1491 return true;
1492 } 1492 }
1493 *block = NULL; 1493 *block = NULL;
1494 return false; 1494 return false;
1495 } 1495 }
1496 1496
1497 virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT 1497 virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
1498 1498
1499 static const int kNoKnownSuccessorIndex = -1; 1499 static const int kNoKnownSuccessorIndex = -1;
1500 int known_successor_index() const { return known_successor_index_; } 1500 int known_successor_index() const {
1501 void set_known_successor_index(int known_successor_index) { 1501 return KnownSuccessorIndexField::decode(bit_field_) -
1502 known_successor_index_ = known_successor_index; 1502 kInternalKnownSuccessorOffset;
1503 }
1504 void set_known_successor_index(int index) {
1505 DCHECK(index >= 0 - kInternalKnownSuccessorOffset);
1506 bit_field_ = KnownSuccessorIndexField::update(
1507 bit_field_, index + kInternalKnownSuccessorOffset);
1503 } 1508 }
1504 1509
1505 Unique<Map> map() const { return map_; } 1510 Unique<Map> map() const { return map_; }
1506 bool map_is_stable() const { return map_is_stable_; } 1511 bool map_is_stable() const { return MapIsStableField::decode(bit_field_); }
1507 1512
1508 virtual Representation RequiredInputRepresentation(int index) OVERRIDE { 1513 virtual Representation RequiredInputRepresentation(int index) OVERRIDE {
1509 return Representation::Tagged(); 1514 return Representation::Tagged();
1510 } 1515 }
1511 1516
1512 DECLARE_CONCRETE_INSTRUCTION(CompareMap) 1517 DECLARE_CONCRETE_INSTRUCTION(CompareMap)
1513 1518
1514 protected: 1519 protected:
1515 virtual int RedefinedOperandIndex() OVERRIDE { return 0; } 1520 virtual int RedefinedOperandIndex() OVERRIDE { return 0; }
1516 1521
1517 private: 1522 private:
1518 HCompareMap(HValue* value, 1523 HCompareMap(HValue* value, Handle<Map> map, HBasicBlock* true_target = NULL,
1519 Handle<Map> map,
1520 HBasicBlock* true_target = NULL,
1521 HBasicBlock* false_target = NULL) 1524 HBasicBlock* false_target = NULL)
1522 : HUnaryControlInstruction(value, true_target, false_target), 1525 : HUnaryControlInstruction(value, true_target, false_target),
1523 known_successor_index_(kNoKnownSuccessorIndex), 1526 bit_field_(KnownSuccessorIndexField::encode(
1524 map_is_stable_(map->is_stable()), 1527 kNoKnownSuccessorIndex + kInternalKnownSuccessorOffset) |
1528 MapIsStableField::encode(map->is_stable())),
1525 map_(Unique<Map>::CreateImmovable(map)) { 1529 map_(Unique<Map>::CreateImmovable(map)) {
1526 set_representation(Representation::Tagged()); 1530 set_representation(Representation::Tagged());
1527 } 1531 }
1528 1532
1529 int known_successor_index_ : 31; 1533 // BitFields can only store unsigned values, so use an offset.
1530 bool map_is_stable_ : 1; 1534 // Adding kInternalKnownSuccessorOffset must yield an unsigned value.
1535 static const int kInternalKnownSuccessorOffset = 1;
1536 STATIC_ASSERT(kNoKnownSuccessorIndex + kInternalKnownSuccessorOffset >= 0);
1537
1538 class KnownSuccessorIndexField : public BitField<int, 0, 31> {};
1539 class MapIsStableField : public BitField<bool, 31, 1> {};
1540
1541 uint32_t bit_field_;
1531 Unique<Map> map_; 1542 Unique<Map> map_;
1532 }; 1543 };
1533 1544
1534 1545
1535 class HContext FINAL : public HTemplateInstruction<0> { 1546 class HContext FINAL : public HTemplateInstruction<0> {
1536 public: 1547 public:
1537 static HContext* New(Zone* zone) { 1548 static HContext* New(Zone* zone) {
1538 return new(zone) HContext(); 1549 return new(zone) HContext();
1539 } 1550 }
1540 1551
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 1807
1797 1808
1798 enum RemovableSimulate { 1809 enum RemovableSimulate {
1799 REMOVABLE_SIMULATE, 1810 REMOVABLE_SIMULATE,
1800 FIXED_SIMULATE 1811 FIXED_SIMULATE
1801 }; 1812 };
1802 1813
1803 1814
1804 class HSimulate FINAL : public HInstruction { 1815 class HSimulate FINAL : public HInstruction {
1805 public: 1816 public:
1806 HSimulate(BailoutId ast_id, 1817 HSimulate(BailoutId ast_id, int pop_count, Zone* zone,
1807 int pop_count,
1808 Zone* zone,
1809 RemovableSimulate removable) 1818 RemovableSimulate removable)
1810 : ast_id_(ast_id), 1819 : ast_id_(ast_id),
1811 pop_count_(pop_count), 1820 pop_count_(pop_count),
1812 values_(2, zone), 1821 values_(2, zone),
1813 assigned_indexes_(2, zone), 1822 assigned_indexes_(2, zone),
1814 zone_(zone), 1823 zone_(zone),
1815 removable_(removable), 1824 bit_field_(RemovableField::encode(removable) |
1816 done_with_replay_(false) {} 1825 DoneWithReplayField::encode(false)) {}
1817 ~HSimulate() {} 1826 ~HSimulate() {}
1818 1827
1819 virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT 1828 virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
1820 1829
1821 bool HasAstId() const { return !ast_id_.IsNone(); } 1830 bool HasAstId() const { return !ast_id_.IsNone(); }
1822 BailoutId ast_id() const { return ast_id_; } 1831 BailoutId ast_id() const { return ast_id_; }
1823 void set_ast_id(BailoutId id) { 1832 void set_ast_id(BailoutId id) {
1824 DCHECK(!HasAstId()); 1833 DCHECK(!HasAstId());
1825 ast_id_ = id; 1834 ast_id_ = id;
1826 } 1835 }
(...skipping 23 matching lines...) Expand all
1850 virtual HValue* OperandAt(int index) const OVERRIDE { 1859 virtual HValue* OperandAt(int index) const OVERRIDE {
1851 return values_[index]; 1860 return values_[index];
1852 } 1861 }
1853 1862
1854 virtual bool HasEscapingOperandAt(int index) OVERRIDE { return false; } 1863 virtual bool HasEscapingOperandAt(int index) OVERRIDE { return false; }
1855 virtual Representation RequiredInputRepresentation(int index) OVERRIDE { 1864 virtual Representation RequiredInputRepresentation(int index) OVERRIDE {
1856 return Representation::None(); 1865 return Representation::None();
1857 } 1866 }
1858 1867
1859 void MergeWith(ZoneList<HSimulate*>* list); 1868 void MergeWith(ZoneList<HSimulate*>* list);
1860 bool is_candidate_for_removal() { return removable_ == REMOVABLE_SIMULATE; } 1869 bool is_candidate_for_removal() {
1870 return RemovableField::decode(bit_field_) == REMOVABLE_SIMULATE;
1871 }
1861 1872
1862 // Replay effects of this instruction on the given environment. 1873 // Replay effects of this instruction on the given environment.
1863 void ReplayEnvironment(HEnvironment* env); 1874 void ReplayEnvironment(HEnvironment* env);
1864 1875
1865 DECLARE_CONCRETE_INSTRUCTION(Simulate) 1876 DECLARE_CONCRETE_INSTRUCTION(Simulate)
1866 1877
1867 #ifdef DEBUG 1878 #ifdef DEBUG
1868 virtual void Verify() OVERRIDE; 1879 virtual void Verify() OVERRIDE;
1869 void set_closure(Handle<JSFunction> closure) { closure_ = closure; } 1880 void set_closure(Handle<JSFunction> closure) { closure_ = closure; }
1870 Handle<JSFunction> closure() const { return closure_; } 1881 Handle<JSFunction> closure() const { return closure_; }
(...skipping 13 matching lines...) Expand all
1884 // Set the operand through the base method in HValue to make sure that the 1895 // Set the operand through the base method in HValue to make sure that the
1885 // use lists are correctly updated. 1896 // use lists are correctly updated.
1886 SetOperandAt(values_.length() - 1, value); 1897 SetOperandAt(values_.length() - 1, value);
1887 } 1898 }
1888 bool HasValueForIndex(int index) { 1899 bool HasValueForIndex(int index) {
1889 for (int i = 0; i < assigned_indexes_.length(); ++i) { 1900 for (int i = 0; i < assigned_indexes_.length(); ++i) {
1890 if (assigned_indexes_[i] == index) return true; 1901 if (assigned_indexes_[i] == index) return true;
1891 } 1902 }
1892 return false; 1903 return false;
1893 } 1904 }
1905 bool is_done_with_replay() const {
1906 return DoneWithReplayField::decode(bit_field_);
1907 }
1908 void set_done_with_replay() {
1909 bit_field_ = DoneWithReplayField::update(bit_field_, true);
1910 }
1911
1912 class RemovableField : public BitField<RemovableSimulate, 0, 1> {};
1913 class DoneWithReplayField : public BitField<bool, 1, 1> {};
1914
1894 BailoutId ast_id_; 1915 BailoutId ast_id_;
1895 int pop_count_; 1916 int pop_count_;
1896 ZoneList<HValue*> values_; 1917 ZoneList<HValue*> values_;
1897 ZoneList<int> assigned_indexes_; 1918 ZoneList<int> assigned_indexes_;
1898 Zone* zone_; 1919 Zone* zone_;
1899 RemovableSimulate removable_ : 2; 1920 uint32_t bit_field_;
1900 bool done_with_replay_ : 1;
1901 1921
1902 #ifdef DEBUG 1922 #ifdef DEBUG
1903 Handle<JSFunction> closure_; 1923 Handle<JSFunction> closure_;
1904 #endif 1924 #endif
1905 }; 1925 };
1906 1926
1907 1927
1908 class HEnvironmentMarker FINAL : public HTemplateInstruction<1> { 1928 class HEnvironmentMarker FINAL : public HTemplateInstruction<1> {
1909 public: 1929 public:
1910 enum Kind { BIND, LOOKUP }; 1930 enum Kind { BIND, LOOKUP };
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
2735 static HCheckMaps* New(Zone* zone, HValue* context, 2755 static HCheckMaps* New(Zone* zone, HValue* context,
2736 HValue* value, SmallMapList* map_list, 2756 HValue* value, SmallMapList* map_list,
2737 HValue* typecheck = NULL) { 2757 HValue* typecheck = NULL) {
2738 UniqueSet<Map>* maps = new(zone) UniqueSet<Map>(map_list->length(), zone); 2758 UniqueSet<Map>* maps = new(zone) UniqueSet<Map>(map_list->length(), zone);
2739 for (int i = 0; i < map_list->length(); ++i) { 2759 for (int i = 0; i < map_list->length(); ++i) {
2740 maps->Add(Unique<Map>::CreateImmovable(map_list->at(i)), zone); 2760 maps->Add(Unique<Map>::CreateImmovable(map_list->at(i)), zone);
2741 } 2761 }
2742 return new(zone) HCheckMaps(value, maps, typecheck); 2762 return new(zone) HCheckMaps(value, maps, typecheck);
2743 } 2763 }
2744 2764
2745 bool IsStabilityCheck() const { return is_stability_check_; } 2765 bool IsStabilityCheck() const {
2766 return IsStabilityCheckField::decode(bit_field_);
2767 }
2746 void MarkAsStabilityCheck() { 2768 void MarkAsStabilityCheck() {
2747 maps_are_stable_ = true; 2769 bit_field_ = MapsAreStableField::encode(true) |
2748 has_migration_target_ = false; 2770 HasMigrationTargetField::encode(false) |
2749 is_stability_check_ = true; 2771 IsStabilityCheckField::encode(true);
2750 ClearChangesFlag(kNewSpacePromotion); 2772 ClearChangesFlag(kNewSpacePromotion);
2751 ClearDependsOnFlag(kElementsKind); 2773 ClearDependsOnFlag(kElementsKind);
2752 ClearDependsOnFlag(kMaps); 2774 ClearDependsOnFlag(kMaps);
2753 } 2775 }
2754 2776
2755 virtual bool HasEscapingOperandAt(int index) OVERRIDE { return false; } 2777 virtual bool HasEscapingOperandAt(int index) OVERRIDE { return false; }
2756 virtual Representation RequiredInputRepresentation(int index) OVERRIDE { 2778 virtual Representation RequiredInputRepresentation(int index) OVERRIDE {
2757 return Representation::Tagged(); 2779 return Representation::Tagged();
2758 } 2780 }
2759 2781
2760 virtual HType CalculateInferredType() OVERRIDE { 2782 virtual HType CalculateInferredType() OVERRIDE {
2761 if (value()->type().IsHeapObject()) return value()->type(); 2783 if (value()->type().IsHeapObject()) return value()->type();
2762 return HType::HeapObject(); 2784 return HType::HeapObject();
2763 } 2785 }
2764 2786
2765 virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT 2787 virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
2766 2788
2767 HValue* value() const { return OperandAt(0); } 2789 HValue* value() const { return OperandAt(0); }
2768 HValue* typecheck() const { return OperandAt(1); } 2790 HValue* typecheck() const { return OperandAt(1); }
2769 2791
2770 const UniqueSet<Map>* maps() const { return maps_; } 2792 const UniqueSet<Map>* maps() const { return maps_; }
2771 void set_maps(const UniqueSet<Map>* maps) { maps_ = maps; } 2793 void set_maps(const UniqueSet<Map>* maps) { maps_ = maps; }
2772 2794
2773 bool maps_are_stable() const { return maps_are_stable_; } 2795 bool maps_are_stable() const {
2796 return MapsAreStableField::decode(bit_field_);
2797 }
2774 2798
2775 bool HasMigrationTarget() const { return has_migration_target_; } 2799 bool HasMigrationTarget() const {
2800 return HasMigrationTargetField::decode(bit_field_);
2801 }
2776 2802
2777 virtual HValue* Canonicalize() OVERRIDE; 2803 virtual HValue* Canonicalize() OVERRIDE;
2778 2804
2779 static HCheckMaps* CreateAndInsertAfter(Zone* zone, 2805 static HCheckMaps* CreateAndInsertAfter(Zone* zone,
2780 HValue* value, 2806 HValue* value,
2781 Unique<Map> map, 2807 Unique<Map> map,
2782 bool map_is_stable, 2808 bool map_is_stable,
2783 HInstruction* instr) { 2809 HInstruction* instr) {
2784 return instr->Append(new(zone) HCheckMaps( 2810 return instr->Append(new(zone) HCheckMaps(
2785 value, new(zone) UniqueSet<Map>(map, zone), map_is_stable)); 2811 value, new(zone) UniqueSet<Map>(map, zone), map_is_stable));
(...skipping 11 matching lines...) Expand all
2797 2823
2798 protected: 2824 protected:
2799 virtual bool DataEquals(HValue* other) OVERRIDE { 2825 virtual bool DataEquals(HValue* other) OVERRIDE {
2800 return this->maps()->Equals(HCheckMaps::cast(other)->maps()); 2826 return this->maps()->Equals(HCheckMaps::cast(other)->maps());
2801 } 2827 }
2802 2828
2803 virtual int RedefinedOperandIndex() OVERRIDE { return 0; } 2829 virtual int RedefinedOperandIndex() OVERRIDE { return 0; }
2804 2830
2805 private: 2831 private:
2806 HCheckMaps(HValue* value, const UniqueSet<Map>* maps, bool maps_are_stable) 2832 HCheckMaps(HValue* value, const UniqueSet<Map>* maps, bool maps_are_stable)
2807 : HTemplateInstruction<2>(HType::HeapObject()), maps_(maps), 2833 : HTemplateInstruction<2>(HType::HeapObject()),
2808 has_migration_target_(false), is_stability_check_(false), 2834 maps_(maps),
2809 maps_are_stable_(maps_are_stable) { 2835 bit_field_(HasMigrationTargetField::encode(false) |
2836 IsStabilityCheckField::encode(false) |
2837 MapsAreStableField::encode(maps_are_stable)) {
2810 DCHECK_NE(0, maps->size()); 2838 DCHECK_NE(0, maps->size());
2811 SetOperandAt(0, value); 2839 SetOperandAt(0, value);
2812 // Use the object value for the dependency. 2840 // Use the object value for the dependency.
2813 SetOperandAt(1, value); 2841 SetOperandAt(1, value);
2814 set_representation(Representation::Tagged()); 2842 set_representation(Representation::Tagged());
2815 SetFlag(kUseGVN); 2843 SetFlag(kUseGVN);
2816 SetDependsOnFlag(kMaps); 2844 SetDependsOnFlag(kMaps);
2817 SetDependsOnFlag(kElementsKind); 2845 SetDependsOnFlag(kElementsKind);
2818 } 2846 }
2819 2847
2820 HCheckMaps(HValue* value, const UniqueSet<Map>* maps, HValue* typecheck) 2848 HCheckMaps(HValue* value, const UniqueSet<Map>* maps, HValue* typecheck)
2821 : HTemplateInstruction<2>(HType::HeapObject()), maps_(maps), 2849 : HTemplateInstruction<2>(HType::HeapObject()),
2822 has_migration_target_(false), is_stability_check_(false), 2850 maps_(maps),
2823 maps_are_stable_(true) { 2851 bit_field_(HasMigrationTargetField::encode(false) |
2852 IsStabilityCheckField::encode(false) |
2853 MapsAreStableField::encode(true)) {
2824 DCHECK_NE(0, maps->size()); 2854 DCHECK_NE(0, maps->size());
2825 SetOperandAt(0, value); 2855 SetOperandAt(0, value);
2826 // Use the object value for the dependency if NULL is passed. 2856 // Use the object value for the dependency if NULL is passed.
2827 SetOperandAt(1, typecheck ? typecheck : value); 2857 SetOperandAt(1, typecheck ? typecheck : value);
2828 set_representation(Representation::Tagged()); 2858 set_representation(Representation::Tagged());
2829 SetFlag(kUseGVN); 2859 SetFlag(kUseGVN);
2830 SetDependsOnFlag(kMaps); 2860 SetDependsOnFlag(kMaps);
2831 SetDependsOnFlag(kElementsKind); 2861 SetDependsOnFlag(kElementsKind);
2832 for (int i = 0; i < maps->size(); ++i) { 2862 for (int i = 0; i < maps->size(); ++i) {
2833 Handle<Map> map = maps->at(i).handle(); 2863 Handle<Map> map = maps->at(i).handle();
2834 if (map->is_migration_target()) has_migration_target_ = true; 2864 if (map->is_migration_target()) {
2835 if (!map->is_stable()) maps_are_stable_ = false; 2865 bit_field_ = HasMigrationTargetField::update(bit_field_, true);
2866 }
2867 if (!map->is_stable()) {
2868 bit_field_ = MapsAreStableField::update(bit_field_, false);
2869 }
2836 } 2870 }
2837 if (has_migration_target_) SetChangesFlag(kNewSpacePromotion); 2871 if (HasMigrationTarget()) SetChangesFlag(kNewSpacePromotion);
2838 } 2872 }
2839 2873
2874 class HasMigrationTargetField : public BitField<bool, 0, 1> {};
2875 class IsStabilityCheckField : public BitField<bool, 1, 1> {};
2876 class MapsAreStableField : public BitField<bool, 2, 1> {};
2877
2840 const UniqueSet<Map>* maps_; 2878 const UniqueSet<Map>* maps_;
2841 bool has_migration_target_ : 1; 2879 uint32_t bit_field_;
2842 bool is_stability_check_ : 1;
2843 bool maps_are_stable_ : 1;
2844 }; 2880 };
2845 2881
2846 2882
2847 class HCheckValue FINAL : public HUnaryOperation { 2883 class HCheckValue FINAL : public HUnaryOperation {
2848 public: 2884 public:
2849 static HCheckValue* New(Zone* zone, HValue* context, 2885 static HCheckValue* New(Zone* zone, HValue* context,
2850 HValue* value, Handle<JSFunction> func) { 2886 HValue* value, Handle<JSFunction> func) {
2851 bool in_new_space = zone->isolate()->heap()->InNewSpace(*func); 2887 bool in_new_space = zone->isolate()->heap()->InNewSpace(*func);
2852 // NOTE: We create an uninitialized Unique and initialize it later. 2888 // NOTE: We create an uninitialized Unique and initialize it later.
2853 // This is because a JSFunction can move due to GC during graph creation. 2889 // This is because a JSFunction can move due to GC during graph creation.
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
3530 } 3566 }
3531 3567
3532 Handle<Object> handle(Isolate* isolate) { 3568 Handle<Object> handle(Isolate* isolate) {
3533 if (object_.handle().is_null()) { 3569 if (object_.handle().is_null()) {
3534 // Default arguments to is_not_in_new_space depend on this heap number 3570 // Default arguments to is_not_in_new_space depend on this heap number
3535 // to be tenured so that it's guaranteed not to be located in new space. 3571 // to be tenured so that it's guaranteed not to be located in new space.
3536 object_ = Unique<Object>::CreateUninitialized( 3572 object_ = Unique<Object>::CreateUninitialized(
3537 isolate->factory()->NewNumber(double_value_, TENURED)); 3573 isolate->factory()->NewNumber(double_value_, TENURED));
3538 } 3574 }
3539 AllowDeferredHandleDereference smi_check; 3575 AllowDeferredHandleDereference smi_check;
3540 DCHECK(has_int32_value_ || !object_.handle()->IsSmi()); 3576 DCHECK(HasInteger32Value() || !object_.handle()->IsSmi());
3541 return object_.handle(); 3577 return object_.handle();
3542 } 3578 }
3543 3579
3544 bool IsSpecialDouble() const { 3580 bool IsSpecialDouble() const {
3545 return has_double_value_ && 3581 return HasDoubleValue() &&
3546 (bit_cast<int64_t>(double_value_) == bit_cast<int64_t>(-0.0) || 3582 (bit_cast<int64_t>(double_value_) == bit_cast<int64_t>(-0.0) ||
3547 FixedDoubleArray::is_the_hole_nan(double_value_) || 3583 FixedDoubleArray::is_the_hole_nan(double_value_) ||
3548 std::isnan(double_value_)); 3584 std::isnan(double_value_));
3549 } 3585 }
3550 3586
3551 bool NotInNewSpace() const { 3587 bool NotInNewSpace() const {
3552 return is_not_in_new_space_; 3588 return IsNotInNewSpaceField::decode(bit_field_);
3553 } 3589 }
3554 3590
3555 bool ImmortalImmovable() const; 3591 bool ImmortalImmovable() const;
3556 3592
3557 bool IsCell() const { 3593 bool IsCell() const {
3558 return instance_type_ == CELL_TYPE || instance_type_ == PROPERTY_CELL_TYPE; 3594 InstanceType instance_type = GetInstanceType();
3559 } 3595 return instance_type == CELL_TYPE || instance_type == PROPERTY_CELL_TYPE;
3560
3561 bool IsMap() const {
3562 return instance_type_ == MAP_TYPE;
3563 } 3596 }
3564 3597
3565 virtual Representation RequiredInputRepresentation(int index) OVERRIDE { 3598 virtual Representation RequiredInputRepresentation(int index) OVERRIDE {
3566 return Representation::None(); 3599 return Representation::None();
3567 } 3600 }
3568 3601
3569 virtual Representation KnownOptimalRepresentation() OVERRIDE { 3602 virtual Representation KnownOptimalRepresentation() OVERRIDE {
3570 if (HasSmiValue() && SmiValuesAre31Bits()) return Representation::Smi(); 3603 if (HasSmiValue() && SmiValuesAre31Bits()) return Representation::Smi();
3571 if (HasInteger32Value()) return Representation::Integer32(); 3604 if (HasInteger32Value()) return Representation::Integer32();
3572 if (HasNumberValue()) return Representation::Double(); 3605 if (HasNumberValue()) return Representation::Double();
3573 if (HasExternalReferenceValue()) return Representation::External(); 3606 if (HasExternalReferenceValue()) return Representation::External();
3574 return Representation::Tagged(); 3607 return Representation::Tagged();
3575 } 3608 }
3576 3609
3577 virtual bool EmitAtUses() OVERRIDE; 3610 virtual bool EmitAtUses() OVERRIDE;
3578 virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT 3611 virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
3579 HConstant* CopyToRepresentation(Representation r, Zone* zone) const; 3612 HConstant* CopyToRepresentation(Representation r, Zone* zone) const;
3580 Maybe<HConstant*> CopyToTruncatedInt32(Zone* zone); 3613 Maybe<HConstant*> CopyToTruncatedInt32(Zone* zone);
3581 Maybe<HConstant*> CopyToTruncatedNumber(Zone* zone); 3614 Maybe<HConstant*> CopyToTruncatedNumber(Zone* zone);
3582 bool HasInteger32Value() const { return has_int32_value_; } 3615 bool HasInteger32Value() const {
3616 return HasInt32ValueField::decode(bit_field_);
3617 }
3583 int32_t Integer32Value() const { 3618 int32_t Integer32Value() const {
3584 DCHECK(HasInteger32Value()); 3619 DCHECK(HasInteger32Value());
3585 return int32_value_; 3620 return int32_value_;
3586 } 3621 }
3587 bool HasSmiValue() const { return has_smi_value_; } 3622 bool HasSmiValue() const { return HasSmiValueField::decode(bit_field_); }
3588 bool HasDoubleValue() const { return has_double_value_; } 3623 bool HasDoubleValue() const {
3624 return HasDoubleValueField::decode(bit_field_);
3625 }
3589 double DoubleValue() const { 3626 double DoubleValue() const {
3590 DCHECK(HasDoubleValue()); 3627 DCHECK(HasDoubleValue());
3591 return double_value_; 3628 return double_value_;
3592 } 3629 }
3593 bool IsTheHole() const { 3630 bool IsTheHole() const {
3594 if (HasDoubleValue() && FixedDoubleArray::is_the_hole_nan(double_value_)) { 3631 if (HasDoubleValue() && FixedDoubleArray::is_the_hole_nan(double_value_)) {
3595 return true; 3632 return true;
3596 } 3633 }
3597 return object_.IsInitialized() && 3634 return object_.IsInitialized() &&
3598 object_.IsKnownGlobal(isolate()->heap()->the_hole_value()); 3635 object_.IsKnownGlobal(isolate()->heap()->the_hole_value());
3599 } 3636 }
3600 bool HasNumberValue() const { return has_double_value_; } 3637 bool HasNumberValue() const { return HasDoubleValue(); }
3601 int32_t NumberValueAsInteger32() const { 3638 int32_t NumberValueAsInteger32() const {
3602 DCHECK(HasNumberValue()); 3639 DCHECK(HasNumberValue());
3603 // Irrespective of whether a numeric HConstant can be safely 3640 // Irrespective of whether a numeric HConstant can be safely
3604 // represented as an int32, we store the (in some cases lossy) 3641 // represented as an int32, we store the (in some cases lossy)
3605 // representation of the number in int32_value_. 3642 // representation of the number in int32_value_.
3606 return int32_value_; 3643 return int32_value_;
3607 } 3644 }
3608 bool HasStringValue() const { 3645 bool HasStringValue() const {
3609 if (has_double_value_ || has_int32_value_) return false; 3646 if (HasNumberValue()) return false;
3610 DCHECK(!object_.handle().is_null()); 3647 DCHECK(!object_.handle().is_null());
3611 return instance_type_ < FIRST_NONSTRING_TYPE; 3648 return GetInstanceType() < FIRST_NONSTRING_TYPE;
3612 } 3649 }
3613 Handle<String> StringValue() const { 3650 Handle<String> StringValue() const {
3614 DCHECK(HasStringValue()); 3651 DCHECK(HasStringValue());
3615 return Handle<String>::cast(object_.handle()); 3652 return Handle<String>::cast(object_.handle());
3616 } 3653 }
3617 bool HasInternalizedStringValue() const { 3654 bool HasInternalizedStringValue() const {
3618 return HasStringValue() && StringShape(instance_type_).IsInternalized(); 3655 return HasStringValue() && StringShape(GetInstanceType()).IsInternalized();
3619 } 3656 }
3620 3657
3621 bool HasExternalReferenceValue() const { 3658 bool HasExternalReferenceValue() const {
3622 return has_external_reference_value_; 3659 return HasExternalReferenceValueField::decode(bit_field_);
3623 } 3660 }
3624 ExternalReference ExternalReferenceValue() const { 3661 ExternalReference ExternalReferenceValue() const {
3625 return external_reference_value_; 3662 return external_reference_value_;
3626 } 3663 }
3627 3664
3628 bool HasBooleanValue() const { return type_.IsBoolean(); } 3665 bool HasBooleanValue() const { return type_.IsBoolean(); }
3629 bool BooleanValue() const { return boolean_value_; } 3666 bool BooleanValue() const { return BooleanValueField::decode(bit_field_); }
3630 bool IsUndetectable() const { return is_undetectable_; } 3667 bool IsUndetectable() const {
3631 InstanceType GetInstanceType() const { return instance_type_; } 3668 return IsUndetectableField::decode(bit_field_);
3669 }
3670 InstanceType GetInstanceType() const {
3671 return InstanceTypeField::decode(bit_field_);
3672 }
3632 3673
3633 bool HasMapValue() const { return instance_type_ == MAP_TYPE; } 3674 bool HasMapValue() const { return GetInstanceType() == MAP_TYPE; }
3634 Unique<Map> MapValue() const { 3675 Unique<Map> MapValue() const {
3635 DCHECK(HasMapValue()); 3676 DCHECK(HasMapValue());
3636 return Unique<Map>::cast(GetUnique()); 3677 return Unique<Map>::cast(GetUnique());
3637 } 3678 }
3638 bool HasStableMapValue() const { 3679 bool HasStableMapValue() const {
3639 DCHECK(HasMapValue() || !has_stable_map_value_); 3680 DCHECK(HasMapValue() || !HasStableMapValueField::decode(bit_field_));
3640 return has_stable_map_value_; 3681 return HasStableMapValueField::decode(bit_field_);
3641 } 3682 }
3642 3683
3643 bool HasObjectMap() const { return !object_map_.IsNull(); } 3684 bool HasObjectMap() const { return !object_map_.IsNull(); }
3644 Unique<Map> ObjectMap() const { 3685 Unique<Map> ObjectMap() const {
3645 DCHECK(HasObjectMap()); 3686 DCHECK(HasObjectMap());
3646 return object_map_; 3687 return object_map_;
3647 } 3688 }
3648 3689
3649 virtual intptr_t Hashcode() OVERRIDE { 3690 virtual intptr_t Hashcode() OVERRIDE {
3650 if (has_int32_value_) { 3691 if (HasInteger32Value()) {
3651 return static_cast<intptr_t>(int32_value_); 3692 return static_cast<intptr_t>(int32_value_);
3652 } else if (has_double_value_) { 3693 } else if (HasDoubleValue()) {
3653 return static_cast<intptr_t>(bit_cast<int64_t>(double_value_)); 3694 return static_cast<intptr_t>(bit_cast<int64_t>(double_value_));
3654 } else if (has_external_reference_value_) { 3695 } else if (HasExternalReferenceValue()) {
3655 return reinterpret_cast<intptr_t>(external_reference_value_.address()); 3696 return reinterpret_cast<intptr_t>(external_reference_value_.address());
3656 } else { 3697 } else {
3657 DCHECK(!object_.handle().is_null()); 3698 DCHECK(!object_.handle().is_null());
3658 return object_.Hashcode(); 3699 return object_.Hashcode();
3659 } 3700 }
3660 } 3701 }
3661 3702
3662 virtual void FinalizeUniqueness() OVERRIDE { 3703 virtual void FinalizeUniqueness() OVERRIDE {
3663 if (!has_double_value_ && !has_external_reference_value_) { 3704 if (!HasDoubleValue() && !HasExternalReferenceValue()) {
3664 DCHECK(!object_.handle().is_null()); 3705 DCHECK(!object_.handle().is_null());
3665 object_ = Unique<Object>(object_.handle()); 3706 object_ = Unique<Object>(object_.handle());
3666 } 3707 }
3667 } 3708 }
3668 3709
3669 Unique<Object> GetUnique() const { 3710 Unique<Object> GetUnique() const {
3670 return object_; 3711 return object_;
3671 } 3712 }
3672 3713
3673 bool EqualsUnique(Unique<Object> other) const { 3714 bool EqualsUnique(Unique<Object> other) const {
3674 return object_.IsInitialized() && object_ == other; 3715 return object_.IsInitialized() && object_ == other;
3675 } 3716 }
3676 3717
3677 virtual bool DataEquals(HValue* other) OVERRIDE { 3718 virtual bool DataEquals(HValue* other) OVERRIDE {
3678 HConstant* other_constant = HConstant::cast(other); 3719 HConstant* other_constant = HConstant::cast(other);
3679 if (has_int32_value_) { 3720 if (HasInteger32Value()) {
3680 return other_constant->has_int32_value_ && 3721 return other_constant->HasInteger32Value() &&
3681 int32_value_ == other_constant->int32_value_; 3722 int32_value_ == other_constant->int32_value_;
3682 } else if (has_double_value_) { 3723 } else if (HasDoubleValue()) {
3683 return other_constant->has_double_value_ && 3724 return other_constant->HasDoubleValue() &&
3684 bit_cast<int64_t>(double_value_) == 3725 bit_cast<int64_t>(double_value_) ==
3685 bit_cast<int64_t>(other_constant->double_value_); 3726 bit_cast<int64_t>(other_constant->double_value_);
3686 } else if (has_external_reference_value_) { 3727 } else if (HasExternalReferenceValue()) {
3687 return other_constant->has_external_reference_value_ && 3728 return other_constant->HasExternalReferenceValue() &&
3688 external_reference_value_ == 3729 external_reference_value_ ==
3689 other_constant->external_reference_value_; 3730 other_constant->external_reference_value_;
3690 } else { 3731 } else {
3691 if (other_constant->has_int32_value_ || 3732 if (other_constant->HasInteger32Value() ||
3692 other_constant->has_double_value_ || 3733 other_constant->HasDoubleValue() ||
3693 other_constant->has_external_reference_value_) { 3734 other_constant->HasExternalReferenceValue()) {
3694 return false; 3735 return false;
3695 } 3736 }
3696 DCHECK(!object_.handle().is_null()); 3737 DCHECK(!object_.handle().is_null());
3697 return other_constant->object_ == object_; 3738 return other_constant->object_ == object_;
3698 } 3739 }
3699 } 3740 }
3700 3741
3701 #ifdef DEBUG 3742 #ifdef DEBUG
3702 virtual void Verify() OVERRIDE { } 3743 virtual void Verify() OVERRIDE { }
3703 #endif 3744 #endif
(...skipping 24 matching lines...) Expand all
3728 bool boolean_value, 3769 bool boolean_value,
3729 bool is_undetectable, 3770 bool is_undetectable,
3730 InstanceType instance_type); 3771 InstanceType instance_type);
3731 3772
3732 explicit HConstant(ExternalReference reference); 3773 explicit HConstant(ExternalReference reference);
3733 3774
3734 void Initialize(Representation r); 3775 void Initialize(Representation r);
3735 3776
3736 virtual bool IsDeletable() const OVERRIDE { return true; } 3777 virtual bool IsDeletable() const OVERRIDE { return true; }
3737 3778
3779 // If object_ is a map, this indicates whether the map is stable.
3780 class HasStableMapValueField : public BitField<bool, 0, 1> {};
3781
3782 // We store the HConstant in the most specific form safely possible.
3783 // These flags tell us if the respective member fields hold valid, safe
3784 // representations of the constant. More specific flags imply more general
3785 // flags, but not the converse (i.e. smi => int32 => double).
3786 class HasSmiValueField : public BitField<bool, 1, 1> {};
3787 class HasInt32ValueField : public BitField<bool, 2, 1> {};
3788 class HasDoubleValueField : public BitField<bool, 3, 1> {};
3789
3790 class HasExternalReferenceValueField : public BitField<bool, 4, 1> {};
3791 class IsNotInNewSpaceField : public BitField<bool, 5, 1> {};
3792 class BooleanValueField : public BitField<bool, 6, 1> {};
3793 class IsUndetectableField : public BitField<bool, 7, 1> {};
3794
3795 static const InstanceType kUnknownInstanceType = FILLER_TYPE;
3796 class InstanceTypeField : public BitField<InstanceType, 8, 8> {};
3797
3738 // If this is a numerical constant, object_ either points to the 3798 // If this is a numerical constant, object_ either points to the
3739 // HeapObject the constant originated from or is null. If the 3799 // HeapObject the constant originated from or is null. If the
3740 // constant is non-numeric, object_ always points to a valid 3800 // constant is non-numeric, object_ always points to a valid
3741 // constant HeapObject. 3801 // constant HeapObject.
3742 Unique<Object> object_; 3802 Unique<Object> object_;
3743 3803
3744 // If object_ is a heap object, this points to the stable map of the object. 3804 // If object_ is a heap object, this points to the stable map of the object.
3745 Unique<Map> object_map_; 3805 Unique<Map> object_map_;
3746 3806
3747 // If object_ is a map, this indicates whether the map is stable. 3807 uint32_t bit_field_;
3748 bool has_stable_map_value_ : 1;
3749 3808
3750 // We store the HConstant in the most specific form safely possible.
3751 // The two flags, has_int32_value_ and has_double_value_ tell us if
3752 // int32_value_ and double_value_ hold valid, safe representations
3753 // of the constant. has_int32_value_ implies has_double_value_ but
3754 // not the converse.
3755 bool has_smi_value_ : 1;
3756 bool has_int32_value_ : 1;
3757 bool has_double_value_ : 1;
3758 bool has_external_reference_value_ : 1;
3759 bool is_not_in_new_space_ : 1;
3760 bool boolean_value_ : 1;
3761 bool is_undetectable_: 1;
3762 int32_t int32_value_; 3809 int32_t int32_value_;
3763 double double_value_; 3810 double double_value_;
3764 ExternalReference external_reference_value_; 3811 ExternalReference external_reference_value_;
3765
3766 static const InstanceType kUnknownInstanceType = FILLER_TYPE;
3767 InstanceType instance_type_;
3768 }; 3812 };
3769 3813
3770 3814
3771 class HBinaryOperation : public HTemplateInstruction<3> { 3815 class HBinaryOperation : public HTemplateInstruction<3> {
3772 public: 3816 public:
3773 HBinaryOperation(HValue* context, HValue* left, HValue* right, 3817 HBinaryOperation(HValue* context, HValue* left, HValue* right,
3774 HType type = HType::Tagged()) 3818 HType type = HType::Tagged())
3775 : HTemplateInstruction<3>(type), 3819 : HTemplateInstruction<3>(type),
3776 observed_output_representation_(Representation::None()) { 3820 observed_output_representation_(Representation::None()) {
3777 DCHECK(left != NULL && right != NULL); 3821 DCHECK(left != NULL && right != NULL);
(...skipping 2954 matching lines...) Expand 10 before | Expand all | Expand 10 after
6732 kBitsForHoleMode = 1, 6776 kBitsForHoleMode = 1,
6733 kBitsForBaseOffset = 25, 6777 kBitsForBaseOffset = 25,
6734 kBitsForIsDehoisted = 1, 6778 kBitsForIsDehoisted = 1,
6735 6779
6736 kStartElementsKind = 0, 6780 kStartElementsKind = 0,
6737 kStartHoleMode = kStartElementsKind + kBitsForElementsKind, 6781 kStartHoleMode = kStartElementsKind + kBitsForElementsKind,
6738 kStartBaseOffset = kStartHoleMode + kBitsForHoleMode, 6782 kStartBaseOffset = kStartHoleMode + kBitsForHoleMode,
6739 kStartIsDehoisted = kStartBaseOffset + kBitsForBaseOffset 6783 kStartIsDehoisted = kStartBaseOffset + kBitsForBaseOffset
6740 }; 6784 };
6741 6785
6742 STATIC_ASSERT((kBitsForElementsKind + kBitsForBaseOffset + 6786 STATIC_ASSERT((kBitsForElementsKind + kBitsForHoleMode + kBitsForBaseOffset +
6743 kBitsForIsDehoisted) <= sizeof(uint32_t)*8); 6787 kBitsForIsDehoisted) <= sizeof(uint32_t) * 8);
6744 STATIC_ASSERT(kElementsKindCount <= (1 << kBitsForElementsKind)); 6788 STATIC_ASSERT(kElementsKindCount <= (1 << kBitsForElementsKind));
6745 class ElementsKindField: 6789 class ElementsKindField:
6746 public BitField<ElementsKind, kStartElementsKind, kBitsForElementsKind> 6790 public BitField<ElementsKind, kStartElementsKind, kBitsForElementsKind>
6747 {}; // NOLINT 6791 {}; // NOLINT
6748 class HoleModeField: 6792 class HoleModeField:
6749 public BitField<LoadKeyedHoleMode, kStartHoleMode, kBitsForHoleMode> 6793 public BitField<LoadKeyedHoleMode, kStartHoleMode, kBitsForHoleMode>
6750 {}; // NOLINT 6794 {}; // NOLINT
6751 class BaseOffsetField: 6795 class BaseOffsetField:
6752 public BitField<uint32_t, kStartBaseOffset, kBitsForBaseOffset> 6796 public BitField<uint32_t, kStartBaseOffset, kBitsForBaseOffset>
6753 {}; // NOLINT 6797 {}; // NOLINT
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
6838 } else if (index == 1) { 6882 } else if (index == 1) {
6839 if (field_representation().IsInteger8() || 6883 if (field_representation().IsInteger8() ||
6840 field_representation().IsUInteger8() || 6884 field_representation().IsUInteger8() ||
6841 field_representation().IsInteger16() || 6885 field_representation().IsInteger16() ||
6842 field_representation().IsUInteger16() || 6886 field_representation().IsUInteger16() ||
6843 field_representation().IsInteger32()) { 6887 field_representation().IsInteger32()) {
6844 return Representation::Integer32(); 6888 return Representation::Integer32();
6845 } else if (field_representation().IsDouble()) { 6889 } else if (field_representation().IsDouble()) {
6846 return field_representation(); 6890 return field_representation();
6847 } else if (field_representation().IsSmi()) { 6891 } else if (field_representation().IsSmi()) {
6848 if (SmiValuesAre32Bits() && store_mode_ == STORE_TO_INITIALIZED_ENTRY) { 6892 if (SmiValuesAre32Bits() &&
6893 store_mode() == STORE_TO_INITIALIZED_ENTRY) {
6849 return Representation::Integer32(); 6894 return Representation::Integer32();
6850 } 6895 }
6851 return field_representation(); 6896 return field_representation();
6852 } else if (field_representation().IsExternal()) { 6897 } else if (field_representation().IsExternal()) {
6853 return Representation::External(); 6898 return Representation::External();
6854 } 6899 }
6855 } 6900 }
6856 return Representation::Tagged(); 6901 return Representation::Tagged();
6857 } 6902 }
6858 virtual bool HandleSideEffectDominator(GVNFlag side_effect, 6903 virtual bool HandleSideEffectDominator(GVNFlag side_effect,
6859 HValue* dominator) OVERRIDE { 6904 HValue* dominator) OVERRIDE {
6860 DCHECK(side_effect == kNewSpacePromotion); 6905 DCHECK(side_effect == kNewSpacePromotion);
6861 if (!FLAG_use_write_barrier_elimination) return false; 6906 if (!FLAG_use_write_barrier_elimination) return false;
6862 dominator_ = dominator; 6907 dominator_ = dominator;
6863 return false; 6908 return false;
6864 } 6909 }
6865 virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT 6910 virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
6866 6911
6867 HValue* object() const { return OperandAt(0); } 6912 HValue* object() const { return OperandAt(0); }
6868 HValue* value() const { return OperandAt(1); } 6913 HValue* value() const { return OperandAt(1); }
6869 HValue* transition() const { return OperandAt(2); } 6914 HValue* transition() const { return OperandAt(2); }
6870 6915
6871 HObjectAccess access() const { return access_; } 6916 HObjectAccess access() const { return access_; }
6872 HValue* dominator() const { return dominator_; } 6917 HValue* dominator() const { return dominator_; }
6873 bool has_transition() const { return has_transition_; } 6918 bool has_transition() const { return HasTransitionField::decode(bit_field_); }
6874 StoreFieldOrKeyedMode store_mode() const { return store_mode_; } 6919 StoreFieldOrKeyedMode store_mode() const {
6920 return StoreModeField::decode(bit_field_);
6921 }
6875 6922
6876 Handle<Map> transition_map() const { 6923 Handle<Map> transition_map() const {
6877 if (has_transition()) { 6924 if (has_transition()) {
6878 return Handle<Map>::cast( 6925 return Handle<Map>::cast(
6879 HConstant::cast(transition())->handle(Isolate::Current())); 6926 HConstant::cast(transition())->handle(Isolate::Current()));
6880 } else { 6927 } else {
6881 return Handle<Map>(); 6928 return Handle<Map>();
6882 } 6929 }
6883 } 6930 }
6884 6931
6885 void SetTransition(HConstant* transition) { 6932 void SetTransition(HConstant* transition) {
6886 DCHECK(!has_transition()); // Only set once. 6933 DCHECK(!has_transition()); // Only set once.
6887 SetOperandAt(2, transition); 6934 SetOperandAt(2, transition);
6888 has_transition_ = true; 6935 bit_field_ = HasTransitionField::update(bit_field_, true);
6889 SetChangesFlag(kMaps); 6936 SetChangesFlag(kMaps);
6890 } 6937 }
6891 6938
6892 bool NeedsWriteBarrier() const { 6939 bool NeedsWriteBarrier() const {
6893 DCHECK(!field_representation().IsDouble() || !has_transition()); 6940 DCHECK(!field_representation().IsDouble() || !has_transition());
6894 if (field_representation().IsDouble()) return false; 6941 if (field_representation().IsDouble()) return false;
6895 if (field_representation().IsSmi()) return false; 6942 if (field_representation().IsSmi()) return false;
6896 if (field_representation().IsInteger32()) return false; 6943 if (field_representation().IsInteger32()) return false;
6897 if (field_representation().IsExternal()) return false; 6944 if (field_representation().IsExternal()) return false;
6898 return StoringValueNeedsWriteBarrier(value()) && 6945 return StoringValueNeedsWriteBarrier(value()) &&
(...skipping 30 matching lines...) Expand all
6929 this->store_mode() == INITIALIZING_STORE && 6976 this->store_mode() == INITIALIZING_STORE &&
6930 that->store_mode() == STORE_TO_INITIALIZED_ENTRY) { 6977 that->store_mode() == STORE_TO_INITIALIZED_ENTRY) {
6931 // We cannot replace an initializing store to a smi field with a store to 6978 // We cannot replace an initializing store to a smi field with a store to
6932 // an initialized entry on 64-bit architectures (with 32-bit smis). 6979 // an initialized entry on 64-bit architectures (with 32-bit smis).
6933 return false; 6980 return false;
6934 } 6981 }
6935 return true; 6982 return true;
6936 } 6983 }
6937 6984
6938 private: 6985 private:
6939 HStoreNamedField(HValue* obj, 6986 HStoreNamedField(HValue* obj, HObjectAccess access, HValue* val,
6940 HObjectAccess access,
6941 HValue* val,
6942 StoreFieldOrKeyedMode store_mode = INITIALIZING_STORE) 6987 StoreFieldOrKeyedMode store_mode = INITIALIZING_STORE)
6943 : access_(access), 6988 : access_(access),
6944 dominator_(NULL), 6989 dominator_(NULL),
6945 has_transition_(false), 6990 bit_field_(HasTransitionField::encode(false) |
6946 store_mode_(store_mode) { 6991 StoreModeField::encode(store_mode)) {
6947 // Stores to a non existing in-object property are allowed only to the 6992 // Stores to a non existing in-object property are allowed only to the
6948 // newly allocated objects (via HAllocate or HInnerAllocatedObject). 6993 // newly allocated objects (via HAllocate or HInnerAllocatedObject).
6949 DCHECK(!access.IsInobject() || access.existing_inobject_property() || 6994 DCHECK(!access.IsInobject() || access.existing_inobject_property() ||
6950 obj->IsAllocate() || obj->IsInnerAllocatedObject()); 6995 obj->IsAllocate() || obj->IsInnerAllocatedObject());
6951 SetOperandAt(0, obj); 6996 SetOperandAt(0, obj);
6952 SetOperandAt(1, val); 6997 SetOperandAt(1, val);
6953 SetOperandAt(2, obj); 6998 SetOperandAt(2, obj);
6954 access.SetGVNFlags(this, STORE); 6999 access.SetGVNFlags(this, STORE);
6955 } 7000 }
6956 7001
7002 class HasTransitionField : public BitField<bool, 0, 1> {};
7003 class StoreModeField : public BitField<StoreFieldOrKeyedMode, 1, 1> {};
7004
6957 HObjectAccess access_; 7005 HObjectAccess access_;
6958 HValue* dominator_; 7006 HValue* dominator_;
6959 bool has_transition_ : 1; 7007 uint32_t bit_field_;
6960 StoreFieldOrKeyedMode store_mode_ : 1;
6961 }; 7008 };
6962 7009
6963 7010
6964 class HStoreNamedGeneric FINAL : public HTemplateInstruction<3> { 7011 class HStoreNamedGeneric FINAL : public HTemplateInstruction<3> {
6965 public: 7012 public:
6966 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HStoreNamedGeneric, HValue*, 7013 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HStoreNamedGeneric, HValue*,
6967 Handle<String>, HValue*, 7014 Handle<String>, HValue*,
6968 StrictMode); 7015 StrictMode);
6969 HValue* object() const { return OperandAt(0); } 7016 HValue* object() const { return OperandAt(0); }
6970 HValue* value() const { return OperandAt(1); } 7017 HValue* value() const { return OperandAt(1); }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
7017 // kind_external: external[int32] = (double | int32) 7064 // kind_external: external[int32] = (double | int32)
7018 if (index == 0) { 7065 if (index == 0) {
7019 return is_external() ? Representation::External() 7066 return is_external() ? Representation::External()
7020 : Representation::Tagged(); 7067 : Representation::Tagged();
7021 } else if (index == 1) { 7068 } else if (index == 1) {
7022 return ArrayInstructionInterface::KeyedAccessIndexRequirement( 7069 return ArrayInstructionInterface::KeyedAccessIndexRequirement(
7023 OperandAt(1)->representation()); 7070 OperandAt(1)->representation());
7024 } 7071 }
7025 7072
7026 DCHECK_EQ(index, 2); 7073 DCHECK_EQ(index, 2);
7027 return RequiredValueRepresentation(elements_kind_, store_mode_); 7074 return RequiredValueRepresentation(elements_kind(), store_mode());
7028 } 7075 }
7029 7076
7030 static Representation RequiredValueRepresentation( 7077 static Representation RequiredValueRepresentation(
7031 ElementsKind kind, StoreFieldOrKeyedMode mode) { 7078 ElementsKind kind, StoreFieldOrKeyedMode mode) {
7032 if (IsDoubleOrFloatElementsKind(kind)) { 7079 if (IsDoubleOrFloatElementsKind(kind)) {
7033 return Representation::Double(); 7080 return Representation::Double();
7034 } 7081 }
7035 7082
7036 if (kind == FAST_SMI_ELEMENTS && SmiValuesAre32Bits() && 7083 if (kind == FAST_SMI_ELEMENTS && SmiValuesAre32Bits() &&
7037 mode == STORE_TO_INITIALIZED_ENTRY) { 7084 mode == STORE_TO_INITIALIZED_ENTRY) {
(...skipping 20 matching lines...) Expand all
7058 7105
7059 bool is_typed_elements() const { 7106 bool is_typed_elements() const {
7060 return is_external() || is_fixed_typed_array(); 7107 return is_external() || is_fixed_typed_array();
7061 } 7108 }
7062 7109
7063 virtual Representation observed_input_representation(int index) OVERRIDE { 7110 virtual Representation observed_input_representation(int index) OVERRIDE {
7064 if (index < 2) return RequiredInputRepresentation(index); 7111 if (index < 2) return RequiredInputRepresentation(index);
7065 if (IsUninitialized()) { 7112 if (IsUninitialized()) {
7066 return Representation::None(); 7113 return Representation::None();
7067 } 7114 }
7068 Representation r = RequiredValueRepresentation(elements_kind_, store_mode_); 7115 Representation r =
7116 RequiredValueRepresentation(elements_kind(), store_mode());
7069 // For fast object elements kinds, don't assume anything. 7117 // For fast object elements kinds, don't assume anything.
7070 if (r.IsTagged()) return Representation::None(); 7118 if (r.IsTagged()) return Representation::None();
7071 return r; 7119 return r;
7072 } 7120 }
7073 7121
7074 HValue* elements() const { return OperandAt(0); } 7122 HValue* elements() const { return OperandAt(0); }
7075 HValue* key() const { return OperandAt(1); } 7123 HValue* key() const { return OperandAt(1); }
7076 HValue* value() const { return OperandAt(2); } 7124 HValue* value() const { return OperandAt(2); }
7077 bool value_is_smi() const { 7125 bool value_is_smi() const { return IsFastSmiElementsKind(elements_kind()); }
7078 return IsFastSmiElementsKind(elements_kind_); 7126 StoreFieldOrKeyedMode store_mode() const {
7127 return StoreModeField::decode(bit_field_);
7079 } 7128 }
7080 StoreFieldOrKeyedMode store_mode() const { return store_mode_; } 7129 ElementsKind elements_kind() const OVERRIDE {
7081 ElementsKind elements_kind() const OVERRIDE { return elements_kind_; } 7130 return ElementsKindField::decode(bit_field_);
7131 }
7082 uint32_t base_offset() const { return base_offset_; } 7132 uint32_t base_offset() const { return base_offset_; }
7083 bool TryIncreaseBaseOffset(uint32_t increase_by_value) OVERRIDE; 7133 bool TryIncreaseBaseOffset(uint32_t increase_by_value) OVERRIDE;
7084 HValue* GetKey() OVERRIDE { return key(); } 7134 HValue* GetKey() OVERRIDE { return key(); }
7085 void SetKey(HValue* key) OVERRIDE { SetOperandAt(1, key); } 7135 void SetKey(HValue* key) OVERRIDE { SetOperandAt(1, key); }
7086 bool IsDehoisted() const OVERRIDE { return is_dehoisted_; } 7136 bool IsDehoisted() const OVERRIDE {
7137 return IsDehoistedField::decode(bit_field_);
7138 }
7087 void SetDehoisted(bool is_dehoisted) OVERRIDE { 7139 void SetDehoisted(bool is_dehoisted) OVERRIDE {
7088 is_dehoisted_ = is_dehoisted; 7140 bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted);
7089 } 7141 }
7090 bool IsUninitialized() { return is_uninitialized_; } 7142 bool IsUninitialized() { return IsUninitializedField::decode(bit_field_); }
7091 void SetUninitialized(bool is_uninitialized) { 7143 void SetUninitialized(bool is_uninitialized) {
7092 is_uninitialized_ = is_uninitialized; 7144 bit_field_ = IsUninitializedField::update(bit_field_, is_uninitialized);
7093 } 7145 }
7094 7146
7095 bool IsConstantHoleStore() { 7147 bool IsConstantHoleStore() {
7096 return value()->IsConstant() && HConstant::cast(value())->IsTheHole(); 7148 return value()->IsConstant() && HConstant::cast(value())->IsTheHole();
7097 } 7149 }
7098 7150
7099 virtual bool HandleSideEffectDominator(GVNFlag side_effect, 7151 virtual bool HandleSideEffectDominator(GVNFlag side_effect,
7100 HValue* dominator) OVERRIDE { 7152 HValue* dominator) OVERRIDE {
7101 DCHECK(side_effect == kNewSpacePromotion); 7153 DCHECK(side_effect == kNewSpacePromotion);
7102 dominator_ = dominator; 7154 dominator_ = dominator;
(...skipping 15 matching lines...) Expand all
7118 return PointersToHereCheckForObject(value(), dominator()); 7170 return PointersToHereCheckForObject(value(), dominator());
7119 } 7171 }
7120 7172
7121 bool NeedsCanonicalization(); 7173 bool NeedsCanonicalization();
7122 7174
7123 virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT 7175 virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
7124 7176
7125 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed) 7177 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed)
7126 7178
7127 private: 7179 private:
7128 HStoreKeyed(HValue* obj, HValue* key, HValue* val, 7180 HStoreKeyed(HValue* obj, HValue* key, HValue* val, ElementsKind elements_kind,
7129 ElementsKind elements_kind,
7130 StoreFieldOrKeyedMode store_mode = INITIALIZING_STORE, 7181 StoreFieldOrKeyedMode store_mode = INITIALIZING_STORE,
7131 int offset = kDefaultKeyedHeaderOffsetSentinel) 7182 int offset = kDefaultKeyedHeaderOffsetSentinel)
7132 : elements_kind_(elements_kind), 7183 : base_offset_(offset == kDefaultKeyedHeaderOffsetSentinel
7133 base_offset_(offset == kDefaultKeyedHeaderOffsetSentinel 7184 ? GetDefaultHeaderSizeForElementsKind(elements_kind)
7134 ? GetDefaultHeaderSizeForElementsKind(elements_kind) 7185 : offset),
7135 : offset), 7186 bit_field_(IsDehoistedField::encode(false) |
7136 is_dehoisted_(false), 7187 IsUninitializedField::encode(false) |
7137 is_uninitialized_(false), 7188 StoreModeField::encode(store_mode) |
7138 store_mode_(store_mode), 7189 ElementsKindField::encode(elements_kind)),
7139 dominator_(NULL) { 7190 dominator_(NULL) {
7140 SetOperandAt(0, obj); 7191 SetOperandAt(0, obj);
7141 SetOperandAt(1, key); 7192 SetOperandAt(1, key);
7142 SetOperandAt(2, val); 7193 SetOperandAt(2, val);
7143 7194
7144 if (IsFastObjectElementsKind(elements_kind)) { 7195 if (IsFastObjectElementsKind(elements_kind)) {
7145 SetFlag(kTrackSideEffectDominators); 7196 SetFlag(kTrackSideEffectDominators);
7146 SetDependsOnFlag(kNewSpacePromotion); 7197 SetDependsOnFlag(kNewSpacePromotion);
7147 } 7198 }
7148 if (is_external()) { 7199 if (is_external()) {
7149 SetChangesFlag(kExternalMemory); 7200 SetChangesFlag(kExternalMemory);
(...skipping 11 matching lines...) Expand all
7161 7212
7162 // EXTERNAL_{UNSIGNED_,}{BYTE,SHORT,INT}_ELEMENTS are truncating. 7213 // EXTERNAL_{UNSIGNED_,}{BYTE,SHORT,INT}_ELEMENTS are truncating.
7163 if ((elements_kind >= EXTERNAL_INT8_ELEMENTS && 7214 if ((elements_kind >= EXTERNAL_INT8_ELEMENTS &&
7164 elements_kind <= EXTERNAL_UINT32_ELEMENTS) || 7215 elements_kind <= EXTERNAL_UINT32_ELEMENTS) ||
7165 (elements_kind >= UINT8_ELEMENTS && 7216 (elements_kind >= UINT8_ELEMENTS &&
7166 elements_kind <= INT32_ELEMENTS)) { 7217 elements_kind <= INT32_ELEMENTS)) {
7167 SetFlag(kTruncatingToInt32); 7218 SetFlag(kTruncatingToInt32);
7168 } 7219 }
7169 } 7220 }
7170 7221
7171 ElementsKind elements_kind_; 7222 class IsDehoistedField : public BitField<bool, 0, 1> {};
7223 class IsUninitializedField : public BitField<bool, 1, 1> {};
7224 class StoreModeField : public BitField<StoreFieldOrKeyedMode, 2, 1> {};
7225 class ElementsKindField : public BitField<ElementsKind, 3, 5> {};
7226
7172 uint32_t base_offset_; 7227 uint32_t base_offset_;
7173 bool is_dehoisted_ : 1; 7228 uint32_t bit_field_;
7174 bool is_uninitialized_ : 1;
7175 StoreFieldOrKeyedMode store_mode_: 1;
7176 HValue* dominator_; 7229 HValue* dominator_;
7177 }; 7230 };
7178 7231
7179 7232
7180 class HStoreKeyedGeneric FINAL : public HTemplateInstruction<4> { 7233 class HStoreKeyedGeneric FINAL : public HTemplateInstruction<4> {
7181 public: 7234 public:
7182 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HStoreKeyedGeneric, HValue*, 7235 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HStoreKeyedGeneric, HValue*,
7183 HValue*, HValue*, StrictMode); 7236 HValue*, HValue*, StrictMode);
7184 7237
7185 HValue* object() const { return OperandAt(0); } 7238 HValue* object() const { return OperandAt(0); }
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
7489 bool); 7542 bool);
7490 HValue* context() { return OperandAt(0); } 7543 HValue* context() { return OperandAt(0); }
7491 7544
7492 virtual Representation RequiredInputRepresentation(int index) OVERRIDE { 7545 virtual Representation RequiredInputRepresentation(int index) OVERRIDE {
7493 return Representation::Tagged(); 7546 return Representation::Tagged();
7494 } 7547 }
7495 7548
7496 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral) 7549 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral)
7497 7550
7498 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } 7551 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; }
7499 bool pretenure() const { return pretenure_; } 7552 bool pretenure() const { return PretenureField::decode(bit_field_); }
7500 bool has_no_literals() const { return has_no_literals_; } 7553 bool has_no_literals() const {
7501 bool is_arrow() const { return IsArrowFunction(kind_); } 7554 return HasNoLiteralsField::decode(bit_field_);
7502 bool is_generator() const { return IsGeneratorFunction(kind_); } 7555 }
7503 bool is_concise_method() const { return IsConciseMethod(kind_); } 7556 bool is_arrow() const { return IsArrowFunction(kind()); }
7504 FunctionKind kind() const { return kind_; } 7557 bool is_generator() const { return IsGeneratorFunction(kind()); }
7505 StrictMode strict_mode() const { return strict_mode_; } 7558 bool is_concise_method() const { return IsConciseMethod(kind()); }
7559 FunctionKind kind() const { return FunctionKindField::decode(bit_field_); }
7560 StrictMode strict_mode() const { return StrictModeField::decode(bit_field_); }
7506 7561
7507 private: 7562 private:
7508 HFunctionLiteral(HValue* context, Handle<SharedFunctionInfo> shared, 7563 HFunctionLiteral(HValue* context, Handle<SharedFunctionInfo> shared,
7509 bool pretenure) 7564 bool pretenure)
7510 : HTemplateInstruction<1>(HType::JSObject()), 7565 : HTemplateInstruction<1>(HType::JSObject()),
7511 shared_info_(shared), 7566 shared_info_(shared),
7512 kind_(shared->kind()), 7567 bit_field_(FunctionKindField::encode(shared->kind()) |
7513 pretenure_(pretenure), 7568 PretenureField::encode(pretenure) |
7514 has_no_literals_(shared->num_literals() == 0), 7569 HasNoLiteralsField::encode(shared->num_literals() == 0) |
7515 strict_mode_(shared->strict_mode()) { 7570 StrictModeField::encode(shared->strict_mode())) {
7516 SetOperandAt(0, context); 7571 SetOperandAt(0, context);
7517 set_representation(Representation::Tagged()); 7572 set_representation(Representation::Tagged());
7518 SetChangesFlag(kNewSpacePromotion); 7573 SetChangesFlag(kNewSpacePromotion);
7519 } 7574 }
7520 7575
7521 virtual bool IsDeletable() const OVERRIDE { return true; } 7576 virtual bool IsDeletable() const OVERRIDE { return true; }
7522 7577
7578 class FunctionKindField : public BitField<FunctionKind, 0, 3> {};
7579 class PretenureField : public BitField<bool, 3, 1> {};
7580 class HasNoLiteralsField : public BitField<bool, 4, 1> {};
7581 class StrictModeField : public BitField<StrictMode, 5, 1> {};
7582
7523 Handle<SharedFunctionInfo> shared_info_; 7583 Handle<SharedFunctionInfo> shared_info_;
7524 FunctionKind kind_; 7584 uint32_t bit_field_;
7525 bool pretenure_ : 1;
7526 bool has_no_literals_ : 1;
7527 StrictMode strict_mode_;
7528 }; 7585 };
7529 7586
7530 7587
7531 class HTypeof FINAL : public HTemplateInstruction<2> { 7588 class HTypeof FINAL : public HTemplateInstruction<2> {
7532 public: 7589 public:
7533 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P1(HTypeof, HValue*); 7590 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P1(HTypeof, HValue*);
7534 7591
7535 HValue* context() const { return OperandAt(0); } 7592 HValue* context() const { return OperandAt(0); }
7536 HValue* value() const { return OperandAt(1); } 7593 HValue* value() const { return OperandAt(1); }
7537 7594
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
7911 }; 7968 };
7912 7969
7913 7970
7914 7971
7915 #undef DECLARE_INSTRUCTION 7972 #undef DECLARE_INSTRUCTION
7916 #undef DECLARE_CONCRETE_INSTRUCTION 7973 #undef DECLARE_CONCRETE_INSTRUCTION
7917 7974
7918 } } // namespace v8::internal 7975 } } // namespace v8::internal
7919 7976
7920 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 7977 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/heap-snapshot-generator-inl.h ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698