Commit d41fe9f5 authored by Jochen Eisinger's avatar Jochen Eisinger Committed by Commit Bot

Replace PREPARE_FOR_EXECUTION_WITH_CONTEXT_IN_RUNTIME_CALL_STATS_SCOPE

Use the appropriate ENTER_V8* macros instead

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

Change-Id: I85d7ae69830f6bad4f7057c4a646906846a1baa0
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Reviewed-on: https://chromium-review.googlesource.com/517793
Commit-Queue: Jochen Eisinger <jochen@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@{#45612}
parent 8a0d687b
...@@ -137,16 +137,6 @@ namespace v8 { ...@@ -137,16 +137,6 @@ namespace v8 {
ENTER_V8_HELPER_DO_NOT_USE(isolate, context, class_name, function_name, \ ENTER_V8_HELPER_DO_NOT_USE(isolate, context, class_name, function_name, \
bailout_value, HandleScopeClass, do_callback); bailout_value, HandleScopeClass, do_callback);
#define PREPARE_FOR_EXECUTION_WITH_CONTEXT_IN_RUNTIME_CALL_STATS_SCOPE( \
category, name, context, class_name, function_name, bailout_value, \
HandleScopeClass, do_callback) \
auto isolate = context.IsEmpty() \
? i::Isolate::Current() \
: reinterpret_cast<i::Isolate*>(context->GetIsolate()); \
TRACE_EVENT_CALL_STATS_SCOPED(isolate, category, name); \
ENTER_V8_HELPER_DO_NOT_USE(isolate, context, class_name, function_name, \
bailout_value, HandleScopeClass, do_callback);
#define PREPARE_FOR_EXECUTION(context, class_name, function_name, T) \ #define PREPARE_FOR_EXECUTION(context, class_name, function_name, T) \
PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, class_name, function_name, \ PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, class_name, function_name, \
MaybeLocal<T>(), InternalEscapableScope, \ MaybeLocal<T>(), InternalEscapableScope, \
...@@ -2051,9 +2041,10 @@ Local<Value> UnboundScript::GetSourceMappingURL() { ...@@ -2051,9 +2041,10 @@ Local<Value> UnboundScript::GetSourceMappingURL() {
MaybeLocal<Value> Script::Run(Local<Context> context) { MaybeLocal<Value> Script::Run(Local<Context> context) {
PREPARE_FOR_EXECUTION_WITH_CONTEXT_IN_RUNTIME_CALL_STATS_SCOPE( auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
"v8", "V8.Execute", context, Script, Run, MaybeLocal<Value>(), TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.Execute");
InternalEscapableScope, true); ENTER_V8(isolate, context, Script, Run, MaybeLocal<Value>(),
InternalEscapableScope);
i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true); i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true);
i::AggregatingHistogramTimerScope timer(isolate->counters()->compile_lazy()); i::AggregatingHistogramTimerScope timer(isolate->counters()->compile_lazy());
i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate);
...@@ -2152,9 +2143,10 @@ Maybe<bool> Module::InstantiateModule(Local<Context> context, ...@@ -2152,9 +2143,10 @@ Maybe<bool> Module::InstantiateModule(Local<Context> context,
} }
MaybeLocal<Value> Module::Evaluate(Local<Context> context) { MaybeLocal<Value> Module::Evaluate(Local<Context> context) {
PREPARE_FOR_EXECUTION_WITH_CONTEXT_IN_RUNTIME_CALL_STATS_SCOPE( auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
"v8", "V8.Execute", context, Module, Evaluate, MaybeLocal<Value>(), TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.Execute");
InternalEscapableScope, true); ENTER_V8(isolate, context, Module, Evaluate, MaybeLocal<Value>(),
InternalEscapableScope);
i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true); i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true);
i::AggregatingHistogramTimerScope timer(isolate->counters()->compile_lazy()); i::AggregatingHistogramTimerScope timer(isolate->counters()->compile_lazy());
i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate);
...@@ -2171,10 +2163,11 @@ MaybeLocal<Value> Module::Evaluate(Local<Context> context) { ...@@ -2171,10 +2163,11 @@ MaybeLocal<Value> Module::Evaluate(Local<Context> context) {
MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundInternal( MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundInternal(
Isolate* v8_isolate, Source* source, CompileOptions options) { Isolate* v8_isolate, Source* source, CompileOptions options) {
PREPARE_FOR_EXECUTION_WITH_CONTEXT_IN_RUNTIME_CALL_STATS_SCOPE( auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
"v8", "V8.ScriptCompiler", v8_isolate->GetCurrentContext(), TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.ScriptCompiler");
ScriptCompiler, CompileUnbound, MaybeLocal<UnboundScript>(), ENTER_V8_NO_SCRIPT(isolate, v8_isolate->GetCurrentContext(), ScriptCompiler,
InternalEscapableScope, false); CompileUnbound, MaybeLocal<UnboundScript>(),
InternalEscapableScope);
// Don't try to produce any kind of cache when the debugger is loaded. // Don't try to produce any kind of cache when the debugger is loaded.
if (isolate->debug()->is_loaded() && if (isolate->debug()->is_loaded() &&
...@@ -5141,9 +5134,10 @@ bool v8::Object::IsConstructor() { ...@@ -5141,9 +5134,10 @@ bool v8::Object::IsConstructor() {
MaybeLocal<Value> Object::CallAsFunction(Local<Context> context, MaybeLocal<Value> Object::CallAsFunction(Local<Context> context,
Local<Value> recv, int argc, Local<Value> recv, int argc,
Local<Value> argv[]) { Local<Value> argv[]) {
PREPARE_FOR_EXECUTION_WITH_CONTEXT_IN_RUNTIME_CALL_STATS_SCOPE( auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
"v8", "V8.Execute", context, Object, CallAsFunction, MaybeLocal<Value>(), TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.Execute");
InternalEscapableScope, true); ENTER_V8(isolate, context, Object, CallAsFunction, MaybeLocal<Value>(),
InternalEscapableScope);
i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate);
auto self = Utils::OpenHandle(this); auto self = Utils::OpenHandle(this);
auto recv_obj = Utils::OpenHandle(*recv); auto recv_obj = Utils::OpenHandle(*recv);
...@@ -5168,9 +5162,10 @@ Local<v8::Value> Object::CallAsFunction(v8::Local<v8::Value> recv, int argc, ...@@ -5168,9 +5162,10 @@ Local<v8::Value> Object::CallAsFunction(v8::Local<v8::Value> recv, int argc,
MaybeLocal<Value> Object::CallAsConstructor(Local<Context> context, int argc, MaybeLocal<Value> Object::CallAsConstructor(Local<Context> context, int argc,
Local<Value> argv[]) { Local<Value> argv[]) {
PREPARE_FOR_EXECUTION_WITH_CONTEXT_IN_RUNTIME_CALL_STATS_SCOPE( auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
"v8", "V8.Execute", context, Object, CallAsConstructor, TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.Execute");
MaybeLocal<Value>(), InternalEscapableScope, true); ENTER_V8(isolate, context, Object, CallAsConstructor, MaybeLocal<Value>(),
InternalEscapableScope);
i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate);
auto self = Utils::OpenHandle(this); auto self = Utils::OpenHandle(this);
STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**));
...@@ -5219,9 +5214,10 @@ Local<v8::Object> Function::NewInstance() const { ...@@ -5219,9 +5214,10 @@ Local<v8::Object> Function::NewInstance() const {
MaybeLocal<Object> Function::NewInstance(Local<Context> context, int argc, MaybeLocal<Object> Function::NewInstance(Local<Context> context, int argc,
v8::Local<v8::Value> argv[]) const { v8::Local<v8::Value> argv[]) const {
PREPARE_FOR_EXECUTION_WITH_CONTEXT_IN_RUNTIME_CALL_STATS_SCOPE( auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
"v8", "V8.Execute", context, Function, NewInstance, MaybeLocal<Object>(), TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.Execute");
InternalEscapableScope, true); ENTER_V8(isolate, context, Function, NewInstance, MaybeLocal<Object>(),
InternalEscapableScope);
i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate);
auto self = Utils::OpenHandle(this); auto self = Utils::OpenHandle(this);
STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**));
...@@ -5244,9 +5240,10 @@ Local<v8::Object> Function::NewInstance(int argc, ...@@ -5244,9 +5240,10 @@ Local<v8::Object> Function::NewInstance(int argc,
MaybeLocal<v8::Value> Function::Call(Local<Context> context, MaybeLocal<v8::Value> Function::Call(Local<Context> context,
v8::Local<v8::Value> recv, int argc, v8::Local<v8::Value> recv, int argc,
v8::Local<v8::Value> argv[]) { v8::Local<v8::Value> argv[]) {
PREPARE_FOR_EXECUTION_WITH_CONTEXT_IN_RUNTIME_CALL_STATS_SCOPE( auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
"v8", "V8.Execute", context, Function, Call, MaybeLocal<Value>(), TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.Execute");
InternalEscapableScope, true); ENTER_V8(isolate, context, Function, Call, MaybeLocal<Value>(),
InternalEscapableScope);
i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate);
auto self = Utils::OpenHandle(this); auto self = Utils::OpenHandle(this);
i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv);
......
...@@ -2128,6 +2128,7 @@ class InspectorFrontend final : public v8_inspector::V8Inspector::Channel { ...@@ -2128,6 +2128,7 @@ class InspectorFrontend final : public v8_inspector::V8Inspector::Channel {
void flushProtocolNotifications() override {} void flushProtocolNotifications() override {}
void Send(const v8_inspector::StringView& string) { void Send(const v8_inspector::StringView& string) {
v8::Isolate::AllowJavascriptExecutionScope allow_script(isolate_);
int length = static_cast<int>(string.length()); int length = static_cast<int>(string.length());
DCHECK(length < v8::String::kMaxLength); DCHECK(length < v8::String::kMaxLength);
Local<String> message = Local<String> message =
......
...@@ -633,6 +633,7 @@ bool Debug::IsMutedAtCurrentLocation(JavaScriptFrame* frame) { ...@@ -633,6 +633,7 @@ bool Debug::IsMutedAtCurrentLocation(JavaScriptFrame* frame) {
MaybeHandle<Object> Debug::CallFunction(const char* name, int argc, MaybeHandle<Object> Debug::CallFunction(const char* name, int argc,
Handle<Object> args[]) { Handle<Object> args[]) {
AllowJavascriptExecutionDebugOnly allow_script(isolate_);
PostponeInterruptsScope no_interrupts(isolate_); PostponeInterruptsScope no_interrupts(isolate_);
AssertDebugContext(); AssertDebugContext();
Handle<JSReceiver> holder = Handle<JSReceiver> holder =
...@@ -2103,6 +2104,7 @@ void Debug::UpdateHookOnFunctionCall() { ...@@ -2103,6 +2104,7 @@ void Debug::UpdateHookOnFunctionCall() {
} }
MaybeHandle<Object> Debug::Call(Handle<Object> fun, Handle<Object> data) { MaybeHandle<Object> Debug::Call(Handle<Object> fun, Handle<Object> data) {
AllowJavascriptExecutionDebugOnly allow_script(isolate_);
DebugScope debug_scope(this); DebugScope debug_scope(this);
if (debug_scope.failed()) return isolate_->factory()->undefined_value(); if (debug_scope.failed()) return isolate_->factory()->undefined_value();
...@@ -2373,6 +2375,7 @@ JavaScriptDebugDelegate::~JavaScriptDebugDelegate() { ...@@ -2373,6 +2375,7 @@ JavaScriptDebugDelegate::~JavaScriptDebugDelegate() {
void JavaScriptDebugDelegate::ProcessDebugEvent(v8::DebugEvent event, void JavaScriptDebugDelegate::ProcessDebugEvent(v8::DebugEvent event,
Handle<JSObject> event_data, Handle<JSObject> event_data,
Handle<JSObject> exec_state) { Handle<JSObject> exec_state) {
AllowJavascriptExecutionDebugOnly allow_script(isolate_);
Handle<Object> argv[] = {Handle<Object>(Smi::FromInt(event), isolate_), Handle<Object> argv[] = {Handle<Object>(Smi::FromInt(event), isolate_),
exec_state, event_data, data_}; exec_state, event_data, data_};
Handle<JSReceiver> global = isolate_->global_proxy(); Handle<JSReceiver> global = isolate_->global_proxy();
......
...@@ -99,6 +99,7 @@ v8::Local<v8::Value> V8FunctionCall::callWithoutExceptionHandling() { ...@@ -99,6 +99,7 @@ v8::Local<v8::Value> V8FunctionCall::callWithoutExceptionHandling() {
} }
v8::MicrotasksScope microtasksScope(m_context->GetIsolate(), v8::MicrotasksScope microtasksScope(m_context->GetIsolate(),
v8::MicrotasksScope::kDoNotRunMicrotasks); v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::Isolate::AllowJavascriptExecutionScope(m_context->GetIsolate());
v8::MaybeLocal<v8::Value> maybeResult = function->Call( v8::MaybeLocal<v8::Value> maybeResult = function->Call(
m_context, thisObject, static_cast<int>(m_arguments.size()), info.get()); m_context, thisObject, static_cast<int>(m_arguments.size()), info.get());
if (contextGroupId) { if (contextGroupId) {
......
...@@ -1741,6 +1741,9 @@ bool Isolate::IsExternalHandlerOnTop(Object* exception) { ...@@ -1741,6 +1741,9 @@ bool Isolate::IsExternalHandlerOnTop(Object* exception) {
void Isolate::ReportPendingMessages() { void Isolate::ReportPendingMessages() {
DCHECK(AllowExceptions::IsAllowed(this)); DCHECK(AllowExceptions::IsAllowed(this));
// The embedder might run script in response to an exception.
AllowJavascriptExecutionDebugOnly allow_script(this);
Object* exception = pending_exception(); Object* exception = pending_exception();
// Try to propagate the exception to an external v8::TryCatch handler. If // Try to propagate the exception to an external v8::TryCatch handler. If
......
...@@ -611,6 +611,7 @@ static void DebugEventCounterClear() { ...@@ -611,6 +611,7 @@ static void DebugEventCounterClear() {
static void DebugEventCounter( static void DebugEventCounter(
const v8::Debug::EventDetails& event_details) { const v8::Debug::EventDetails& event_details) {
v8::Isolate::AllowJavascriptExecutionScope allow_script(CcTest::isolate());
v8::DebugEvent event = event_details.GetEvent(); v8::DebugEvent event = event_details.GetEvent();
v8::Local<v8::Object> exec_state = event_details.GetExecutionState(); v8::Local<v8::Object> exec_state = event_details.GetExecutionState();
v8::Local<v8::Object> event_data = event_details.GetEventData(); v8::Local<v8::Object> event_data = event_details.GetEventData();
...@@ -6372,6 +6373,7 @@ static void NoInterruptsOnDebugEvent( ...@@ -6372,6 +6373,7 @@ static void NoInterruptsOnDebugEvent(
// Do not allow nested AfterCompile events. // Do not allow nested AfterCompile events.
CHECK(after_compile_handler_depth <= 1); CHECK(after_compile_handler_depth <= 1);
v8::Isolate* isolate = event_details.GetEventContext()->GetIsolate(); v8::Isolate* isolate = event_details.GetEventContext()->GetIsolate();
v8::Isolate::AllowJavascriptExecutionScope allow_script(isolate);
isolate->RequestInterrupt(&HandleInterrupt, nullptr); isolate->RequestInterrupt(&HandleInterrupt, nullptr);
CompileRun("function foo() {}; foo();"); CompileRun("function foo() {}; foo();");
--after_compile_handler_depth; --after_compile_handler_depth;
......
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