Commit 79b5f0b5 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[mjsunit] Fix flakyness in mjsunittest

This mjsunittest assumed specific internal types (i.e. Smi)
for certain fields; it generates some dozens of variants of
the test using new Function, but used the same property names
in all of them. This causes V8 to sometimes learn more general
types for fields (i.e. unboxed double), which the test did not
expect. This commit uses unique field names for each of the test
variants.


Change-Id: Ib1ecb3ae33a57c8a1293a29a2233dad4e16a39fb
Reviewed-on: https://chromium-review.googlesource.com/1004897
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52528}
parent f590c153
......@@ -4,6 +4,8 @@
// Flags: --allow-natives-syntax --opt --no-always-opt
let id = 0;
function runTest(f, message, mkICTraining, deoptArg) {
function test(f, message, ictraining, deoptArg) {
// Train the call ic to the maps.
......@@ -58,7 +60,14 @@ function runTest(f, message, mkICTraining, deoptArg) {
// Substitute parameters.
testString = testString.replace(new RegExp("ictraining", 'g'), mkICTraining.toString());
testString = testString.replace(new RegExp("deoptArg", 'g'),
deoptArg ? JSON.stringify(deoptArg) : "undefined");
deoptArg ? JSON.stringify(deoptArg).replace(/"/g,'') : "undefined");
// Make field names unique to avoid learning of types.
id = id + 1;
testString = testString.replace(/[.]el/g, '.el' + id);
testString = testString.replace(/el:/g, 'el' + id + ':');
testString = testString.replace(/[.]arr/g, '.arr' + id);
testString = testString.replace(/arr:/g, 'arr' + id + ':');
var modTest = new Function("message", testString);
//print(modTest);
......@@ -114,10 +123,10 @@ Object.keys(checks).forEach(
let check = checks[key];
for (fnc in functions) {
runTest(functions[fnc], "test-reliable-" + key, check.mkTrainingArguments);
runTest(functions[fnc], "test-" + fnc + "-" + key, check.mkTrainingArguments);
// Test each deopting arg separately.
for (let deoptArg of check.deoptingArguments) {
runTest(functions[fnc], "testDeopt-reliable-" + key, check.mkTrainingArguments, deoptArg);
runTest(functions[fnc], "testDeopt-" + fnc + "-" + key, check.mkTrainingArguments, deoptArg);
}
}
}
......
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