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 4440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4451 } | 4451 } |
4452 | 4452 |
4453 // Check the state of the object | 4453 // Check the state of the object |
4454 ASSERT(JSObject::cast(result)->HasFastProperties()); | 4454 ASSERT(JSObject::cast(result)->HasFastProperties()); |
4455 ASSERT(JSObject::cast(result)->HasFastObjectElements()); | 4455 ASSERT(JSObject::cast(result)->HasFastObjectElements()); |
4456 | 4456 |
4457 return result; | 4457 return result; |
4458 } | 4458 } |
4459 | 4459 |
4460 | 4460 |
4461 MaybeObject* Heap::AllocateInitialMap(JSFunction* fun) { | |
4462 ASSERT(!fun->has_initial_map()); | |
4463 | |
4464 // First create a new map with the size and number of in-object properties | |
4465 // suggested by the function. | |
4466 InstanceType instance_type; | |
4467 int instance_size; | |
4468 int in_object_properties; | |
4469 if (fun->shared()->is_generator()) { | |
4470 instance_type = JS_GENERATOR_OBJECT_TYPE; | |
4471 instance_size = JSGeneratorObject::kSize; | |
4472 in_object_properties = 0; | |
4473 } else { | |
4474 instance_type = JS_OBJECT_TYPE; | |
4475 instance_size = fun->shared()->CalculateInstanceSize(); | |
4476 in_object_properties = fun->shared()->CalculateInObjectProperties(); | |
4477 } | |
4478 Map* map; | |
4479 MaybeObject* maybe_map = AllocateMap(instance_type, instance_size); | |
4480 if (!maybe_map->To(&map)) return maybe_map; | |
4481 | |
4482 // Fetch or allocate prototype. | |
4483 Object* prototype; | |
4484 if (fun->has_instance_prototype()) { | |
4485 prototype = fun->instance_prototype(); | |
4486 } else { | |
4487 MaybeObject* maybe_prototype = AllocateFunctionPrototype(fun); | |
4488 if (!maybe_prototype->To(&prototype)) return maybe_prototype; | |
4489 } | |
4490 map->set_inobject_properties(in_object_properties); | |
4491 map->set_unused_property_fields(in_object_properties); | |
4492 map->set_prototype(prototype); | |
4493 ASSERT(map->has_fast_object_elements()); | |
4494 | |
4495 if (!fun->shared()->is_generator()) { | |
4496 fun->shared()->StartInobjectSlackTracking(map); | |
4497 } | |
4498 | |
4499 return map; | |
4500 } | |
4501 | |
4502 | |
4503 void Heap::InitializeJSObjectFromMap(JSObject* obj, | 4461 void Heap::InitializeJSObjectFromMap(JSObject* obj, |
4504 FixedArray* properties, | 4462 FixedArray* properties, |
4505 Map* map) { | 4463 Map* map) { |
4506 obj->set_properties(properties); | 4464 obj->set_properties(properties); |
4507 obj->initialize_elements(); | 4465 obj->initialize_elements(); |
4508 // TODO(1240798): Initialize the object's body using valid initial values | 4466 // TODO(1240798): Initialize the object's body using valid initial values |
4509 // according to the object's initial map. For example, if the map's | 4467 // according to the object's initial map. For example, if the map's |
4510 // instance type is JS_ARRAY_TYPE, the length field should be initialized | 4468 // instance type is JS_ARRAY_TYPE, the length field should be initialized |
4511 // to a number (e.g. Smi::FromInt(0)) and the elements initialized to a | 4469 // to a number (e.g. Smi::FromInt(0)) and the elements initialized to a |
4512 // fixed array (e.g. Heap::empty_fixed_array()). Currently, the object | 4470 // fixed array (e.g. Heap::empty_fixed_array()). Currently, the object |
(...skipping 3393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7906 if (FLAG_concurrent_recompilation) { | 7864 if (FLAG_concurrent_recompilation) { |
7907 heap_->relocation_mutex_->Lock(); | 7865 heap_->relocation_mutex_->Lock(); |
7908 #ifdef DEBUG | 7866 #ifdef DEBUG |
7909 heap_->relocation_mutex_locked_by_optimizer_thread_ = | 7867 heap_->relocation_mutex_locked_by_optimizer_thread_ = |
7910 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); | 7868 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); |
7911 #endif // DEBUG | 7869 #endif // DEBUG |
7912 } | 7870 } |
7913 } | 7871 } |
7914 | 7872 |
7915 } } // namespace v8::internal | 7873 } } // namespace v8::internal |
OLD | NEW |