| 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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 return Map::cast(map->transitions()->GetValue(number_)); | 330 return Map::cast(map->transitions()->GetValue(number_)); |
| 331 } | 331 } |
| 332 | 332 |
| 333 int GetFieldIndex() { | 333 int GetFieldIndex() { |
| 334 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); | 334 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); |
| 335 ASSERT(IsField()); | 335 ASSERT(IsField()); |
| 336 return Descriptor::IndexFromValue(GetValue()); | 336 return Descriptor::IndexFromValue(GetValue()); |
| 337 } | 337 } |
| 338 | 338 |
| 339 int GetLocalFieldIndexFromMap(Map* map) { | 339 int GetLocalFieldIndexFromMap(Map* map) { |
| 340 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); | |
| 341 ASSERT(IsField()); | 340 ASSERT(IsField()); |
| 342 return Descriptor::IndexFromValue( | 341 return Descriptor::IndexFromValue(GetValueFromMap(map)) - |
| 343 map->instance_descriptors()->GetValue(number_)) - | |
| 344 map->inobject_properties(); | 342 map->inobject_properties(); |
| 345 } | 343 } |
| 346 | 344 |
| 347 int GetDictionaryEntry() { | 345 int GetDictionaryEntry() { |
| 348 ASSERT(lookup_type_ == DICTIONARY_TYPE); | 346 ASSERT(lookup_type_ == DICTIONARY_TYPE); |
| 349 return number_; | 347 return number_; |
| 350 } | 348 } |
| 351 | 349 |
| 352 JSFunction* GetConstantFunction() { | 350 JSFunction* GetConstantFunction() { |
| 353 ASSERT(type() == CONSTANT_FUNCTION); | 351 ASSERT(type() == CONSTANT_FUNCTION); |
| 354 return JSFunction::cast(GetValue()); | 352 return JSFunction::cast(GetValue()); |
| 355 } | 353 } |
| 356 | 354 |
| 357 JSFunction* GetConstantFunctionFromMap(Map* map) { | 355 JSFunction* GetConstantFunctionFromMap(Map* map) { |
| 358 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); | |
| 359 ASSERT(type() == CONSTANT_FUNCTION); | 356 ASSERT(type() == CONSTANT_FUNCTION); |
| 360 return JSFunction::cast(map->instance_descriptors()->GetValue(number_)); | 357 return JSFunction::cast(GetValueFromMap(map)); |
| 361 } | 358 } |
| 362 | 359 |
| 363 Object* GetCallbackObject() { | 360 Object* GetCallbackObject() { |
| 364 switch (lookup_type_) { | 361 switch (lookup_type_) { |
| 365 case CONSTANT_TYPE: | 362 case CONSTANT_TYPE: |
| 366 return HEAP->prototype_accessors(); | 363 return HEAP->prototype_accessors(); |
| 367 case TRANSITION_TYPE: | 364 case TRANSITION_TYPE: |
| 368 return GetTransitionValue(); | 365 return GetTransitionValue(); |
| 369 default: | 366 default: |
| 370 return GetValue(); | 367 return GetValue(); |
| 371 } | 368 } |
| 372 } | 369 } |
| 373 | 370 |
| 374 #ifdef OBJECT_PRINT | 371 #ifdef OBJECT_PRINT |
| 375 void Print(FILE* out); | 372 void Print(FILE* out); |
| 376 #endif | 373 #endif |
| 377 | 374 |
| 378 Object* GetValue() { | 375 Object* GetValue() { |
| 379 if (lookup_type_ == DESCRIPTOR_TYPE) { | 376 if (lookup_type_ == DESCRIPTOR_TYPE) { |
| 380 DescriptorArray* descriptors = holder()->map()->instance_descriptors(); | 377 return GetValueFromMap(holder()->map()); |
| 381 return descriptors->GetValue(number_); | |
| 382 } | 378 } |
| 383 // In the dictionary case, the data is held in the value field. | 379 // In the dictionary case, the data is held in the value field. |
| 384 ASSERT(lookup_type_ == DICTIONARY_TYPE); | 380 ASSERT(lookup_type_ == DICTIONARY_TYPE); |
| 385 return holder()->GetNormalizedProperty(this); | 381 return holder()->GetNormalizedProperty(this); |
| 386 } | 382 } |
| 387 | 383 |
| 384 Object* GetValueFromMap(Map* map) const { |
| 385 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); |
| 386 return map->instance_descriptors()->GetValue(number_); |
| 387 } |
| 388 |
| 388 void Iterate(ObjectVisitor* visitor); | 389 void Iterate(ObjectVisitor* visitor); |
| 389 | 390 |
| 390 private: | 391 private: |
| 391 Isolate* isolate_; | 392 Isolate* isolate_; |
| 392 LookupResult* next_; | 393 LookupResult* next_; |
| 393 | 394 |
| 394 // Where did we find the result; | 395 // Where did we find the result; |
| 395 enum { | 396 enum { |
| 396 NOT_FOUND, | 397 NOT_FOUND, |
| 397 DESCRIPTOR_TYPE, | 398 DESCRIPTOR_TYPE, |
| 398 TRANSITION_TYPE, | 399 TRANSITION_TYPE, |
| 399 DICTIONARY_TYPE, | 400 DICTIONARY_TYPE, |
| 400 HANDLER_TYPE, | 401 HANDLER_TYPE, |
| 401 INTERCEPTOR_TYPE, | 402 INTERCEPTOR_TYPE, |
| 402 CONSTANT_TYPE | 403 CONSTANT_TYPE |
| 403 } lookup_type_; | 404 } lookup_type_; |
| 404 | 405 |
| 405 JSReceiver* holder_; | 406 JSReceiver* holder_; |
| 406 int number_; | 407 int number_; |
| 407 bool cacheable_; | 408 bool cacheable_; |
| 408 PropertyDetails details_; | 409 PropertyDetails details_; |
| 409 }; | 410 }; |
| 410 | 411 |
| 411 | 412 |
| 412 } } // namespace v8::internal | 413 } } // namespace v8::internal |
| 413 | 414 |
| 414 #endif // V8_PROPERTY_H_ | 415 #endif // V8_PROPERTY_H_ |
| OLD | NEW |