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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 public: | 99 public: |
100 FieldDescriptor(Name* key, | 100 FieldDescriptor(Name* key, |
101 int field_index, | 101 int field_index, |
102 PropertyAttributes attributes, | 102 PropertyAttributes attributes, |
103 Representation representation) | 103 Representation representation) |
104 : Descriptor(key, Smi::FromInt(0), attributes, | 104 : Descriptor(key, Smi::FromInt(0), attributes, |
105 FIELD, representation, field_index) {} | 105 FIELD, representation, field_index) {} |
106 }; | 106 }; |
107 | 107 |
108 | 108 |
109 class ConstantFunctionDescriptor: public Descriptor { | 109 class ConstantDescriptor: public Descriptor { |
110 public: | 110 public: |
111 ConstantFunctionDescriptor(Name* key, | 111 ConstantDescriptor(Name* key, |
112 JSFunction* function, | 112 Object* value, |
113 PropertyAttributes attributes) | 113 PropertyAttributes attributes) |
114 : Descriptor(key, function, attributes, CONSTANT_FUNCTION, | 114 : Descriptor(key, value, attributes, CONSTANT, |
115 Representation::HeapObject()) {} | 115 value->OptimalRepresentation()) {} |
116 }; | 116 }; |
117 | 117 |
118 | 118 |
119 class CallbacksDescriptor: public Descriptor { | 119 class CallbacksDescriptor: public Descriptor { |
120 public: | 120 public: |
121 CallbacksDescriptor(Name* key, | 121 CallbacksDescriptor(Name* key, |
122 Object* foreign, | 122 Object* foreign, |
123 PropertyAttributes attributes) | 123 PropertyAttributes attributes) |
124 : Descriptor(key, foreign, attributes, CALLBACKS, | 124 : Descriptor(key, foreign, attributes, CALLBACKS, |
125 Representation::Tagged()) {} | 125 Representation::Tagged()) {} |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 bool IsField() { | 296 bool IsField() { |
297 ASSERT(!(details_.type() == FIELD && !IsFound())); | 297 ASSERT(!(details_.type() == FIELD && !IsFound())); |
298 return details_.type() == FIELD; | 298 return details_.type() == FIELD; |
299 } | 299 } |
300 | 300 |
301 bool IsNormal() { | 301 bool IsNormal() { |
302 ASSERT(!(details_.type() == NORMAL && !IsFound())); | 302 ASSERT(!(details_.type() == NORMAL && !IsFound())); |
303 return details_.type() == NORMAL; | 303 return details_.type() == NORMAL; |
304 } | 304 } |
305 | 305 |
| 306 bool IsConstant() { |
| 307 ASSERT(!(details_.type() == CONSTANT && !IsFound())); |
| 308 return details_.type() == CONSTANT; |
| 309 } |
| 310 |
306 bool IsConstantFunction() { | 311 bool IsConstantFunction() { |
307 ASSERT(!(details_.type() == CONSTANT_FUNCTION && !IsFound())); | 312 return IsConstant() && GetValue()->IsJSFunction(); |
308 return details_.type() == CONSTANT_FUNCTION; | |
309 } | 313 } |
310 | 314 |
311 bool IsDontDelete() { return details_.IsDontDelete(); } | 315 bool IsDontDelete() { return details_.IsDontDelete(); } |
312 bool IsDontEnum() { return details_.IsDontEnum(); } | 316 bool IsDontEnum() { return details_.IsDontEnum(); } |
313 bool IsFound() { return lookup_type_ != NOT_FOUND; } | 317 bool IsFound() { return lookup_type_ != NOT_FOUND; } |
314 bool IsTransition() { return lookup_type_ == TRANSITION_TYPE; } | 318 bool IsTransition() { return lookup_type_ == TRANSITION_TYPE; } |
315 bool IsHandler() { return lookup_type_ == HANDLER_TYPE; } | 319 bool IsHandler() { return lookup_type_ == HANDLER_TYPE; } |
316 bool IsInterceptor() { return lookup_type_ == INTERCEPTOR_TYPE; } | 320 bool IsInterceptor() { return lookup_type_ == INTERCEPTOR_TYPE; } |
317 | 321 |
318 // Is the result is a property excluding transitions and the null descriptor? | 322 // Is the result is a property excluding transitions and the null descriptor? |
319 bool IsProperty() { | 323 bool IsProperty() { |
320 return IsFound() && !IsTransition(); | 324 return IsFound() && !IsTransition(); |
321 } | 325 } |
322 | 326 |
323 bool IsDataProperty() { | 327 bool IsDataProperty() { |
324 switch (type()) { | 328 switch (type()) { |
325 case FIELD: | 329 case FIELD: |
326 case NORMAL: | 330 case NORMAL: |
327 case CONSTANT_FUNCTION: | 331 case CONSTANT: |
328 return true; | 332 return true; |
329 case CALLBACKS: { | 333 case CALLBACKS: { |
330 Object* callback = GetCallbackObject(); | 334 Object* callback = GetCallbackObject(); |
331 return callback->IsAccessorInfo() || callback->IsForeign(); | 335 return callback->IsAccessorInfo() || callback->IsForeign(); |
332 } | 336 } |
333 case HANDLER: | 337 case HANDLER: |
334 case INTERCEPTOR: | 338 case INTERCEPTOR: |
335 case TRANSITION: | 339 case TRANSITION: |
336 case NONEXISTENT: | 340 case NONEXISTENT: |
337 return false; | 341 return false; |
(...skipping 10 matching lines...) Expand all Loading... |
348 case FIELD: | 352 case FIELD: |
349 return holder()->RawFastPropertyAt(GetFieldIndex().field_index()); | 353 return holder()->RawFastPropertyAt(GetFieldIndex().field_index()); |
350 case NORMAL: { | 354 case NORMAL: { |
351 Object* value; | 355 Object* value; |
352 value = holder()->property_dictionary()->ValueAt(GetDictionaryEntry()); | 356 value = holder()->property_dictionary()->ValueAt(GetDictionaryEntry()); |
353 if (holder()->IsGlobalObject()) { | 357 if (holder()->IsGlobalObject()) { |
354 value = PropertyCell::cast(value)->value(); | 358 value = PropertyCell::cast(value)->value(); |
355 } | 359 } |
356 return value; | 360 return value; |
357 } | 361 } |
358 case CONSTANT_FUNCTION: | 362 case CONSTANT: |
359 return GetConstantFunction(); | 363 return GetConstant(); |
360 case CALLBACKS: | 364 case CALLBACKS: |
361 case HANDLER: | 365 case HANDLER: |
362 case INTERCEPTOR: | 366 case INTERCEPTOR: |
363 case TRANSITION: | 367 case TRANSITION: |
364 case NONEXISTENT: | 368 case NONEXISTENT: |
365 return isolate()->heap()->the_hole_value(); | 369 return isolate()->heap()->the_hole_value(); |
366 } | 370 } |
367 UNREACHABLE(); | 371 UNREACHABLE(); |
368 return NULL; | 372 return NULL; |
369 } | 373 } |
(...skipping 15 matching lines...) Expand all Loading... |
385 } | 389 } |
386 | 390 |
387 PropertyDetails GetTransitionDetails() { | 391 PropertyDetails GetTransitionDetails() { |
388 return GetTransitionDetails(holder()->map()); | 392 return GetTransitionDetails(holder()->map()); |
389 } | 393 } |
390 | 394 |
391 bool IsTransitionToField(Map* map) { | 395 bool IsTransitionToField(Map* map) { |
392 return IsTransition() && GetTransitionDetails(map).type() == FIELD; | 396 return IsTransition() && GetTransitionDetails(map).type() == FIELD; |
393 } | 397 } |
394 | 398 |
395 bool IsTransitionToConstantFunction(Map* map) { | 399 bool IsTransitionToConstant(Map* map) { |
396 return IsTransition() && | 400 return IsTransition() && GetTransitionDetails(map).type() == CONSTANT; |
397 GetTransitionDetails(map).type() == CONSTANT_FUNCTION; | |
398 } | 401 } |
399 | 402 |
400 Map* GetTransitionMap() { | 403 Map* GetTransitionMap() { |
401 ASSERT(IsTransition()); | 404 ASSERT(IsTransition()); |
402 return Map::cast(GetValue()); | 405 return Map::cast(GetValue()); |
403 } | 406 } |
404 | 407 |
405 Map* GetTransitionMapFromMap(Map* map) { | 408 Map* GetTransitionMapFromMap(Map* map) { |
406 ASSERT(IsTransition()); | 409 ASSERT(IsTransition()); |
407 return map->transitions()->GetTarget(number_); | 410 return map->transitions()->GetTarget(number_); |
(...skipping 19 matching lines...) Expand all Loading... |
427 ASSERT(IsField()); | 430 ASSERT(IsField()); |
428 return GetFieldIndexFromMap(map) - map->inobject_properties(); | 431 return GetFieldIndexFromMap(map) - map->inobject_properties(); |
429 } | 432 } |
430 | 433 |
431 int GetDictionaryEntry() { | 434 int GetDictionaryEntry() { |
432 ASSERT(lookup_type_ == DICTIONARY_TYPE); | 435 ASSERT(lookup_type_ == DICTIONARY_TYPE); |
433 return number_; | 436 return number_; |
434 } | 437 } |
435 | 438 |
436 JSFunction* GetConstantFunction() { | 439 JSFunction* GetConstantFunction() { |
437 ASSERT(type() == CONSTANT_FUNCTION); | 440 ASSERT(type() == CONSTANT); |
438 return JSFunction::cast(GetValue()); | 441 return JSFunction::cast(GetValue()); |
439 } | 442 } |
440 | 443 |
| 444 Object* GetConstantFromMap(Map* map) { |
| 445 ASSERT(type() == CONSTANT); |
| 446 return GetValueFromMap(map); |
| 447 } |
| 448 |
441 JSFunction* GetConstantFunctionFromMap(Map* map) { | 449 JSFunction* GetConstantFunctionFromMap(Map* map) { |
442 ASSERT(type() == CONSTANT_FUNCTION); | 450 return JSFunction::cast(GetConstantFromMap(map)); |
443 return JSFunction::cast(GetValueFromMap(map)); | 451 } |
| 452 |
| 453 Object* GetConstant() { |
| 454 ASSERT(type() == CONSTANT); |
| 455 return GetValue(); |
444 } | 456 } |
445 | 457 |
446 Object* GetCallbackObject() { | 458 Object* GetCallbackObject() { |
447 ASSERT(type() == CALLBACKS && !IsTransition()); | 459 ASSERT(type() == CALLBACKS && !IsTransition()); |
448 return GetValue(); | 460 return GetValue(); |
449 } | 461 } |
450 | 462 |
451 #ifdef OBJECT_PRINT | 463 #ifdef OBJECT_PRINT |
452 void Print(FILE* out); | 464 void Print(FILE* out); |
453 #endif | 465 #endif |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 JSReceiver* holder_; | 504 JSReceiver* holder_; |
493 int number_; | 505 int number_; |
494 bool cacheable_; | 506 bool cacheable_; |
495 PropertyDetails details_; | 507 PropertyDetails details_; |
496 }; | 508 }; |
497 | 509 |
498 | 510 |
499 } } // namespace v8::internal | 511 } } // namespace v8::internal |
500 | 512 |
501 #endif // V8_PROPERTY_H_ | 513 #endif // V8_PROPERTY_H_ |
OLD | NEW |