Commit 9c1933ca authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Use V8 RegExp::Exec directly.

A new API was exposed to call regexp exec directly instead of having to
go through a js call function so use it.

BUG=966405

Change-Id: I6e6defcdd1a2c7bded6c1a295d10885151635bad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1913467Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714923}
parent bcea1458
...@@ -88,16 +88,10 @@ int ScriptRegexp::Match(const String& string, ...@@ -88,16 +88,10 @@ int ScriptRegexp::Match(const String& string,
v8::TryCatch try_catch(isolate); v8::TryCatch try_catch(isolate);
v8::Local<v8::RegExp> regex = regex_.NewLocal(isolate); v8::Local<v8::RegExp> regex = regex_.NewLocal(isolate);
v8::Local<v8::Value> exec; v8::Local<v8::String> subject =
if (!regex->Get(context, V8AtomicString(isolate, "exec")).ToLocal(&exec)) V8String(isolate, string.Substring(start_from));
return -1;
v8::Local<v8::Value> argv[] = {
V8String(isolate, string.Substring(start_from))};
v8::Local<v8::Value> return_value; v8::Local<v8::Value> return_value;
if (!V8ScriptRunner::CallInternalFunction(isolate, nullptr, if (!regex->Exec(context, subject).ToLocal(&return_value))
exec.As<v8::Function>(), regex,
base::size(argv), argv)
.ToLocal(&return_value))
return -1; return -1;
// RegExp#exec returns null if there's no match, otherwise it returns an // RegExp#exec returns null if there's no match, otherwise it returns an
......
...@@ -478,26 +478,6 @@ v8::MaybeLocal<v8::Value> V8ScriptRunner::CallFunction( ...@@ -478,26 +478,6 @@ v8::MaybeLocal<v8::Value> V8ScriptRunner::CallFunction(
return result; return result;
} }
v8::MaybeLocal<v8::Value> V8ScriptRunner::CallInternalFunction(
v8::Isolate* isolate,
v8::MicrotaskQueue* microtask_queue,
v8::Local<v8::Function> function,
v8::Local<v8::Value> receiver,
int argc,
v8::Local<v8::Value> args[]) {
TRACE_EVENT0("v8", "v8.callFunction");
RuntimeCallStatsScopedTracer rcs_scoped_tracer(isolate);
RUNTIME_CALL_TIMER_SCOPE(isolate, RuntimeCallStats::CounterId::kV8);
v8::Isolate::SafeForTerminationScope safe_for_termination(isolate);
v8::MicrotasksScope microtasks_scope(
isolate, microtask_queue, v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::MaybeLocal<v8::Value> result =
function->Call(isolate->GetCurrentContext(), receiver, argc, args);
CHECK(!isolate->IsDead());
return result;
}
v8::MaybeLocal<v8::Value> V8ScriptRunner::EvaluateModule( v8::MaybeLocal<v8::Value> V8ScriptRunner::EvaluateModule(
v8::Isolate* isolate, v8::Isolate* isolate,
ExecutionContext* execution_context, ExecutionContext* execution_context,
......
...@@ -79,13 +79,6 @@ class CORE_EXPORT V8ScriptRunner final { ...@@ -79,13 +79,6 @@ class CORE_EXPORT V8ScriptRunner final {
ExecutionContext*, ExecutionContext*,
int argc = 0, int argc = 0,
v8::Local<v8::Value> argv[] = nullptr); v8::Local<v8::Value> argv[] = nullptr);
static v8::MaybeLocal<v8::Value> CallInternalFunction(
v8::Isolate*,
v8::MicrotaskQueue*,
v8::Local<v8::Function>,
v8::Local<v8::Value> receiver,
int argc,
v8::Local<v8::Value> info[]);
static v8::MaybeLocal<v8::Value> CallFunction(v8::Local<v8::Function>, static v8::MaybeLocal<v8::Value> CallFunction(v8::Local<v8::Function>,
ExecutionContext*, ExecutionContext*,
v8::Local<v8::Value> receiver, v8::Local<v8::Value> receiver,
......
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