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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/api.cc ('k') | src/builtins/builtins.h » ('j') | src/js/promise.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index ee3525ac6be2340155d222c6c5b83c12f14aeb1e..2d4d4b6bce979961ea414587ffb0032325d9a013 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -1855,9 +1855,25 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
prototype, factory->to_string_tag_symbol(), factory->Promise_string(),
static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
- SimpleInstallFunction(prototype, "then", Builtins::kPromiseThen, 2, true,
+ Handle<JSFunction> promise_then =
+ SimpleCreateFunction(isolate, isolate->factory()->then_string(),
+ Builtins::kPromiseThen, 2, true);
+ JSObject::AddProperty(prototype, isolate->factory()->then_string(),
+ promise_then, DONT_ENUM);
+ InstallWithIntrinsicDefaultProto(isolate, promise_then,
+ Context::PROMISE_THEN_INDEX);
+
+ // TODO(gsathya): Move to TF
+ SimpleInstallFunction(prototype, "catch", Builtins::kIllegal, 1, true,
DONT_ENUM);
+ Handle<Map> prototype_map(prototype->map());
+ Map::SetShouldBeFastPrototypeMap(prototype_map, true, isolate);
+
+ // Store the initial Promise.prototype map. This is used in fast-path
+ // checks. Do not alter the prototype after this point.
+ native_context()->set_promise_prototype_map(*prototype_map);
+
{ // Internal: PromiseInternalConstructor
Handle<JSFunction> function =
SimpleCreateFunction(isolate, factory->empty_string(),
@@ -1889,6 +1905,14 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Context::PERFORM_PROMISE_THEN_INDEX);
}
+ { // Internal: ResolvePromise
+ Handle<JSFunction> function =
+ SimpleCreateFunction(isolate, factory->empty_string(),
+ Builtins::kResolvePromise, 2, false);
+ InstallWithIntrinsicDefaultProto(isolate, function,
+ Context::PROMISE_RESOLVE_INDEX);
+ }
+
{
Handle<Code> code =
handle(isolate->builtins()->builtin(Builtins::kPromiseResolveClosure),
@@ -3523,6 +3547,9 @@ bool Genesis::InstallNatives(GlobalContextType context_type) {
InstallInternalArray(extras_utils, "InternalPackedArray", FAST_ELEMENTS);
+ InstallFunction(extras_utils, isolate()->promise_resolve(),
+ factory()->NewStringFromAsciiChecked("resolvePromise"));
+
int builtin_index = Natives::GetDebuggerCount();
// Only run prologue.js and runtime.js at this point.
DCHECK_EQ(builtin_index, Natives::GetIndex("prologue"));
« 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