Commit ffbda136 authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[Cleanup] Avoid using deprecated v8::Function::Call in v8_script_runner.

BUG=v8:7290,v8:8238

Change-Id: Icb327a0da2bb9abd4b3fa058ce922f96ed7782a0
Reviewed-on: https://chromium-review.googlesource.com/c/1349267Reviewed-by: default avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610610}
parent 9703d737
...@@ -69,7 +69,8 @@ void ThrowScriptForbiddenException(v8::Isolate* isolate) { ...@@ -69,7 +69,8 @@ void ThrowScriptForbiddenException(v8::Isolate* isolate) {
V8ThrowException::ThrowError(isolate, "Script execution is forbidden."); V8ThrowException::ThrowError(isolate, "Script execution is forbidden.");
} }
v8::Local<v8::Value> ThrowStackOverflowExceptionIfNeeded(v8::Isolate* isolate) { v8::MaybeLocal<v8::Value> ThrowStackOverflowExceptionIfNeeded(
v8::Isolate* isolate) {
if (V8PerIsolateData::From(isolate)->IsHandlingRecursionLevelError()) { if (V8PerIsolateData::From(isolate)->IsHandlingRecursionLevelError()) {
// If we are already handling a recursion level error, we should // If we are already handling a recursion level error, we should
// not invoke v8::Function::Call. // not invoke v8::Function::Call.
...@@ -80,12 +81,13 @@ v8::Local<v8::Value> ThrowStackOverflowExceptionIfNeeded(v8::Isolate* isolate) { ...@@ -80,12 +81,13 @@ v8::Local<v8::Value> ThrowStackOverflowExceptionIfNeeded(v8::Isolate* isolate) {
V8PerIsolateData::From(isolate)->SetIsHandlingRecursionLevelError(true); V8PerIsolateData::From(isolate)->SetIsHandlingRecursionLevelError(true);
ScriptForbiddenScope::AllowUserAgentScript allow_script; ScriptForbiddenScope::AllowUserAgentScript allow_script;
v8::Local<v8::Value> result = v8::Local<v8::Context> context = isolate->GetCurrentContext();
v8::Function::New(isolate->GetCurrentContext(), v8::MaybeLocal<v8::Value> result =
ThrowStackOverflowException, v8::Local<v8::Value>(), 0, v8::Function::New(context, ThrowStackOverflowException,
v8::Local<v8::Value>(), 0,
v8::ConstructorBehavior::kThrow) v8::ConstructorBehavior::kThrow)
.ToLocalChecked() .ToLocalChecked()
->Call(v8::Undefined(isolate), 0, nullptr); ->Call(context, v8::Undefined(isolate), 0, nullptr);
V8PerIsolateData::From(isolate)->SetIsHandlingRecursionLevelError(false); V8PerIsolateData::From(isolate)->SetIsHandlingRecursionLevelError(false);
return result; return result;
...@@ -342,8 +344,7 @@ v8::MaybeLocal<v8::Value> V8ScriptRunner::CallAsConstructor( ...@@ -342,8 +344,7 @@ v8::MaybeLocal<v8::Value> V8ScriptRunner::CallAsConstructor(
int depth = v8::MicrotasksScope::GetCurrentDepth(isolate); int depth = v8::MicrotasksScope::GetCurrentDepth(isolate);
if (depth >= kMaxRecursionDepth) if (depth >= kMaxRecursionDepth)
return v8::MaybeLocal<v8::Value>( return ThrowStackOverflowExceptionIfNeeded(isolate);
ThrowStackOverflowExceptionIfNeeded(isolate));
CHECK(!context->IsIteratingOverObservers()); CHECK(!context->IsIteratingOverObservers());
...@@ -385,8 +386,7 @@ v8::MaybeLocal<v8::Value> V8ScriptRunner::CallFunction( ...@@ -385,8 +386,7 @@ v8::MaybeLocal<v8::Value> V8ScriptRunner::CallFunction(
int depth = v8::MicrotasksScope::GetCurrentDepth(isolate); int depth = v8::MicrotasksScope::GetCurrentDepth(isolate);
if (depth >= kMaxRecursionDepth) if (depth >= kMaxRecursionDepth)
return v8::MaybeLocal<v8::Value>( return ThrowStackOverflowExceptionIfNeeded(isolate);
ThrowStackOverflowExceptionIfNeeded(isolate));
CHECK(!context->IsIteratingOverObservers()); CHECK(!context->IsIteratingOverObservers());
......
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