OLD | NEW |
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 Name* GetKey() { return key_; } | 59 Name* GetKey() { return key_; } |
60 Object* GetValue() { return value_; } | 60 Object* GetValue() { return value_; } |
61 PropertyDetails GetDetails() { return details_; } | 61 PropertyDetails GetDetails() { return details_; } |
62 | 62 |
63 #ifdef OBJECT_PRINT | 63 #ifdef OBJECT_PRINT |
64 void Print(FILE* out); | 64 void Print(FILE* out); |
65 #endif | 65 #endif |
66 | 66 |
67 void SetEnumerationIndex(int index) { | 67 void SetEnumerationIndex(int index) { |
68 details_ = PropertyDetails(details_.attributes(), details_.type(), index); | 68 details_ = PropertyDetails(details_.attributes(), details_.type(), |
| 69 details_.representation(), index); |
69 } | 70 } |
70 | 71 |
71 void SetSortedKeyIndex(int index) { details_ = details_.set_pointer(index); } | 72 void SetSortedKeyIndex(int index) { details_ = details_.set_pointer(index); } |
72 | 73 |
73 private: | 74 private: |
74 Name* key_; | 75 Name* key_; |
75 Object* value_; | 76 Object* value_; |
76 PropertyDetails details_; | 77 PropertyDetails details_; |
77 | 78 |
78 protected: | 79 protected: |
79 Descriptor() : details_(Smi::FromInt(0)) {} | 80 Descriptor() : details_(Smi::FromInt(0)) {} |
80 | 81 |
81 void Init(Name* key, Object* value, PropertyDetails details) { | 82 void Init(Name* key, Object* value, PropertyDetails details) { |
82 key_ = key; | 83 key_ = key; |
83 value_ = value; | 84 value_ = value; |
84 details_ = details; | 85 details_ = details; |
85 } | 86 } |
86 | 87 |
87 Descriptor(Name* key, Object* value, PropertyDetails details) | 88 Descriptor(Name* key, Object* value, PropertyDetails details) |
88 : key_(key), | 89 : key_(key), |
89 value_(value), | 90 value_(value), |
90 details_(details) { } | 91 details_(details) { } |
91 | 92 |
92 Descriptor(Name* key, | 93 Descriptor(Name* key, |
93 Object* value, | 94 Object* value, |
94 PropertyAttributes attributes, | 95 PropertyAttributes attributes, |
95 PropertyType type, | 96 PropertyType type, |
| 97 Representation representation, |
96 int index) | 98 int index) |
97 : key_(key), | 99 : key_(key), |
98 value_(value), | 100 value_(value), |
99 details_(attributes, type, index) { } | 101 details_(attributes, type, representation, index) { } |
100 | 102 |
101 friend class DescriptorArray; | 103 friend class DescriptorArray; |
102 }; | 104 }; |
103 | 105 |
104 | 106 |
105 class FieldDescriptor: public Descriptor { | 107 class FieldDescriptor: public Descriptor { |
106 public: | 108 public: |
107 FieldDescriptor(Name* key, | 109 FieldDescriptor(Name* key, |
108 int field_index, | 110 int field_index, |
109 PropertyAttributes attributes, | 111 PropertyAttributes attributes, |
| 112 Representation representation, |
110 int index = 0) | 113 int index = 0) |
111 : Descriptor(key, Smi::FromInt(field_index), attributes, FIELD, index) {} | 114 : Descriptor(key, Smi::FromInt(field_index), attributes, |
| 115 FIELD, representation, index) {} |
112 }; | 116 }; |
113 | 117 |
114 | 118 |
115 class ConstantFunctionDescriptor: public Descriptor { | 119 class ConstantFunctionDescriptor: public Descriptor { |
116 public: | 120 public: |
117 ConstantFunctionDescriptor(Name* key, | 121 ConstantFunctionDescriptor(Name* key, |
118 JSFunction* function, | 122 JSFunction* function, |
119 PropertyAttributes attributes, | 123 PropertyAttributes attributes, |
120 int index) | 124 int index) |
121 : Descriptor(key, function, attributes, CONSTANT_FUNCTION, index) {} | 125 : Descriptor(key, function, attributes, |
| 126 CONSTANT_FUNCTION, Representation::Tagged(), index) {} |
122 }; | 127 }; |
123 | 128 |
124 | 129 |
125 class CallbacksDescriptor: public Descriptor { | 130 class CallbacksDescriptor: public Descriptor { |
126 public: | 131 public: |
127 CallbacksDescriptor(Name* key, | 132 CallbacksDescriptor(Name* key, |
128 Object* foreign, | 133 Object* foreign, |
129 PropertyAttributes attributes, | 134 PropertyAttributes attributes, |
130 int index = 0) | 135 int index = 0) |
131 : Descriptor(key, foreign, attributes, CALLBACKS, index) {} | 136 : Descriptor(key, foreign, attributes, CALLBACKS, |
| 137 Representation::Tagged(), index) {} |
132 }; | 138 }; |
133 | 139 |
134 | 140 |
135 // Holds a property index value distinguishing if it is a field index or an | 141 // Holds a property index value distinguishing if it is a field index or an |
136 // index inside the object header. | 142 // index inside the object header. |
137 class PropertyIndex { | 143 class PropertyIndex { |
138 public: | 144 public: |
139 static PropertyIndex NewFieldIndex(int index) { | 145 static PropertyIndex NewFieldIndex(int index) { |
140 return PropertyIndex(index, false); | 146 return PropertyIndex(index, false); |
141 } | 147 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 189 |
184 | 190 |
185 class LookupResult BASE_EMBEDDED { | 191 class LookupResult BASE_EMBEDDED { |
186 public: | 192 public: |
187 explicit LookupResult(Isolate* isolate) | 193 explicit LookupResult(Isolate* isolate) |
188 : isolate_(isolate), | 194 : isolate_(isolate), |
189 next_(isolate->top_lookup_result()), | 195 next_(isolate->top_lookup_result()), |
190 lookup_type_(NOT_FOUND), | 196 lookup_type_(NOT_FOUND), |
191 holder_(NULL), | 197 holder_(NULL), |
192 cacheable_(true), | 198 cacheable_(true), |
193 details_(NONE, NONEXISTENT) { | 199 details_(NONE, NONEXISTENT, Representation::None()) { |
194 isolate->SetTopLookupResult(this); | 200 isolate->SetTopLookupResult(this); |
195 } | 201 } |
196 | 202 |
197 ~LookupResult() { | 203 ~LookupResult() { |
198 ASSERT(isolate()->top_lookup_result() == this); | 204 ASSERT(isolate()->top_lookup_result() == this); |
199 isolate()->SetTopLookupResult(next_); | 205 isolate()->SetTopLookupResult(next_); |
200 } | 206 } |
201 | 207 |
202 Isolate* isolate() const { return isolate_; } | 208 Isolate* isolate() const { return isolate_; } |
203 | 209 |
204 void DescriptorResult(JSObject* holder, PropertyDetails details, int number) { | 210 void DescriptorResult(JSObject* holder, PropertyDetails details, int number) { |
205 lookup_type_ = DESCRIPTOR_TYPE; | 211 lookup_type_ = DESCRIPTOR_TYPE; |
206 holder_ = holder; | 212 holder_ = holder; |
207 details_ = details; | 213 details_ = details; |
208 number_ = number; | 214 number_ = number; |
209 } | 215 } |
210 | 216 |
| 217 bool CanStore(Handle<Object> value) { |
| 218 return value->FitsRepresentation(details_.representation()); |
| 219 } |
| 220 |
211 void TransitionResult(JSObject* holder, int number) { | 221 void TransitionResult(JSObject* holder, int number) { |
212 lookup_type_ = TRANSITION_TYPE; | 222 lookup_type_ = TRANSITION_TYPE; |
213 details_ = PropertyDetails(NONE, TRANSITION); | 223 details_ = PropertyDetails(NONE, TRANSITION, Representation::None()); |
214 holder_ = holder; | 224 holder_ = holder; |
215 number_ = number; | 225 number_ = number; |
216 } | 226 } |
217 | 227 |
218 void DictionaryResult(JSObject* holder, int entry) { | 228 void DictionaryResult(JSObject* holder, int entry) { |
219 lookup_type_ = DICTIONARY_TYPE; | 229 lookup_type_ = DICTIONARY_TYPE; |
220 holder_ = holder; | 230 holder_ = holder; |
221 details_ = holder->property_dictionary()->DetailsAt(entry); | 231 details_ = holder->property_dictionary()->DetailsAt(entry); |
222 number_ = entry; | 232 number_ = entry; |
223 } | 233 } |
224 | 234 |
225 void HandlerResult(JSProxy* proxy) { | 235 void HandlerResult(JSProxy* proxy) { |
226 lookup_type_ = HANDLER_TYPE; | 236 lookup_type_ = HANDLER_TYPE; |
227 holder_ = proxy; | 237 holder_ = proxy; |
228 details_ = PropertyDetails(NONE, HANDLER); | 238 details_ = PropertyDetails(NONE, HANDLER, Representation::None()); |
229 cacheable_ = false; | 239 cacheable_ = false; |
230 } | 240 } |
231 | 241 |
232 void InterceptorResult(JSObject* holder) { | 242 void InterceptorResult(JSObject* holder) { |
233 lookup_type_ = INTERCEPTOR_TYPE; | 243 lookup_type_ = INTERCEPTOR_TYPE; |
234 holder_ = holder; | 244 holder_ = holder; |
235 details_ = PropertyDetails(NONE, INTERCEPTOR); | 245 details_ = PropertyDetails(NONE, INTERCEPTOR, Representation::None()); |
236 } | 246 } |
237 | 247 |
238 void NotFound() { | 248 void NotFound() { |
239 lookup_type_ = NOT_FOUND; | 249 lookup_type_ = NOT_FOUND; |
240 details_ = PropertyDetails(NONE, NONEXISTENT); | 250 details_ = PropertyDetails(NONE, NONEXISTENT, Representation::None()); |
241 holder_ = NULL; | 251 holder_ = NULL; |
242 } | 252 } |
243 | 253 |
244 JSObject* holder() { | 254 JSObject* holder() { |
245 ASSERT(IsFound()); | 255 ASSERT(IsFound()); |
246 return JSObject::cast(holder_); | 256 return JSObject::cast(holder_); |
247 } | 257 } |
248 | 258 |
249 JSProxy* proxy() { | 259 JSProxy* proxy() { |
250 ASSERT(IsFound()); | 260 ASSERT(IsFound()); |
251 return JSProxy::cast(holder_); | 261 return JSProxy::cast(holder_); |
252 } | 262 } |
253 | 263 |
254 PropertyType type() { | 264 PropertyType type() { |
255 ASSERT(IsFound()); | 265 ASSERT(IsFound()); |
256 return details_.type(); | 266 return details_.type(); |
257 } | 267 } |
258 | 268 |
| 269 Representation representation() { |
| 270 ASSERT(IsFound()); |
| 271 return details_.representation(); |
| 272 } |
| 273 |
259 PropertyAttributes GetAttributes() { | 274 PropertyAttributes GetAttributes() { |
260 ASSERT(!IsTransition()); | 275 ASSERT(!IsTransition()); |
261 ASSERT(IsFound()); | 276 ASSERT(IsFound()); |
262 ASSERT(details_.type() != NONEXISTENT); | 277 ASSERT(details_.type() != NONEXISTENT); |
263 return details_.attributes(); | 278 return details_.attributes(); |
264 } | 279 } |
265 | 280 |
266 PropertyDetails GetPropertyDetails() { | 281 PropertyDetails GetPropertyDetails() { |
267 ASSERT(!IsTransition()); | 282 ASSERT(!IsTransition()); |
268 return details_; | 283 return details_; |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 JSReceiver* holder_; | 492 JSReceiver* holder_; |
478 int number_; | 493 int number_; |
479 bool cacheable_; | 494 bool cacheable_; |
480 PropertyDetails details_; | 495 PropertyDetails details_; |
481 }; | 496 }; |
482 | 497 |
483 | 498 |
484 } } // namespace v8::internal | 499 } } // namespace v8::internal |
485 | 500 |
486 #endif // V8_PROPERTY_H_ | 501 #endif // V8_PROPERTY_H_ |
OLD | NEW |