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
This diff is collapsed.
......@@ -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