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

Side by Side Diff: src/bootstrapper.cc

Issue 2541283002: [promises] Port ResolvePromise to TF (Closed)
Patch Set: remove ResolvePromise Created 4 years 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
OLDNEW
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 1829 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 1840
1841 // Install the "constructor" property on the {prototype}. 1841 // Install the "constructor" property on the {prototype}.
1842 JSObject::AddProperty(prototype, factory->constructor_string(), promise_fun, 1842 JSObject::AddProperty(prototype, factory->constructor_string(), promise_fun,
1843 DONT_ENUM); 1843 DONT_ENUM);
1844 1844
1845 // Install the @@toStringTag property on the {prototype}. 1845 // Install the @@toStringTag property on the {prototype}.
1846 JSObject::AddProperty( 1846 JSObject::AddProperty(
1847 prototype, factory->to_string_tag_symbol(), factory->Promise_string(), 1847 prototype, factory->to_string_tag_symbol(), factory->Promise_string(),
1848 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); 1848 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
1849 1849
1850 SimpleInstallFunction(prototype, "then", Builtins::kPromiseThen, 2, true, 1850 Handle<JSFunction> promise_then =
1851 SimpleCreateFunction(isolate, isolate->factory()->then_string(),
1852 Builtins::kPromiseThen, 2, true);
1853 JSObject::AddProperty(prototype, isolate->factory()->then_string(),
1854 promise_then, DONT_ENUM);
1855 InstallWithIntrinsicDefaultProto(isolate, promise_then,
1856 Context::PROMISE_THEN_INDEX);
1857
1858 // TODO(gsathya): Move to TF
1859 SimpleInstallFunction(prototype, "catch", Builtins::kIllegal, 1, true,
1851 DONT_ENUM); 1860 DONT_ENUM);
1852 1861
1862 Handle<Map> prototype_map(prototype->map());
1863 Map::SetShouldBeFastPrototypeMap(prototype_map, true, isolate);
1864
1865 // Store the initial Promise.prototype map. This is used in fast-path
1866 // checks. Do not alter the prototype after this point.
1867 native_context()->set_promise_prototype_map(*prototype_map);
1868
1853 { // Internal: PromiseInternalConstructor 1869 { // Internal: PromiseInternalConstructor
1854 Handle<JSFunction> function = 1870 Handle<JSFunction> function =
1855 SimpleCreateFunction(isolate, factory->empty_string(), 1871 SimpleCreateFunction(isolate, factory->empty_string(),
1856 Builtins::kPromiseInternalConstructor, 0, false); 1872 Builtins::kPromiseInternalConstructor, 0, false);
1857 InstallWithIntrinsicDefaultProto( 1873 InstallWithIntrinsicDefaultProto(
1858 isolate, function, Context::PROMISE_INTERNAL_CONSTRUCTOR_INDEX); 1874 isolate, function, Context::PROMISE_INTERNAL_CONSTRUCTOR_INDEX);
1859 } 1875 }
1860 1876
1861 { // Internal: PromiseCreateAndSet 1877 { // Internal: PromiseCreateAndSet
1862 Handle<JSFunction> function = 1878 Handle<JSFunction> function =
(...skipping 11 matching lines...) Expand all
1874 } 1890 }
1875 1891
1876 { // Internal: PerformPromiseThen 1892 { // Internal: PerformPromiseThen
1877 Handle<JSFunction> function = 1893 Handle<JSFunction> function =
1878 SimpleCreateFunction(isolate, factory->empty_string(), 1894 SimpleCreateFunction(isolate, factory->empty_string(),
1879 Builtins::kPerformPromiseThen, 4, false); 1895 Builtins::kPerformPromiseThen, 4, false);
1880 InstallWithIntrinsicDefaultProto(isolate, function, 1896 InstallWithIntrinsicDefaultProto(isolate, function,
1881 Context::PERFORM_PROMISE_THEN_INDEX); 1897 Context::PERFORM_PROMISE_THEN_INDEX);
1882 } 1898 }
1883 1899
1900 { // Internal: ResolvePromise
1901 Handle<JSFunction> function =
1902 SimpleCreateFunction(isolate, factory->empty_string(),
1903 Builtins::kResolvePromise, 2, false);
1904 InstallWithIntrinsicDefaultProto(isolate, function,
1905 Context::PROMISE_RESOLVE_INDEX);
1906 }
1907
1884 { 1908 {
1885 Handle<Code> code = 1909 Handle<Code> code =
1886 handle(isolate->builtins()->builtin(Builtins::kPromiseResolveClosure), 1910 handle(isolate->builtins()->builtin(Builtins::kPromiseResolveClosure),
1887 isolate); 1911 isolate);
1888 Handle<SharedFunctionInfo> info = 1912 Handle<SharedFunctionInfo> info =
1889 factory->NewSharedFunctionInfo(factory->empty_string(), code, false); 1913 factory->NewSharedFunctionInfo(factory->empty_string(), code, false);
1890 info->set_internal_formal_parameter_count(1); 1914 info->set_internal_formal_parameter_count(1);
1891 info->set_length(1); 1915 info->set_length(1);
1892 native_context()->set_promise_resolve_shared_fun(*info); 1916 native_context()->set_promise_resolve_shared_fun(*info);
1893 1917
(...skipping 1614 matching lines...) Expand 10 before | Expand all | Expand 10 after
3508 native_context()->set_natives_utils_object(*utils); 3532 native_context()->set_natives_utils_object(*utils);
3509 3533
3510 // Set up the extras utils object as a shared container between native 3534 // Set up the extras utils object as a shared container between native
3511 // scripts and extras. (Extras consume things added there by native scripts.) 3535 // scripts and extras. (Extras consume things added there by native scripts.)
3512 Handle<JSObject> extras_utils = 3536 Handle<JSObject> extras_utils =
3513 factory()->NewJSObject(isolate()->object_function()); 3537 factory()->NewJSObject(isolate()->object_function());
3514 native_context()->set_extras_utils_object(*extras_utils); 3538 native_context()->set_extras_utils_object(*extras_utils);
3515 3539
3516 InstallInternalArray(extras_utils, "InternalPackedArray", FAST_ELEMENTS); 3540 InstallInternalArray(extras_utils, "InternalPackedArray", FAST_ELEMENTS);
3517 3541
3542 InstallFunction(extras_utils, isolate()->promise_resolve(),
3543 factory()->NewStringFromAsciiChecked("resolvePromise"));
3544
3518 int builtin_index = Natives::GetDebuggerCount(); 3545 int builtin_index = Natives::GetDebuggerCount();
3519 // Only run prologue.js and runtime.js at this point. 3546 // Only run prologue.js and runtime.js at this point.
3520 DCHECK_EQ(builtin_index, Natives::GetIndex("prologue")); 3547 DCHECK_EQ(builtin_index, Natives::GetIndex("prologue"));
3521 if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false; 3548 if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false;
3522 DCHECK_EQ(builtin_index, Natives::GetIndex("runtime")); 3549 DCHECK_EQ(builtin_index, Natives::GetIndex("runtime"));
3523 if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false; 3550 if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false;
3524 3551
3525 { 3552 {
3526 // Builtin function for OpaqueReference -- a JSValue-based object, 3553 // Builtin function for OpaqueReference -- a JSValue-based object,
3527 // that keeps its field isolated from JavaScript code. It may store 3554 // that keeps its field isolated from JavaScript code. It may store
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after
4617 } 4644 }
4618 4645
4619 4646
4620 // Called when the top-level V8 mutex is destroyed. 4647 // Called when the top-level V8 mutex is destroyed.
4621 void Bootstrapper::FreeThreadResources() { 4648 void Bootstrapper::FreeThreadResources() {
4622 DCHECK(!IsActive()); 4649 DCHECK(!IsActive());
4623 } 4650 }
4624 4651
4625 } // namespace internal 4652 } // namespace internal
4626 } // namespace v8 4653 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698