diff --git a/test/mjsunit/optimized-map.js b/test/mjsunit/optimized-map.js index 550db9249c..54d6575f8a 100644 --- a/test/mjsunit/optimized-map.js +++ b/test/mjsunit/optimized-map.js @@ -362,6 +362,33 @@ 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]; (function() { var result = 0; var to_double = 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 { + // Then return smi values and make sure they can live in the double + // array. + return v; + } + } + return c.map(callback); + } + to_double(); + to_double(); + %OptimizeFunctionOnNextCall(to_double); + var output = to_double(); + assertTrue(%HasDoubleElements(output)); + assertEquals(1.5, output[0]); + assertEquals(6, output[5]); + assertEquals(975, result); + assertOptimized(to_double); +})(); + +(function() { + var result = 0; + var to_fast = function() { var callback = function(v,i,o) { result += v; if (i < 5) { @@ -378,13 +405,14 @@ 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]; } return c.map(callback); } - to_double(); - to_double(); - %OptimizeFunctionOnNextCall(to_double); - var output = to_double(); + to_fast(); + to_fast(); + %OptimizeFunctionOnNextCall(to_fast); + var output = to_fast(); + %HasObjectElements(output); assertEquals(975, result); assertEquals("11hello", output[10]); - assertOptimized(to_double); + assertOptimized(to_fast); })(); // Messing with the Array species constructor causes deoptimization.