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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index 0242f56712b2616dcf9e09ae1867e13675fa44d4..cadda3bf6539ca125bf303f9c126ae9f62d9ebb4 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -1847,9 +1847,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(),
@@ -1881,6 +1897,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),
@@ -3515,6 +3539,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"));

Powered by Google App Engine
This is Rietveld 408576698