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

Side by Side Diff: src/heap.cc

Issue 10876067: Introduce global contexts to represent lexical global scope(s). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 3 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 2421 matching lines...) Expand 10 before | Expand all | Expand 10 after
2432 set_block_context_map(Map::cast(obj)); 2432 set_block_context_map(Map::cast(obj));
2433 2433
2434 { MaybeObject* maybe_obj = 2434 { MaybeObject* maybe_obj =
2435 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); 2435 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel);
2436 if (!maybe_obj->ToObject(&obj)) return false; 2436 if (!maybe_obj->ToObject(&obj)) return false;
2437 } 2437 }
2438 set_module_context_map(Map::cast(obj)); 2438 set_module_context_map(Map::cast(obj));
2439 2439
2440 { MaybeObject* maybe_obj = 2440 { MaybeObject* maybe_obj =
2441 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); 2441 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel);
2442 if (!maybe_obj->ToObject(&obj)) return false; 2442 if (!maybe_obj->ToObject(&obj)) return false;
Sven Panne 2012/08/27 06:24:54 Consider templatized 'To'
rossberg 2012/08/27 09:07:16 Yeah, none of the other functions around here does
2443 } 2443 }
2444 set_global_context_map(Map::cast(obj));
2445
2446 { MaybeObject* maybe_obj =
2447 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel);
2448 if (!maybe_obj->ToObject(&obj)) return false;
2449 }
2444 Map* native_context_map = Map::cast(obj); 2450 Map* native_context_map = Map::cast(obj);
2445 native_context_map->set_dictionary_map(true); 2451 native_context_map->set_dictionary_map(true);
2446 native_context_map->set_visitor_id(StaticVisitorBase::kVisitNativeContext); 2452 native_context_map->set_visitor_id(StaticVisitorBase::kVisitNativeContext);
2447 set_native_context_map(native_context_map); 2453 set_native_context_map(native_context_map);
2448 2454
2449 { MaybeObject* maybe_obj = AllocateMap(SHARED_FUNCTION_INFO_TYPE, 2455 { MaybeObject* maybe_obj = AllocateMap(SHARED_FUNCTION_INFO_TYPE,
2450 SharedFunctionInfo::kAlignedSize); 2456 SharedFunctionInfo::kAlignedSize);
2451 if (!maybe_obj->ToObject(&obj)) return false; 2457 if (!maybe_obj->ToObject(&obj)) return false;
2452 } 2458 }
2453 set_shared_function_info_map(Map::cast(obj)); 2459 set_shared_function_info_map(Map::cast(obj));
(...skipping 2444 matching lines...) Expand 10 before | Expand all | Expand 10 after
4898 } 4904 }
4899 Context* context = reinterpret_cast<Context*>(result); 4905 Context* context = reinterpret_cast<Context*>(result);
4900 context->set_map_no_write_barrier(native_context_map()); 4906 context->set_map_no_write_barrier(native_context_map());
4901 context->set_js_array_maps(undefined_value()); 4907 context->set_js_array_maps(undefined_value());
4902 ASSERT(context->IsNativeContext()); 4908 ASSERT(context->IsNativeContext());
4903 ASSERT(result->IsContext()); 4909 ASSERT(result->IsContext());
4904 return result; 4910 return result;
4905 } 4911 }
4906 4912
4907 4913
4914 MaybeObject* Heap::AllocateGlobalContext(JSFunction* function,
4915 ScopeInfo* scope_info) {
4916 Object* result;
4917 { MaybeObject* maybe_result =
4918 AllocateFixedArray(scope_info->ContextLength(), TENURED);
4919 if (!maybe_result->ToObject(&result)) return maybe_result;
4920 }
4921 Context* context = reinterpret_cast<Context*>(result);
4922 context->set_map_no_write_barrier(global_context_map());
4923 context->set_closure(function);
4924 context->set_extension(scope_info);
4925 ASSERT(context->IsGlobalContext());
4926 ASSERT(result->IsContext());
4927 return context;
4928 }
4929
4930
4908 MaybeObject* Heap::AllocateModuleContext(ScopeInfo* scope_info) { 4931 MaybeObject* Heap::AllocateModuleContext(ScopeInfo* scope_info) {
4909 Object* result; 4932 Object* result;
4910 { MaybeObject* maybe_result = 4933 { MaybeObject* maybe_result =
4911 AllocateFixedArray(scope_info->ContextLength(), TENURED); 4934 AllocateFixedArray(scope_info->ContextLength(), TENURED);
4912 if (!maybe_result->ToObject(&result)) return maybe_result; 4935 if (!maybe_result->ToObject(&result)) return maybe_result;
4913 } 4936 }
4914 Context* context = reinterpret_cast<Context*>(result); 4937 Context* context = reinterpret_cast<Context*>(result);
4915 context->set_map_no_write_barrier(module_context_map()); 4938 context->set_map_no_write_barrier(module_context_map());
4916 // Context links will be set later. 4939 // Context links will be set later.
4917 context->set_extension(Smi::FromInt(0)); 4940 context->set_extension(Smi::FromInt(0));
(...skipping 2344 matching lines...) Expand 10 before | Expand all | Expand 10 after
7262 static_cast<int>(object_sizes_last_time_[index])); 7285 static_cast<int>(object_sizes_last_time_[index]));
7263 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) 7286 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT)
7264 #undef ADJUST_LAST_TIME_OBJECT_COUNT 7287 #undef ADJUST_LAST_TIME_OBJECT_COUNT
7265 7288
7266 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 7289 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
7267 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 7290 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
7268 ClearObjectStats(); 7291 ClearObjectStats();
7269 } 7292 }
7270 7293
7271 } } // namespace v8::internal 7294 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698