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 "src/bootstrapper.h" | 5 #include "src/bootstrapper.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
9 #include "src/base/ieee754.h" | 9 #include "src/base/ieee754.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 map->set_immutable_proto(true); | 586 map->set_immutable_proto(true); |
587 object_function_prototype->set_map(*map); | 587 object_function_prototype->set_map(*map); |
588 | 588 |
589 native_context()->set_initial_object_prototype(*object_function_prototype); | 589 native_context()->set_initial_object_prototype(*object_function_prototype); |
590 // For bootstrapping set the array prototype to be the same as the object | 590 // For bootstrapping set the array prototype to be the same as the object |
591 // prototype, otherwise the missing initial_array_prototype will cause | 591 // prototype, otherwise the missing initial_array_prototype will cause |
592 // assertions during startup. | 592 // assertions during startup. |
593 native_context()->set_initial_array_prototype(*object_function_prototype); | 593 native_context()->set_initial_array_prototype(*object_function_prototype); |
594 Accessors::FunctionSetPrototype(object_fun, object_function_prototype) | 594 Accessors::FunctionSetPrototype(object_fun, object_function_prototype) |
595 .Assert(); | 595 .Assert(); |
| 596 |
| 597 { |
| 598 // Set up slow map for Object.create(null) instances without in-object |
| 599 // properties. |
| 600 Handle<Map> map = handle(object_fun->initial_map(), isolate); |
| 601 map = Map::CopyInitialMapNormalized(map); |
| 602 Map::SetPrototype(map, isolate->factory()->null_value()); |
| 603 native_context()->set_slow_object_with_null_prototype_map(*map); |
| 604 |
| 605 // Set up slow map for literals with too many properties. |
| 606 map = Map::Copy(map, "slow_object_with_object_prototype_map"); |
| 607 Map::SetPrototype(map, object_function_prototype); |
| 608 native_context()->set_slow_object_with_object_prototype_map(*map); |
| 609 } |
596 } | 610 } |
597 | 611 |
598 // Allocate the empty function as the prototype for function - ES6 19.2.3 | 612 // Allocate the empty function as the prototype for function - ES6 19.2.3 |
599 Handle<Code> code(isolate->builtins()->EmptyFunction()); | 613 Handle<Code> code(isolate->builtins()->EmptyFunction()); |
600 Handle<JSFunction> empty_function = | 614 Handle<JSFunction> empty_function = |
601 factory->NewFunctionWithoutPrototype(factory->empty_string(), code); | 615 factory->NewFunctionWithoutPrototype(factory->empty_string(), code); |
602 | 616 |
603 // Allocate the function map first and then patch the prototype later | 617 // Allocate the function map first and then patch the prototype later |
604 Handle<Map> empty_function_map = | 618 Handle<Map> empty_function_map = |
605 factory->CreateSloppyFunctionMap(FUNCTION_WITHOUT_PROTOTYPE); | 619 factory->CreateSloppyFunctionMap(FUNCTION_WITHOUT_PROTOTYPE); |
(...skipping 3465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4071 native_context()->set_fast_template_instantiations_cache( | 4085 native_context()->set_fast_template_instantiations_cache( |
4072 *fast_template_instantiations_cache); | 4086 *fast_template_instantiations_cache); |
4073 | 4087 |
4074 auto slow_template_instantiations_cache = UnseededNumberDictionary::New( | 4088 auto slow_template_instantiations_cache = UnseededNumberDictionary::New( |
4075 isolate(), ApiNatives::kInitialFunctionCacheSize); | 4089 isolate(), ApiNatives::kInitialFunctionCacheSize); |
4076 native_context()->set_slow_template_instantiations_cache( | 4090 native_context()->set_slow_template_instantiations_cache( |
4077 *slow_template_instantiations_cache); | 4091 *slow_template_instantiations_cache); |
4078 | 4092 |
4079 // Store the map for the %ObjectPrototype% after the natives has been compiled | 4093 // Store the map for the %ObjectPrototype% after the natives has been compiled |
4080 // and the Object function has been set up. | 4094 // and the Object function has been set up. |
4081 Handle<JSFunction> object_function(native_context()->object_function()); | 4095 { |
4082 DCHECK(JSObject::cast(object_function->initial_map()->prototype()) | 4096 Handle<JSFunction> object_function(native_context()->object_function()); |
4083 ->HasFastProperties()); | 4097 DCHECK(JSObject::cast(object_function->initial_map()->prototype()) |
4084 native_context()->set_object_function_prototype_map( | 4098 ->HasFastProperties()); |
4085 HeapObject::cast(object_function->initial_map()->prototype())->map()); | 4099 native_context()->set_object_function_prototype_map( |
4086 | 4100 HeapObject::cast(object_function->initial_map()->prototype())->map()); |
4087 // Set up the map for Object.create(null) instances. | 4101 } |
4088 Handle<Map> slow_object_with_null_prototype_map = | |
4089 Map::CopyInitialMap(handle(object_function->initial_map(), isolate())); | |
4090 slow_object_with_null_prototype_map->set_dictionary_map(true); | |
4091 Map::SetPrototype(slow_object_with_null_prototype_map, | |
4092 isolate()->factory()->null_value()); | |
4093 native_context()->set_slow_object_with_null_prototype_map( | |
4094 *slow_object_with_null_prototype_map); | |
4095 | 4102 |
4096 // Store the map for the %StringPrototype% after the natives has been compiled | 4103 // Store the map for the %StringPrototype% after the natives has been compiled |
4097 // and the String function has been set up. | 4104 // and the String function has been set up. |
4098 Handle<JSFunction> string_function(native_context()->string_function()); | 4105 Handle<JSFunction> string_function(native_context()->string_function()); |
4099 JSObject* string_function_prototype = | 4106 JSObject* string_function_prototype = |
4100 JSObject::cast(string_function->initial_map()->prototype()); | 4107 JSObject::cast(string_function->initial_map()->prototype()); |
4101 DCHECK(string_function_prototype->HasFastProperties()); | 4108 DCHECK(string_function_prototype->HasFastProperties()); |
4102 native_context()->set_string_function_prototype_map( | 4109 native_context()->set_string_function_prototype_map( |
4103 string_function_prototype->map()); | 4110 string_function_prototype->map()); |
4104 | 4111 |
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5061 } | 5068 } |
5062 | 5069 |
5063 | 5070 |
5064 // Called when the top-level V8 mutex is destroyed. | 5071 // Called when the top-level V8 mutex is destroyed. |
5065 void Bootstrapper::FreeThreadResources() { | 5072 void Bootstrapper::FreeThreadResources() { |
5066 DCHECK(!IsActive()); | 5073 DCHECK(!IsActive()); |
5067 } | 5074 } |
5068 | 5075 |
5069 } // namespace internal | 5076 } // namespace internal |
5070 } // namespace v8 | 5077 } // namespace v8 |
OLD | NEW |