Commit b1a58122 authored by dcarney's avatar dcarney Committed by Commit bot

the IsPromise function should not execute js

BUG=v8:3929
LOG=n

Review URL: https://codereview.chromium.org/998943002

Cr-Commit-Position: refs/heads/master@{#27130}
parent e77d0abd
......@@ -6113,23 +6113,17 @@ Local<Object> Array::CloneElementAt(uint32_t index) {
bool Value::IsPromise() const {
i::Handle<i::Object> val = Utils::OpenHandle(this);
if (!val->IsJSObject()) return false;
i::Handle<i::JSObject> obj = i::Handle<i::JSObject>::cast(val);
i::Isolate* isolate = obj->GetIsolate();
LOG_API(isolate, "IsPromise");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
i::Handle<i::Object> argv[] = { obj };
i::Handle<i::Object> b;
has_pending_exception = !i::Execution::Call(
isolate,
isolate->is_promise(),
isolate->factory()->undefined_value(),
arraysize(argv), argv,
false).ToHandle(&b);
EXCEPTION_BAILOUT_CHECK(isolate, false);
return b->BooleanValue();
auto self = Utils::OpenHandle(this);
if (!self->IsJSObject()) return false;
auto js_object = i::Handle<i::JSObject>::cast(self);
// Promises can't have access checks.
if (js_object->map()->is_access_check_needed()) return false;
auto isolate = js_object->GetIsolate();
// TODO(dcarney): this should just be read from the symbol registry so as not
// to be context dependent.
auto key = isolate->promise_status();
// Shouldn't be possible to throw here.
return i::JSObject::HasRealNamedProperty(js_object, key).FromJust();
}
......
......@@ -1554,7 +1554,7 @@ void Genesis::InstallNativeFunctions() {
INSTALL_NATIVE(JSFunction, "ToCompletePropertyDescriptor",
to_complete_property_descriptor);
INSTALL_NATIVE(JSFunction, "IsPromise", is_promise);
INSTALL_NATIVE(Symbol, "promiseStatus", promise_status);
INSTALL_NATIVE(JSFunction, "PromiseCreate", promise_create);
INSTALL_NATIVE(JSFunction, "PromiseResolve", promise_resolve);
INSTALL_NATIVE(JSFunction, "PromiseReject", promise_reject);
......
......@@ -155,7 +155,7 @@ enum BindingFlags {
V(ALLOW_CODE_GEN_FROM_STRINGS_INDEX, Object, allow_code_gen_from_strings) \
V(ERROR_MESSAGE_FOR_CODE_GEN_FROM_STRINGS_INDEX, Object, \
error_message_for_code_gen_from_strings) \
V(IS_PROMISE_INDEX, JSFunction, is_promise) \
V(PROMISE_STATUS_INDEX, Symbol, promise_status) \
V(PROMISE_CREATE_INDEX, JSFunction, promise_create) \
V(PROMISE_RESOLVE_INDEX, JSFunction, promise_resolve) \
V(PROMISE_REJECT_INDEX, JSFunction, promise_reject) \
......@@ -390,7 +390,7 @@ class Context: public FixedArray {
ERROR_MESSAGE_FOR_CODE_GEN_FROM_STRINGS_INDEX,
RUN_MICROTASKS_INDEX,
ENQUEUE_MICROTASK_INDEX,
IS_PROMISE_INDEX,
PROMISE_STATUS_INDEX,
PROMISE_CREATE_INDEX,
PROMISE_RESOLVE_INDEX,
PROMISE_REJECT_INDEX,
......
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