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 3361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3372 | 3372 |
3373 Map* map_of_this = map(); | 3373 Map* map_of_this = map(); |
3374 | 3374 |
3375 // Allocate new content. | 3375 // Allocate new content. |
3376 int property_count = map_of_this->NumberOfDescribedProperties(); | 3376 int property_count = map_of_this->NumberOfDescribedProperties(); |
3377 if (expected_additional_properties > 0) { | 3377 if (expected_additional_properties > 0) { |
3378 property_count += expected_additional_properties; | 3378 property_count += expected_additional_properties; |
3379 } else { | 3379 } else { |
3380 property_count += 2; // Make space for two more properties. | 3380 property_count += 2; // Make space for two more properties. |
3381 } | 3381 } |
3382 Object* obj; | 3382 StringDictionary* dictionary; |
3383 { MaybeObject* maybe_obj = | 3383 { MaybeObject* maybe_dictionary = StringDictionary::Allocate(property_count); |
3384 StringDictionary::Allocate(property_count); | 3384 if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary; |
3385 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | |
3386 } | 3385 } |
3387 StringDictionary* dictionary = StringDictionary::cast(obj); | |
3388 | 3386 |
3389 DescriptorArray* descs = map_of_this->instance_descriptors(); | 3387 DescriptorArray* descs = map_of_this->instance_descriptors(); |
3390 for (int i = 0; i < descs->number_of_descriptors(); i++) { | 3388 for (int i = 0; i < descs->number_of_descriptors(); i++) { |
3391 PropertyDetails details(descs->GetDetails(i)); | 3389 PropertyDetails details(descs->GetDetails(i)); |
3392 switch (details.type()) { | 3390 switch (details.type()) { |
3393 case CONSTANT_FUNCTION: { | 3391 case CONSTANT_FUNCTION: { |
3394 PropertyDetails d = | 3392 PropertyDetails d = |
3395 PropertyDetails(details.attributes(), NORMAL, details.index()); | 3393 PropertyDetails(details.attributes(), NORMAL, details.index()); |
3396 Object* value = descs->GetConstantFunction(i); | 3394 Object* value = descs->GetConstantFunction(i); |
3397 Object* result; | 3395 MaybeObject* maybe_dictionary = |
3398 { MaybeObject* maybe_result = | 3396 dictionary->Add(descs->GetKey(i), value, d); |
3399 dictionary->Add(descs->GetKey(i), value, d); | 3397 if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary; |
3400 if (!maybe_result->ToObject(&result)) return maybe_result; | |
3401 } | |
3402 dictionary = StringDictionary::cast(result); | |
3403 break; | 3398 break; |
3404 } | 3399 } |
3405 case FIELD: { | 3400 case FIELD: { |
3406 PropertyDetails d = | 3401 PropertyDetails d = |
3407 PropertyDetails(details.attributes(), NORMAL, details.index()); | 3402 PropertyDetails(details.attributes(), NORMAL, details.index()); |
3408 Object* value = FastPropertyAt(descs->GetFieldIndex(i)); | 3403 Object* value = FastPropertyAt(descs->GetFieldIndex(i)); |
3409 Object* result; | 3404 MaybeObject* maybe_dictionary = |
3410 { MaybeObject* maybe_result = | 3405 dictionary->Add(descs->GetKey(i), value, d); |
3411 dictionary->Add(descs->GetKey(i), value, d); | 3406 if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary; |
3412 if (!maybe_result->ToObject(&result)) return maybe_result; | |
3413 } | |
3414 dictionary = StringDictionary::cast(result); | |
3415 break; | 3407 break; |
3416 } | 3408 } |
3417 case CALLBACKS: { | 3409 case CALLBACKS: { |
3418 PropertyDetails d = | 3410 if (!descs->IsProperty(i)) break; |
3419 PropertyDetails(details.attributes(), CALLBACKS, details.index()); | |
3420 Object* value = descs->GetCallbacksObject(i); | 3411 Object* value = descs->GetCallbacksObject(i); |
3421 Object* result; | 3412 if (value->IsAccessorPair()) { |
3422 { MaybeObject* maybe_result = | 3413 MaybeObject* maybe_copy = |
3423 dictionary->Add(descs->GetKey(i), value, d); | 3414 AccessorPair::cast(value)->CopyWithoutTransitions(); |
3424 if (!maybe_result->ToObject(&result)) return maybe_result; | 3415 if (!maybe_copy->To(&value)) return maybe_copy; |
3425 } | 3416 } |
3426 dictionary = StringDictionary::cast(result); | 3417 MaybeObject* maybe_dictionary = |
| 3418 dictionary->Add(descs->GetKey(i), value, details); |
| 3419 if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary; |
3427 break; | 3420 break; |
3428 } | 3421 } |
3429 case MAP_TRANSITION: | 3422 case MAP_TRANSITION: |
3430 case CONSTANT_TRANSITION: | 3423 case CONSTANT_TRANSITION: |
3431 case NULL_DESCRIPTOR: | 3424 case NULL_DESCRIPTOR: |
3432 case INTERCEPTOR: | 3425 case INTERCEPTOR: |
3433 case ELEMENTS_TRANSITION: | 3426 case ELEMENTS_TRANSITION: |
3434 break; | 3427 break; |
3435 case HANDLER: | 3428 case HANDLER: |
3436 case NORMAL: | 3429 case NORMAL: |
3437 UNREACHABLE(); | 3430 UNREACHABLE(); |
3438 break; | 3431 break; |
3439 } | 3432 } |
3440 } | 3433 } |
3441 | 3434 |
3442 Heap* current_heap = GetHeap(); | 3435 Heap* current_heap = GetHeap(); |
3443 | 3436 |
3444 // Copy the next enumeration index from instance descriptor. | 3437 // Copy the next enumeration index from instance descriptor. |
3445 int index = map_of_this->instance_descriptors()->NextEnumerationIndex(); | 3438 int index = map_of_this->instance_descriptors()->NextEnumerationIndex(); |
3446 dictionary->SetNextEnumerationIndex(index); | 3439 dictionary->SetNextEnumerationIndex(index); |
3447 | 3440 |
3448 { MaybeObject* maybe_obj = | 3441 Map* new_map; |
| 3442 { MaybeObject* maybe_map = |
3449 current_heap->isolate()->context()->global_context()-> | 3443 current_heap->isolate()->context()->global_context()-> |
3450 normalized_map_cache()->Get(this, mode); | 3444 normalized_map_cache()->Get(this, mode); |
3451 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 3445 if (!maybe_map->To(&new_map)) return maybe_map; |
3452 } | 3446 } |
3453 Map* new_map = Map::cast(obj); | |
3454 | 3447 |
3455 // We have now successfully allocated all the necessary objects. | 3448 // We have now successfully allocated all the necessary objects. |
3456 // Changes can now be made with the guarantee that all of them take effect. | 3449 // Changes can now be made with the guarantee that all of them take effect. |
3457 | 3450 |
3458 // Resize the object in the heap if necessary. | 3451 // Resize the object in the heap if necessary. |
3459 int new_instance_size = new_map->instance_size(); | 3452 int new_instance_size = new_map->instance_size(); |
3460 int instance_size_delta = map_of_this->instance_size() - new_instance_size; | 3453 int instance_size_delta = map_of_this->instance_size() - new_instance_size; |
3461 ASSERT(instance_size_delta >= 0); | 3454 ASSERT(instance_size_delta >= 0); |
3462 current_heap->CreateFillerObjectAt(this->address() + new_instance_size, | 3455 current_heap->CreateFillerObjectAt(this->address() + new_instance_size, |
3463 instance_size_delta); | 3456 instance_size_delta); |
(...skipping 9610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13074 if (break_point_objects()->IsUndefined()) return 0; | 13067 if (break_point_objects()->IsUndefined()) return 0; |
13075 // Single break point. | 13068 // Single break point. |
13076 if (!break_point_objects()->IsFixedArray()) return 1; | 13069 if (!break_point_objects()->IsFixedArray()) return 1; |
13077 // Multiple break points. | 13070 // Multiple break points. |
13078 return FixedArray::cast(break_point_objects())->length(); | 13071 return FixedArray::cast(break_point_objects())->length(); |
13079 } | 13072 } |
13080 #endif // ENABLE_DEBUGGER_SUPPORT | 13073 #endif // ENABLE_DEBUGGER_SUPPORT |
13081 | 13074 |
13082 | 13075 |
13083 } } // namespace v8::internal | 13076 } } // namespace v8::internal |
OLD | NEW |