|
|
Description[regexp] Add fast-path for global, callable replace
This adds a fast-path for calls to RegExp.prototype[@@replace] for cases in
which the given regexp is unmodified and global, and the given replace argument
is callable.
The fast-path implementation itself is almost identical to the original JS
implementation except that it currently does not reuse result_array.
SunSpider/unpack-code relies heavily on this codepath.
BUG=v8:5339
Committed: https://crrev.com/a8e30c0e689a68a8d5d457be28eec1fb5b7a3702
Cr-Commit-Position: refs/heads/master@{#40504}
Patch Set 1 #Patch Set 2 : Fix double-tagged smi and remove asserts #Patch Set 3 : Re-add asserts and COW array usage #
Total comments: 7
Patch Set 4 : Remove callable path from RegExpReplace #Patch Set 5 : Rebase on map-based checks #Patch Set 6 : Unmark coerce-* tests as failing #Patch Set 7 : Rebase #
Depends on Patchset: Messages
Total messages: 44 (33 generated)
The CQ bit was checked by jgruber@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
jgruber@chromium.org changed reviewers: + yangguo@chromium.org
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: v8_linux64_gyp_rel_ng on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux64_gyp_rel_ng/build...)
The CQ bit was checked by jgruber@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: v8_linux64_gyp_rel_ng on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux64_gyp_rel_ng/build...)
The CQ bit was checked by jgruber@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Some comments mainly for myself, but I'd also appreciate input. Much of this would be better off in a follow-up commit. https://chromiumcodereview.appspot.com/2433923003/diff/40001/src/runtime/runt... File src/runtime/runtime-regexp.cc (right): https://chromiumcodereview.appspot.com/2433923003/diff/40001/src/runtime/runt... src/runtime/runtime-regexp.cc:1004: // The cache FixedArray is a COW-array and we need to return a copy. It might not make sense anymore for the result cache to store COW arrays, now that our implementation operates directly on fixed arrays (which ignores any COW logic). In principle, we could also move away from JSArray wrappers, but in this case the StringBuilderConcat runtime function still expects a JSArray. Maybe operate on FixedArrays here and wrap it in a JSArray shortly before the call to SBC? https://chromiumcodereview.appspot.com/2433923003/diff/40001/src/runtime/runt... src/runtime/runtime-regexp.cc:1279: DCHECK(!global); // Handled as fast path. The entire functional_replace branch should be removed since it is dispatched directly from the TF impl. We should also use the same map-based fast-path checks from C++ as in TF. For replace, we could even dispatch all 'fast' paths (in the sense of unmodified JSRegExp instances) from TF and only keep the slow path in Runtime_RegExpReplace. https://chromiumcodereview.appspot.com/2433923003/diff/40001/src/runtime/runt... src/runtime/runtime-regexp.cc:1299: CONVERT_ARG_HANDLE_CHECKED(JSArray, result_array, 3); Reusing the result array does not seem to make any runtime difference for ss/unpack-code. We could probably remove the result_array arg entirely and just create it as needed in SearchRegExpMultiple.
lgtm https://codereview.chromium.org/2433923003/diff/40001/src/runtime/runtime-reg... File src/runtime/runtime-regexp.cc (right): https://codereview.chromium.org/2433923003/diff/40001/src/runtime/runtime-reg... src/runtime/runtime-regexp.cc:1004: // The cache FixedArray is a COW-array and we need to return a copy. On 2016/10/19 16:39:13, jgruber wrote: > It might not make sense anymore for the result cache to store COW arrays, now > that our implementation operates directly on fixed arrays (which ignores any COW > logic). > > In principle, we could also move away from JSArray wrappers, but in this case > the StringBuilderConcat runtime function still expects a JSArray. Maybe operate > on FixedArrays here and wrap it in a JSArray shortly before the call to SBC? I'd simply introduce a version of SBC that only takes FixedArrays. Maybe we can avoid modifying the FixedArray altogether, so that we don't need to make a copy for caching. Iirc we modify the FixedArray because we call the function and replace elements by the return values. That whole FixedArray is then passed to SBC. Maybe we could have RegExpMultiple return a FixedArray for the regexp results, which is cacheable. Return values of calling the functions is collected in a second FixedArray, and SBC can then merge both to the final result. Does that make sense? https://codereview.chromium.org/2433923003/diff/40001/src/runtime/runtime-reg... src/runtime/runtime-regexp.cc:1299: CONVERT_ARG_HANDLE_CHECKED(JSArray, result_array, 3); On 2016/10/19 16:39:13, jgruber wrote: > Reusing the result array does not seem to make any runtime difference for > ss/unpack-code. We could probably remove the result_array arg entirely and just > create it as needed in SearchRegExpMultiple. I wonder whether we need a JSArray for this at all. Can't we just return a FixedArray directly?
The CQ bit was checked by jgruber@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Thanks for the review! https://codereview.chromium.org/2433923003/diff/40001/src/runtime/runtime-reg... File src/runtime/runtime-regexp.cc (right): https://codereview.chromium.org/2433923003/diff/40001/src/runtime/runtime-reg... src/runtime/runtime-regexp.cc:1004: // The cache FixedArray is a COW-array and we need to return a copy. On 2016/10/20 09:53:14, Yang wrote: > On 2016/10/19 16:39:13, jgruber wrote: > > It might not make sense anymore for the result cache to store COW arrays, now > > that our implementation operates directly on fixed arrays (which ignores any > COW > > logic). > > > > In principle, we could also move away from JSArray wrappers, but in this case > > the StringBuilderConcat runtime function still expects a JSArray. Maybe > operate > > on FixedArrays here and wrap it in a JSArray shortly before the call to SBC? > > > I'd simply introduce a version of SBC that only takes FixedArrays. > > Maybe we can avoid modifying the FixedArray altogether, so that we don't need to > make a copy for caching. Iirc we modify the FixedArray because we call the > function and replace elements by the return values. That whole FixedArray is > then passed to SBC. > > Maybe we could have RegExpMultiple return a FixedArray for the regexp results, > which is cacheable. Return values of calling the functions is collected in a > second FixedArray, and SBC can then merge both to the final result. Does that > make sense? That would work, I'm just not sure what we would gain. We still need to create an array of the same size (initialized with holes so O(n)), and then do one write per function result. The same amount of work as now, but added complexity because of a new SBC that can handle merging. What about we: * Move RegExpExecMultiple to take and return FixedArrays. * Remove the result_array arg and alloc in REExecMultiple as needed. * Always return copies of the cached FixedArrays. * Wrap the FixedArray in a JSArray just before the call to SBC. If we need to optimize, we still have the option of adding a new SBC that takes FixedArrays. https://codereview.chromium.org/2433923003/diff/40001/src/runtime/runtime-reg... src/runtime/runtime-regexp.cc:1299: CONVERT_ARG_HANDLE_CHECKED(JSArray, result_array, 3); On 2016/10/20 09:53:14, Yang wrote: > On 2016/10/19 16:39:13, jgruber wrote: > > Reusing the result array does not seem to make any runtime difference for > > ss/unpack-code. We could probably remove the result_array arg entirely and > just > > create it as needed in SearchRegExpMultiple. > > I wonder whether we need a JSArray for this at all. Can't we just return a > FixedArray directly? Sure. I kept the JSArray return type for now because of the interaction with StringBuilderConcat. This is something worth looking at in a follow-up though.
The CQ bit was unchecked by jgruber@chromium.org
The CQ bit was checked by jgruber@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from yangguo@chromium.org Link to the patchset: https://codereview.chromium.org/2433923003/#ps60001 (title: "Remove callable path from RegExpReplace")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: v8_presubmit on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_presubmit/builds/26942)
jgruber@chromium.org changed reviewers: + bmeurer@chromium.org
+ bmeurer for compiler/
lgtm
The CQ bit was checked by jgruber@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: v8_linux64_asan_rel_ng on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux64_asan_rel_ng/buil...)
The CQ bit was checked by jgruber@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by jgruber@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by jgruber@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from bmeurer@chromium.org, yangguo@chromium.org Link to the patchset: https://codereview.chromium.org/2433923003/#ps120001 (title: "Rebase")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Committed patchset #7 (id:120001)
Message was sent while issue was closed.
Description was changed from ========== [regexp] Add fast-path for global, callable replace This adds a fast-path for calls to RegExp.prototype[@@replace] for cases in which the given regexp is unmodified and global, and the given replace argument is callable. The fast-path implementation itself is almost identical to the original JS implementation except that it currently does not reuse result_array. SunSpider/unpack-code relies heavily on this codepath. BUG=v8:5339 ========== to ========== [regexp] Add fast-path for global, callable replace This adds a fast-path for calls to RegExp.prototype[@@replace] for cases in which the given regexp is unmodified and global, and the given replace argument is callable. The fast-path implementation itself is almost identical to the original JS implementation except that it currently does not reuse result_array. SunSpider/unpack-code relies heavily on this codepath. BUG=v8:5339 Committed: https://crrev.com/a8e30c0e689a68a8d5d457be28eec1fb5b7a3702 Cr-Commit-Position: refs/heads/master@{#40504} ==========
Message was sent while issue was closed.
Patchset 7 (id:??) landed as https://crrev.com/a8e30c0e689a68a8d5d457be28eec1fb5b7a3702 Cr-Commit-Position: refs/heads/master@{#40504} |