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

Side by Side Diff: src/heap.cc

Issue 10690043: Implement proper module linking. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed Michael's comments. Created 8 years, 5 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 3988 matching lines...) Expand 10 before | Expand all | Expand 10 after
3999 constructor->initial_map(), pretenure); 3999 constructor->initial_map(), pretenure);
4000 #ifdef DEBUG 4000 #ifdef DEBUG
4001 // Make sure result is NOT a global object if valid. 4001 // Make sure result is NOT a global object if valid.
4002 Object* non_failure; 4002 Object* non_failure;
4003 ASSERT(!result->ToObject(&non_failure) || !non_failure->IsGlobalObject()); 4003 ASSERT(!result->ToObject(&non_failure) || !non_failure->IsGlobalObject());
4004 #endif 4004 #endif
4005 return result; 4005 return result;
4006 } 4006 }
4007 4007
4008 4008
4009 MaybeObject* Heap::AllocateJSModule() { 4009 MaybeObject* Heap::AllocateJSModule(Context* context, ScopeInfo* scope_info) {
4010 // Allocate a fresh map. Modules do not have a prototype. 4010 // Allocate a fresh map. Modules do not have a prototype.
4011 Map* map; 4011 Map* map;
4012 MaybeObject* maybe_map = AllocateMap(JS_MODULE_TYPE, JSModule::kSize); 4012 MaybeObject* maybe_map = AllocateMap(JS_MODULE_TYPE, JSModule::kSize);
4013 if (!maybe_map->To(&map)) return maybe_map; 4013 if (!maybe_map->To(&map)) return maybe_map;
4014 // Allocate the object based on the map. 4014 // Allocate the object based on the map.
4015 return AllocateJSObjectFromMap(map, TENURED); 4015 JSModule* module;
4016 MaybeObject* maybe_module = AllocateJSObjectFromMap(map, TENURED);
4017 if (!maybe_module->To(&module)) return maybe_module;
4018 module->set_context(context);
4019 module->set_scope_info(scope_info);
4020 return module;
4016 } 4021 }
4017 4022
4018 4023
4019 MaybeObject* Heap::AllocateJSArrayAndStorage( 4024 MaybeObject* Heap::AllocateJSArrayAndStorage(
4020 ElementsKind elements_kind, 4025 ElementsKind elements_kind,
4021 int length, 4026 int length,
4022 int capacity, 4027 int capacity,
4023 ArrayStorageAllocationMode mode, 4028 ArrayStorageAllocationMode mode,
4024 PretenureFlag pretenure) { 4029 PretenureFlag pretenure) {
4025 ASSERT(capacity >= length); 4030 ASSERT(capacity >= length);
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
4904 } 4909 }
4905 Context* context = reinterpret_cast<Context*>(result); 4910 Context* context = reinterpret_cast<Context*>(result);
4906 context->set_map_no_write_barrier(global_context_map()); 4911 context->set_map_no_write_barrier(global_context_map());
4907 context->set_js_array_maps(undefined_value()); 4912 context->set_js_array_maps(undefined_value());
4908 ASSERT(context->IsGlobalContext()); 4913 ASSERT(context->IsGlobalContext());
4909 ASSERT(result->IsContext()); 4914 ASSERT(result->IsContext());
4910 return result; 4915 return result;
4911 } 4916 }
4912 4917
4913 4918
4914 MaybeObject* Heap::AllocateModuleContext(Context* previous, 4919 MaybeObject* Heap::AllocateModuleContext(ScopeInfo* scope_info) {
4915 ScopeInfo* scope_info) {
4916 Object* result; 4920 Object* result;
4917 { MaybeObject* maybe_result = 4921 { MaybeObject* maybe_result =
4918 AllocateFixedArrayWithHoles(scope_info->ContextLength(), TENURED); 4922 AllocateFixedArray(scope_info->ContextLength(), TENURED);
4919 if (!maybe_result->ToObject(&result)) return maybe_result; 4923 if (!maybe_result->ToObject(&result)) return maybe_result;
4920 } 4924 }
4921 Context* context = reinterpret_cast<Context*>(result); 4925 Context* context = reinterpret_cast<Context*>(result);
4922 context->set_map_no_write_barrier(module_context_map()); 4926 context->set_map_no_write_barrier(module_context_map());
4923 context->set_previous(previous); 4927 // Context links will be set later.
4924 context->set_extension(scope_info); 4928 context->set_extension(Smi::FromInt(0));
4925 context->set_global(previous->global());
4926 return context; 4929 return context;
4927 } 4930 }
4928 4931
4929 4932
4930 MaybeObject* Heap::AllocateFunctionContext(int length, JSFunction* function) { 4933 MaybeObject* Heap::AllocateFunctionContext(int length, JSFunction* function) {
4931 ASSERT(length >= Context::MIN_CONTEXT_SLOTS); 4934 ASSERT(length >= Context::MIN_CONTEXT_SLOTS);
4932 Object* result; 4935 Object* result;
4933 { MaybeObject* maybe_result = AllocateFixedArray(length); 4936 { MaybeObject* maybe_result = AllocateFixedArray(length);
4934 if (!maybe_result->ToObject(&result)) return maybe_result; 4937 if (!maybe_result->ToObject(&result)) return maybe_result;
4935 } 4938 }
4936 Context* context = reinterpret_cast<Context*>(result); 4939 Context* context = reinterpret_cast<Context*>(result);
4937 context->set_map_no_write_barrier(function_context_map()); 4940 context->set_map_no_write_barrier(function_context_map());
4938 context->set_closure(function); 4941 context->set_closure(function);
4939 context->set_previous(function->context()); 4942 context->set_previous(function->context());
4940 context->set_extension(NULL); 4943 context->set_extension(Smi::FromInt(0));
4941 context->set_global(function->context()->global()); 4944 context->set_global(function->context()->global());
4942 return context; 4945 return context;
4943 } 4946 }
4944 4947
4945 4948
4946 MaybeObject* Heap::AllocateCatchContext(JSFunction* function, 4949 MaybeObject* Heap::AllocateCatchContext(JSFunction* function,
4947 Context* previous, 4950 Context* previous,
4948 String* name, 4951 String* name,
4949 Object* thrown_object) { 4952 Object* thrown_object) {
4950 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == Context::THROWN_OBJECT_INDEX); 4953 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == Context::THROWN_OBJECT_INDEX);
(...skipping 2270 matching lines...) Expand 10 before | Expand all | Expand 10 after
7221 } else { 7224 } else {
7222 p ^= 0x1d1ed & (Page::kPageSize - 1); // I died. 7225 p ^= 0x1d1ed & (Page::kPageSize - 1); // I died.
7223 } 7226 }
7224 remembered_unmapped_pages_[remembered_unmapped_pages_index_] = 7227 remembered_unmapped_pages_[remembered_unmapped_pages_index_] =
7225 reinterpret_cast<Address>(p); 7228 reinterpret_cast<Address>(p);
7226 remembered_unmapped_pages_index_++; 7229 remembered_unmapped_pages_index_++;
7227 remembered_unmapped_pages_index_ %= kRememberedUnmappedPages; 7230 remembered_unmapped_pages_index_ %= kRememberedUnmappedPages;
7228 } 7231 }
7229 7232
7230 } } // namespace v8::internal 7233 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698