Commit 40f9cf49 authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[Perf] Add ExpressionDepth test.

Adds a 'performance' test which tracks the number of expressions
which can be nested before the compiler runs out of stack space.
This isn't really a performance test, but is created as a js-perf-test
to enable regression tracking in the dashboards.

Change-Id: Iee0c00df53b38b083e2dde09676ac9b13e439461
Reviewed-on: https://chromium-review.googlesource.com/539419Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46019}
parent 22aad80e
// Copyright 2017 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.
// Logical Expressions
AddTest('Or-Value', '||', false);
AddTest('Or-Test', '||', true);
AddTest('And-Value', '&&', false);
AddTest('And-Test', '&&', true);
AddTest('Comma-Value', ',', false);
AddTest('Comma-Test', ',', true);
AddTest('Comma-Test', ',', true);
// Compare Expressions
AddTest('Equals-Value', '==', false);
AddTest('Equals-Test', '==', true);
AddTest('StrictEquals-Value', '===', false);
AddTest('StrictEquals-Test', '===', true);
AddTest('GreaterThan-Value', '>', false);
AddTest('GreaterThan-Test', '>', true);
// Binary Expressions
AddTest('Add', '+');
AddTest('Sub', '-');
AddTest('BitwiseOr', '|');
AddTestCustomPrologue('StringConcat', '+', '"string" +');
function TestExpressionDepth(depth, expression, prologue, epilogue) {
var func = '(function f(a) {\n' + prologue;
for (var i = 0; i < depth; i++) {
func += 'a ' + expression;
}
func += 'a' + epilogue + '})();'
eval(func);
}
function RunTest(name, expression, prologue, epilogue) {
var depth;
try {
for (depth = 0; depth < 20000; depth += 100) {
TestExpressionDepth(depth, expression, prologue, epilogue);
}
} catch (e) {
if (!e instanceof RangeError) {
print(name + '-ExpressionDepth(Score): ERROR');
return;
}
}
print(name + '-ExpressionDepth(Score): ' + depth);
}
function AddTest(name, expression, in_test) {
prologue = '';
epilogue = '';
if (in_test) {
prologue = 'if (';
epilogue = ') { return 1; }';
}
RunTest(name, expression, prologue, epilogue);
}
function AddTestCustomPrologue(name, expression, prologue) {
RunTest(name, expression, prologue, '');
}
......@@ -480,6 +480,31 @@
]
}
]
},
{
"name": "ExpressionDepth",
"path": ["ExpressionDepth"],
"main": "run.js",
"flags": [ "--no-opt" ],
"results_regexp": "^%s\\-ExpressionDepth\\(Score\\): (.+)$",
"tests": [
{"name": "Or-Value"},
{"name": "Or-Test"},
{"name": "And-Value"},
{"name": "And-Test"},
{"name": "Comma-Value"},
{"name": "Comma-Test"},
{"name": "Equals-Value"},
{"name": "Equals-Test"},
{"name": "StrictEquals-Value"},
{"name": "StrictEquals-Test"},
{"name": "GreaterThan-Value"},
{"name": "GreaterThan-Test"},
{"name": "Add"},
{"name": "Sub"},
{"name": "StringConcat"},
{"name": "BitwiseOr"}
]
}
]
}
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