Commit 14ba446b authored by Jochen Eisinger's avatar Jochen Eisinger Committed by Commit Bot

Replace PREPARE_FOR_EXECUTION_PRIMITIVE

In most cases, I'm using ENTER_V8 which is due to the fact that the
respective methods might end up executing script, either because they
invoke some callback, or because they might trigger a proxy trap.

Also add microtask suppression scopes in the debugger to all the places
that need one according to tests.

BUG=v8:5830
R=marja@chromium.org,jgruber@chromium.org

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Change-Id: I24cc3de37fc0d8156acfe86b290568e5f8f662b4
Reviewed-on: https://chromium-review.googlesource.com/519262
Commit-Queue: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46146}
parent b015961d
......@@ -142,16 +142,6 @@ namespace v8 {
MaybeLocal<T>(), InternalEscapableScope, \
false)
#define PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, class_name, \
function_name, T) \
PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, class_name, function_name, \
MaybeLocal<T>(), InternalEscapableScope, \
true)
#define PREPARE_FOR_EXECUTION_PRIMITIVE(context, class_name, function_name, T) \
PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, class_name, function_name, \
Nothing<T>(), i::HandleScope, false)
#define ENTER_V8(isolate, context, class_name, function_name, bailout_value, \
HandleScopeClass) \
ENTER_V8_HELPER_DO_NOT_USE(isolate, context, class_name, function_name, \
......@@ -2082,8 +2072,9 @@ Local<UnboundScript> Script::GetUnboundScript() {
Maybe<bool> DynamicImportResult::FinishDynamicImportSuccess(
Local<Context> context, Local<Module> module) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Module, FinishDynamicImportSuccess,
bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Module, FinishDynamicImportSuccess,
Nothing<bool>(), i::HandleScope);
auto promise = Utils::OpenHandle(this);
i::Handle<i::Module> module_obj = Utils::OpenHandle(*module);
i::Handle<i::JSModuleNamespace> module_namespace =
......@@ -2100,8 +2091,9 @@ Maybe<bool> DynamicImportResult::FinishDynamicImportSuccess(
Maybe<bool> DynamicImportResult::FinishDynamicImportFailure(
Local<Context> context, Local<Value> exception) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Module, FinishDynamicImportFailure,
bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Module, FinishDynamicImportFailure,
Nothing<bool>(), i::HandleScope);
auto promise = Utils::OpenHandle(this);
// We pass true to trigger the debugger's on exception handler.
i::Handle<i::Object> argv[] = {promise, Utils::OpenHandle(*exception),
......@@ -2154,7 +2146,9 @@ bool Module::Instantiate(Local<Context> context,
Maybe<bool> Module::InstantiateModule(Local<Context> context,
Module::ResolveCallback callback) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Module, InstantiateModule, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8_NO_SCRIPT(isolate, context, Module, InstantiateModule,
Nothing<bool>(), i::HandleScope);
has_pending_exception =
!i::Module::Instantiate(Utils::OpenHandle(this), context, callback);
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
......@@ -3290,7 +3284,9 @@ void ValueSerializer::SetTreatArrayBufferViewsAsHostObjects(bool mode) {
Maybe<bool> ValueSerializer::WriteValue(Local<Context> context,
Local<Value> value) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, ValueSerializer, WriteValue, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, ValueSerializer, WriteValue, Nothing<bool>(),
i::HandleScope);
i::Handle<i::Object> object = Utils::OpenHandle(*value);
Maybe<bool> result = private_->serializer.WriteObject(object);
has_pending_exception = result.IsNothing();
......@@ -3381,7 +3377,9 @@ ValueDeserializer::ValueDeserializer(Isolate* isolate, const uint8_t* data,
ValueDeserializer::~ValueDeserializer() { delete private_; }
Maybe<bool> ValueDeserializer::ReadHeader(Local<Context> context) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, ValueDeserializer, ReadHeader, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8_NO_SCRIPT(isolate, context, ValueDeserializer, ReadHeader,
Nothing<bool>(), i::HandleScope);
// We could have aborted during the constructor.
// If so, ReadHeader is where we report it.
......@@ -4075,7 +4073,9 @@ bool Value::BooleanValue() const {
Maybe<double> Value::NumberValue(Local<Context> context) const {
auto obj = Utils::OpenHandle(this);
if (obj->IsNumber()) return Just(obj->Number());
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, NumberValue, double);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Value, NumberValue, Nothing<double>(),
i::HandleScope);
i::Handle<i::Object> num;
has_pending_exception = !i::Object::ToNumber(obj).ToHandle(&num);
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(double);
......@@ -4096,7 +4096,9 @@ Maybe<int64_t> Value::IntegerValue(Local<Context> context) const {
if (obj->IsNumber()) {
return Just(NumberToInt64(*obj));
}
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, IntegerValue, int64_t);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Value, IntegerValue, Nothing<int64_t>(),
i::HandleScope);
i::Handle<i::Object> num;
has_pending_exception = !i::Object::ToInteger(isolate, obj).ToHandle(&num);
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int64_t);
......@@ -4120,7 +4122,9 @@ int64_t Value::IntegerValue() const {
Maybe<int32_t> Value::Int32Value(Local<Context> context) const {
auto obj = Utils::OpenHandle(this);
if (obj->IsNumber()) return Just(NumberToInt32(*obj));
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, Int32Value, int32_t);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Value, Int32Value, Nothing<int32_t>(),
i::HandleScope);
i::Handle<i::Object> num;
has_pending_exception = !i::Object::ToInt32(isolate, obj).ToHandle(&num);
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int32_t);
......@@ -4139,7 +4143,9 @@ int32_t Value::Int32Value() const {
Maybe<uint32_t> Value::Uint32Value(Local<Context> context) const {
auto obj = Utils::OpenHandle(this);
if (obj->IsNumber()) return Just(NumberToUint32(*obj));
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, Uint32Value, uint32_t);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Value, Uint32Value, Nothing<uint32_t>(),
i::HandleScope);
i::Handle<i::Object> num;
has_pending_exception = !i::Object::ToUint32(isolate, obj).ToHandle(&num);
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(uint32_t);
......@@ -4236,7 +4242,9 @@ Local<String> Value::TypeOf(v8::Isolate* external_isolate) {
Maybe<bool> Value::InstanceOf(v8::Local<v8::Context> context,
v8::Local<v8::Object> object) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Value, InstanceOf, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Value, InstanceOf, Nothing<bool>(),
i::HandleScope);
auto left = Utils::OpenHandle(this);
auto right = Utils::OpenHandle(*object);
i::Handle<i::Object> result;
......@@ -4248,7 +4256,8 @@ Maybe<bool> Value::InstanceOf(v8::Local<v8::Context> context,
Maybe<bool> v8::Object::Set(v8::Local<v8::Context> context,
v8::Local<Value> key, v8::Local<Value> value) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, Set, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Object, Set, Nothing<bool>(), i::HandleScope);
auto self = Utils::OpenHandle(this);
auto key_obj = Utils::OpenHandle(*key);
auto value_obj = Utils::OpenHandle(*value);
......@@ -4268,7 +4277,8 @@ bool v8::Object::Set(v8::Local<Value> key, v8::Local<Value> value) {
Maybe<bool> v8::Object::Set(v8::Local<v8::Context> context, uint32_t index,
v8::Local<Value> value) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, Set, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Object, Set, Nothing<bool>(), i::HandleScope);
auto self = Utils::OpenHandle(this);
auto value_obj = Utils::OpenHandle(*value);
has_pending_exception = i::Object::SetElement(isolate, self, index, value_obj,
......@@ -4287,7 +4297,9 @@ bool v8::Object::Set(uint32_t index, v8::Local<Value> value) {
Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context,
v8::Local<Name> key,
v8::Local<Value> value) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, CreateDataProperty, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Object, CreateDataProperty, Nothing<bool>(),
i::HandleScope);
i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
i::Handle<i::Name> key_obj = Utils::OpenHandle(*key);
i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
......@@ -4305,7 +4317,9 @@ Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context,
Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context,
uint32_t index,
v8::Local<Value> value) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, CreateDataProperty, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Object, CreateDataProperty, Nothing<bool>(),
i::HandleScope);
i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
......@@ -4414,7 +4428,9 @@ Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context,
v8::Local<Name> key,
v8::Local<Value> value,
v8::PropertyAttribute attributes) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, DefineOwnProperty, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Object, DefineOwnProperty, Nothing<bool>(),
i::HandleScope);
i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
i::Handle<i::Name> key_obj = Utils::OpenHandle(*key);
i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
......@@ -4434,7 +4450,9 @@ Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context,
Maybe<bool> v8::Object::DefineProperty(v8::Local<v8::Context> context,
v8::Local<Name> key,
PropertyDescriptor& descriptor) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, DefineProperty, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Object, DefineOwnProperty, Nothing<bool>(),
i::HandleScope);
i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
i::Handle<i::Name> key_obj = Utils::OpenHandle(*key);
......@@ -4463,7 +4481,9 @@ static i::MaybeHandle<i::Object> DefineObjectProperty(
Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context,
v8::Local<Value> key, v8::Local<Value> value,
v8::PropertyAttribute attribs) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, ForceSet, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8_NO_SCRIPT(isolate, context, Object, ForceSet, Nothing<bool>(),
i::HandleScope);
auto self = i::Handle<i::JSObject>::cast(Utils::OpenHandle(this));
auto key_obj = Utils::OpenHandle(*key);
auto value_obj = Utils::OpenHandle(*value);
......@@ -4478,7 +4498,9 @@ Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context,
Maybe<bool> v8::Object::SetPrivate(Local<Context> context, Local<Private> key,
Local<Value> value) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, SetPrivate, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8_NO_SCRIPT(isolate, context, Object, SetPrivate, Nothing<bool>(),
i::HandleScope);
auto self = Utils::OpenHandle(this);
auto key_obj = Utils::OpenHandle(reinterpret_cast<Name*>(*key));
auto value_obj = Utils::OpenHandle(*value);
......@@ -4546,8 +4568,9 @@ MaybeLocal<Value> v8::Object::GetPrivate(Local<Context> context,
Maybe<PropertyAttribute> v8::Object::GetPropertyAttributes(
Local<Context> context, Local<Value> key) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, GetPropertyAttributes,
PropertyAttribute);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Object, GetPropertyAttributes,
Nothing<PropertyAttribute>(), i::HandleScope);
auto self = Utils::OpenHandle(this);
auto key_obj = Utils::OpenHandle(*key);
if (!key_obj->IsName()) {
......@@ -4605,7 +4628,9 @@ Local<Value> v8::Object::GetPrototype() {
Maybe<bool> v8::Object::SetPrototype(Local<Context> context,
Local<Value> value) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, SetPrototype, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Object, SetPrototype, Nothing<bool>(),
i::HandleScope);
auto self = Utils::OpenHandle(this);
auto value_obj = Utils::OpenHandle(*value);
// We do not allow exceptions thrown while setting the prototype
......@@ -4716,7 +4741,9 @@ Local<String> v8::Object::GetConstructorName() {
Maybe<bool> v8::Object::SetIntegrityLevel(Local<Context> context,
IntegrityLevel level) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, SetIntegrityLevel, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Object, SetIntegrityLevel, Nothing<bool>(),
i::HandleScope);
auto self = Utils::OpenHandle(this);
i::JSReceiver::IntegrityLevel i_level =
level == IntegrityLevel::kFrozen ? i::FROZEN : i::SEALED;
......@@ -4728,7 +4755,8 @@ Maybe<bool> v8::Object::SetIntegrityLevel(Local<Context> context,
}
Maybe<bool> v8::Object::Delete(Local<Context> context, Local<Value> key) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, Delete, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Object, Delete, Nothing<bool>(), i::HandleScope);
auto self = Utils::OpenHandle(this);
auto key_obj = Utils::OpenHandle(*key);
Maybe<bool> result =
......@@ -4752,7 +4780,8 @@ Maybe<bool> v8::Object::DeletePrivate(Local<Context> context,
Maybe<bool> v8::Object::Has(Local<Context> context, Local<Value> key) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, Get, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Object, Has, Nothing<bool>(), i::HandleScope);
auto self = Utils::OpenHandle(this);
auto key_obj = Utils::OpenHandle(*key);
Maybe<bool> maybe = Nothing<bool>();
......@@ -4785,7 +4814,8 @@ Maybe<bool> v8::Object::HasPrivate(Local<Context> context, Local<Private> key) {
Maybe<bool> v8::Object::Delete(Local<Context> context, uint32_t index) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, DeleteProperty, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Object, Delete, Nothing<bool>(), i::HandleScope);
auto self = Utils::OpenHandle(this);
Maybe<bool> result = i::JSReceiver::DeleteElement(self, index);
has_pending_exception = result.IsNothing();
......@@ -4801,7 +4831,8 @@ bool v8::Object::Delete(uint32_t index) {
Maybe<bool> v8::Object::Has(Local<Context> context, uint32_t index) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, Get, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Object, Has, Nothing<bool>(), i::HandleScope);
auto self = Utils::OpenHandle(this);
auto maybe = i::JSReceiver::HasElement(self, index);
has_pending_exception = maybe.IsNothing();
......@@ -4822,7 +4853,9 @@ static Maybe<bool> ObjectSetAccessor(Local<Context> context, Object* self,
AccessControl settings,
PropertyAttribute attributes,
bool is_special_data_property) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, SetAccessor, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8_NO_SCRIPT(isolate, context, Object, SetAccessor, Nothing<bool>(),
i::HandleScope);
if (!Utils::OpenHandle(self)->IsJSObject()) return Just(false);
i::Handle<i::JSObject> obj =
i::Handle<i::JSObject>::cast(Utils::OpenHandle(self));
......@@ -4906,7 +4939,9 @@ Maybe<bool> Object::SetNativeDataProperty(v8::Local<v8::Context> context,
Maybe<bool> v8::Object::HasOwnProperty(Local<Context> context,
Local<Name> key) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, HasOwnProperty, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Object, HasOwnProperty, Nothing<bool>(),
i::HandleScope);
auto self = Utils::OpenHandle(this);
auto key_val = Utils::OpenHandle(*key);
auto result = i::JSReceiver::HasOwnProperty(self, key_val);
......@@ -4916,7 +4951,9 @@ Maybe<bool> v8::Object::HasOwnProperty(Local<Context> context,
}
Maybe<bool> v8::Object::HasOwnProperty(Local<Context> context, uint32_t index) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, HasOwnProperty, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Object, HasOwnProperty, Nothing<bool>(),
i::HandleScope);
auto self = Utils::OpenHandle(this);
auto result = i::JSReceiver::HasOwnProperty(self, index);
has_pending_exception = result.IsNothing();
......@@ -4932,7 +4969,9 @@ bool v8::Object::HasOwnProperty(Local<String> key) {
Maybe<bool> v8::Object::HasRealNamedProperty(Local<Context> context,
Local<Name> key) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, HasRealNamedProperty, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8_NO_SCRIPT(isolate, context, Object, HasRealNamedProperty,
Nothing<bool>(), i::HandleScope);
auto self = Utils::OpenHandle(this);
if (!self->IsJSObject()) return Just(false);
auto key_val = Utils::OpenHandle(*key);
......@@ -4952,8 +4991,9 @@ bool v8::Object::HasRealNamedProperty(Local<String> key) {
Maybe<bool> v8::Object::HasRealIndexedProperty(Local<Context> context,
uint32_t index) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, HasRealIndexedProperty,
bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8_NO_SCRIPT(isolate, context, Object, HasRealIndexedProperty,
Nothing<bool>(), i::HandleScope);
auto self = Utils::OpenHandle(this);
if (!self->IsJSObject()) return Just(false);
auto result = i::JSObject::HasRealElementProperty(
......@@ -4972,8 +5012,9 @@ bool v8::Object::HasRealIndexedProperty(uint32_t index) {
Maybe<bool> v8::Object::HasRealNamedCallbackProperty(Local<Context> context,
Local<Name> key) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, HasRealNamedCallbackProperty,
bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8_NO_SCRIPT(isolate, context, Object, HasRealNamedCallbackProperty,
Nothing<bool>(), i::HandleScope);
auto self = Utils::OpenHandle(this);
if (!self->IsJSObject()) return Just(false);
auto key_val = Utils::OpenHandle(*key);
......@@ -5038,9 +5079,10 @@ Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain(
Maybe<PropertyAttribute>
v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(
Local<Context> context, Local<Name> key) {
PREPARE_FOR_EXECUTION_PRIMITIVE(
context, Object, GetRealNamedPropertyAttributesInPrototypeChain,
PropertyAttribute);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8_NO_SCRIPT(isolate, context, Object,
GetRealNamedPropertyAttributesInPrototypeChain,
Nothing<PropertyAttribute>(), i::HandleScope);
i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
if (!self->IsJSObject()) return Nothing<PropertyAttribute>();
i::Handle<i::Name> key_obj = Utils::OpenHandle(*key);
......@@ -5091,8 +5133,9 @@ Local<Value> v8::Object::GetRealNamedProperty(Local<String> key) {
Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes(
Local<Context> context, Local<Name> key) {
PREPARE_FOR_EXECUTION_PRIMITIVE(
context, Object, GetRealNamedPropertyAttributes, PropertyAttribute);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8_NO_SCRIPT(isolate, context, Object, GetRealNamedPropertyAttributes,
Nothing<PropertyAttribute>(), i::HandleScope);
auto self = Utils::OpenHandle(this);
auto key_obj = Utils::OpenHandle(*key);
i::LookupIterator it = i::LookupIterator::PropertyOrElement(
......@@ -7306,7 +7349,8 @@ MaybeLocal<Map> Map::Set(Local<Context> context, Local<Value> key,
Maybe<bool> Map::Has(Local<Context> context, Local<Value> key) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Map, Has, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Map, Has, Nothing<bool>(), i::HandleScope);
auto self = Utils::OpenHandle(this);
i::Handle<i::Object> result;
i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)};
......@@ -7319,7 +7363,8 @@ Maybe<bool> Map::Has(Local<Context> context, Local<Value> key) {
Maybe<bool> Map::Delete(Local<Context> context, Local<Value> key) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Map, Delete, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Map, Delete, Nothing<bool>(), i::HandleScope);
auto self = Utils::OpenHandle(this);
i::Handle<i::Object> result;
i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)};
......@@ -7412,7 +7457,8 @@ MaybeLocal<Set> Set::Add(Local<Context> context, Local<Value> key) {
Maybe<bool> Set::Has(Local<Context> context, Local<Value> key) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Set, Has, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Set, Has, Nothing<bool>(), i::HandleScope);
auto self = Utils::OpenHandle(this);
i::Handle<i::Object> result;
i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)};
......@@ -7425,7 +7471,8 @@ Maybe<bool> Set::Has(Local<Context> context, Local<Value> key) {
Maybe<bool> Set::Delete(Local<Context> context, Local<Value> key) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Set, Delete, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Set, Delete, Nothing<bool>(), i::HandleScope);
auto self = Utils::OpenHandle(this);
i::Handle<i::Object> result;
i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)};
......@@ -7497,7 +7544,9 @@ Local<Promise> Promise::Resolver::GetPromise() {
Maybe<bool> Promise::Resolver::Resolve(Local<Context> context,
Local<Value> value) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Promise_Resolver, Resolve, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Promise_Resolver, Resolve, Nothing<bool>(),
i::HandleScope);
auto self = Utils::OpenHandle(this);
i::Handle<i::Object> argv[] = {self, Utils::OpenHandle(*value)};
has_pending_exception =
......@@ -7518,7 +7567,9 @@ void Promise::Resolver::Resolve(Local<Value> value) {
Maybe<bool> Promise::Resolver::Reject(Local<Context> context,
Local<Value> value) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, Promise_Resolver, Resolve, bool);
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Promise_Resolver, Reject, Nothing<bool>(),
i::HandleScope);
auto self = Utils::OpenHandle(this);
// We pass true to trigger the debugger's on exception handler.
......
......@@ -633,14 +633,12 @@ class RuntimeCallTimer final {
V(Object_GetRealNamedPropertyAttributes) \
V(Object_GetRealNamedPropertyAttributesInPrototypeChain) \
V(Object_GetRealNamedPropertyInPrototypeChain) \
V(Object_Has) \
V(Object_HasOwnProperty) \
V(Object_HasRealIndexedProperty) \
V(Object_HasRealNamedCallbackProperty) \
V(Object_HasRealNamedProperty) \
V(Object_Int32Value) \
V(Object_IntegerValue) \
V(Object_New) \
V(Object_NumberValue) \
V(Object_ObjectProtoToString) \
V(Object_Set) \
V(Object_SetAccessor) \
......@@ -657,7 +655,6 @@ class RuntimeCallTimer final {
V(Object_ToObject) \
V(Object_ToString) \
V(Object_ToUint32) \
V(Object_Uint32Value) \
V(Persistent_New) \
V(Private_New) \
V(Promise_Catch) \
......@@ -665,6 +662,7 @@ class RuntimeCallTimer final {
V(Promise_HasRejectHandler) \
V(Promise_Resolver_New) \
V(Promise_Resolver_Resolve) \
V(Promise_Resolver_Reject) \
V(Promise_Result) \
V(Promise_Status) \
V(Promise_Then) \
......@@ -709,7 +707,11 @@ class RuntimeCallTimer final {
V(UnboundScript_GetSourceMappingURL) \
V(UnboundScript_GetSourceURL) \
V(Value_InstanceOf) \
V(Value_IntegerValue) \
V(Value_Int32Value) \
V(Value_NumberValue) \
V(Value_TypeOf) \
V(Value_Uint32Value) \
V(ValueDeserializer_ReadHeader) \
V(ValueDeserializer_ReadValue) \
V(ValueSerializer_WriteValue)
......
......@@ -63,6 +63,8 @@ std::unique_ptr<InjectedScript> InjectedScript::create(
v8::HandleScope handles(isolate);
v8::Local<v8::Context> context = inspectedContext->context();
v8::Context::Scope scope(context);
v8::MicrotasksScope microtasksScope(isolate,
v8::MicrotasksScope::kDoNotRunMicrotasks);
// Inject javascript into the context. The compiled script is supposed to
// evaluate into
......@@ -91,8 +93,6 @@ std::unique_ptr<InjectedScript> InjectedScript::create(
v8::Local<v8::Value> info[] = {
scriptHostWrapper, windowGlobal,
v8::Number::New(isolate, inspectedContext->contextId())};
v8::MicrotasksScope microtasksScope(isolate,
v8::MicrotasksScope::kDoNotRunMicrotasks);
int contextGroupId = inspectedContext->contextGroupId();
int contextId = inspectedContext->contextId();
......
......@@ -761,6 +761,8 @@ V8Console::CommandLineAPIScope::CommandLineAPIScope(
m_global(global),
m_installedMethods(v8::Set::New(context->GetIsolate())),
m_cleanup(false) {
v8::MicrotasksScope microtasksScope(context->GetIsolate(),
v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::Local<v8::Array> names;
if (!m_commandLineAPI->GetOwnPropertyNames(context).ToLocal(&names)) return;
v8::Local<v8::External> externalThis =
......@@ -786,6 +788,8 @@ V8Console::CommandLineAPIScope::CommandLineAPIScope(
}
V8Console::CommandLineAPIScope::~CommandLineAPIScope() {
v8::MicrotasksScope microtasksScope(m_context->GetIsolate(),
v8::MicrotasksScope::kDoNotRunMicrotasks);
m_cleanup = true;
v8::Local<v8::Array> names = m_installedMethods->AsArray();
for (uint32_t i = 0; i < names->Length(); ++i) {
......
......@@ -464,6 +464,8 @@ Response V8DebuggerAgentImpl::getPossibleBreakpoints(
v8::Local<v8::Context> debuggerContext =
v8::debug::GetDebugContext(m_isolate);
v8::Context::Scope contextScope(debuggerContext);
v8::MicrotasksScope microtasks(m_isolate,
v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::TryCatch tryCatch(m_isolate);
it->second->getPossibleBreakpoints(
v8Start, v8End, restrictToFunction.fromMaybe(false), &v8Locations);
......@@ -930,6 +932,8 @@ Response V8DebuggerAgentImpl::currentCallFrames(
v8::Local<v8::Context> debuggerContext =
v8::debug::GetDebugContext(m_isolate);
v8::Context::Scope contextScope(debuggerContext);
v8::MicrotasksScope microtasks(m_isolate,
v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::Local<v8::Array> objects = v8::Array::New(m_isolate);
......
......@@ -229,6 +229,8 @@ String16 V8Debugger::setBreakpoint(const ScriptBreakpoint& breakpoint,
v8::HandleScope scope(m_isolate);
v8::Local<v8::Context> context = debuggerContext();
v8::Context::Scope contextScope(context);
v8::MicrotasksScope microtasks(m_isolate,
v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::Local<v8::Object> info = v8::Object::New(m_isolate);
bool success = false;
......@@ -276,6 +278,8 @@ void V8Debugger::removeBreakpoint(const String16& breakpointId) {
v8::HandleScope scope(m_isolate);
v8::Local<v8::Context> context = debuggerContext();
v8::Context::Scope contextScope(context);
v8::MicrotasksScope microtasks(m_isolate,
v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::Local<v8::Object> info = v8::Object::New(m_isolate);
bool success = false;
......
......@@ -465,6 +465,8 @@ Response V8RuntimeAgentImpl::getProperties(
if (!response.isSuccess()) return response;
scope.ignoreExceptionsAndMuteConsole();
v8::MicrotasksScope microtasks_scope(m_inspector->isolate(),
v8::MicrotasksScope::kRunMicrotasks);
if (!scope.object()->IsObject())
return Response::Error("Value with given id is not an object");
......
......@@ -24156,6 +24156,7 @@ TEST(Promises) {
TEST(PromiseThen) {
LocalContext context;
v8::Isolate* isolate = context->GetIsolate();
isolate->SetMicrotasksPolicy(v8::MicrotasksPolicy::kExplicit);
v8::HandleScope scope(isolate);
Local<Object> global = context->Global();
......
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