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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 }; | 177 }; |
178 | 178 |
179 | 179 |
180 class LookupResult BASE_EMBEDDED { | 180 class LookupResult BASE_EMBEDDED { |
181 public: | 181 public: |
182 explicit LookupResult(Isolate* isolate) | 182 explicit LookupResult(Isolate* isolate) |
183 : isolate_(isolate), | 183 : isolate_(isolate), |
184 next_(isolate->top_lookup_result()), | 184 next_(isolate->top_lookup_result()), |
185 lookup_type_(NOT_FOUND), | 185 lookup_type_(NOT_FOUND), |
186 holder_(NULL), | 186 holder_(NULL), |
| 187 transition_(NULL), |
187 cacheable_(true), | 188 cacheable_(true), |
188 details_(NONE, NONEXISTENT, Representation::None()) { | 189 details_(NONE, NONEXISTENT, Representation::None()) { |
189 isolate->SetTopLookupResult(this); | 190 isolate->SetTopLookupResult(this); |
190 } | 191 } |
191 | 192 |
192 ~LookupResult() { | 193 ~LookupResult() { |
193 ASSERT(isolate()->top_lookup_result() == this); | 194 ASSERT(isolate()->top_lookup_result() == this); |
194 isolate()->SetTopLookupResult(next_); | 195 isolate()->SetTopLookupResult(next_); |
195 } | 196 } |
196 | 197 |
197 Isolate* isolate() const { return isolate_; } | 198 Isolate* isolate() const { return isolate_; } |
198 | 199 |
199 void DescriptorResult(JSObject* holder, PropertyDetails details, int number) { | 200 void DescriptorResult(JSObject* holder, PropertyDetails details, int number) { |
200 lookup_type_ = DESCRIPTOR_TYPE; | 201 lookup_type_ = DESCRIPTOR_TYPE; |
201 holder_ = holder; | 202 holder_ = holder; |
202 details_ = details; | 203 details_ = details; |
203 number_ = number; | 204 number_ = number; |
| 205 transition_ = NULL; |
204 } | 206 } |
205 | 207 |
206 bool CanHoldValue(Handle<Object> value) { | 208 bool CanHoldValue(Handle<Object> value) { |
207 if (IsNormal()) return true; | 209 if (IsNormal()) return true; |
208 ASSERT(!IsTransition()); | 210 ASSERT(!IsTransition()); |
209 return value->FitsRepresentation(details_.representation()); | 211 return value->FitsRepresentation(details_.representation()); |
210 } | 212 } |
211 | 213 |
212 void TransitionResult(JSObject* holder, int number) { | 214 void TransitionResult(JSObject* holder, Map* target) { |
213 lookup_type_ = TRANSITION_TYPE; | 215 lookup_type_ = TRANSITION_TYPE; |
214 details_ = PropertyDetails(NONE, TRANSITION, Representation::None()); | 216 details_ = PropertyDetails(NONE, TRANSITION, Representation::None()); |
215 holder_ = holder; | 217 holder_ = holder; |
216 number_ = number; | 218 transition_ = target; |
| 219 number_ = 0xAAAA; |
217 } | 220 } |
218 | 221 |
219 void DictionaryResult(JSObject* holder, int entry) { | 222 void DictionaryResult(JSObject* holder, int entry) { |
220 lookup_type_ = DICTIONARY_TYPE; | 223 lookup_type_ = DICTIONARY_TYPE; |
221 holder_ = holder; | 224 holder_ = holder; |
| 225 transition_ = NULL; |
222 details_ = holder->property_dictionary()->DetailsAt(entry); | 226 details_ = holder->property_dictionary()->DetailsAt(entry); |
223 number_ = entry; | 227 number_ = entry; |
224 } | 228 } |
225 | 229 |
226 void HandlerResult(JSProxy* proxy) { | 230 void HandlerResult(JSProxy* proxy) { |
227 lookup_type_ = HANDLER_TYPE; | 231 lookup_type_ = HANDLER_TYPE; |
228 holder_ = proxy; | 232 holder_ = proxy; |
| 233 transition_ = NULL; |
229 details_ = PropertyDetails(NONE, HANDLER, Representation::Tagged()); | 234 details_ = PropertyDetails(NONE, HANDLER, Representation::Tagged()); |
230 cacheable_ = false; | 235 cacheable_ = false; |
231 } | 236 } |
232 | 237 |
233 void InterceptorResult(JSObject* holder) { | 238 void InterceptorResult(JSObject* holder) { |
234 lookup_type_ = INTERCEPTOR_TYPE; | 239 lookup_type_ = INTERCEPTOR_TYPE; |
235 holder_ = holder; | 240 holder_ = holder; |
| 241 transition_ = NULL; |
236 details_ = PropertyDetails(NONE, INTERCEPTOR, Representation::Tagged()); | 242 details_ = PropertyDetails(NONE, INTERCEPTOR, Representation::Tagged()); |
237 } | 243 } |
238 | 244 |
239 void NotFound() { | 245 void NotFound() { |
240 lookup_type_ = NOT_FOUND; | 246 lookup_type_ = NOT_FOUND; |
241 details_ = PropertyDetails(NONE, NONEXISTENT, Representation::None()); | 247 details_ = PropertyDetails(NONE, NONEXISTENT, Representation::None()); |
242 holder_ = NULL; | 248 holder_ = NULL; |
243 } | 249 } |
244 | 250 |
245 JSObject* holder() { | 251 JSObject* holder() { |
246 ASSERT(IsFound()); | 252 ASSERT(IsFound()); |
247 return JSObject::cast(holder_); | 253 return JSObject::cast(holder_); |
248 } | 254 } |
249 | 255 |
250 JSProxy* proxy() { | 256 JSProxy* proxy() { |
251 ASSERT(IsFound()); | 257 ASSERT(IsHandler()); |
252 return JSProxy::cast(holder_); | 258 return JSProxy::cast(holder_); |
253 } | 259 } |
254 | 260 |
255 PropertyType type() { | 261 PropertyType type() { |
256 ASSERT(IsFound()); | 262 ASSERT(IsFound()); |
257 return details_.type(); | 263 return details_.type(); |
258 } | 264 } |
259 | 265 |
260 Representation representation() { | 266 Representation representation() { |
261 ASSERT(IsFound()); | 267 ASSERT(IsFound()); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 case HANDLER: | 372 case HANDLER: |
367 case INTERCEPTOR: | 373 case INTERCEPTOR: |
368 case TRANSITION: | 374 case TRANSITION: |
369 case NONEXISTENT: | 375 case NONEXISTENT: |
370 return isolate()->heap()->the_hole_value(); | 376 return isolate()->heap()->the_hole_value(); |
371 } | 377 } |
372 UNREACHABLE(); | 378 UNREACHABLE(); |
373 return NULL; | 379 return NULL; |
374 } | 380 } |
375 | 381 |
376 Map* GetTransitionTarget(Map* map) { | |
377 ASSERT(IsTransition()); | |
378 TransitionArray* transitions = map->transitions(); | |
379 return transitions->GetTarget(number_); | |
380 } | |
381 | |
382 Map* GetTransitionTarget() { | 382 Map* GetTransitionTarget() { |
383 return GetTransitionTarget(holder()->map()); | 383 return transition_; |
384 } | |
385 | |
386 PropertyDetails GetTransitionDetails(Map* map) { | |
387 ASSERT(IsTransition()); | |
388 TransitionArray* transitions = map->transitions(); | |
389 return transitions->GetTargetDetails(number_); | |
390 } | 384 } |
391 | 385 |
392 PropertyDetails GetTransitionDetails() { | 386 PropertyDetails GetTransitionDetails() { |
393 return GetTransitionDetails(holder()->map()); | 387 return transition_->GetLastDescriptorDetails(); |
394 } | 388 } |
395 | 389 |
396 bool IsTransitionToField(Map* map) { | 390 bool IsTransitionToField() { |
397 return IsTransition() && GetTransitionDetails(map).type() == FIELD; | 391 return IsTransition() && GetTransitionDetails().type() == FIELD; |
398 } | 392 } |
399 | 393 |
400 bool IsTransitionToConstant(Map* map) { | 394 bool IsTransitionToConstant() { |
401 return IsTransition() && GetTransitionDetails(map).type() == CONSTANT; | 395 return IsTransition() && GetTransitionDetails().type() == CONSTANT; |
402 } | |
403 | |
404 Map* GetTransitionMap() { | |
405 ASSERT(IsTransition()); | |
406 return Map::cast(GetValue()); | |
407 } | |
408 | |
409 Map* GetTransitionMapFromMap(Map* map) { | |
410 ASSERT(IsTransition()); | |
411 return map->transitions()->GetTarget(number_); | |
412 } | 396 } |
413 | 397 |
414 int GetTransitionIndex() { | 398 int GetTransitionIndex() { |
415 ASSERT(IsTransition()); | 399 ASSERT(IsTransition()); |
416 return number_; | 400 return number_; |
417 } | 401 } |
418 | 402 |
419 int GetDescriptorIndex() { | 403 int GetDescriptorIndex() { |
420 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); | 404 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); |
421 return number_; | 405 return number_; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 enum { | 478 enum { |
495 NOT_FOUND, | 479 NOT_FOUND, |
496 DESCRIPTOR_TYPE, | 480 DESCRIPTOR_TYPE, |
497 TRANSITION_TYPE, | 481 TRANSITION_TYPE, |
498 DICTIONARY_TYPE, | 482 DICTIONARY_TYPE, |
499 HANDLER_TYPE, | 483 HANDLER_TYPE, |
500 INTERCEPTOR_TYPE | 484 INTERCEPTOR_TYPE |
501 } lookup_type_; | 485 } lookup_type_; |
502 | 486 |
503 JSReceiver* holder_; | 487 JSReceiver* holder_; |
| 488 Map* transition_; |
504 int number_; | 489 int number_; |
505 bool cacheable_; | 490 bool cacheable_; |
506 PropertyDetails details_; | 491 PropertyDetails details_; |
507 }; | 492 }; |
508 | 493 |
509 | 494 |
510 } } // namespace v8::internal | 495 } } // namespace v8::internal |
511 | 496 |
512 #endif // V8_PROPERTY_H_ | 497 #endif // V8_PROPERTY_H_ |
OLD | NEW |