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/property-details.h

Issue 14996004: Track heap objects. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/objects-inl.h ('k') | src/x64/lithium-codegen-x64.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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 }; 76 };
77 77
78 78
79 class Representation { 79 class Representation {
80 public: 80 public:
81 enum Kind { 81 enum Kind {
82 kNone, 82 kNone,
83 kSmi, 83 kSmi,
84 kInteger32, 84 kInteger32,
85 kDouble, 85 kDouble,
86 kHeapObject,
86 kTagged, 87 kTagged,
87 kExternal, 88 kExternal,
88 kNumRepresentations 89 kNumRepresentations
89 }; 90 };
90 91
91 Representation() : kind_(kNone) { } 92 Representation() : kind_(kNone) { }
92 93
93 static Representation None() { return Representation(kNone); } 94 static Representation None() { return Representation(kNone); }
94 static Representation Tagged() { return Representation(kTagged); } 95 static Representation Tagged() { return Representation(kTagged); }
95 static Representation Smi() { return Representation(kSmi); } 96 static Representation Smi() { return Representation(kSmi); }
96 static Representation Integer32() { return Representation(kInteger32); } 97 static Representation Integer32() { return Representation(kInteger32); }
97 static Representation Double() { return Representation(kDouble); } 98 static Representation Double() { return Representation(kDouble); }
99 static Representation HeapObject() { return Representation(kHeapObject); }
98 static Representation External() { return Representation(kExternal); } 100 static Representation External() { return Representation(kExternal); }
99 101
100 static Representation FromKind(Kind kind) { return Representation(kind); } 102 static Representation FromKind(Kind kind) { return Representation(kind); }
101 103
102 bool Equals(const Representation& other) const { 104 bool Equals(const Representation& other) const {
103 return kind_ == other.kind_; 105 return kind_ == other.kind_;
104 } 106 }
105 107
106 bool IsCompatibleForLoad(const Representation& other) const { 108 bool IsCompatibleForLoad(const Representation& other) const {
107 return (IsDouble() && other.IsDouble()) || 109 return (IsDouble() && other.IsDouble()) ||
108 (!IsDouble() && !other.IsDouble()); 110 (!IsDouble() && !other.IsDouble());
109 } 111 }
110 112
111 bool is_more_general_than(const Representation& other) const { 113 bool is_more_general_than(const Representation& other) const {
112 ASSERT(kind_ != kExternal); 114 ASSERT(kind_ != kExternal);
113 ASSERT(other.kind_ != kExternal); 115 ASSERT(other.kind_ != kExternal);
116 if (IsHeapObject()) return other.IsDouble();
114 return kind_ > other.kind_; 117 return kind_ > other.kind_;
115 } 118 }
116 119
117 bool fits_into(const Representation& other) const { 120 bool fits_into(const Representation& other) const {
118 return other.is_more_general_than(*this) || other.Equals(*this); 121 return other.is_more_general_than(*this) || other.Equals(*this);
119 } 122 }
120 123
121 Representation generalize(Representation other) { 124 Representation generalize(Representation other) {
122 if (is_more_general_than(other)) { 125 if (other.fits_into(*this)) return *this;
123 return *this; 126 if (other.is_more_general_than(*this)) return other;
124 } else { 127 return Representation::Tagged();
125 return other;
126 }
127 } 128 }
128 129
129 Kind kind() const { return static_cast<Kind>(kind_); } 130 Kind kind() const { return static_cast<Kind>(kind_); }
130 bool IsNone() const { return kind_ == kNone; } 131 bool IsNone() const { return kind_ == kNone; }
131 bool IsTagged() const { return kind_ == kTagged; } 132 bool IsTagged() const { return kind_ == kTagged; }
132 bool IsSmi() const { return kind_ == kSmi; } 133 bool IsSmi() const { return kind_ == kSmi; }
133 bool IsInteger32() const { return kind_ == kInteger32; } 134 bool IsInteger32() const { return kind_ == kInteger32; }
134 bool IsDouble() const { return kind_ == kDouble; } 135 bool IsDouble() const { return kind_ == kDouble; }
136 bool IsHeapObject() const { return kind_ == kHeapObject; }
135 bool IsExternal() const { return kind_ == kExternal; } 137 bool IsExternal() const { return kind_ == kExternal; }
136 bool IsSpecialization() const { 138 bool IsSpecialization() const {
137 return kind_ == kInteger32 || kind_ == kDouble; 139 return kind_ == kInteger32 || kind_ == kDouble;
138 } 140 }
139 const char* Mnemonic() const; 141 const char* Mnemonic() const;
140 142
141 private: 143 private:
142 explicit Representation(Kind k) : kind_(k) { } 144 explicit Representation(Kind k) : kind_(k) { }
143 145
144 // Make sure kind fits in int8. 146 // Make sure kind fits in int8.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 value_ = RepresentationField::update( 237 value_ = RepresentationField::update(
236 value, EncodeRepresentation(representation)); 238 value, EncodeRepresentation(representation));
237 } 239 }
238 240
239 uint32_t value_; 241 uint32_t value_;
240 }; 242 };
241 243
242 } } // namespace v8::internal 244 } } // namespace v8::internal
243 245
244 #endif // V8_PROPERTY_DETAILS_H_ 246 #endif // V8_PROPERTY_DETAILS_H_
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698