Commit fbc681d3 authored by Sathya Gunasekaran's avatar Sathya Gunasekaran Committed by Commit Bot

[Promise] Move IsPromise to CPP

This was previously used by our js builtins but they no longer
exist. This has been exposed to API which means we can't remove it
just yet. Moving to CPP for now to save binary size.

Bug: v8:5343
Change-Id: I2a3e5a4169310b2ba13ce13f0386336e9733d71f
Reviewed-on: https://chromium-review.googlesource.com/575024Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46721}
parent f7f2d2a4
...@@ -1208,6 +1208,7 @@ v8_source_set("v8_base") { ...@@ -1208,6 +1208,7 @@ v8_source_set("v8_base") {
"src/builtins/builtins-math.cc", "src/builtins/builtins-math.cc",
"src/builtins/builtins-number.cc", "src/builtins/builtins-number.cc",
"src/builtins/builtins-object.cc", "src/builtins/builtins-object.cc",
"src/builtins/builtins-promise.cc",
"src/builtins/builtins-reflect.cc", "src/builtins/builtins-reflect.cc",
"src/builtins/builtins-regexp.cc", "src/builtins/builtins-regexp.cc",
"src/builtins/builtins-sharedarraybuffer.cc", "src/builtins/builtins-sharedarraybuffer.cc",
......
...@@ -763,7 +763,7 @@ namespace internal { ...@@ -763,7 +763,7 @@ namespace internal {
/* ES6 #sec-promise-executor */ \ /* ES6 #sec-promise-executor */ \
TFJ(PromiseConstructor, 1, kExecutor) \ TFJ(PromiseConstructor, 1, kExecutor) \
TFJ(PromiseInternalConstructor, 1, kParent) \ TFJ(PromiseInternalConstructor, 1, kParent) \
TFJ(IsPromise, 1, kObject) \ CPP(IsPromise) \
/* ES #sec-promise-resolve-functions */ \ /* ES #sec-promise-resolve-functions */ \
TFJ(PromiseResolveClosure, 1, kValue) \ TFJ(PromiseResolveClosure, 1, kValue) \
/* ES #sec-promise-reject-functions */ \ /* ES #sec-promise-reject-functions */ \
......
...@@ -1155,20 +1155,6 @@ TF_BUILTIN(PromiseInternalConstructor, PromiseBuiltinsAssembler) { ...@@ -1155,20 +1155,6 @@ TF_BUILTIN(PromiseInternalConstructor, PromiseBuiltinsAssembler) {
Return(AllocateAndInitJSPromise(context, parent)); Return(AllocateAndInitJSPromise(context, parent));
} }
TF_BUILTIN(IsPromise, PromiseBuiltinsAssembler) {
Node* const maybe_promise = Parameter(Descriptor::kObject);
Label if_notpromise(this, Label::kDeferred);
GotoIf(TaggedIsSmi(maybe_promise), &if_notpromise);
Node* const result =
SelectBooleanConstant(HasInstanceType(maybe_promise, JS_PROMISE_TYPE));
Return(result);
BIND(&if_notpromise);
Return(FalseConstant());
}
// ES#sec-promise.prototype.then // ES#sec-promise.prototype.then
// Promise.prototype.catch ( onFulfilled, onRejected ) // Promise.prototype.catch ( onFulfilled, onRejected )
TF_BUILTIN(PromiseThen, PromiseBuiltinsAssembler) { TF_BUILTIN(PromiseThen, PromiseBuiltinsAssembler) {
......
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/builtins/builtins-utils.h"
#include "src/builtins/builtins.h"
#include "src/objects-inl.h"
namespace v8 {
namespace internal {
BUILTIN(IsPromise) {
SealHandleScope scope(isolate);
Handle<Object> object = args.atOrUndefined(isolate, 1);
return isolate->heap()->ToBoolean(object->IsJSPromise());
}
} // namespace internal
} // namespace v8
...@@ -647,6 +647,7 @@ ...@@ -647,6 +647,7 @@
'builtins/builtins-math.cc', 'builtins/builtins-math.cc',
'builtins/builtins-number.cc', 'builtins/builtins-number.cc',
'builtins/builtins-object.cc', 'builtins/builtins-object.cc',
'builtins/builtins-promise.cc',
'builtins/builtins-reflect.cc', 'builtins/builtins-reflect.cc',
'builtins/builtins-regexp.cc', 'builtins/builtins-regexp.cc',
'builtins/builtins-sharedarraybuffer.cc', 'builtins/builtins-sharedarraybuffer.cc',
......
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