Chromium Code Reviews| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 void CreateRoots(); | 167 void CreateRoots(); |
| 168 // Creates the empty function. Used for creating a context from scratch. | 168 // Creates the empty function. Used for creating a context from scratch. |
| 169 Handle<JSFunction> CreateEmptyFunction(Isolate* isolate); | 169 Handle<JSFunction> CreateEmptyFunction(Isolate* isolate); |
| 170 // Creates the ThrowTypeError function. ECMA 5th Ed. 13.2.3 | 170 // Creates the ThrowTypeError function. ECMA 5th Ed. 13.2.3 |
| 171 Handle<JSFunction> GetRestrictedFunctionPropertiesThrower(); | 171 Handle<JSFunction> GetRestrictedFunctionPropertiesThrower(); |
| 172 Handle<JSFunction> GetStrictArgumentsPoisonFunction(); | 172 Handle<JSFunction> GetStrictArgumentsPoisonFunction(); |
| 173 Handle<JSFunction> GetThrowTypeErrorIntrinsic(Builtins::Name builtin_name); | 173 Handle<JSFunction> GetThrowTypeErrorIntrinsic(Builtins::Name builtin_name); |
| 174 | 174 |
| 175 void CreateStrictModeFunctionMaps(Handle<JSFunction> empty); | 175 void CreateStrictModeFunctionMaps(Handle<JSFunction> empty); |
| 176 void CreateIteratorMaps(Handle<JSFunction> empty); | 176 void CreateIteratorMaps(Handle<JSFunction> empty); |
| 177 void CreateAsyncIteratorMaps(Handle<JSFunction> empty); | |
| 177 void CreateAsyncFunctionMaps(Handle<JSFunction> empty); | 178 void CreateAsyncFunctionMaps(Handle<JSFunction> empty); |
| 178 void CreateJSProxyMaps(); | 179 void CreateJSProxyMaps(); |
| 179 | 180 |
| 180 // Make the "arguments" and "caller" properties throw a TypeError on access. | 181 // Make the "arguments" and "caller" properties throw a TypeError on access. |
| 181 void AddRestrictedFunctionProperties(Handle<JSFunction> empty); | 182 void AddRestrictedFunctionProperties(Handle<JSFunction> empty); |
| 182 | 183 |
| 183 // Creates the global objects using the global proxy and the template passed | 184 // Creates the global objects using the global proxy and the template passed |
| 184 // in through the API. We call this regardless of whether we are building a | 185 // in through the API. We call this regardless of whether we are building a |
| 185 // context from scratch or using a deserialized one from the partial snapshot | 186 // context from scratch or using a deserialized one from the partial snapshot |
| 186 // but in the latter case we don't use the objects it produces directly, as | 187 // 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... | |
| 781 Map::SetPrototype(generator_function_map, generator_function_prototype); | 782 Map::SetPrototype(generator_function_map, generator_function_prototype); |
| 782 native_context()->set_generator_function_map(*generator_function_map); | 783 native_context()->set_generator_function_map(*generator_function_map); |
| 783 | 784 |
| 784 Handle<JSFunction> object_function(native_context()->object_function()); | 785 Handle<JSFunction> object_function(native_context()->object_function()); |
| 785 Handle<Map> generator_object_prototype_map = Map::Create(isolate(), 0); | 786 Handle<Map> generator_object_prototype_map = Map::Create(isolate(), 0); |
| 786 Map::SetPrototype(generator_object_prototype_map, generator_object_prototype); | 787 Map::SetPrototype(generator_object_prototype_map, generator_object_prototype); |
| 787 native_context()->set_generator_object_prototype_map( | 788 native_context()->set_generator_object_prototype_map( |
| 788 *generator_object_prototype_map); | 789 *generator_object_prototype_map); |
| 789 } | 790 } |
| 790 | 791 |
| 792 void Genesis::CreateAsyncIteratorMaps(Handle<JSFunction> empty) { | |
|
jgruber
2017/02/17 12:28:22
The argument is unused.
caitp
2017/02/17 14:56:10
Removed (will re-add in the next CL I guess)
| |
| 793 // %AsyncIteratorPrototype% | |
| 794 // proposal-async-iteration/#sec-asynciteratorprototype | |
| 795 Handle<JSObject> async_iterator_prototype = | |
| 796 factory()->NewJSObject(isolate()->object_function(), TENURED); | |
| 797 | |
| 798 Handle<JSFunction> async_iterator_prototype_iterator = SimpleCreateFunction( | |
| 799 isolate(), factory()->NewStringFromAsciiChecked("[Symbol.asyncIterator]"), | |
| 800 Builtins::kReturnReceiver, 0, true); | |
| 801 async_iterator_prototype_iterator->shared()->set_native(true); | |
|
jgruber
2017/02/17 12:28:22
set_native is done by SimpleCreateFunction AFAIK.
caitp
2017/02/17 14:56:10
Removed duplicate call
| |
| 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 | |
| 791 void Genesis::CreateAsyncFunctionMaps(Handle<JSFunction> empty) { | 837 void Genesis::CreateAsyncFunctionMaps(Handle<JSFunction> empty) { |
| 792 // %AsyncFunctionPrototype% intrinsic | 838 // %AsyncFunctionPrototype% intrinsic |
| 793 Handle<JSObject> async_function_prototype = | 839 Handle<JSObject> async_function_prototype = |
| 794 factory()->NewJSObject(isolate()->object_function(), TENURED); | 840 factory()->NewJSObject(isolate()->object_function(), TENURED); |
| 795 JSObject::ForceSetPrototype(async_function_prototype, empty); | 841 JSObject::ForceSetPrototype(async_function_prototype, empty); |
| 796 | 842 |
| 797 JSObject::AddProperty(async_function_prototype, | 843 JSObject::AddProperty(async_function_prototype, |
| 798 factory()->to_string_tag_symbol(), | 844 factory()->to_string_tag_symbol(), |
| 799 factory()->NewStringFromAsciiChecked("AsyncFunction"), | 845 factory()->NewStringFromAsciiChecked("AsyncFunction"), |
| 800 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... | |
| 1291 | 1337 |
| 1292 // Install the "constructor" property on the %FunctionPrototype%. | 1338 // Install the "constructor" property on the %FunctionPrototype%. |
| 1293 JSObject::AddProperty(prototype, factory->constructor_string(), | 1339 JSObject::AddProperty(prototype, factory->constructor_string(), |
| 1294 function_fun, DONT_ENUM); | 1340 function_fun, DONT_ENUM); |
| 1295 | 1341 |
| 1296 sloppy_function_map_writable_prototype_->SetConstructor(*function_fun); | 1342 sloppy_function_map_writable_prototype_->SetConstructor(*function_fun); |
| 1297 strict_function_map_writable_prototype_->SetConstructor(*function_fun); | 1343 strict_function_map_writable_prototype_->SetConstructor(*function_fun); |
| 1298 class_function_map_->SetConstructor(*function_fun); | 1344 class_function_map_->SetConstructor(*function_fun); |
| 1299 } | 1345 } |
| 1300 | 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 | |
| 1301 { // --- A r r a y --- | 1357 { // --- A r r a y --- |
| 1302 Handle<JSFunction> array_function = | 1358 Handle<JSFunction> array_function = |
| 1303 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, | 1359 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, |
| 1304 isolate->initial_object_prototype(), | 1360 isolate->initial_object_prototype(), |
| 1305 Builtins::kArrayCode); | 1361 Builtins::kArrayCode); |
| 1306 array_function->shared()->DontAdaptArguments(); | 1362 array_function->shared()->DontAdaptArguments(); |
| 1307 array_function->shared()->set_builtin_function_id(kArrayCode); | 1363 array_function->shared()->set_builtin_function_id(kArrayCode); |
| 1308 | 1364 |
| 1309 // 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 |
| 1310 // is 1. | 1366 // is 1. |
| (...skipping 3439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4750 HookUpGlobalProxy(global_proxy); | 4806 HookUpGlobalProxy(global_proxy); |
| 4751 } | 4807 } |
| 4752 DCHECK(!global_proxy->IsDetachedFrom(native_context()->global_object())); | 4808 DCHECK(!global_proxy->IsDetachedFrom(native_context()->global_object())); |
| 4753 } else { | 4809 } else { |
| 4754 DCHECK_EQ(0u, context_snapshot_index); | 4810 DCHECK_EQ(0u, context_snapshot_index); |
| 4755 // We get here if there was no context snapshot. | 4811 // We get here if there was no context snapshot. |
| 4756 CreateRoots(); | 4812 CreateRoots(); |
| 4757 Handle<JSFunction> empty_function = CreateEmptyFunction(isolate); | 4813 Handle<JSFunction> empty_function = CreateEmptyFunction(isolate); |
| 4758 CreateStrictModeFunctionMaps(empty_function); | 4814 CreateStrictModeFunctionMaps(empty_function); |
| 4759 CreateIteratorMaps(empty_function); | 4815 CreateIteratorMaps(empty_function); |
| 4816 CreateAsyncIteratorMaps(empty_function); | |
| 4760 CreateAsyncFunctionMaps(empty_function); | 4817 CreateAsyncFunctionMaps(empty_function); |
| 4761 Handle<JSGlobalObject> global_object = | 4818 Handle<JSGlobalObject> global_object = |
| 4762 CreateNewGlobals(global_proxy_template, global_proxy); | 4819 CreateNewGlobals(global_proxy_template, global_proxy); |
| 4763 InitializeGlobal(global_object, empty_function, context_type); | 4820 InitializeGlobal(global_object, empty_function, context_type); |
| 4764 InitializeNormalizedMapCaches(); | 4821 InitializeNormalizedMapCaches(); |
| 4765 | 4822 |
| 4766 if (!InstallNatives(context_type)) return; | 4823 if (!InstallNatives(context_type)) return; |
| 4767 | 4824 |
| 4768 MakeFunctionInstancePrototypeWritable(); | 4825 MakeFunctionInstancePrototypeWritable(); |
| 4769 | 4826 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4901 } | 4958 } |
| 4902 | 4959 |
| 4903 | 4960 |
| 4904 // Called when the top-level V8 mutex is destroyed. | 4961 // Called when the top-level V8 mutex is destroyed. |
| 4905 void Bootstrapper::FreeThreadResources() { | 4962 void Bootstrapper::FreeThreadResources() { |
| 4906 DCHECK(!IsActive()); | 4963 DCHECK(!IsActive()); |
| 4907 } | 4964 } |
| 4908 | 4965 |
| 4909 } // namespace internal | 4966 } // namespace internal |
| 4910 } // namespace v8 | 4967 } // namespace v8 |
| OLD | NEW |