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

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: Rebased Created 8 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') | src/hydrogen.cc » ('j') | 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 3809 matching lines...) Expand 10 before | Expand all | Expand 10 after
3820 constructor->initial_map(), pretenure); 3820 constructor->initial_map(), pretenure);
3821 #ifdef DEBUG 3821 #ifdef DEBUG
3822 // Make sure result is NOT a global object if valid. 3822 // Make sure result is NOT a global object if valid.
3823 Object* non_failure; 3823 Object* non_failure;
3824 ASSERT(!result->ToObject(&non_failure) || !non_failure->IsGlobalObject()); 3824 ASSERT(!result->ToObject(&non_failure) || !non_failure->IsGlobalObject());
3825 #endif 3825 #endif
3826 return result; 3826 return result;
3827 } 3827 }
3828 3828
3829 3829
3830 MaybeObject* Heap::AllocateJSModule() {
3831 // Allocate a fresh map. Modules do not have a prototype.
3832 Map* map;
3833 MaybeObject* maybe_map = AllocateMap(JS_MODULE_TYPE, JSModule::kSize);
3834 if (!maybe_map->To(&map)) return maybe_map;
3835 // Allocate the object based on the map.
3836 return AllocateJSObjectFromMap(map, TENURED);
3837 }
3838
3839
3830 MaybeObject* Heap::AllocateJSArrayAndStorage( 3840 MaybeObject* Heap::AllocateJSArrayAndStorage(
3831 ElementsKind elements_kind, 3841 ElementsKind elements_kind,
3832 int length, 3842 int length,
3833 int capacity, 3843 int capacity,
3834 ArrayStorageAllocationMode mode, 3844 ArrayStorageAllocationMode mode,
3835 PretenureFlag pretenure) { 3845 PretenureFlag pretenure) {
3836 ASSERT(capacity >= length); 3846 ASSERT(capacity >= length);
3837 MaybeObject* maybe_array = AllocateJSArray(elements_kind, pretenure); 3847 MaybeObject* maybe_array = AllocateJSArray(elements_kind, pretenure);
3838 JSArray* array; 3848 JSArray* array;
3839 if (!maybe_array->To(&array)) return maybe_array; 3849 if (!maybe_array->To(&array)) return maybe_array;
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
4694 context->set_map_no_write_barrier(global_context_map()); 4704 context->set_map_no_write_barrier(global_context_map());
4695 context->set_smi_js_array_map(undefined_value()); 4705 context->set_smi_js_array_map(undefined_value());
4696 context->set_double_js_array_map(undefined_value()); 4706 context->set_double_js_array_map(undefined_value());
4697 context->set_object_js_array_map(undefined_value()); 4707 context->set_object_js_array_map(undefined_value());
4698 ASSERT(context->IsGlobalContext()); 4708 ASSERT(context->IsGlobalContext());
4699 ASSERT(result->IsContext()); 4709 ASSERT(result->IsContext());
4700 return result; 4710 return result;
4701 } 4711 }
4702 4712
4703 4713
4714 MaybeObject* Heap::AllocateModuleContext(Context* previous,
4715 ScopeInfo* scope_info) {
4716 Object* result;
4717 { MaybeObject* maybe_result =
4718 AllocateFixedArrayWithHoles(scope_info->ContextLength(), TENURED);
4719 if (!maybe_result->ToObject(&result)) return maybe_result;
4720 }
4721 Context* context = reinterpret_cast<Context*>(result);
4722 context->set_map_no_write_barrier(module_context_map());
4723 context->set_previous(previous);
4724 context->set_extension(scope_info);
4725 context->set_global(previous->global());
4726 return context;
4727 }
4728
4729
4704 MaybeObject* Heap::AllocateFunctionContext(int length, JSFunction* function) { 4730 MaybeObject* Heap::AllocateFunctionContext(int length, JSFunction* function) {
4705 ASSERT(length >= Context::MIN_CONTEXT_SLOTS); 4731 ASSERT(length >= Context::MIN_CONTEXT_SLOTS);
4706 Object* result; 4732 Object* result;
4707 { MaybeObject* maybe_result = AllocateFixedArray(length); 4733 { MaybeObject* maybe_result = AllocateFixedArray(length);
4708 if (!maybe_result->ToObject(&result)) return maybe_result; 4734 if (!maybe_result->ToObject(&result)) return maybe_result;
4709 } 4735 }
4710 Context* context = reinterpret_cast<Context*>(result); 4736 Context* context = reinterpret_cast<Context*>(result);
4711 context->set_map_no_write_barrier(function_context_map()); 4737 context->set_map_no_write_barrier(function_context_map());
4712 context->set_closure(function); 4738 context->set_closure(function);
4713 context->set_previous(function->context()); 4739 context->set_previous(function->context());
(...skipping 2266 matching lines...) Expand 10 before | Expand all | Expand 10 after
6980 } else { 7006 } else {
6981 p ^= 0x1d1ed & (Page::kPageSize - 1); // I died. 7007 p ^= 0x1d1ed & (Page::kPageSize - 1); // I died.
6982 } 7008 }
6983 remembered_unmapped_pages_[remembered_unmapped_pages_index_] = 7009 remembered_unmapped_pages_[remembered_unmapped_pages_index_] =
6984 reinterpret_cast<Address>(p); 7010 reinterpret_cast<Address>(p);
6985 remembered_unmapped_pages_index_++; 7011 remembered_unmapped_pages_index_++;
6986 remembered_unmapped_pages_index_ %= kRememberedUnmappedPages; 7012 remembered_unmapped_pages_index_ %= kRememberedUnmappedPages;
6987 } 7013 }
6988 7014
6989 } } // namespace v8::internal 7015 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698