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

Unified Diff: src/api.cc

Issue 998943002: the IsPromise function should not execute js (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months 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
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index e7667ba006fd38a553f78265b0e40502fadaf4df..c1c77360f3841a8147b7e93252c21a5afaf2b25f 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -6114,23 +6114,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();
}
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698