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

Side by Side Diff: src/heap.cc

Issue 7003058: A collection of context-related refactoring changes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 6 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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1857 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 { MaybeObject* maybe_obj = 1868 { MaybeObject* maybe_obj =
1869 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); 1869 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel);
1870 if (!maybe_obj->ToObject(&obj)) return false; 1870 if (!maybe_obj->ToObject(&obj)) return false;
1871 } 1871 }
1872 set_hash_table_map(Map::cast(obj)); 1872 set_hash_table_map(Map::cast(obj));
1873 1873
1874 { MaybeObject* maybe_obj = 1874 { MaybeObject* maybe_obj =
1875 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); 1875 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel);
1876 if (!maybe_obj->ToObject(&obj)) return false; 1876 if (!maybe_obj->ToObject(&obj)) return false;
1877 } 1877 }
1878 set_context_map(Map::cast(obj)); 1878 set_function_context_map(Map::cast(obj));
1879 1879
1880 { MaybeObject* maybe_obj = 1880 { MaybeObject* maybe_obj =
1881 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); 1881 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel);
1882 if (!maybe_obj->ToObject(&obj)) return false; 1882 if (!maybe_obj->ToObject(&obj)) return false;
1883 } 1883 }
1884 set_catch_context_map(Map::cast(obj)); 1884 set_catch_context_map(Map::cast(obj));
1885 1885
1886 { MaybeObject* maybe_obj = 1886 { MaybeObject* maybe_obj =
1887 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); 1887 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel);
1888 if (!maybe_obj->ToObject(&obj)) return false; 1888 if (!maybe_obj->ToObject(&obj)) return false;
1889 } 1889 }
1890 set_with_context_map(Map::cast(obj));
1891
1892 { MaybeObject* maybe_obj =
1893 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel);
1894 if (!maybe_obj->ToObject(&obj)) return false;
1895 }
1890 Map* global_context_map = Map::cast(obj); 1896 Map* global_context_map = Map::cast(obj);
1891 global_context_map->set_visitor_id(StaticVisitorBase::kVisitGlobalContext); 1897 global_context_map->set_visitor_id(StaticVisitorBase::kVisitGlobalContext);
1892 set_global_context_map(global_context_map); 1898 set_global_context_map(global_context_map);
1893 1899
1894 { MaybeObject* maybe_obj = AllocateMap(SHARED_FUNCTION_INFO_TYPE, 1900 { MaybeObject* maybe_obj = AllocateMap(SHARED_FUNCTION_INFO_TYPE,
1895 SharedFunctionInfo::kAlignedSize); 1901 SharedFunctionInfo::kAlignedSize);
1896 if (!maybe_obj->ToObject(&obj)) return false; 1902 if (!maybe_obj->ToObject(&obj)) return false;
1897 } 1903 }
1898 set_shared_function_info_map(Map::cast(obj)); 1904 set_shared_function_info_map(Map::cast(obj));
1899 1905
(...skipping 1937 matching lines...) Expand 10 before | Expand all | Expand 10 after
3837 } 3843 }
3838 3844
3839 3845
3840 MaybeObject* Heap::AllocateFunctionContext(int length, JSFunction* function) { 3846 MaybeObject* Heap::AllocateFunctionContext(int length, JSFunction* function) {
3841 ASSERT(length >= Context::MIN_CONTEXT_SLOTS); 3847 ASSERT(length >= Context::MIN_CONTEXT_SLOTS);
3842 Object* result; 3848 Object* result;
3843 { MaybeObject* maybe_result = AllocateFixedArray(length); 3849 { MaybeObject* maybe_result = AllocateFixedArray(length);
3844 if (!maybe_result->ToObject(&result)) return maybe_result; 3850 if (!maybe_result->ToObject(&result)) return maybe_result;
3845 } 3851 }
3846 Context* context = reinterpret_cast<Context*>(result); 3852 Context* context = reinterpret_cast<Context*>(result);
3847 context->set_map(context_map()); 3853 context->set_map(function_context_map());
3848 context->set_closure(function); 3854 context->set_closure(function);
3849 context->set_fcontext(context); 3855 context->set_fcontext(context);
3850 context->set_previous(NULL); 3856 context->set_previous(NULL);
3851 context->set_extension(NULL); 3857 context->set_extension(NULL);
3852 context->set_global(function->context()->global()); 3858 context->set_global(function->context()->global());
3853 ASSERT(!context->IsGlobalContext()); 3859 return context;
3854 ASSERT(context->is_function_context());
3855 ASSERT(result->IsContext());
3856 return result;
3857 } 3860 }
3858 3861
3859 3862
3860 MaybeObject* Heap::AllocateWithContext(Context* previous, 3863 MaybeObject* Heap::AllocateCatchContext(Context* previous,
3861 JSObject* extension, 3864 JSObject* extension) {
3862 bool is_catch_context) {
3863 Object* result; 3865 Object* result;
3864 { MaybeObject* maybe_result = AllocateFixedArray(Context::MIN_CONTEXT_SLOTS); 3866 { MaybeObject* maybe_result = AllocateFixedArray(Context::MIN_CONTEXT_SLOTS);
3865 if (!maybe_result->ToObject(&result)) return maybe_result; 3867 if (!maybe_result->ToObject(&result)) return maybe_result;
3866 } 3868 }
3867 Context* context = reinterpret_cast<Context*>(result); 3869 Context* context = reinterpret_cast<Context*>(result);
3868 context->set_map(is_catch_context ? catch_context_map() : 3870 context->set_map(catch_context_map());
3869 context_map());
3870 context->set_closure(previous->closure()); 3871 context->set_closure(previous->closure());
3871 context->set_fcontext(previous->fcontext()); 3872 context->set_fcontext(previous->fcontext());
3872 context->set_previous(previous); 3873 context->set_previous(previous);
3873 context->set_extension(extension); 3874 context->set_extension(extension);
3874 context->set_global(previous->global()); 3875 context->set_global(previous->global());
3875 ASSERT(!context->IsGlobalContext()); 3876 return context;
3876 ASSERT(!context->is_function_context());
3877 ASSERT(result->IsContext());
3878 return result;
3879 } 3877 }
3880 3878
3881 3879
3880 MaybeObject* Heap::AllocateWithContext(Context* previous,
3881 JSObject* extension) {
3882 Object* result;
3883 { MaybeObject* maybe_result = AllocateFixedArray(Context::MIN_CONTEXT_SLOTS);
3884 if (!maybe_result->ToObject(&result)) return maybe_result;
3885 }
3886 Context* context = reinterpret_cast<Context*>(result);
3887 context->set_map(with_context_map());
3888 context->set_closure(previous->closure());
3889 context->set_fcontext(previous->fcontext());
3890 context->set_previous(previous);
3891 context->set_extension(extension);
3892 context->set_global(previous->global());
3893 return context;
3894 }
3895
3896
3882 MaybeObject* Heap::AllocateStruct(InstanceType type) { 3897 MaybeObject* Heap::AllocateStruct(InstanceType type) {
3883 Map* map; 3898 Map* map;
3884 switch (type) { 3899 switch (type) {
3885 #define MAKE_CASE(NAME, Name, name) \ 3900 #define MAKE_CASE(NAME, Name, name) \
3886 case NAME##_TYPE: map = name##_map(); break; 3901 case NAME##_TYPE: map = name##_map(); break;
3887 STRUCT_LIST(MAKE_CASE) 3902 STRUCT_LIST(MAKE_CASE)
3888 #undef MAKE_CASE 3903 #undef MAKE_CASE
3889 default: 3904 default:
3890 UNREACHABLE(); 3905 UNREACHABLE();
3891 return Failure::InternalError(); 3906 return Failure::InternalError();
(...skipping 2049 matching lines...) Expand 10 before | Expand all | Expand 10 after
5941 } 5956 }
5942 5957
5943 5958
5944 void ExternalStringTable::TearDown() { 5959 void ExternalStringTable::TearDown() {
5945 new_space_strings_.Free(); 5960 new_space_strings_.Free();
5946 old_space_strings_.Free(); 5961 old_space_strings_.Free();
5947 } 5962 }
5948 5963
5949 5964
5950 } } // namespace v8::internal 5965 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698