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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 6096 matching lines...) Expand 10 before | Expand all | Expand 10 after
6107 } 6107 }
6108 6108
6109 6109
6110 Local<Object> Array::CloneElementAt(uint32_t index) { 6110 Local<Object> Array::CloneElementAt(uint32_t index) {
6111 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 6111 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
6112 RETURN_TO_LOCAL_UNCHECKED(CloneElementAt(context, index), Object); 6112 RETURN_TO_LOCAL_UNCHECKED(CloneElementAt(context, index), Object);
6113 } 6113 }
6114 6114
6115 6115
6116 bool Value::IsPromise() const { 6116 bool Value::IsPromise() const {
6117 i::Handle<i::Object> val = Utils::OpenHandle(this); 6117 auto self = Utils::OpenHandle(this);
6118 if (!val->IsJSObject()) return false; 6118 if (!self->IsJSObject()) return false;
6119 i::Handle<i::JSObject> obj = i::Handle<i::JSObject>::cast(val); 6119 auto js_object = i::Handle<i::JSObject>::cast(self);
6120 i::Isolate* isolate = obj->GetIsolate(); 6120 // Promises can't have access checks.
6121 LOG_API(isolate, "IsPromise"); 6121 if (js_object->map()->is_access_check_needed()) return false;
6122 ENTER_V8(isolate); 6122 auto isolate = js_object->GetIsolate();
6123 EXCEPTION_PREAMBLE(isolate); 6123 // TODO(dcarney): this should just be read from the symbol registry so as not
6124 i::Handle<i::Object> argv[] = { obj }; 6124 // to be context dependent.
6125 i::Handle<i::Object> b; 6125 auto key = isolate->promise_status();
6126 has_pending_exception = !i::Execution::Call( 6126 // Shouldn't be possible to throw here.
6127 isolate, 6127 return i::JSObject::HasRealNamedProperty(js_object, key).FromJust();
6128 isolate->is_promise(),
6129 isolate->factory()->undefined_value(),
6130 arraysize(argv), argv,
6131 false).ToHandle(&b);
6132 EXCEPTION_BAILOUT_CHECK(isolate, false);
6133 return b->BooleanValue();
6134 } 6128 }
6135 6129
6136 6130
6137 MaybeLocal<Promise::Resolver> Promise::Resolver::New(Local<Context> context) { 6131 MaybeLocal<Promise::Resolver> Promise::Resolver::New(Local<Context> context) {
6138 PREPARE_FOR_EXECUTION(context, "Promise::Resolver::New", Resolver); 6132 PREPARE_FOR_EXECUTION(context, "Promise::Resolver::New", Resolver);
6139 i::Handle<i::Object> result; 6133 i::Handle<i::Object> result;
6140 has_pending_exception = !i::Execution::Call( 6134 has_pending_exception = !i::Execution::Call(
6141 isolate, 6135 isolate,
6142 isolate->promise_create(), 6136 isolate->promise_create(),
6143 isolate->factory()->undefined_value(), 6137 isolate->factory()->undefined_value(),
(...skipping 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after
7983 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7977 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7984 Address callback_address = 7978 Address callback_address =
7985 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7979 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7986 VMState<EXTERNAL> state(isolate); 7980 VMState<EXTERNAL> state(isolate);
7987 ExternalCallbackScope call_scope(isolate, callback_address); 7981 ExternalCallbackScope call_scope(isolate, callback_address);
7988 callback(info); 7982 callback(info);
7989 } 7983 }
7990 7984
7991 7985
7992 } } // namespace v8::internal 7986 } } // namespace v8::internal
OLDNEW
« 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