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

Side by Side Diff: src/heap.cc

Issue 9844002: Implement rudimentary module linking. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 9 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
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 3810 matching lines...) Expand 10 before | Expand all | Expand 10 after
3821 constructor->initial_map(), pretenure); 3821 constructor->initial_map(), pretenure);
3822 #ifdef DEBUG 3822 #ifdef DEBUG
3823 // Make sure result is NOT a global object if valid. 3823 // Make sure result is NOT a global object if valid.
3824 Object* non_failure; 3824 Object* non_failure;
3825 ASSERT(!result->ToObject(&non_failure) || !non_failure->IsGlobalObject()); 3825 ASSERT(!result->ToObject(&non_failure) || !non_failure->IsGlobalObject());
3826 #endif 3826 #endif
3827 return result; 3827 return result;
3828 } 3828 }
3829 3829
3830 3830
3831 MaybeObject* Heap::AllocateJSModule() {
3832 // Allocate a fresh map. Modules do not have a prototype.
3833 Map* map;
3834 MaybeObject* maybe_map = AllocateMap(JS_MODULE_TYPE, JSModule::kSize);
3835 if (!maybe_map->To<Map>(&map)) return maybe_map;
Sven Panne 2012/03/30 11:42:20 No need for the template parameter, I think.
rossberg 2012/04/10 14:01:15 Done.
3836 // Allocate the object based on the map.
3837 MaybeObject* result = AllocateJSObjectFromMap(map, TENURED);
Sven Panne 2012/03/30 11:42:20 No need to name the result.
rossberg 2012/04/10 14:01:15 Done.
3838 return result;
3839 }
3840
3841
3831 MaybeObject* Heap::AllocateJSArrayAndStorage( 3842 MaybeObject* Heap::AllocateJSArrayAndStorage(
3832 ElementsKind elements_kind, 3843 ElementsKind elements_kind,
3833 int length, 3844 int length,
3834 int capacity, 3845 int capacity,
3835 ArrayStorageAllocationMode mode, 3846 ArrayStorageAllocationMode mode,
3836 PretenureFlag pretenure) { 3847 PretenureFlag pretenure) {
3837 ASSERT(capacity >= length); 3848 ASSERT(capacity >= length);
3838 MaybeObject* maybe_array = AllocateJSArray(elements_kind, pretenure); 3849 MaybeObject* maybe_array = AllocateJSArray(elements_kind, pretenure);
3839 JSArray* array; 3850 JSArray* array;
3840 if (!maybe_array->To(&array)) return maybe_array; 3851 if (!maybe_array->To(&array)) return maybe_array;
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
4695 context->set_map_no_write_barrier(global_context_map()); 4706 context->set_map_no_write_barrier(global_context_map());
4696 context->set_smi_js_array_map(undefined_value()); 4707 context->set_smi_js_array_map(undefined_value());
4697 context->set_double_js_array_map(undefined_value()); 4708 context->set_double_js_array_map(undefined_value());
4698 context->set_object_js_array_map(undefined_value()); 4709 context->set_object_js_array_map(undefined_value());
4699 ASSERT(context->IsGlobalContext()); 4710 ASSERT(context->IsGlobalContext());
4700 ASSERT(result->IsContext()); 4711 ASSERT(result->IsContext());
4701 return result; 4712 return result;
4702 } 4713 }
4703 4714
4704 4715
4716 MaybeObject* Heap::AllocateModuleContext(Context* previous,
4717 ScopeInfo* scope_info) {
4718 Object* result;
4719 { MaybeObject* maybe_result =
4720 AllocateFixedArrayWithHoles(scope_info->ContextLength(), TENURED);
4721 if (!maybe_result->ToObject(&result)) return maybe_result;
Sven Panne 2012/03/30 11:42:20 Use templatized "To", removing the need for an exp
rossberg 2012/04/10 14:01:15 Unfortunately, that doesn't work here, because the
4722 }
4723 Context* context = reinterpret_cast<Context*>(result);
4724 context->set_map_no_write_barrier(module_context_map());
4725 context->set_previous(previous);
4726 context->set_extension(scope_info);
4727 context->set_global(previous->global());
4728 return context;
4729 }
4730
4731
4705 MaybeObject* Heap::AllocateFunctionContext(int length, JSFunction* function) { 4732 MaybeObject* Heap::AllocateFunctionContext(int length, JSFunction* function) {
4706 ASSERT(length >= Context::MIN_CONTEXT_SLOTS); 4733 ASSERT(length >= Context::MIN_CONTEXT_SLOTS);
4707 Object* result; 4734 Object* result;
4708 { MaybeObject* maybe_result = AllocateFixedArray(length); 4735 { MaybeObject* maybe_result = AllocateFixedArray(length);
4709 if (!maybe_result->ToObject(&result)) return maybe_result; 4736 if (!maybe_result->ToObject(&result)) return maybe_result;
4710 } 4737 }
4711 Context* context = reinterpret_cast<Context*>(result); 4738 Context* context = reinterpret_cast<Context*>(result);
4712 context->set_map_no_write_barrier(function_context_map()); 4739 context->set_map_no_write_barrier(function_context_map());
4713 context->set_closure(function); 4740 context->set_closure(function);
4714 context->set_previous(function->context()); 4741 context->set_previous(function->context());
(...skipping 2250 matching lines...) Expand 10 before | Expand all | Expand 10 after
6965 isolate_->heap()->store_buffer()->Compact(); 6992 isolate_->heap()->store_buffer()->Compact();
6966 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); 6993 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED);
6967 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { 6994 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) {
6968 next = chunk->next_chunk(); 6995 next = chunk->next_chunk();
6969 isolate_->memory_allocator()->Free(chunk); 6996 isolate_->memory_allocator()->Free(chunk);
6970 } 6997 }
6971 chunks_queued_for_free_ = NULL; 6998 chunks_queued_for_free_ = NULL;
6972 } 6999 }
6973 7000
6974 } } // namespace v8::internal 7001 } } // namespace v8::internal
OLDNEW
« src/full-codegen.cc ('K') | « src/heap.h ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698