RegExp.test fastpath not taken by default |
||
Issue descriptionChrome Version: https://chromium.googlesource.com/v8/v8.git/+/a8a05aff3c678a9566519c876bf3299b5b8c08af%5E%21/ OS: any The commit above introduced a bug in the regexp.test fast path handling. I.e. the following javascript triggers a CSA_ASSERT: ``` function foo() { let r = /asdf/; r.exec = console.log; return r.test('asdf'); } try {foo();} catch {} %OptimizeFunctionOnNextCall(foo); foo(); ``` v8/out/x64.debug/d8 --allow-natives-syntax test.js abort: CSA_ASSERT failed: IsFastRegExpWithOriginalExec(context, regexp) [../../src/builtins/builtins-regexp-gen.cc:1774] It's supposed to take the fast path if exec is a DataConstant and it's pointing to RegExp.prototype.regex. However, the code is checking that it's _not_ pointing to RegExp.prototype.regex by accident: + if (ai_exec.IsDataConstant()) { + if (ai_exec.constant().is_identical_to(isolate()->regexp_exec_function())) { + return NoChange(); + } + } [...] do_fastpath(); So in the common case, the fastpath is never taken. To fix, add a logical not to the check: - if (ai_exec.constant().is_identical_to(isolate()->regexp_exec_function())) { + if (!ai_exec.constant().is_identical_to(isolate()->regexp_exec_function())) {
,
Nov 20
,
Nov 20
|
||
►
Sign in to add a comment |
||
Comment 1 by bmeu...@chromium.org
, Nov 20Status: Assigned (was: Untriaged)