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

Side by Side Diff: src/property-details.h

Issue 185653004: Experimental parser: merge to r19637 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 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/property.cc ('k') | src/regexp-macro-assembler.h » ('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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // bitfield. It is only used as a return value meaning the attributes of 52 // bitfield. It is only used as a return value meaning the attributes of
53 // a non-existent property. 53 // a non-existent property.
54 }; 54 };
55 55
56 56
57 namespace v8 { 57 namespace v8 {
58 namespace internal { 58 namespace internal {
59 59
60 class Smi; 60 class Smi;
61 template<class> class TypeImpl; 61 template<class> class TypeImpl;
62 struct HeapTypeConfig; 62 struct ZoneTypeConfig;
63 typedef TypeImpl<HeapTypeConfig> Type; 63 typedef TypeImpl<ZoneTypeConfig> Type;
64 class TypeInfo; 64 class TypeInfo;
65 65
66 // Type of properties. 66 // Type of properties.
67 // Order of properties is significant. 67 // Order of properties is significant.
68 // Must fit in the BitField PropertyDetails::TypeField. 68 // Must fit in the BitField PropertyDetails::TypeField.
69 // A copy of this is in mirror-debugger.js. 69 // A copy of this is in mirror-debugger.js.
70 enum PropertyType { 70 enum PropertyType {
71 // Only in slow mode. 71 // Only in slow mode.
72 NORMAL = 0, 72 NORMAL = 0,
73 // Only in fast mode. 73 // Only in fast mode.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 static Representation Integer16() { return Representation(kInteger16); } 109 static Representation Integer16() { return Representation(kInteger16); }
110 static Representation UInteger16() { return Representation(kUInteger16); } 110 static Representation UInteger16() { return Representation(kUInteger16); }
111 static Representation Smi() { return Representation(kSmi); } 111 static Representation Smi() { return Representation(kSmi); }
112 static Representation Integer32() { return Representation(kInteger32); } 112 static Representation Integer32() { return Representation(kInteger32); }
113 static Representation Double() { return Representation(kDouble); } 113 static Representation Double() { return Representation(kDouble); }
114 static Representation HeapObject() { return Representation(kHeapObject); } 114 static Representation HeapObject() { return Representation(kHeapObject); }
115 static Representation External() { return Representation(kExternal); } 115 static Representation External() { return Representation(kExternal); }
116 116
117 static Representation FromKind(Kind kind) { return Representation(kind); } 117 static Representation FromKind(Kind kind) { return Representation(kind); }
118 118
119 static Representation FromType(Handle<Type> type); 119 static Representation FromType(Type* type);
120 120
121 bool Equals(const Representation& other) const { 121 bool Equals(const Representation& other) const {
122 return kind_ == other.kind_; 122 return kind_ == other.kind_;
123 } 123 }
124 124
125 bool IsCompatibleForLoad(const Representation& other) const { 125 bool IsCompatibleForLoad(const Representation& other) const {
126 return (IsDouble() && other.IsDouble()) || 126 return (IsDouble() && other.IsDouble()) ||
127 (!IsDouble() && !other.IsDouble()); 127 (!IsDouble() && !other.IsDouble());
128 } 128 }
129 129
130 bool IsCompatibleForStore(const Representation& other) const { 130 bool IsCompatibleForStore(const Representation& other) const {
131 return Equals(other); 131 return Equals(other);
132 } 132 }
133 133
134 bool is_more_general_than(const Representation& other) const { 134 bool is_more_general_than(const Representation& other) const {
135 if (kind_ == kExternal && other.kind_ == kNone) return true; 135 if (kind_ == kExternal && other.kind_ == kNone) return true;
136 if (kind_ == kExternal && other.kind_ == kExternal) return false; 136 if (kind_ == kExternal && other.kind_ == kExternal) return false;
137 if (kind_ == kNone && other.kind_ == kExternal) return false; 137 if (kind_ == kNone && other.kind_ == kExternal) return false;
138 138
139 ASSERT(kind_ != kExternal); 139 ASSERT(kind_ != kExternal);
140 ASSERT(other.kind_ != kExternal); 140 ASSERT(other.kind_ != kExternal);
141 if (IsHeapObject()) return other.IsDouble() || other.IsNone(); 141 if (IsHeapObject()) return other.IsNone();
142 if (kind_ == kUInteger8 && other.kind_ == kInteger8) return false; 142 if (kind_ == kUInteger8 && other.kind_ == kInteger8) return false;
143 if (kind_ == kUInteger16 && other.kind_ == kInteger16) return false; 143 if (kind_ == kUInteger16 && other.kind_ == kInteger16) return false;
144 return kind_ > other.kind_; 144 return kind_ > other.kind_;
145 } 145 }
146 146
147 bool fits_into(const Representation& other) const { 147 bool fits_into(const Representation& other) const {
148 return other.is_more_general_than(*this) || other.Equals(*this); 148 return other.is_more_general_than(*this) || other.Equals(*this);
149 } 149 }
150 150
151 Representation generalize(Representation other) { 151 Representation generalize(Representation other) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 PropertyDetails(PropertyAttributes attributes, 226 PropertyDetails(PropertyAttributes attributes,
227 PropertyType type, 227 PropertyType type,
228 Representation representation, 228 Representation representation,
229 int field_index = 0) { 229 int field_index = 0) {
230 value_ = TypeField::encode(type) 230 value_ = TypeField::encode(type)
231 | AttributesField::encode(attributes) 231 | AttributesField::encode(attributes)
232 | RepresentationField::encode(EncodeRepresentation(representation)) 232 | RepresentationField::encode(EncodeRepresentation(representation))
233 | FieldIndexField::encode(field_index); 233 | FieldIndexField::encode(field_index);
234 } 234 }
235 235
236 int pointer() { return DescriptorPointer::decode(value_); } 236 int pointer() const { return DescriptorPointer::decode(value_); }
237 237
238 PropertyDetails set_pointer(int i) { return PropertyDetails(value_, i); } 238 PropertyDetails set_pointer(int i) { return PropertyDetails(value_, i); }
239 239
240 PropertyDetails CopyWithRepresentation(Representation representation) { 240 PropertyDetails CopyWithRepresentation(Representation representation) const {
241 return PropertyDetails(value_, representation); 241 return PropertyDetails(value_, representation);
242 } 242 }
243 PropertyDetails CopyAddAttributes(PropertyAttributes new_attributes) { 243 PropertyDetails CopyAddAttributes(PropertyAttributes new_attributes) {
244 new_attributes = 244 new_attributes =
245 static_cast<PropertyAttributes>(attributes() | new_attributes); 245 static_cast<PropertyAttributes>(attributes() | new_attributes);
246 return PropertyDetails(value_, new_attributes); 246 return PropertyDetails(value_, new_attributes);
247 } 247 }
248 248
249 // Conversion for storing details as Object*. 249 // Conversion for storing details as Object*.
250 explicit inline PropertyDetails(Smi* smi); 250 explicit inline PropertyDetails(Smi* smi);
251 inline Smi* AsSmi(); 251 inline Smi* AsSmi() const;
252 252
253 static uint8_t EncodeRepresentation(Representation representation) { 253 static uint8_t EncodeRepresentation(Representation representation) {
254 return representation.kind(); 254 return representation.kind();
255 } 255 }
256 256
257 static Representation DecodeRepresentation(uint32_t bits) { 257 static Representation DecodeRepresentation(uint32_t bits) {
258 return Representation::FromKind(static_cast<Representation::Kind>(bits)); 258 return Representation::FromKind(static_cast<Representation::Kind>(bits));
259 } 259 }
260 260
261 PropertyType type() { return TypeField::decode(value_); } 261 PropertyType type() const { return TypeField::decode(value_); }
262 262
263 PropertyAttributes attributes() const { 263 PropertyAttributes attributes() const {
264 return AttributesField::decode(value_); 264 return AttributesField::decode(value_);
265 } 265 }
266 266
267 int dictionary_index() { 267 int dictionary_index() const {
268 return DictionaryStorageField::decode(value_); 268 return DictionaryStorageField::decode(value_);
269 } 269 }
270 270
271 Representation representation() { 271 Representation representation() const {
272 ASSERT(type() != NORMAL); 272 ASSERT(type() != NORMAL);
273 return DecodeRepresentation(RepresentationField::decode(value_)); 273 return DecodeRepresentation(RepresentationField::decode(value_));
274 } 274 }
275 275
276 int field_index() { 276 int field_index() const {
277 return FieldIndexField::decode(value_); 277 return FieldIndexField::decode(value_);
278 } 278 }
279 279
280 inline PropertyDetails AsDeleted(); 280 inline PropertyDetails AsDeleted() const;
281 281
282 static bool IsValidIndex(int index) { 282 static bool IsValidIndex(int index) {
283 return DictionaryStorageField::is_valid(index); 283 return DictionaryStorageField::is_valid(index);
284 } 284 }
285 285
286 bool IsReadOnly() const { return (attributes() & READ_ONLY) != 0; } 286 bool IsReadOnly() const { return (attributes() & READ_ONLY) != 0; }
287 bool IsDontDelete() const { return (attributes() & DONT_DELETE) != 0; } 287 bool IsDontDelete() const { return (attributes() & DONT_DELETE) != 0; }
288 bool IsDontEnum() const { return (attributes() & DONT_ENUM) != 0; } 288 bool IsDontEnum() const { return (attributes() & DONT_ENUM) != 0; }
289 bool IsDeleted() const { return DeletedField::decode(value_) != 0;} 289 bool IsDeleted() const { return DeletedField::decode(value_) != 0;}
290 290
(...skipping 29 matching lines...) Expand all
320 PropertyDetails(int value, PropertyAttributes attributes) { 320 PropertyDetails(int value, PropertyAttributes attributes) {
321 value_ = AttributesField::update(value, attributes); 321 value_ = AttributesField::update(value, attributes);
322 } 322 }
323 323
324 uint32_t value_; 324 uint32_t value_;
325 }; 325 };
326 326
327 } } // namespace v8::internal 327 } } // namespace v8::internal
328 328
329 #endif // V8_PROPERTY_DETAILS_H_ 329 #endif // V8_PROPERTY_DETAILS_H_
OLDNEW
« no previous file with comments | « src/property.cc ('k') | src/regexp-macro-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698