Commit 6f1de288 authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[regexp] Add use counters for slow exec and replace calls

These counters track how often the slow path of these two builtins is
hit. Exec is very permissive, its fast-path check doesn't look at the
regexp prototype at all. Replace is strict; any change on the
prototype will trigger the slow path.

Chromium CL: https://crrev.com/c/1875250

Bug: v8:5577
Change-Id: I9807f43829981445b75b5c5d29800cbdac9bc26a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1873698Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64496}
parent 4f52630b
......@@ -8141,6 +8141,8 @@ class V8_EXPORT Isolate {
kCallSiteAPIGetFunctionSloppyCall = 76,
kCallSiteAPIGetThisSloppyCall = 77,
kRegExpMatchAllWithNonGlobalRegExp = 78,
kRegExpExecCalledOnSlowRegExp = 79,
kRegExpReplaceCalledOnSlowRegExp = 80,
// If you add new values here, you'll also need to update Chromium's:
// web_feature.mojom, use_counter_callback.cc, and enums.xml. V8 changes to
......
......@@ -701,6 +701,8 @@ RegExpBuiltinsAssembler::RegExpPrototypeExecBodyWithoutResult(
TNode<Context> context, TNode<JSReceiver> maybe_regexp,
TNode<String> string, const bool is_fastpath, Label* if_didnotmatch) {
if (!is_fastpath) {
CallRuntime(Runtime::kIncrementUseCounter, context,
SmiConstant(v8::Isolate::kRegExpExecCalledOnSlowRegExp));
ThrowIfNotInstanceType(context, maybe_regexp, JS_REG_EXP_TYPE,
"RegExp.prototype.exec");
}
......
......@@ -211,6 +211,9 @@ namespace regexp {
}
}
const kRegExpReplaceCalledOnSlowRegExp: constexpr int31
generates 'v8::Isolate::kRegExpReplaceCalledOnSlowRegExp';
transitioning javascript builtin RegExpPrototypeReplace(
js-implicit context: Context, receiver: JSAny)(...arguments): JSAny {
const methodName: constexpr string = 'RegExp.prototype.@@replace';
......@@ -250,6 +253,8 @@ namespace regexp {
return RegExpReplace(fastRx, s, replaceValue);
}
label Runtime deferred {
IncrementUseCounter(
context, SmiConstant(kRegExpReplaceCalledOnSlowRegExp));
return RegExpReplaceRT(context, rx, s, replaceValue);
}
}
......
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