v8/test/mjsunit/regress/regress-475705.js
Mythri 7371c34b6b Use --opt instead of --crankshaft in tests.
1. Replaces --crankshaft with --opt in tests.
2. Also fixes presubmit to check for --opt flag when
assertOptimized is used.
3. Updates testrunner/local/variants.py and 
v8_foozie.py to use --opt flag.
This would mean, nooptimize variant means there are
no optimizations. Not even with %OptimizeFunctionOnNextCall.

Bug:v8:6325

Change-Id: I638e743d0773a6729c6b9749e2ca1e2537f12ce6
Reviewed-on: https://chromium-review.googlesource.com/490206
Commit-Queue: Mythri Alle <mythria@chromium.org>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44985}
2017-04-28 14:20:39 +00:00

64 lines
1.6 KiB
JavaScript

// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Crankshaft changes the stack usage and messes up the binary search for the
// stack depth that causes a stack overflow. The issue only arises without
// regexp optimization, which can happen on pages that create a lot of regexps.
// Flags: --noopt --noregexp-optimization
// Should not crash with a stack overflow in the regexp compiler, even when the
// JS has used most of the stack.
function use_space_then_do_test(depth) {
try {
// The "+ depth" is to avoid the regexp compilation cache.
var regexp_src = repeat(".(.)", 12) + depth;
use_space(depth, regexp_src);
return true;
} catch (e) {
assertFalse(("" + e).indexOf("tack") == -1); // Check for [Ss]tack.
return false;
}
}
function use_space(n, regexp_src) {
if (--n == 0) {
do_test(regexp_src);
return;
}
use_space(n, regexp_src);
}
function repeat(str, n) {
var answer = "";
while (n-- != 0) {
answer += str;
}
return answer;
}
var subject = repeat("y", 200);
function do_test(regexp_src) {
var re = new RegExp(regexp_src);
re.test(subject);
}
function try_different_stack_limits() {
var lower = 100;
var higher = 100000;
while (lower < higher - 1) {
var average = Math.floor((lower + higher) / 2);
if (use_space_then_do_test(average)) {
lower = average;
} else {
higher = average;
}
}
for (var i = lower - 5; i < higher + 5; i++) {
use_space_then_do_test(i);
}
}
try_different_stack_limits();