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 4336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4347 function->initialize_elements(); | 4347 function->initialize_elements(); |
4348 function->set_shared(shared); | 4348 function->set_shared(shared); |
4349 function->set_code(shared->code()); | 4349 function->set_code(shared->code()); |
4350 function->set_prototype_or_initial_map(prototype); | 4350 function->set_prototype_or_initial_map(prototype); |
4351 function->set_context(undefined_value()); | 4351 function->set_context(undefined_value()); |
4352 function->set_literals_or_bindings(empty_fixed_array()); | 4352 function->set_literals_or_bindings(empty_fixed_array()); |
4353 function->set_next_function_link(undefined_value()); | 4353 function->set_next_function_link(undefined_value()); |
4354 } | 4354 } |
4355 | 4355 |
4356 | 4356 |
4357 MaybeObject* Heap::AllocateFunctionPrototype(JSFunction* function) { | |
4358 // Make sure to use globals from the function's context, since the function | |
4359 // can be from a different context. | |
4360 Context* native_context = function->context()->native_context(); | |
4361 Map* new_map; | |
4362 if (function->shared()->is_generator()) { | |
4363 // Generator prototypes can share maps since they don't have "constructor" | |
4364 // properties. | |
4365 new_map = native_context->generator_object_prototype_map(); | |
4366 } else { | |
4367 // Each function prototype gets a fresh map to avoid unwanted sharing of | |
4368 // maps between prototypes of different constructors. | |
4369 JSFunction* object_function = native_context->object_function(); | |
4370 ASSERT(object_function->has_initial_map()); | |
4371 MaybeObject* maybe_map = object_function->initial_map()->Copy(); | |
4372 if (!maybe_map->To(&new_map)) return maybe_map; | |
4373 } | |
4374 | |
4375 Object* prototype; | |
4376 MaybeObject* maybe_prototype = AllocateJSObjectFromMap(new_map); | |
4377 if (!maybe_prototype->ToObject(&prototype)) return maybe_prototype; | |
4378 | |
4379 if (!function->shared()->is_generator()) { | |
4380 MaybeObject* maybe_failure = | |
4381 JSObject::cast(prototype)->SetLocalPropertyIgnoreAttributesTrampoline( | |
4382 constructor_string(), function, DONT_ENUM); | |
4383 if (maybe_failure->IsFailure()) return maybe_failure; | |
4384 } | |
4385 | |
4386 return prototype; | |
4387 } | |
4388 | |
4389 | |
4390 MaybeObject* Heap::AllocateFunction(Map* function_map, | 4357 MaybeObject* Heap::AllocateFunction(Map* function_map, |
4391 SharedFunctionInfo* shared, | 4358 SharedFunctionInfo* shared, |
4392 Object* prototype, | 4359 Object* prototype, |
4393 PretenureFlag pretenure) { | 4360 PretenureFlag pretenure) { |
4394 AllocationSpace space = | 4361 AllocationSpace space = |
4395 (pretenure == TENURED) ? OLD_POINTER_SPACE : NEW_SPACE; | 4362 (pretenure == TENURED) ? OLD_POINTER_SPACE : NEW_SPACE; |
4396 Object* result; | 4363 Object* result; |
4397 { MaybeObject* maybe_result = Allocate(function_map, space); | 4364 { MaybeObject* maybe_result = Allocate(function_map, space); |
4398 if (!maybe_result->ToObject(&result)) return maybe_result; | 4365 if (!maybe_result->ToObject(&result)) return maybe_result; |
4399 } | 4366 } |
(...skipping 3464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7864 if (FLAG_concurrent_recompilation) { | 7831 if (FLAG_concurrent_recompilation) { |
7865 heap_->relocation_mutex_->Lock(); | 7832 heap_->relocation_mutex_->Lock(); |
7866 #ifdef DEBUG | 7833 #ifdef DEBUG |
7867 heap_->relocation_mutex_locked_by_optimizer_thread_ = | 7834 heap_->relocation_mutex_locked_by_optimizer_thread_ = |
7868 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); | 7835 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); |
7869 #endif // DEBUG | 7836 #endif // DEBUG |
7870 } | 7837 } |
7871 } | 7838 } |
7872 | 7839 |
7873 } } // namespace v8::internal | 7840 } } // namespace v8::internal |
OLD | NEW |