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

Side by Side Diff: src/bootstrapper.cc

Issue 10780031: Grouping all map creation code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing 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
« no previous file with comments | « src/api.cc ('k') | src/factory.h » ('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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 } 310 }
311 } 311 }
312 return Handle<Context>(); 312 return Handle<Context>();
313 } 313 }
314 314
315 315
316 static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) { 316 static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) {
317 // object.__proto__ = proto; 317 // object.__proto__ = proto;
318 Factory* factory = object->GetIsolate()->factory(); 318 Factory* factory = object->GetIsolate()->factory();
319 Handle<Map> old_to_map = Handle<Map>(object->map()); 319 Handle<Map> old_to_map = Handle<Map>(object->map());
320 Handle<Map> new_to_map = factory->CopyMapDropTransitions(old_to_map); 320 Handle<Map> new_to_map = factory->CopyMap(old_to_map);
321 new_to_map->set_prototype(*proto); 321 new_to_map->set_prototype(*proto);
322 object->set_map(*new_to_map); 322 object->set_map(*new_to_map);
323 } 323 }
324 324
325 325
326 void Bootstrapper::DetachGlobal(Handle<Context> env) { 326 void Bootstrapper::DetachGlobal(Handle<Context> env) {
327 Factory* factory = env->GetIsolate()->factory(); 327 Factory* factory = env->GetIsolate()->factory();
328 JSGlobalProxy::cast(env->global_proxy())->set_context(*factory->null_value()); 328 JSGlobalProxy::cast(env->global_proxy())->set_context(*factory->null_value());
329 SetObjectPrototype(Handle<JSObject>(env->global_proxy()), 329 SetObjectPrototype(Handle<JSObject>(env->global_proxy()),
330 factory->null_value()); 330 factory->null_value());
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 992
993 initial_map->set_inobject_properties(5); 993 initial_map->set_inobject_properties(5);
994 initial_map->set_pre_allocated_property_fields(5); 994 initial_map->set_pre_allocated_property_fields(5);
995 initial_map->set_unused_property_fields(0); 995 initial_map->set_unused_property_fields(0);
996 initial_map->set_instance_size( 996 initial_map->set_instance_size(
997 initial_map->instance_size() + 5 * kPointerSize); 997 initial_map->instance_size() + 5 * kPointerSize);
998 initial_map->set_instance_descriptors(*descriptors); 998 initial_map->set_instance_descriptors(*descriptors);
999 initial_map->set_visitor_id(StaticVisitorBase::GetVisitorId(*initial_map)); 999 initial_map->set_visitor_id(StaticVisitorBase::GetVisitorId(*initial_map));
1000 1000
1001 // RegExp prototype object is itself a RegExp. 1001 // RegExp prototype object is itself a RegExp.
1002 Handle<Map> proto_map = factory->CopyMapDropTransitions(initial_map); 1002 Handle<Map> proto_map = factory->CopyMap(initial_map);
1003 proto_map->set_prototype(global_context()->initial_object_prototype()); 1003 proto_map->set_prototype(global_context()->initial_object_prototype());
1004 Handle<JSObject> proto = factory->NewJSObjectFromMap(proto_map); 1004 Handle<JSObject> proto = factory->NewJSObjectFromMap(proto_map);
1005 proto->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, 1005 proto->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex,
1006 heap->query_colon_symbol()); 1006 heap->query_colon_symbol());
1007 proto->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex, 1007 proto->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex,
1008 heap->false_value()); 1008 heap->false_value());
1009 proto->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex, 1009 proto->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex,
1010 heap->false_value()); 1010 heap->false_value());
1011 proto->InObjectPropertyAtPut(JSRegExp::kMultilineFieldIndex, 1011 proto->InObjectPropertyAtPut(JSRegExp::kMultilineFieldIndex,
1012 heap->false_value()); 1012 heap->false_value());
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 // Set up a well-formed parameter map to make assertions happy. 1094 // Set up a well-formed parameter map to make assertions happy.
1095 Handle<FixedArray> elements = factory->NewFixedArray(2); 1095 Handle<FixedArray> elements = factory->NewFixedArray(2);
1096 elements->set_map(heap->non_strict_arguments_elements_map()); 1096 elements->set_map(heap->non_strict_arguments_elements_map());
1097 Handle<FixedArray> array; 1097 Handle<FixedArray> array;
1098 array = factory->NewFixedArray(0); 1098 array = factory->NewFixedArray(0);
1099 elements->set(0, *array); 1099 elements->set(0, *array);
1100 array = factory->NewFixedArray(0); 1100 array = factory->NewFixedArray(0);
1101 elements->set(1, *array); 1101 elements->set(1, *array);
1102 1102
1103 Handle<Map> old_map(global_context()->arguments_boilerplate()->map()); 1103 Handle<Map> old_map(global_context()->arguments_boilerplate()->map());
1104 Handle<Map> new_map = factory->CopyMapDropTransitions(old_map); 1104 Handle<Map> new_map = factory->CopyMap(old_map);
1105 new_map->set_pre_allocated_property_fields(2); 1105 new_map->set_pre_allocated_property_fields(2);
1106 Handle<JSObject> result = factory->NewJSObjectFromMap(new_map); 1106 Handle<JSObject> result = factory->NewJSObjectFromMap(new_map);
1107 // Set elements kind after allocating the object because 1107 // Set elements kind after allocating the object because
1108 // NewJSObjectFromMap assumes a fast elements map. 1108 // NewJSObjectFromMap assumes a fast elements map.
1109 new_map->set_elements_kind(NON_STRICT_ARGUMENTS_ELEMENTS); 1109 new_map->set_elements_kind(NON_STRICT_ARGUMENTS_ELEMENTS);
1110 result->set_elements(*elements); 1110 result->set_elements(*elements);
1111 ASSERT(result->HasNonStrictArgumentsElements()); 1111 ASSERT(result->HasNonStrictArgumentsElements());
1112 global_context()->set_aliased_arguments_boilerplate(*result); 1112 global_context()->set_aliased_arguments_boilerplate(*result);
1113 } 1113 }
1114 1114
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1623 array_function->shared()->set_construct_stub( 1623 array_function->shared()->set_construct_stub(
1624 isolate()->builtins()->builtin(Builtins::kArrayConstructCode)); 1624 isolate()->builtins()->builtin(Builtins::kArrayConstructCode));
1625 array_function->shared()->DontAdaptArguments(); 1625 array_function->shared()->DontAdaptArguments();
1626 1626
1627 // InternalArrays should not use Smi-Only array optimizations. There are too 1627 // InternalArrays should not use Smi-Only array optimizations. There are too
1628 // many places in the C++ runtime code (e.g. RegEx) that assume that 1628 // many places in the C++ runtime code (e.g. RegEx) that assume that
1629 // elements in InternalArrays can be set to non-Smi values without going 1629 // elements in InternalArrays can be set to non-Smi values without going
1630 // through a common bottleneck that would make the SMI_ONLY -> FAST_ELEMENT 1630 // through a common bottleneck that would make the SMI_ONLY -> FAST_ELEMENT
1631 // transition easy to trap. Moreover, they rarely are smi-only. 1631 // transition easy to trap. Moreover, they rarely are smi-only.
1632 MaybeObject* maybe_map = 1632 MaybeObject* maybe_map =
1633 array_function->initial_map()->CopyDropTransitions( 1633 array_function->initial_map()->Copy(DescriptorArray::MAY_BE_SHARED);
1634 DescriptorArray::MAY_BE_SHARED);
1635 Map* new_map; 1634 Map* new_map;
1636 if (!maybe_map->To(&new_map)) return false; 1635 if (!maybe_map->To(&new_map)) return false;
1637 new_map->set_elements_kind(FAST_HOLEY_ELEMENTS); 1636 new_map->set_elements_kind(FAST_HOLEY_ELEMENTS);
1638 array_function->set_initial_map(new_map); 1637 array_function->set_initial_map(new_map);
1639 1638
1640 // Make "length" magic on instances. 1639 // Make "length" magic on instances.
1641 Handle<DescriptorArray> array_descriptors = 1640 Handle<DescriptorArray> array_descriptors =
1642 factory()->CopyAppendForeignDescriptor( 1641 factory()->CopyAppendForeignDescriptor(
1643 factory()->empty_descriptor_array(), 1642 factory()->empty_descriptor_array(),
1644 factory()->length_symbol(), 1643 factory()->length_symbol(),
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
2240 Factory* factory = from->GetIsolate()->factory(); 2239 Factory* factory = from->GetIsolate()->factory();
2241 2240
2242 ASSERT(!from->IsJSArray()); 2241 ASSERT(!from->IsJSArray());
2243 ASSERT(!to->IsJSArray()); 2242 ASSERT(!to->IsJSArray());
2244 2243
2245 TransferNamedProperties(from, to); 2244 TransferNamedProperties(from, to);
2246 TransferIndexedProperties(from, to); 2245 TransferIndexedProperties(from, to);
2247 2246
2248 // Transfer the prototype (new map is needed). 2247 // Transfer the prototype (new map is needed).
2249 Handle<Map> old_to_map = Handle<Map>(to->map()); 2248 Handle<Map> old_to_map = Handle<Map>(to->map());
2250 Handle<Map> new_to_map = factory->CopyMapDropTransitions(old_to_map); 2249 Handle<Map> new_to_map = factory->CopyMap(old_to_map);
2251 new_to_map->set_prototype(from->map()->prototype()); 2250 new_to_map->set_prototype(from->map()->prototype());
2252 to->set_map(*new_to_map); 2251 to->set_map(*new_to_map);
2253 } 2252 }
2254 2253
2255 2254
2256 void Genesis::MakeFunctionInstancePrototypeWritable() { 2255 void Genesis::MakeFunctionInstancePrototypeWritable() {
2257 // The maps with writable prototype are created in CreateEmptyFunction 2256 // The maps with writable prototype are created in CreateEmptyFunction
2258 // and CreateStrictModeFunctionMaps respectively. Initially the maps are 2257 // and CreateStrictModeFunctionMaps respectively. Initially the maps are
2259 // created with read-only prototype for JS builtins processing. 2258 // created with read-only prototype for JS builtins processing.
2260 ASSERT(!function_instance_map_writable_prototype_.is_null()); 2259 ASSERT(!function_instance_map_writable_prototype_.is_null());
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
2354 return from + sizeof(NestingCounterType); 2353 return from + sizeof(NestingCounterType);
2355 } 2354 }
2356 2355
2357 2356
2358 // Called when the top-level V8 mutex is destroyed. 2357 // Called when the top-level V8 mutex is destroyed.
2359 void Bootstrapper::FreeThreadResources() { 2358 void Bootstrapper::FreeThreadResources() {
2360 ASSERT(!IsActive()); 2359 ASSERT(!IsActive());
2361 } 2360 }
2362 2361
2363 } } // namespace v8::internal 2362 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698