Commit dfc08e88 authored by gsathya's avatar gsathya Committed by Commit bot

[promises] Remove IsPromise

Use %is_promise instead

BUG=v8:5343

Review-Url: https://codereview.chromium.org/2521723003
Cr-Commit-Position: refs/heads/master@{#41440}
parent 2b991784
......@@ -219,7 +219,6 @@ void Builtins::Generate_PromiseInternalConstructor(
a.Return(instance);
}
// TODO(gsathya): Refactor promise.js::IsPromise to use this.
void Builtins::Generate_IsPromise(compiler::CodeAssemblerState* state) {
CodeStubAssembler a(state);
typedef compiler::Node Node;
......
......@@ -106,12 +106,6 @@ function ClearMirrorCache(value) {
}
function ObjectIsPromise(value) {
return IS_RECEIVER(value) &&
!IS_UNDEFINED(%DebugGetProperty(value, promiseStateSymbol));
}
/**
* Returns the mirror for a specified value or object.
*
......@@ -168,7 +162,7 @@ function MakeMirror(value, opt_transient) {
mirror = new SetMirror(value);
} else if (IS_MAP_ITERATOR(value) || IS_SET_ITERATOR(value)) {
mirror = new IteratorMirror(value);
} else if (ObjectIsPromise(value)) {
} else if (%is_promise(value)) {
mirror = new PromiseMirror(value);
} else if (IS_GENERATOR(value)) {
mirror = new GeneratorMirror(value);
......
......@@ -13,7 +13,6 @@
var AsyncFunctionNext;
var AsyncFunctionThrow;
var IsPromise;
var CreateInternalPromiseCapability;
var PerformPromiseThen;
var PromiseCreate;
......@@ -24,7 +23,6 @@ var ResolvePromise;
utils.Import(function(from) {
AsyncFunctionNext = from.AsyncFunctionNext;
AsyncFunctionThrow = from.AsyncFunctionThrow;
IsPromise = from.IsPromise;
CreateInternalPromiseCapability = from.CreateInternalPromiseCapability;
PerformPromiseThen = from.PerformPromiseThen;
PromiseCreate = from.PromiseCreate;
......@@ -46,7 +44,7 @@ var promiseHasHandlerSymbol =
// -------------------------------------------------------------------
function PromiseCastResolved(value) {
if (IsPromise(value)) {
if (%is_promise(value)) {
return value;
} else {
var promise = PromiseCreate();
......@@ -96,7 +94,7 @@ function AsyncFunctionAwait(generator, awaited, outerPromise) {
SET_PRIVATE(throwawayCapability.promise, promiseHasHandlerSymbol, true);
if (DEBUG_IS_ACTIVE) {
if (IsPromise(awaited)) {
if (%is_promise(awaited)) {
// Mark the reject handler callback to be a forwarding edge, rather
// than a meaningful catch handler
SET_PRIVATE(onRejected, promiseForwardingHandlerSymbol, true);
......@@ -120,7 +118,7 @@ function AsyncFunctionAwaitUncaught(generator, awaited, outerPromise) {
// Called by the parser from the desugaring of 'await' when catch
// prediction indicates that there is a locally surrounding catch block
function AsyncFunctionAwaitCaught(generator, awaited, outerPromise) {
if (DEBUG_IS_ACTIVE && IsPromise(awaited)) {
if (DEBUG_IS_ACTIVE && %is_promise(awaited)) {
SET_PRIVATE(awaited, promiseHandledHintSymbol, true);
}
AsyncFunctionAwait(generator, awaited, outerPromise);
......
......@@ -180,12 +180,6 @@ SET_PRIVATE(PromiseIdRejectHandler, promiseForwardingHandlerSymbol, true);
// For bootstrapper.
// Only used by utils
// ES#sec-ispromise IsPromise ( x )
function IsPromise(x) {
return IS_RECEIVER(x) && HAS_DEFINED_PRIVATE(x, promiseStateSymbol);
}
function PromiseCreate() {
return PromiseInit(%promise_internal_constructor());
}
......@@ -212,7 +206,7 @@ function ResolvePromise(promise, resolution) {
// Resolution is a native promise and if it's already resolved or
// rejected, shortcircuit the resolution procedure by directly
// reusing the value from the promise.
if (IsPromise(resolution) && then === PromiseThen) {
if (%is_promise(resolution) && then === PromiseThen) {
var thenableState = GET_PRIVATE(resolution, promiseStateSymbol);
if (thenableState === kFulfilled) {
// This goes inside the if-else to save one symbol lookup in
......@@ -239,7 +233,7 @@ function ResolvePromise(promise, resolution) {
}
if (IS_CALLABLE(then)) {
if (DEBUG_IS_ACTIVE && IsPromise(resolution)) {
if (DEBUG_IS_ACTIVE && %is_promise(resolution)) {
// Mark the dependency of the new promise on the resolution
SET_PRIVATE(resolution, promiseHandledBySymbol, promise);
}
......@@ -358,7 +352,7 @@ function PerformPromiseThen(promise, onResolve, onReject, resultCapability) {
// Promise.prototype.then ( onFulfilled, onRejected )
// Multi-unwrapped chaining with thenable coercion.
function PromiseThen(onResolve, onReject) {
if (!IsPromise(this)) {
if (!%is_promise(this)) {
throw %make_type_error(kNotAPromise, this);
}
......@@ -388,7 +382,7 @@ function PromiseResolve(x) {
if (!IS_RECEIVER(this)) {
throw %make_type_error(kCalledOnNonObject, PromiseResolve);
}
if (IsPromise(x) && x.constructor === this) return x;
if (%is_promise(x) && x.constructor === this) return x;
// Avoid creating resolving functions.
if (this === GlobalPromise) {
......@@ -448,7 +442,7 @@ function PromiseAll(iterable) {
deferred.reject);
// For catch prediction, mark that rejections here are semantically
// handled by the combined Promise.
if (instrumenting && IsPromise(throwawayPromise)) {
if (instrumenting && %is_promise(throwawayPromise)) {
SET_PRIVATE(throwawayPromise, promiseHandledBySymbol, deferred.promise);
}
++i;
......@@ -491,7 +485,7 @@ function PromiseRace(iterable) {
deferred.reject);
// For catch prediction, mark that rejections here are semantically
// handled by the combined Promise.
if (instrumenting && IsPromise(throwawayPromise)) {
if (instrumenting && %is_promise(throwawayPromise)) {
SET_PRIVATE(throwawayPromise, promiseHandledBySymbol, deferred.promise);
}
}
......@@ -611,7 +605,6 @@ utils.InstallFunctions(extrasUtils, 0, [
]);
utils.Export(function(to) {
to.IsPromise = IsPromise;
to.PromiseCreate = PromiseCreate;
to.PromiseThen = PromiseThen;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment