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 5392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5403 | 5403 |
5404 MaybeObject* Heap::AllocatePrivateSymbol() { | 5404 MaybeObject* Heap::AllocatePrivateSymbol() { |
5405 MaybeObject* maybe = AllocateSymbol(); | 5405 MaybeObject* maybe = AllocateSymbol(); |
5406 Symbol* symbol; | 5406 Symbol* symbol; |
5407 if (!maybe->To(&symbol)) return maybe; | 5407 if (!maybe->To(&symbol)) return maybe; |
5408 symbol->set_is_private(true); | 5408 symbol->set_is_private(true); |
5409 return symbol; | 5409 return symbol; |
5410 } | 5410 } |
5411 | 5411 |
5412 | 5412 |
5413 MaybeObject* Heap::AllocateGlobalContext(JSFunction* function, | |
5414 ScopeInfo* scope_info) { | |
5415 Object* result; | |
5416 { MaybeObject* maybe_result = | |
5417 AllocateFixedArray(scope_info->ContextLength(), TENURED); | |
5418 if (!maybe_result->ToObject(&result)) return maybe_result; | |
5419 } | |
5420 Context* context = reinterpret_cast<Context*>(result); | |
5421 context->set_map_no_write_barrier(global_context_map()); | |
5422 context->set_closure(function); | |
5423 context->set_previous(function->context()); | |
5424 context->set_extension(scope_info); | |
5425 context->set_global_object(function->context()->global_object()); | |
5426 ASSERT(context->IsGlobalContext()); | |
5427 ASSERT(result->IsContext()); | |
5428 return context; | |
5429 } | |
5430 | |
5431 | |
5432 MaybeObject* Heap::AllocateFunctionContext(int length, JSFunction* function) { | |
5433 ASSERT(length >= Context::MIN_CONTEXT_SLOTS); | |
5434 Object* result; | |
5435 { MaybeObject* maybe_result = AllocateFixedArray(length); | |
5436 if (!maybe_result->ToObject(&result)) return maybe_result; | |
5437 } | |
5438 Context* context = reinterpret_cast<Context*>(result); | |
5439 context->set_map_no_write_barrier(function_context_map()); | |
5440 context->set_closure(function); | |
5441 context->set_previous(function->context()); | |
5442 context->set_extension(Smi::FromInt(0)); | |
5443 context->set_global_object(function->context()->global_object()); | |
5444 return context; | |
5445 } | |
5446 | |
5447 | |
5448 MaybeObject* Heap::AllocateCatchContext(JSFunction* function, | |
5449 Context* previous, | |
5450 String* name, | |
5451 Object* thrown_object) { | |
5452 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == Context::THROWN_OBJECT_INDEX); | |
5453 Object* result; | |
5454 { MaybeObject* maybe_result = | |
5455 AllocateFixedArray(Context::MIN_CONTEXT_SLOTS + 1); | |
5456 if (!maybe_result->ToObject(&result)) return maybe_result; | |
5457 } | |
5458 Context* context = reinterpret_cast<Context*>(result); | |
5459 context->set_map_no_write_barrier(catch_context_map()); | |
5460 context->set_closure(function); | |
5461 context->set_previous(previous); | |
5462 context->set_extension(name); | |
5463 context->set_global_object(previous->global_object()); | |
5464 context->set(Context::THROWN_OBJECT_INDEX, thrown_object); | |
5465 return context; | |
5466 } | |
5467 | |
5468 | |
5469 MaybeObject* Heap::AllocateWithContext(JSFunction* function, | |
5470 Context* previous, | |
5471 JSReceiver* extension) { | |
5472 Object* result; | |
5473 { MaybeObject* maybe_result = AllocateFixedArray(Context::MIN_CONTEXT_SLOTS); | |
5474 if (!maybe_result->ToObject(&result)) return maybe_result; | |
5475 } | |
5476 Context* context = reinterpret_cast<Context*>(result); | |
5477 context->set_map_no_write_barrier(with_context_map()); | |
5478 context->set_closure(function); | |
5479 context->set_previous(previous); | |
5480 context->set_extension(extension); | |
5481 context->set_global_object(previous->global_object()); | |
5482 return context; | |
5483 } | |
5484 | |
5485 | |
5486 MaybeObject* Heap::AllocateBlockContext(JSFunction* function, | |
5487 Context* previous, | |
5488 ScopeInfo* scope_info) { | |
5489 Object* result; | |
5490 { MaybeObject* maybe_result = | |
5491 AllocateFixedArrayWithHoles(scope_info->ContextLength()); | |
5492 if (!maybe_result->ToObject(&result)) return maybe_result; | |
5493 } | |
5494 Context* context = reinterpret_cast<Context*>(result); | |
5495 context->set_map_no_write_barrier(block_context_map()); | |
5496 context->set_closure(function); | |
5497 context->set_previous(previous); | |
5498 context->set_extension(scope_info); | |
5499 context->set_global_object(previous->global_object()); | |
5500 return context; | |
5501 } | |
5502 | |
5503 | |
5504 MaybeObject* Heap::AllocateStruct(InstanceType type) { | 5413 MaybeObject* Heap::AllocateStruct(InstanceType type) { |
5505 Map* map; | 5414 Map* map; |
5506 switch (type) { | 5415 switch (type) { |
5507 #define MAKE_CASE(NAME, Name, name) \ | 5416 #define MAKE_CASE(NAME, Name, name) \ |
5508 case NAME##_TYPE: map = name##_map(); break; | 5417 case NAME##_TYPE: map = name##_map(); break; |
5509 STRUCT_LIST(MAKE_CASE) | 5418 STRUCT_LIST(MAKE_CASE) |
5510 #undef MAKE_CASE | 5419 #undef MAKE_CASE |
5511 default: | 5420 default: |
5512 UNREACHABLE(); | 5421 UNREACHABLE(); |
5513 return Failure::InternalError(); | 5422 return Failure::InternalError(); |
(...skipping 2196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7710 static_cast<int>(object_sizes_last_time_[index])); | 7619 static_cast<int>(object_sizes_last_time_[index])); |
7711 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 7620 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
7712 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7621 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
7713 | 7622 |
7714 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7623 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
7715 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7624 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
7716 ClearObjectStats(); | 7625 ClearObjectStats(); |
7717 } | 7626 } |
7718 | 7627 |
7719 } } // namespace v8::internal | 7628 } } // namespace v8::internal |
OLD | NEW |