Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: test/mjsunit/regress/regress-475705.js

Issue 1082763002: Reduce regexp compiler stack size when not optimizing regexps (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: More recursion limiting. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/jsregexp.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Crankshaft changes the stack usage and messes up the binary search for the
6 // stack depth that causes a stack overflow. The issue only arises without
7 // regexp optimization, which can happen on pages that create a lot of regexps.
8 // Flags: --nocrankshaft --noregexp-optimization
9
10 // Should not crash with a stack overflow in the regexp compiler, even when the
11 // JS has used most of the stack.
12 function use_space_then_do_test(depth) {
13 try {
14 // The "+ depth" is to avoid the regexp compilation cache.
15 var regexp_src = repeat(".(.)", 12) + depth;
16 use_space(depth, regexp_src);
17 return true;
18 } catch (e) {
19 assertFalse(("" + e).indexOf("tack") == -1); // Check for [Ss]tack.
20 return false;
21 }
22 }
23
24 function use_space(n, regexp_src) {
25 if (--n == 0) {
26 do_test(regexp_src);
27 return;
28 }
29 use_space(n, regexp_src);
30 }
31
32 function repeat(str, n) {
33 var answer = "";
34 while (n-- != 0) {
35 answer += str;
36 }
37 return answer;
38 }
39
40 var subject = repeat("y", 200);
41
42 function do_test(regexp_src) {
43 var re = new RegExp(regexp_src);
44 re.test(subject);
45 }
46
47 function try_different_stack_limits() {
48 var lower = 100;
49 var higher = 100000;
50 while (lower < higher - 1) {
51 var average = Math.floor((lower + higher) / 2);
52 if (use_space_then_do_test(average)) {
53 lower = average;
54 } else {
55 higher = average;
56 }
57 }
58 for (var i = lower - 5; i < higher + 5; i++) {
59 use_space_then_do_test(i);
60 }
61 }
62
63 try_different_stack_limits();
OLDNEW
« no previous file with comments | « src/jsregexp.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698