Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: src/heap.cc

Issue 227533002: Handlify six allocator functions from the Heap. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2672 matching lines...) Expand 10 before | Expand all | Expand 10 after
2683 code_cache->set_normal_type_cache(undefined_value(), SKIP_WRITE_BARRIER); 2683 code_cache->set_normal_type_cache(undefined_value(), SKIP_WRITE_BARRIER);
2684 return code_cache; 2684 return code_cache;
2685 } 2685 }
2686 2686
2687 2687
2688 MaybeObject* Heap::AllocatePolymorphicCodeCache() { 2688 MaybeObject* Heap::AllocatePolymorphicCodeCache() {
2689 return AllocateStruct(POLYMORPHIC_CODE_CACHE_TYPE); 2689 return AllocateStruct(POLYMORPHIC_CODE_CACHE_TYPE);
2690 } 2690 }
2691 2691
2692 2692
2693 MaybeObject* Heap::AllocateAccessorPair() {
2694 AccessorPair* accessors;
2695 { MaybeObject* maybe_accessors = AllocateStruct(ACCESSOR_PAIR_TYPE);
2696 if (!maybe_accessors->To(&accessors)) return maybe_accessors;
2697 }
2698 accessors->set_getter(the_hole_value(), SKIP_WRITE_BARRIER);
2699 accessors->set_setter(the_hole_value(), SKIP_WRITE_BARRIER);
2700 accessors->set_access_flags(Smi::FromInt(0), SKIP_WRITE_BARRIER);
2701 return accessors;
2702 }
2703
2704
2705 MaybeObject* Heap::AllocateTypeFeedbackInfo() {
2706 TypeFeedbackInfo* info;
2707 { MaybeObject* maybe_info = AllocateStruct(TYPE_FEEDBACK_INFO_TYPE);
2708 if (!maybe_info->To(&info)) return maybe_info;
2709 }
2710 info->initialize_storage();
2711 info->set_feedback_vector(empty_fixed_array(), SKIP_WRITE_BARRIER);
2712 return info;
2713 }
2714
2715
2716 MaybeObject* Heap::AllocateAliasedArgumentsEntry(int aliased_context_slot) { 2693 MaybeObject* Heap::AllocateAliasedArgumentsEntry(int aliased_context_slot) {
2717 AliasedArgumentsEntry* entry; 2694 AliasedArgumentsEntry* entry;
2718 { MaybeObject* maybe_entry = AllocateStruct(ALIASED_ARGUMENTS_ENTRY_TYPE); 2695 { MaybeObject* maybe_entry = AllocateStruct(ALIASED_ARGUMENTS_ENTRY_TYPE);
2719 if (!maybe_entry->To(&entry)) return maybe_entry; 2696 if (!maybe_entry->To(&entry)) return maybe_entry;
2720 } 2697 }
2721 entry->set_aliased_context_slot(aliased_context_slot); 2698 entry->set_aliased_context_slot(aliased_context_slot);
2722 return entry; 2699 return entry;
2723 } 2700 }
2724 2701
2725 2702
(...skipping 2770 matching lines...) Expand 10 before | Expand all | Expand 10 after
5496 5473
5497 MaybeObject* Heap::AllocatePrivateSymbol() { 5474 MaybeObject* Heap::AllocatePrivateSymbol() {
5498 MaybeObject* maybe = AllocateSymbol(); 5475 MaybeObject* maybe = AllocateSymbol();
5499 Symbol* symbol; 5476 Symbol* symbol;
5500 if (!maybe->To(&symbol)) return maybe; 5477 if (!maybe->To(&symbol)) return maybe;
5501 symbol->set_is_private(true); 5478 symbol->set_is_private(true);
5502 return symbol; 5479 return symbol;
5503 } 5480 }
5504 5481
5505 5482
5506 MaybeObject* Heap::AllocateNativeContext() {
5507 Object* result;
5508 { MaybeObject* maybe_result =
5509 AllocateFixedArray(Context::NATIVE_CONTEXT_SLOTS);
5510 if (!maybe_result->ToObject(&result)) return maybe_result;
5511 }
5512 Context* context = reinterpret_cast<Context*>(result);
5513 context->set_map_no_write_barrier(native_context_map());
5514 context->set_js_array_maps(undefined_value());
5515 ASSERT(context->IsNativeContext());
5516 ASSERT(result->IsContext());
5517 return result;
5518 }
5519
5520
5521 MaybeObject* Heap::AllocateGlobalContext(JSFunction* function, 5483 MaybeObject* Heap::AllocateGlobalContext(JSFunction* function,
5522 ScopeInfo* scope_info) { 5484 ScopeInfo* scope_info) {
5523 Object* result; 5485 Object* result;
5524 { MaybeObject* maybe_result = 5486 { MaybeObject* maybe_result =
5525 AllocateFixedArray(scope_info->ContextLength(), TENURED); 5487 AllocateFixedArray(scope_info->ContextLength(), TENURED);
5526 if (!maybe_result->ToObject(&result)) return maybe_result; 5488 if (!maybe_result->ToObject(&result)) return maybe_result;
5527 } 5489 }
5528 Context* context = reinterpret_cast<Context*>(result); 5490 Context* context = reinterpret_cast<Context*>(result);
5529 context->set_map_no_write_barrier(global_context_map()); 5491 context->set_map_no_write_barrier(global_context_map());
5530 context->set_closure(function); 5492 context->set_closure(function);
5531 context->set_previous(function->context()); 5493 context->set_previous(function->context());
5532 context->set_extension(scope_info); 5494 context->set_extension(scope_info);
5533 context->set_global_object(function->context()->global_object()); 5495 context->set_global_object(function->context()->global_object());
5534 ASSERT(context->IsGlobalContext()); 5496 ASSERT(context->IsGlobalContext());
5535 ASSERT(result->IsContext()); 5497 ASSERT(result->IsContext());
5536 return context; 5498 return context;
5537 } 5499 }
5538 5500
5539 5501
5540 MaybeObject* Heap::AllocateModuleContext(ScopeInfo* scope_info) {
5541 Object* result;
5542 { MaybeObject* maybe_result =
5543 AllocateFixedArray(scope_info->ContextLength(), TENURED);
5544 if (!maybe_result->ToObject(&result)) return maybe_result;
5545 }
5546 Context* context = reinterpret_cast<Context*>(result);
5547 context->set_map_no_write_barrier(module_context_map());
5548 // Instance link will be set later.
5549 context->set_extension(Smi::FromInt(0));
5550 return context;
5551 }
5552
5553
5554 MaybeObject* Heap::AllocateFunctionContext(int length, JSFunction* function) { 5502 MaybeObject* Heap::AllocateFunctionContext(int length, JSFunction* function) {
5555 ASSERT(length >= Context::MIN_CONTEXT_SLOTS); 5503 ASSERT(length >= Context::MIN_CONTEXT_SLOTS);
5556 Object* result; 5504 Object* result;
5557 { MaybeObject* maybe_result = AllocateFixedArray(length); 5505 { MaybeObject* maybe_result = AllocateFixedArray(length);
5558 if (!maybe_result->ToObject(&result)) return maybe_result; 5506 if (!maybe_result->ToObject(&result)) return maybe_result;
5559 } 5507 }
5560 Context* context = reinterpret_cast<Context*>(result); 5508 Context* context = reinterpret_cast<Context*>(result);
5561 context->set_map_no_write_barrier(function_context_map()); 5509 context->set_map_no_write_barrier(function_context_map());
5562 context->set_closure(function); 5510 context->set_closure(function);
5563 context->set_previous(function->context()); 5511 context->set_previous(function->context());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
5616 Context* context = reinterpret_cast<Context*>(result); 5564 Context* context = reinterpret_cast<Context*>(result);
5617 context->set_map_no_write_barrier(block_context_map()); 5565 context->set_map_no_write_barrier(block_context_map());
5618 context->set_closure(function); 5566 context->set_closure(function);
5619 context->set_previous(previous); 5567 context->set_previous(previous);
5620 context->set_extension(scope_info); 5568 context->set_extension(scope_info);
5621 context->set_global_object(previous->global_object()); 5569 context->set_global_object(previous->global_object());
5622 return context; 5570 return context;
5623 } 5571 }
5624 5572
5625 5573
5626 MaybeObject* Heap::AllocateScopeInfo(int length) {
5627 FixedArray* scope_info;
5628 MaybeObject* maybe_scope_info = AllocateFixedArray(length, TENURED);
5629 if (!maybe_scope_info->To(&scope_info)) return maybe_scope_info;
5630 scope_info->set_map_no_write_barrier(scope_info_map());
5631 return scope_info;
5632 }
5633
5634
5635 MaybeObject* Heap::AllocateExternal(void* value) {
5636 Foreign* foreign;
5637 { MaybeObject* maybe_result = AllocateForeign(static_cast<Address>(value));
5638 if (!maybe_result->To(&foreign)) return maybe_result;
5639 }
5640 JSObject* external;
5641 { MaybeObject* maybe_result = AllocateJSObjectFromMap(external_map());
5642 if (!maybe_result->To(&external)) return maybe_result;
5643 }
5644 external->SetInternalField(0, foreign);
5645 return external;
5646 }
5647
5648
5649 MaybeObject* Heap::AllocateStruct(InstanceType type) { 5574 MaybeObject* Heap::AllocateStruct(InstanceType type) {
5650 Map* map; 5575 Map* map;
5651 switch (type) { 5576 switch (type) {
5652 #define MAKE_CASE(NAME, Name, name) \ 5577 #define MAKE_CASE(NAME, Name, name) \
5653 case NAME##_TYPE: map = name##_map(); break; 5578 case NAME##_TYPE: map = name##_map(); break;
5654 STRUCT_LIST(MAKE_CASE) 5579 STRUCT_LIST(MAKE_CASE)
5655 #undef MAKE_CASE 5580 #undef MAKE_CASE
5656 default: 5581 default:
5657 UNREACHABLE(); 5582 UNREACHABLE();
5658 return Failure::InternalError(); 5583 return Failure::InternalError();
(...skipping 2206 matching lines...) Expand 10 before | Expand all | Expand 10 after
7865 static_cast<int>(object_sizes_last_time_[index])); 7790 static_cast<int>(object_sizes_last_time_[index]));
7866 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 7791 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
7867 #undef ADJUST_LAST_TIME_OBJECT_COUNT 7792 #undef ADJUST_LAST_TIME_OBJECT_COUNT
7868 7793
7869 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 7794 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
7870 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 7795 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
7871 ClearObjectStats(); 7796 ClearObjectStats();
7872 } 7797 }
7873 7798
7874 } } // namespace v8::internal 7799 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698