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 3988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 Loading... | |
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_previous(NULL); |
Michael Starzinger
2012/07/06 10:53:22
I would prefer Smi::FromInt(0) instead of NULL her
rossberg
2012/07/06 15:39:28
Done (also in old code below).
| |
4925 context->set_global(previous->global()); | 4929 context->set_global(NULL); |
4930 context->set_extension(NULL); | |
4926 return context; | 4931 return context; |
4927 } | 4932 } |
4928 | 4933 |
4929 | 4934 |
4930 MaybeObject* Heap::AllocateFunctionContext(int length, JSFunction* function) { | 4935 MaybeObject* Heap::AllocateFunctionContext(int length, JSFunction* function) { |
4931 ASSERT(length >= Context::MIN_CONTEXT_SLOTS); | 4936 ASSERT(length >= Context::MIN_CONTEXT_SLOTS); |
4932 Object* result; | 4937 Object* result; |
4933 { MaybeObject* maybe_result = AllocateFixedArray(length); | 4938 { MaybeObject* maybe_result = AllocateFixedArray(length); |
4934 if (!maybe_result->ToObject(&result)) return maybe_result; | 4939 if (!maybe_result->ToObject(&result)) return maybe_result; |
4935 } | 4940 } |
(...skipping 2285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7221 } else { | 7226 } else { |
7222 p ^= 0x1d1ed & (Page::kPageSize - 1); // I died. | 7227 p ^= 0x1d1ed & (Page::kPageSize - 1); // I died. |
7223 } | 7228 } |
7224 remembered_unmapped_pages_[remembered_unmapped_pages_index_] = | 7229 remembered_unmapped_pages_[remembered_unmapped_pages_index_] = |
7225 reinterpret_cast<Address>(p); | 7230 reinterpret_cast<Address>(p); |
7226 remembered_unmapped_pages_index_++; | 7231 remembered_unmapped_pages_index_++; |
7227 remembered_unmapped_pages_index_ %= kRememberedUnmappedPages; | 7232 remembered_unmapped_pages_index_ %= kRememberedUnmappedPages; |
7228 } | 7233 } |
7229 | 7234 |
7230 } } // namespace v8::internal | 7235 } } // namespace v8::internal |
OLD | NEW |