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->set_top_lookup_result(this); | 190 isolate->set_top_lookup_result(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()->set_top_lookup_result(next_); | 195 isolate()->set_top_lookup_result(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; |
| 203 transition_ = NULL; |
202 details_ = details; | 204 details_ = details; |
203 number_ = number; | 205 number_ = number; |
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; |
| 249 transition_ = NULL; |
243 } | 250 } |
244 | 251 |
245 JSObject* holder() { | 252 JSObject* holder() { |
246 ASSERT(IsFound()); | 253 ASSERT(IsFound()); |
247 return JSObject::cast(holder_); | 254 return JSObject::cast(holder_); |
248 } | 255 } |
249 | 256 |
250 JSProxy* proxy() { | 257 JSProxy* proxy() { |
251 ASSERT(IsFound()); | 258 ASSERT(IsHandler()); |
252 return JSProxy::cast(holder_); | 259 return JSProxy::cast(holder_); |
253 } | 260 } |
254 | 261 |
255 PropertyType type() { | 262 PropertyType type() { |
256 ASSERT(IsFound()); | 263 ASSERT(IsFound()); |
257 return details_.type(); | 264 return details_.type(); |
258 } | 265 } |
259 | 266 |
260 Representation representation() { | 267 Representation representation() { |
261 ASSERT(IsFound()); | 268 ASSERT(IsFound()); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 case HANDLER: | 373 case HANDLER: |
367 case INTERCEPTOR: | 374 case INTERCEPTOR: |
368 case TRANSITION: | 375 case TRANSITION: |
369 case NONEXISTENT: | 376 case NONEXISTENT: |
370 return isolate()->heap()->the_hole_value(); | 377 return isolate()->heap()->the_hole_value(); |
371 } | 378 } |
372 UNREACHABLE(); | 379 UNREACHABLE(); |
373 return NULL; | 380 return NULL; |
374 } | 381 } |
375 | 382 |
376 Map* GetTransitionTarget(Map* map) { | |
377 ASSERT(IsTransition()); | |
378 TransitionArray* transitions = map->transitions(); | |
379 return transitions->GetTarget(number_); | |
380 } | |
381 | |
382 Map* GetTransitionTarget() { | 383 Map* GetTransitionTarget() { |
383 return GetTransitionTarget(holder()->map()); | 384 return transition_; |
384 } | |
385 | |
386 PropertyDetails GetTransitionDetails(Map* map) { | |
387 ASSERT(IsTransition()); | |
388 TransitionArray* transitions = map->transitions(); | |
389 return transitions->GetTargetDetails(number_); | |
390 } | 385 } |
391 | 386 |
392 PropertyDetails GetTransitionDetails() { | 387 PropertyDetails GetTransitionDetails() { |
393 return GetTransitionDetails(holder()->map()); | 388 ASSERT(IsTransition()); |
| 389 return transition_->GetLastDescriptorDetails(); |
394 } | 390 } |
395 | 391 |
396 bool IsTransitionToField(Map* map) { | 392 bool IsTransitionToField() { |
397 return IsTransition() && GetTransitionDetails(map).type() == FIELD; | 393 return IsTransition() && GetTransitionDetails().type() == FIELD; |
398 } | 394 } |
399 | 395 |
400 bool IsTransitionToConstant(Map* map) { | 396 bool IsTransitionToConstant() { |
401 return IsTransition() && GetTransitionDetails(map).type() == CONSTANT; | 397 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 } | |
413 | |
414 int GetTransitionIndex() { | |
415 ASSERT(IsTransition()); | |
416 return number_; | |
417 } | 398 } |
418 | 399 |
419 int GetDescriptorIndex() { | 400 int GetDescriptorIndex() { |
420 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); | 401 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); |
421 return number_; | 402 return number_; |
422 } | 403 } |
423 | 404 |
424 PropertyIndex GetFieldIndex() { | 405 PropertyIndex GetFieldIndex() { |
425 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); | 406 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); |
426 return PropertyIndex::NewFieldIndex(GetFieldIndexFromMap(holder()->map())); | 407 return PropertyIndex::NewFieldIndex(GetFieldIndexFromMap(holder()->map())); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 enum { | 475 enum { |
495 NOT_FOUND, | 476 NOT_FOUND, |
496 DESCRIPTOR_TYPE, | 477 DESCRIPTOR_TYPE, |
497 TRANSITION_TYPE, | 478 TRANSITION_TYPE, |
498 DICTIONARY_TYPE, | 479 DICTIONARY_TYPE, |
499 HANDLER_TYPE, | 480 HANDLER_TYPE, |
500 INTERCEPTOR_TYPE | 481 INTERCEPTOR_TYPE |
501 } lookup_type_; | 482 } lookup_type_; |
502 | 483 |
503 JSReceiver* holder_; | 484 JSReceiver* holder_; |
| 485 Map* transition_; |
504 int number_; | 486 int number_; |
505 bool cacheable_; | 487 bool cacheable_; |
506 PropertyDetails details_; | 488 PropertyDetails details_; |
507 }; | 489 }; |
508 | 490 |
509 | 491 |
510 } } // namespace v8::internal | 492 } } // namespace v8::internal |
511 | 493 |
512 #endif // V8_PROPERTY_H_ | 494 #endif // V8_PROPERTY_H_ |
OLD | NEW |