| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "bootstrapper.h" | 5 #include "bootstrapper.h" |
| 6 | 6 |
| 7 #include "accessors.h" | 7 #include "accessors.h" |
| 8 #include "isolate-inl.h" | 8 #include "isolate-inl.h" |
| 9 #include "natives.h" | 9 #include "natives.h" |
| 10 #include "snapshot.h" | 10 #include "snapshot.h" |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 Handle<Context> env = genesis.result(); | 321 Handle<Context> env = genesis.result(); |
| 322 if (env.is_null() || !InstallExtensions(env, extensions)) { | 322 if (env.is_null() || !InstallExtensions(env, extensions)) { |
| 323 return Handle<Context>(); | 323 return Handle<Context>(); |
| 324 } | 324 } |
| 325 return scope.CloseAndEscape(env); | 325 return scope.CloseAndEscape(env); |
| 326 } | 326 } |
| 327 | 327 |
| 328 | 328 |
| 329 static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) { | 329 static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) { |
| 330 // object.__proto__ = proto; | 330 // object.__proto__ = proto; |
| 331 Factory* factory = object->GetIsolate()->factory(); | |
| 332 Handle<Map> old_to_map = Handle<Map>(object->map()); | 331 Handle<Map> old_to_map = Handle<Map>(object->map()); |
| 333 Handle<Map> new_to_map = factory->CopyMap(old_to_map); | 332 Handle<Map> new_to_map = Map::Copy(old_to_map); |
| 334 new_to_map->set_prototype(*proto); | 333 new_to_map->set_prototype(*proto); |
| 335 object->set_map(*new_to_map); | 334 object->set_map(*new_to_map); |
| 336 } | 335 } |
| 337 | 336 |
| 338 | 337 |
| 339 void Bootstrapper::DetachGlobal(Handle<Context> env) { | 338 void Bootstrapper::DetachGlobal(Handle<Context> env) { |
| 340 Factory* factory = env->GetIsolate()->factory(); | 339 Factory* factory = env->GetIsolate()->factory(); |
| 341 Handle<JSGlobalProxy> global_proxy(JSGlobalProxy::cast(env->global_proxy())); | 340 Handle<JSGlobalProxy> global_proxy(JSGlobalProxy::cast(env->global_proxy())); |
| 342 global_proxy->set_native_context(*factory->null_value()); | 341 global_proxy->set_native_context(*factory->null_value()); |
| 343 SetObjectPrototype(global_proxy, factory->null_value()); | 342 SetObjectPrototype(global_proxy, factory->null_value()); |
| (...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 } | 1009 } |
| 1011 | 1010 |
| 1012 initial_map->set_inobject_properties(5); | 1011 initial_map->set_inobject_properties(5); |
| 1013 initial_map->set_pre_allocated_property_fields(5); | 1012 initial_map->set_pre_allocated_property_fields(5); |
| 1014 initial_map->set_unused_property_fields(0); | 1013 initial_map->set_unused_property_fields(0); |
| 1015 initial_map->set_instance_size( | 1014 initial_map->set_instance_size( |
| 1016 initial_map->instance_size() + 5 * kPointerSize); | 1015 initial_map->instance_size() + 5 * kPointerSize); |
| 1017 initial_map->set_visitor_id(StaticVisitorBase::GetVisitorId(*initial_map)); | 1016 initial_map->set_visitor_id(StaticVisitorBase::GetVisitorId(*initial_map)); |
| 1018 | 1017 |
| 1019 // RegExp prototype object is itself a RegExp. | 1018 // RegExp prototype object is itself a RegExp. |
| 1020 Handle<Map> proto_map = factory->CopyMap(initial_map); | 1019 Handle<Map> proto_map = Map::Copy(initial_map); |
| 1021 proto_map->set_prototype(native_context()->initial_object_prototype()); | 1020 proto_map->set_prototype(native_context()->initial_object_prototype()); |
| 1022 Handle<JSObject> proto = factory->NewJSObjectFromMap(proto_map); | 1021 Handle<JSObject> proto = factory->NewJSObjectFromMap(proto_map); |
| 1023 proto->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, | 1022 proto->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, |
| 1024 heap->query_colon_string()); | 1023 heap->query_colon_string()); |
| 1025 proto->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex, | 1024 proto->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex, |
| 1026 heap->false_value()); | 1025 heap->false_value()); |
| 1027 proto->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex, | 1026 proto->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex, |
| 1028 heap->false_value()); | 1027 heap->false_value()); |
| 1029 proto->InObjectPropertyAtPut(JSRegExp::kMultilineFieldIndex, | 1028 proto->InObjectPropertyAtPut(JSRegExp::kMultilineFieldIndex, |
| 1030 heap->false_value()); | 1029 heap->false_value()); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 Handle<FixedArray> elements = factory->NewFixedArray(2); | 1142 Handle<FixedArray> elements = factory->NewFixedArray(2); |
| 1144 elements->set_map(heap->sloppy_arguments_elements_map()); | 1143 elements->set_map(heap->sloppy_arguments_elements_map()); |
| 1145 Handle<FixedArray> array; | 1144 Handle<FixedArray> array; |
| 1146 array = factory->NewFixedArray(0); | 1145 array = factory->NewFixedArray(0); |
| 1147 elements->set(0, *array); | 1146 elements->set(0, *array); |
| 1148 array = factory->NewFixedArray(0); | 1147 array = factory->NewFixedArray(0); |
| 1149 elements->set(1, *array); | 1148 elements->set(1, *array); |
| 1150 | 1149 |
| 1151 Handle<Map> old_map( | 1150 Handle<Map> old_map( |
| 1152 native_context()->sloppy_arguments_boilerplate()->map()); | 1151 native_context()->sloppy_arguments_boilerplate()->map()); |
| 1153 Handle<Map> new_map = factory->CopyMap(old_map); | 1152 Handle<Map> new_map = Map::Copy(old_map); |
| 1154 new_map->set_pre_allocated_property_fields(2); | 1153 new_map->set_pre_allocated_property_fields(2); |
| 1155 Handle<JSObject> result = factory->NewJSObjectFromMap(new_map); | 1154 Handle<JSObject> result = factory->NewJSObjectFromMap(new_map); |
| 1156 // Set elements kind after allocating the object because | 1155 // Set elements kind after allocating the object because |
| 1157 // NewJSObjectFromMap assumes a fast elements map. | 1156 // NewJSObjectFromMap assumes a fast elements map. |
| 1158 new_map->set_elements_kind(SLOPPY_ARGUMENTS_ELEMENTS); | 1157 new_map->set_elements_kind(SLOPPY_ARGUMENTS_ELEMENTS); |
| 1159 result->set_elements(*elements); | 1158 result->set_elements(*elements); |
| 1160 ASSERT(result->HasSloppyArgumentsElements()); | 1159 ASSERT(result->HasSloppyArgumentsElements()); |
| 1161 native_context()->set_aliased_arguments_boilerplate(*result); | 1160 native_context()->set_aliased_arguments_boilerplate(*result); |
| 1162 } | 1161 } |
| 1163 | 1162 |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1352 generator_object_prototype, Builtins::kIllegal, | 1351 generator_object_prototype, Builtins::kIllegal, |
| 1353 false, false); | 1352 false, false); |
| 1354 InstallFunction(builtins, "GeneratorFunction", | 1353 InstallFunction(builtins, "GeneratorFunction", |
| 1355 JS_FUNCTION_TYPE, JSFunction::kSize, | 1354 JS_FUNCTION_TYPE, JSFunction::kSize, |
| 1356 generator_function_prototype, Builtins::kIllegal, | 1355 generator_function_prototype, Builtins::kIllegal, |
| 1357 false, false); | 1356 false, false); |
| 1358 | 1357 |
| 1359 // Create maps for generator functions and their prototypes. Store those | 1358 // Create maps for generator functions and their prototypes. Store those |
| 1360 // maps in the native context. | 1359 // maps in the native context. |
| 1361 Handle<Map> function_map(native_context()->sloppy_function_map()); | 1360 Handle<Map> function_map(native_context()->sloppy_function_map()); |
| 1362 Handle<Map> generator_function_map = factory()->CopyMap(function_map); | 1361 Handle<Map> generator_function_map = Map::Copy(function_map); |
| 1363 generator_function_map->set_prototype(*generator_function_prototype); | 1362 generator_function_map->set_prototype(*generator_function_prototype); |
| 1364 native_context()->set_sloppy_generator_function_map( | 1363 native_context()->set_sloppy_generator_function_map( |
| 1365 *generator_function_map); | 1364 *generator_function_map); |
| 1366 | 1365 |
| 1367 Handle<Map> strict_mode_function_map( | 1366 Handle<Map> strict_mode_function_map( |
| 1368 native_context()->strict_function_map()); | 1367 native_context()->strict_function_map()); |
| 1369 Handle<Map> strict_mode_generator_function_map = factory()->CopyMap( | 1368 Handle<Map> strict_mode_generator_function_map = |
| 1370 strict_mode_function_map); | 1369 Map::Copy(strict_mode_function_map); |
| 1371 strict_mode_generator_function_map->set_prototype( | 1370 strict_mode_generator_function_map->set_prototype( |
| 1372 *generator_function_prototype); | 1371 *generator_function_prototype); |
| 1373 native_context()->set_strict_generator_function_map( | 1372 native_context()->set_strict_generator_function_map( |
| 1374 *strict_mode_generator_function_map); | 1373 *strict_mode_generator_function_map); |
| 1375 | 1374 |
| 1376 Handle<Map> object_map(native_context()->object_function()->initial_map()); | 1375 Handle<Map> object_map(native_context()->object_function()->initial_map()); |
| 1377 Handle<Map> generator_object_prototype_map = factory()->CopyMap( | 1376 Handle<Map> generator_object_prototype_map = factory()->CopyMap( |
| 1378 object_map, 0); | 1377 object_map, 0); |
| 1379 generator_object_prototype_map->set_prototype( | 1378 generator_object_prototype_map->set_prototype( |
| 1380 *generator_object_prototype); | 1379 *generator_object_prototype); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1605 Handle<JSObject> prototype = | 1604 Handle<JSObject> prototype = |
| 1606 factory()->NewJSObject(isolate()->object_function(), TENURED); | 1605 factory()->NewJSObject(isolate()->object_function(), TENURED); |
| 1607 Accessors::FunctionSetPrototype(array_function, prototype); | 1606 Accessors::FunctionSetPrototype(array_function, prototype); |
| 1608 | 1607 |
| 1609 InternalArrayConstructorStub internal_array_constructor_stub(isolate()); | 1608 InternalArrayConstructorStub internal_array_constructor_stub(isolate()); |
| 1610 Handle<Code> code = internal_array_constructor_stub.GetCode(isolate()); | 1609 Handle<Code> code = internal_array_constructor_stub.GetCode(isolate()); |
| 1611 array_function->shared()->set_construct_stub(*code); | 1610 array_function->shared()->set_construct_stub(*code); |
| 1612 array_function->shared()->DontAdaptArguments(); | 1611 array_function->shared()->DontAdaptArguments(); |
| 1613 | 1612 |
| 1614 Handle<Map> original_map(array_function->initial_map()); | 1613 Handle<Map> original_map(array_function->initial_map()); |
| 1615 Handle<Map> initial_map = factory()->CopyMap(original_map); | 1614 Handle<Map> initial_map = Map::Copy(original_map); |
| 1616 initial_map->set_elements_kind(elements_kind); | 1615 initial_map->set_elements_kind(elements_kind); |
| 1617 array_function->set_initial_map(*initial_map); | 1616 array_function->set_initial_map(*initial_map); |
| 1618 | 1617 |
| 1619 // Make "length" magic on instances. | 1618 // Make "length" magic on instances. |
| 1620 Handle<DescriptorArray> array_descriptors( | 1619 Handle<DescriptorArray> array_descriptors( |
| 1621 factory()->NewDescriptorArray(0, 1)); | 1620 factory()->NewDescriptorArray(0, 1)); |
| 1622 DescriptorArray::WhitenessWitness witness(*array_descriptors); | 1621 DescriptorArray::WhitenessWitness witness(*array_descriptors); |
| 1623 | 1622 |
| 1624 Handle<Foreign> array_length(factory()->NewForeign( | 1623 Handle<Foreign> array_length(factory()->NewForeign( |
| 1625 &Accessors::ArrayLength)); | 1624 &Accessors::ArrayLength)); |
| (...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2517 HandleScope outer(isolate()); | 2516 HandleScope outer(isolate()); |
| 2518 | 2517 |
| 2519 ASSERT(!from->IsJSArray()); | 2518 ASSERT(!from->IsJSArray()); |
| 2520 ASSERT(!to->IsJSArray()); | 2519 ASSERT(!to->IsJSArray()); |
| 2521 | 2520 |
| 2522 TransferNamedProperties(from, to); | 2521 TransferNamedProperties(from, to); |
| 2523 TransferIndexedProperties(from, to); | 2522 TransferIndexedProperties(from, to); |
| 2524 | 2523 |
| 2525 // Transfer the prototype (new map is needed). | 2524 // Transfer the prototype (new map is needed). |
| 2526 Handle<Map> old_to_map = Handle<Map>(to->map()); | 2525 Handle<Map> old_to_map = Handle<Map>(to->map()); |
| 2527 Handle<Map> new_to_map = factory()->CopyMap(old_to_map); | 2526 Handle<Map> new_to_map = Map::Copy(old_to_map); |
| 2528 new_to_map->set_prototype(from->map()->prototype()); | 2527 new_to_map->set_prototype(from->map()->prototype()); |
| 2529 to->set_map(*new_to_map); | 2528 to->set_map(*new_to_map); |
| 2530 } | 2529 } |
| 2531 | 2530 |
| 2532 | 2531 |
| 2533 void Genesis::MakeFunctionInstancePrototypeWritable() { | 2532 void Genesis::MakeFunctionInstancePrototypeWritable() { |
| 2534 // The maps with writable prototype are created in CreateEmptyFunction | 2533 // The maps with writable prototype are created in CreateEmptyFunction |
| 2535 // and CreateStrictModeFunctionMaps respectively. Initially the maps are | 2534 // and CreateStrictModeFunctionMaps respectively. Initially the maps are |
| 2536 // created with read-only prototype for JS builtins processing. | 2535 // created with read-only prototype for JS builtins processing. |
| 2537 ASSERT(!sloppy_function_map_writable_prototype_.is_null()); | 2536 ASSERT(!sloppy_function_map_writable_prototype_.is_null()); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2722 return from + sizeof(NestingCounterType); | 2721 return from + sizeof(NestingCounterType); |
| 2723 } | 2722 } |
| 2724 | 2723 |
| 2725 | 2724 |
| 2726 // Called when the top-level V8 mutex is destroyed. | 2725 // Called when the top-level V8 mutex is destroyed. |
| 2727 void Bootstrapper::FreeThreadResources() { | 2726 void Bootstrapper::FreeThreadResources() { |
| 2728 ASSERT(!IsActive()); | 2727 ASSERT(!IsActive()); |
| 2729 } | 2728 } |
| 2730 | 2729 |
| 2731 } } // namespace v8::internal | 2730 } } // namespace v8::internal |
| OLD | NEW |