| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 void CreateRoots(); | 168 void CreateRoots(); |
| 169 // Creates the empty function. Used for creating a context from scratch. | 169 // Creates the empty function. Used for creating a context from scratch. |
| 170 Handle<JSFunction> CreateEmptyFunction(Isolate* isolate); | 170 Handle<JSFunction> CreateEmptyFunction(Isolate* isolate); |
| 171 // Creates the ThrowTypeError function. ECMA 5th Ed. 13.2.3 | 171 // Creates the ThrowTypeError function. ECMA 5th Ed. 13.2.3 |
| 172 Handle<JSFunction> GetRestrictedFunctionPropertiesThrower(); | 172 Handle<JSFunction> GetRestrictedFunctionPropertiesThrower(); |
| 173 Handle<JSFunction> GetStrictArgumentsPoisonFunction(); | 173 Handle<JSFunction> GetStrictArgumentsPoisonFunction(); |
| 174 Handle<JSFunction> GetThrowTypeErrorIntrinsic(Builtins::Name builtin_name); | 174 Handle<JSFunction> GetThrowTypeErrorIntrinsic(Builtins::Name builtin_name); |
| 175 | 175 |
| 176 void CreateStrictModeFunctionMaps(Handle<JSFunction> empty); | 176 void CreateStrictModeFunctionMaps(Handle<JSFunction> empty); |
| 177 void CreateIteratorMaps(Handle<JSFunction> empty); | 177 void CreateIteratorMaps(Handle<JSFunction> empty); |
| 178 void CreateAsyncIteratorMaps(); |
| 178 void CreateAsyncFunctionMaps(Handle<JSFunction> empty); | 179 void CreateAsyncFunctionMaps(Handle<JSFunction> empty); |
| 179 void CreateJSProxyMaps(); | 180 void CreateJSProxyMaps(); |
| 180 | 181 |
| 181 // Make the "arguments" and "caller" properties throw a TypeError on access. | 182 // Make the "arguments" and "caller" properties throw a TypeError on access. |
| 182 void AddRestrictedFunctionProperties(Handle<JSFunction> empty); | 183 void AddRestrictedFunctionProperties(Handle<JSFunction> empty); |
| 183 | 184 |
| 184 // Creates the global objects using the global proxy and the template passed | 185 // Creates the global objects using the global proxy and the template passed |
| 185 // in through the API. We call this regardless of whether we are building a | 186 // in through the API. We call this regardless of whether we are building a |
| 186 // context from scratch or using a deserialized one from the partial snapshot | 187 // context from scratch or using a deserialized one from the partial snapshot |
| 187 // but in the latter case we don't use the objects it produces directly, as | 188 // but in the latter case we don't use the objects it produces directly, as |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 Map::SetPrototype(generator_function_map, generator_function_prototype); | 783 Map::SetPrototype(generator_function_map, generator_function_prototype); |
| 783 native_context()->set_generator_function_map(*generator_function_map); | 784 native_context()->set_generator_function_map(*generator_function_map); |
| 784 | 785 |
| 785 Handle<JSFunction> object_function(native_context()->object_function()); | 786 Handle<JSFunction> object_function(native_context()->object_function()); |
| 786 Handle<Map> generator_object_prototype_map = Map::Create(isolate(), 0); | 787 Handle<Map> generator_object_prototype_map = Map::Create(isolate(), 0); |
| 787 Map::SetPrototype(generator_object_prototype_map, generator_object_prototype); | 788 Map::SetPrototype(generator_object_prototype_map, generator_object_prototype); |
| 788 native_context()->set_generator_object_prototype_map( | 789 native_context()->set_generator_object_prototype_map( |
| 789 *generator_object_prototype_map); | 790 *generator_object_prototype_map); |
| 790 } | 791 } |
| 791 | 792 |
| 793 void Genesis::CreateAsyncIteratorMaps() { |
| 794 // %AsyncIteratorPrototype% |
| 795 // proposal-async-iteration/#sec-asynciteratorprototype |
| 796 Handle<JSObject> async_iterator_prototype = |
| 797 factory()->NewJSObject(isolate()->object_function(), TENURED); |
| 798 |
| 799 Handle<JSFunction> async_iterator_prototype_iterator = SimpleCreateFunction( |
| 800 isolate(), factory()->NewStringFromAsciiChecked("[Symbol.asyncIterator]"), |
| 801 Builtins::kReturnReceiver, 0, true); |
| 802 |
| 803 JSObject::AddProperty(async_iterator_prototype, |
| 804 factory()->async_iterator_symbol(), |
| 805 async_iterator_prototype_iterator, DONT_ENUM); |
| 806 |
| 807 // %AsyncFromSyncIteratorPrototype% |
| 808 // proposal-async-iteration/#sec-%asyncfromsynciteratorprototype%-object |
| 809 Handle<JSObject> async_from_sync_iterator_prototype = |
| 810 factory()->NewJSObject(isolate()->object_function(), TENURED); |
| 811 SimpleInstallFunction(async_from_sync_iterator_prototype, |
| 812 factory()->next_string(), |
| 813 Builtins::kAsyncFromSyncIteratorPrototypeNext, 1, true); |
| 814 SimpleInstallFunction( |
| 815 async_from_sync_iterator_prototype, factory()->return_string(), |
| 816 Builtins::kAsyncFromSyncIteratorPrototypeReturn, 1, true); |
| 817 SimpleInstallFunction( |
| 818 async_from_sync_iterator_prototype, factory()->throw_string(), |
| 819 Builtins::kAsyncFromSyncIteratorPrototypeThrow, 1, true); |
| 820 |
| 821 JSObject::AddProperty( |
| 822 async_from_sync_iterator_prototype, factory()->to_string_tag_symbol(), |
| 823 factory()->NewStringFromAsciiChecked("Async-from-Sync Iterator"), |
| 824 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); |
| 825 |
| 826 JSObject::ForceSetPrototype(async_from_sync_iterator_prototype, |
| 827 async_iterator_prototype); |
| 828 |
| 829 Handle<Map> async_from_sync_iterator_map = factory()->NewMap( |
| 830 JS_ASYNC_FROM_SYNC_ITERATOR_TYPE, JSAsyncFromSyncIterator::kSize); |
| 831 Map::SetPrototype(async_from_sync_iterator_map, |
| 832 async_from_sync_iterator_prototype); |
| 833 native_context()->set_async_from_sync_iterator_map( |
| 834 *async_from_sync_iterator_map); |
| 835 } |
| 836 |
| 792 void Genesis::CreateAsyncFunctionMaps(Handle<JSFunction> empty) { | 837 void Genesis::CreateAsyncFunctionMaps(Handle<JSFunction> empty) { |
| 793 // %AsyncFunctionPrototype% intrinsic | 838 // %AsyncFunctionPrototype% intrinsic |
| 794 Handle<JSObject> async_function_prototype = | 839 Handle<JSObject> async_function_prototype = |
| 795 factory()->NewJSObject(isolate()->object_function(), TENURED); | 840 factory()->NewJSObject(isolate()->object_function(), TENURED); |
| 796 JSObject::ForceSetPrototype(async_function_prototype, empty); | 841 JSObject::ForceSetPrototype(async_function_prototype, empty); |
| 797 | 842 |
| 798 JSObject::AddProperty(async_function_prototype, | 843 JSObject::AddProperty(async_function_prototype, |
| 799 factory()->to_string_tag_symbol(), | 844 factory()->to_string_tag_symbol(), |
| 800 factory()->NewStringFromAsciiChecked("AsyncFunction"), | 845 factory()->NewStringFromAsciiChecked("AsyncFunction"), |
| 801 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); | 846 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1292 | 1337 |
| 1293 // Install the "constructor" property on the %FunctionPrototype%. | 1338 // Install the "constructor" property on the %FunctionPrototype%. |
| 1294 JSObject::AddProperty(prototype, factory->constructor_string(), | 1339 JSObject::AddProperty(prototype, factory->constructor_string(), |
| 1295 function_fun, DONT_ENUM); | 1340 function_fun, DONT_ENUM); |
| 1296 | 1341 |
| 1297 sloppy_function_map_writable_prototype_->SetConstructor(*function_fun); | 1342 sloppy_function_map_writable_prototype_->SetConstructor(*function_fun); |
| 1298 strict_function_map_writable_prototype_->SetConstructor(*function_fun); | 1343 strict_function_map_writable_prototype_->SetConstructor(*function_fun); |
| 1299 class_function_map_->SetConstructor(*function_fun); | 1344 class_function_map_->SetConstructor(*function_fun); |
| 1300 } | 1345 } |
| 1301 | 1346 |
| 1347 { |
| 1348 // --- A s y n c F r o m S y n c I t e r a t o r |
| 1349 Handle<Code> code = isolate->builtins()->AsyncIteratorValueUnwrap(); |
| 1350 Handle<SharedFunctionInfo> info = |
| 1351 factory->NewSharedFunctionInfo(factory->empty_string(), code, false); |
| 1352 info->set_internal_formal_parameter_count(1); |
| 1353 info->set_length(1); |
| 1354 native_context()->set_async_iterator_value_unwrap_shared_fun(*info); |
| 1355 } |
| 1356 |
| 1302 { // --- A r r a y --- | 1357 { // --- A r r a y --- |
| 1303 Handle<JSFunction> array_function = | 1358 Handle<JSFunction> array_function = |
| 1304 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, | 1359 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, |
| 1305 isolate->initial_object_prototype(), | 1360 isolate->initial_object_prototype(), |
| 1306 Builtins::kArrayCode); | 1361 Builtins::kArrayCode); |
| 1307 array_function->shared()->DontAdaptArguments(); | 1362 array_function->shared()->DontAdaptArguments(); |
| 1308 array_function->shared()->set_builtin_function_id(kArrayCode); | 1363 array_function->shared()->set_builtin_function_id(kArrayCode); |
| 1309 | 1364 |
| 1310 // This seems a bit hackish, but we need to make sure Array.length | 1365 // This seems a bit hackish, but we need to make sure Array.length |
| 1311 // is 1. | 1366 // is 1. |
| (...skipping 3530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4842 HookUpGlobalProxy(global_proxy); | 4897 HookUpGlobalProxy(global_proxy); |
| 4843 } | 4898 } |
| 4844 DCHECK(!global_proxy->IsDetachedFrom(native_context()->global_object())); | 4899 DCHECK(!global_proxy->IsDetachedFrom(native_context()->global_object())); |
| 4845 } else { | 4900 } else { |
| 4846 DCHECK_EQ(0u, context_snapshot_index); | 4901 DCHECK_EQ(0u, context_snapshot_index); |
| 4847 // We get here if there was no context snapshot. | 4902 // We get here if there was no context snapshot. |
| 4848 CreateRoots(); | 4903 CreateRoots(); |
| 4849 Handle<JSFunction> empty_function = CreateEmptyFunction(isolate); | 4904 Handle<JSFunction> empty_function = CreateEmptyFunction(isolate); |
| 4850 CreateStrictModeFunctionMaps(empty_function); | 4905 CreateStrictModeFunctionMaps(empty_function); |
| 4851 CreateIteratorMaps(empty_function); | 4906 CreateIteratorMaps(empty_function); |
| 4907 CreateAsyncIteratorMaps(); |
| 4852 CreateAsyncFunctionMaps(empty_function); | 4908 CreateAsyncFunctionMaps(empty_function); |
| 4853 Handle<JSGlobalObject> global_object = | 4909 Handle<JSGlobalObject> global_object = |
| 4854 CreateNewGlobals(global_proxy_template, global_proxy); | 4910 CreateNewGlobals(global_proxy_template, global_proxy); |
| 4855 InitializeGlobal(global_object, empty_function, context_type); | 4911 InitializeGlobal(global_object, empty_function, context_type); |
| 4856 InitializeNormalizedMapCaches(); | 4912 InitializeNormalizedMapCaches(); |
| 4857 | 4913 |
| 4858 if (!InstallNatives(context_type)) return; | 4914 if (!InstallNatives(context_type)) return; |
| 4859 | 4915 |
| 4860 MakeFunctionInstancePrototypeWritable(); | 4916 MakeFunctionInstancePrototypeWritable(); |
| 4861 | 4917 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5004 } | 5060 } |
| 5005 | 5061 |
| 5006 | 5062 |
| 5007 // Called when the top-level V8 mutex is destroyed. | 5063 // Called when the top-level V8 mutex is destroyed. |
| 5008 void Bootstrapper::FreeThreadResources() { | 5064 void Bootstrapper::FreeThreadResources() { |
| 5009 DCHECK(!IsActive()); | 5065 DCHECK(!IsActive()); |
| 5010 } | 5066 } |
| 5011 | 5067 |
| 5012 } // namespace internal | 5068 } // namespace internal |
| 5013 } // namespace v8 | 5069 } // namespace v8 |
| OLD | NEW |