[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: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52528}
This commit is contained in:
Sigurd Schneider 2018-04-10 18:10:28 +02:00 committed by Commit Bot
parent f590c153e2
commit 79b5f0b560

View File

@ -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);
}
}
}