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