Commit 950e4f46 authored by Mike Stanton's avatar Mike Stanton Committed by Commit Bot

[TurboFan] Improved unit test for optimized Array.prototype.map.

Test mjsunit/optimized-map walked an array through different
ElementsKind transitions, but it failed to verify that the
expected ElementsKind was in place. Although we have a regression
test for the bug, it's a good idea to make sure the basic
test covers all paths.

Bug: chromium:747075
Change-Id: I1424880801857f3356bfd63839d351d6fd1521e0
Reviewed-on: https://chromium-review.googlesource.com/584837Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Michael Stanton <mvstanton@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46933}
parent b1e10f4b
......@@ -367,13 +367,10 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
if (i < 5) {
// First transition the output array to PACKED_DOUBLE_ELEMENTS.
return v + 0.5;
} else if (i < 10) {
} else {
// Then return smi values and make sure they can live in the double
// array.
return v;
} else {
// Later, to PACKED_ELEMENTS.
return v + 'hello';
}
}
return c.map(callback);
......@@ -382,11 +379,42 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
to_double();
%OptimizeFunctionOnNextCall(to_double);
var output = to_double();
assertTrue(%HasDoubleElements(output));
assertEquals(1.5, output[0]);
assertEquals(6, output[5]);
assertEquals(975, result);
assertEquals("11hello", output[10]);
assertOptimized(to_double);
})();
(function() {
var result = 0;
var to_fast = function() {
var callback = function(v,i,o) {
result += v;
if (i < 5) {
// First transition the output array to PACKED_DOUBLE_ELEMENTS.
return v + 0.5;
} else if (i < 10) {
// Then return smi values and make sure they can live in the double
// array.
return v;
} else {
// Later, to PACKED_ELEMENTS.
return v + 'hello';
}
}
return c.map(callback);
}
to_fast();
to_fast();
%OptimizeFunctionOnNextCall(to_fast);
var output = to_fast();
%HasObjectElements(output);
assertEquals(975, result);
assertEquals("11hello", output[10]);
assertOptimized(to_fast);
})();
// Messing with the Array species constructor causes deoptimization.
(function() {
var result = 0;
......
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