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 4457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4468 // We might want to shrink the object later. | 4468 // We might want to shrink the object later. |
4469 ASSERT(obj->GetInternalFieldCount() == 0); | 4469 ASSERT(obj->GetInternalFieldCount() == 0); |
4470 filler = Heap::one_pointer_filler_map(); | 4470 filler = Heap::one_pointer_filler_map(); |
4471 } else { | 4471 } else { |
4472 filler = Heap::undefined_value(); | 4472 filler = Heap::undefined_value(); |
4473 } | 4473 } |
4474 obj->InitializeBody(map, Heap::undefined_value(), filler); | 4474 obj->InitializeBody(map, Heap::undefined_value(), filler); |
4475 } | 4475 } |
4476 | 4476 |
4477 | 4477 |
4478 MaybeObject* Heap::AllocateJSObjectFromMap(Map* map, PretenureFlag pretenure) { | 4478 MaybeObject* Heap::AllocateJSObjectFromMap( |
| 4479 Map* map, PretenureFlag pretenure, bool allocate_properties) { |
4479 // JSFunctions should be allocated using AllocateFunction to be | 4480 // JSFunctions should be allocated using AllocateFunction to be |
4480 // properly initialized. | 4481 // properly initialized. |
4481 ASSERT(map->instance_type() != JS_FUNCTION_TYPE); | 4482 ASSERT(map->instance_type() != JS_FUNCTION_TYPE); |
4482 | 4483 |
4483 // Both types of global objects should be allocated using | 4484 // Both types of global objects should be allocated using |
4484 // AllocateGlobalObject to be properly initialized. | 4485 // AllocateGlobalObject to be properly initialized. |
4485 ASSERT(map->instance_type() != JS_GLOBAL_OBJECT_TYPE); | 4486 ASSERT(map->instance_type() != JS_GLOBAL_OBJECT_TYPE); |
4486 ASSERT(map->instance_type() != JS_BUILTINS_OBJECT_TYPE); | 4487 ASSERT(map->instance_type() != JS_BUILTINS_OBJECT_TYPE); |
4487 | 4488 |
4488 // Allocate the backing storage for the properties. | 4489 // Allocate the backing storage for the properties. |
4489 int prop_size = map->InitialPropertiesLength(); | 4490 FixedArray* properties; |
4490 ASSERT(prop_size >= 0); | 4491 if (allocate_properties) { |
4491 Object* properties; | 4492 int prop_size = map->InitialPropertiesLength(); |
4492 { MaybeObject* maybe_properties = AllocateFixedArray(prop_size, pretenure); | 4493 ASSERT(prop_size >= 0); |
4493 if (!maybe_properties->ToObject(&properties)) return maybe_properties; | 4494 { MaybeObject* maybe_properties = AllocateFixedArray(prop_size, pretenure); |
| 4495 if (!maybe_properties->To(&properties)) return maybe_properties; |
| 4496 } |
| 4497 } else { |
| 4498 properties = empty_fixed_array(); |
4494 } | 4499 } |
4495 | 4500 |
4496 // Allocate the JSObject. | 4501 // Allocate the JSObject. |
4497 AllocationSpace space = | 4502 AllocationSpace space = |
4498 (pretenure == TENURED) ? OLD_POINTER_SPACE : NEW_SPACE; | 4503 (pretenure == TENURED) ? OLD_POINTER_SPACE : NEW_SPACE; |
4499 if (map->instance_size() > Page::kMaxNonCodeHeapObjectSize) space = LO_SPACE; | 4504 if (map->instance_size() > Page::kMaxNonCodeHeapObjectSize) space = LO_SPACE; |
4500 Object* obj; | 4505 Object* obj; |
4501 MaybeObject* maybe_obj = Allocate(map, space); | 4506 MaybeObject* maybe_obj = Allocate(map, space); |
4502 if (!maybe_obj->To(&obj)) return maybe_obj; | 4507 if (!maybe_obj->To(&obj)) return maybe_obj; |
4503 | 4508 |
4504 // Initialize the JSObject. | 4509 // Initialize the JSObject. |
4505 InitializeJSObjectFromMap(JSObject::cast(obj), | 4510 InitializeJSObjectFromMap(JSObject::cast(obj), properties, map); |
4506 FixedArray::cast(properties), | |
4507 map); | |
4508 ASSERT(JSObject::cast(obj)->HasFastElements() || | 4511 ASSERT(JSObject::cast(obj)->HasFastElements() || |
4509 JSObject::cast(obj)->HasExternalArrayElements()); | 4512 JSObject::cast(obj)->HasExternalArrayElements()); |
4510 return obj; | 4513 return obj; |
4511 } | 4514 } |
4512 | 4515 |
4513 | 4516 |
4514 MaybeObject* Heap::AllocateJSObjectFromMapWithAllocationSite(Map* map, | 4517 MaybeObject* Heap::AllocateJSObjectFromMapWithAllocationSite( |
4515 Handle<AllocationSite> allocation_site) { | 4518 Map* map, Handle<AllocationSite> allocation_site) { |
4516 // JSFunctions should be allocated using AllocateFunction to be | 4519 // JSFunctions should be allocated using AllocateFunction to be |
4517 // properly initialized. | 4520 // properly initialized. |
4518 ASSERT(map->instance_type() != JS_FUNCTION_TYPE); | 4521 ASSERT(map->instance_type() != JS_FUNCTION_TYPE); |
4519 | 4522 |
4520 // Both types of global objects should be allocated using | 4523 // Both types of global objects should be allocated using |
4521 // AllocateGlobalObject to be properly initialized. | 4524 // AllocateGlobalObject to be properly initialized. |
4522 ASSERT(map->instance_type() != JS_GLOBAL_OBJECT_TYPE); | 4525 ASSERT(map->instance_type() != JS_GLOBAL_OBJECT_TYPE); |
4523 ASSERT(map->instance_type() != JS_BUILTINS_OBJECT_TYPE); | 4526 ASSERT(map->instance_type() != JS_BUILTINS_OBJECT_TYPE); |
4524 | 4527 |
4525 // Allocate the backing storage for the properties. | 4528 // Allocate the backing storage for the properties. |
4526 int prop_size = map->InitialPropertiesLength(); | 4529 int prop_size = map->InitialPropertiesLength(); |
4527 ASSERT(prop_size >= 0); | 4530 ASSERT(prop_size >= 0); |
4528 Object* properties; | 4531 FixedArray* properties; |
4529 { MaybeObject* maybe_properties = AllocateFixedArray(prop_size); | 4532 { MaybeObject* maybe_properties = AllocateFixedArray(prop_size); |
4530 if (!maybe_properties->ToObject(&properties)) return maybe_properties; | 4533 if (!maybe_properties->To(&properties)) return maybe_properties; |
4531 } | 4534 } |
4532 | 4535 |
4533 // Allocate the JSObject. | 4536 // Allocate the JSObject. |
4534 AllocationSpace space = NEW_SPACE; | 4537 AllocationSpace space = NEW_SPACE; |
4535 if (map->instance_size() > Page::kMaxNonCodeHeapObjectSize) space = LO_SPACE; | 4538 if (map->instance_size() > Page::kMaxNonCodeHeapObjectSize) space = LO_SPACE; |
4536 Object* obj; | 4539 Object* obj; |
4537 MaybeObject* maybe_obj = | 4540 MaybeObject* maybe_obj = |
4538 AllocateWithAllocationSite(map, space, allocation_site); | 4541 AllocateWithAllocationSite(map, space, allocation_site); |
4539 if (!maybe_obj->To(&obj)) return maybe_obj; | 4542 if (!maybe_obj->To(&obj)) return maybe_obj; |
4540 | 4543 |
4541 // Initialize the JSObject. | 4544 // Initialize the JSObject. |
4542 InitializeJSObjectFromMap(JSObject::cast(obj), | 4545 InitializeJSObjectFromMap(JSObject::cast(obj), properties, map); |
4543 FixedArray::cast(properties), | |
4544 map); | |
4545 ASSERT(JSObject::cast(obj)->HasFastElements()); | 4546 ASSERT(JSObject::cast(obj)->HasFastElements()); |
4546 return obj; | 4547 return obj; |
4547 } | 4548 } |
4548 | 4549 |
4549 | 4550 |
4550 MaybeObject* Heap::AllocateJSObject(JSFunction* constructor, | 4551 MaybeObject* Heap::AllocateJSObject(JSFunction* constructor, |
4551 PretenureFlag pretenure) { | 4552 PretenureFlag pretenure) { |
4552 // Allocate the initial map if absent. | 4553 // Allocate the initial map if absent. |
4553 if (!constructor->has_initial_map()) { | 4554 if (!constructor->has_initial_map()) { |
4554 Object* initial_map; | 4555 Object* initial_map; |
(...skipping 3483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8038 if (FLAG_parallel_recompilation) { | 8039 if (FLAG_parallel_recompilation) { |
8039 heap_->relocation_mutex_->Lock(); | 8040 heap_->relocation_mutex_->Lock(); |
8040 #ifdef DEBUG | 8041 #ifdef DEBUG |
8041 heap_->relocation_mutex_locked_by_optimizer_thread_ = | 8042 heap_->relocation_mutex_locked_by_optimizer_thread_ = |
8042 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); | 8043 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); |
8043 #endif // DEBUG | 8044 #endif // DEBUG |
8044 } | 8045 } |
8045 } | 8046 } |
8046 | 8047 |
8047 } } // namespace v8::internal | 8048 } } // namespace v8::internal |
OLD | NEW |