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

Side by Side Diff: src/bootstrapper.cc

Issue 2541283002: [promises] Port ResolvePromise to TF (Closed)
Patch Set: fix nits 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 1837 matching lines...) Expand 10 before | Expand all | Expand 10 after
1848 1848
1849 // Install the "constructor" property on the {prototype}. 1849 // Install the "constructor" property on the {prototype}.
1850 JSObject::AddProperty(prototype, factory->constructor_string(), promise_fun, 1850 JSObject::AddProperty(prototype, factory->constructor_string(), promise_fun,
1851 DONT_ENUM); 1851 DONT_ENUM);
1852 1852
1853 // Install the @@toStringTag property on the {prototype}. 1853 // Install the @@toStringTag property on the {prototype}.
1854 JSObject::AddProperty( 1854 JSObject::AddProperty(
1855 prototype, factory->to_string_tag_symbol(), factory->Promise_string(), 1855 prototype, factory->to_string_tag_symbol(), factory->Promise_string(),
1856 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); 1856 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
1857 1857
1858 SimpleInstallFunction(prototype, "then", Builtins::kPromiseThen, 2, true, 1858 Handle<JSFunction> promise_then =
1859 SimpleCreateFunction(isolate, isolate->factory()->then_string(),
1860 Builtins::kPromiseThen, 2, true);
1861 JSObject::AddProperty(prototype, isolate->factory()->then_string(),
1862 promise_then, DONT_ENUM);
1863 InstallWithIntrinsicDefaultProto(isolate, promise_then,
1864 Context::PROMISE_THEN_INDEX);
1865
1866 // TODO(gsathya): Move to TF
1867 SimpleInstallFunction(prototype, "catch", Builtins::kIllegal, 1, true,
1859 DONT_ENUM); 1868 DONT_ENUM);
1860 1869
1870 Handle<Map> prototype_map(prototype->map());
1871 Map::SetShouldBeFastPrototypeMap(prototype_map, true, isolate);
1872
1873 // Store the initial Promise.prototype map. This is used in fast-path
1874 // checks. Do not alter the prototype after this point.
1875 native_context()->set_promise_prototype_map(*prototype_map);
1876
1861 { // Internal: PromiseInternalConstructor 1877 { // Internal: PromiseInternalConstructor
1862 Handle<JSFunction> function = 1878 Handle<JSFunction> function =
1863 SimpleCreateFunction(isolate, factory->empty_string(), 1879 SimpleCreateFunction(isolate, factory->empty_string(),
1864 Builtins::kPromiseInternalConstructor, 0, false); 1880 Builtins::kPromiseInternalConstructor, 0, false);
1865 InstallWithIntrinsicDefaultProto( 1881 InstallWithIntrinsicDefaultProto(
1866 isolate, function, Context::PROMISE_INTERNAL_CONSTRUCTOR_INDEX); 1882 isolate, function, Context::PROMISE_INTERNAL_CONSTRUCTOR_INDEX);
1867 } 1883 }
1868 1884
1869 { // Internal: PromiseCreateAndSet 1885 { // Internal: PromiseCreateAndSet
1870 Handle<JSFunction> function = 1886 Handle<JSFunction> function =
(...skipping 11 matching lines...) Expand all
1882 } 1898 }
1883 1899
1884 { // Internal: PerformPromiseThen 1900 { // Internal: PerformPromiseThen
1885 Handle<JSFunction> function = 1901 Handle<JSFunction> function =
1886 SimpleCreateFunction(isolate, factory->empty_string(), 1902 SimpleCreateFunction(isolate, factory->empty_string(),
1887 Builtins::kPerformPromiseThen, 4, false); 1903 Builtins::kPerformPromiseThen, 4, false);
1888 InstallWithIntrinsicDefaultProto(isolate, function, 1904 InstallWithIntrinsicDefaultProto(isolate, function,
1889 Context::PERFORM_PROMISE_THEN_INDEX); 1905 Context::PERFORM_PROMISE_THEN_INDEX);
1890 } 1906 }
1891 1907
1908 { // Internal: ResolvePromise
1909 Handle<JSFunction> function =
1910 SimpleCreateFunction(isolate, factory->empty_string(),
1911 Builtins::kResolvePromise, 2, false);
1912 InstallWithIntrinsicDefaultProto(isolate, function,
1913 Context::PROMISE_RESOLVE_INDEX);
1914 }
1915
1892 { 1916 {
1893 Handle<Code> code = 1917 Handle<Code> code =
1894 handle(isolate->builtins()->builtin(Builtins::kPromiseResolveClosure), 1918 handle(isolate->builtins()->builtin(Builtins::kPromiseResolveClosure),
1895 isolate); 1919 isolate);
1896 Handle<SharedFunctionInfo> info = 1920 Handle<SharedFunctionInfo> info =
1897 factory->NewSharedFunctionInfo(factory->empty_string(), code, false); 1921 factory->NewSharedFunctionInfo(factory->empty_string(), code, false);
1898 info->set_internal_formal_parameter_count(1); 1922 info->set_internal_formal_parameter_count(1);
1899 info->set_length(1); 1923 info->set_length(1);
1900 native_context()->set_promise_resolve_shared_fun(*info); 1924 native_context()->set_promise_resolve_shared_fun(*info);
1901 1925
(...skipping 1614 matching lines...) Expand 10 before | Expand all | Expand 10 after
3516 native_context()->set_natives_utils_object(*utils); 3540 native_context()->set_natives_utils_object(*utils);
3517 3541
3518 // Set up the extras utils object as a shared container between native 3542 // Set up the extras utils object as a shared container between native
3519 // scripts and extras. (Extras consume things added there by native scripts.) 3543 // scripts and extras. (Extras consume things added there by native scripts.)
3520 Handle<JSObject> extras_utils = 3544 Handle<JSObject> extras_utils =
3521 factory()->NewJSObject(isolate()->object_function()); 3545 factory()->NewJSObject(isolate()->object_function());
3522 native_context()->set_extras_utils_object(*extras_utils); 3546 native_context()->set_extras_utils_object(*extras_utils);
3523 3547
3524 InstallInternalArray(extras_utils, "InternalPackedArray", FAST_ELEMENTS); 3548 InstallInternalArray(extras_utils, "InternalPackedArray", FAST_ELEMENTS);
3525 3549
3550 InstallFunction(extras_utils, isolate()->promise_resolve(),
3551 factory()->NewStringFromAsciiChecked("resolvePromise"));
3552
3526 int builtin_index = Natives::GetDebuggerCount(); 3553 int builtin_index = Natives::GetDebuggerCount();
3527 // Only run prologue.js and runtime.js at this point. 3554 // Only run prologue.js and runtime.js at this point.
3528 DCHECK_EQ(builtin_index, Natives::GetIndex("prologue")); 3555 DCHECK_EQ(builtin_index, Natives::GetIndex("prologue"));
3529 if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false; 3556 if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false;
3530 DCHECK_EQ(builtin_index, Natives::GetIndex("runtime")); 3557 DCHECK_EQ(builtin_index, Natives::GetIndex("runtime"));
3531 if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false; 3558 if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false;
3532 3559
3533 { 3560 {
3534 // Builtin function for OpaqueReference -- a JSValue-based object, 3561 // Builtin function for OpaqueReference -- a JSValue-based object,
3535 // that keeps its field isolated from JavaScript code. It may store 3562 // that keeps its field isolated from JavaScript code. It may store
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after
4625 } 4652 }
4626 4653
4627 4654
4628 // Called when the top-level V8 mutex is destroyed. 4655 // Called when the top-level V8 mutex is destroyed.
4629 void Bootstrapper::FreeThreadResources() { 4656 void Bootstrapper::FreeThreadResources() {
4630 DCHECK(!IsActive()); 4657 DCHECK(!IsActive());
4631 } 4658 }
4632 4659
4633 } // namespace internal 4660 } // namespace internal
4634 } // namespace v8 4661 } // namespace v8
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/builtins/builtins.h » ('j') | src/js/promise.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698