1 // Copyright 2015 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Flags: --allow-natives-syntax 6 7 function boom(a1, a2) { 8 // Do something with a2 that needs a map check (for DOUBLE_ELEMENTS). 9 var s = a2[0]; 10 // Emit a load that transitions a1 to FAST_ELEMENTS. 11 var t = a1[0]; 12 // Emit a store to a2 that assumes DOUBLE_ELEMENTS. 13 // The map check is considered redundant and will be eliminated. 14 a2[0] = 0.3; 15 } 16 17 // Prepare type feedback for the "t = a1[0]" load: fast elements. 18 var fast_elem = new Array(1); 19 fast_elem[0] = "tagged"; 20 boom(fast_elem, [1]); 21 22 // Prepare type feedback for the "a2[0] = 0.3" store: double elements. 23 var double_elem = new Array(1); 24 double_elem[0] = 0.1; 25 boom(double_elem, double_elem); 26 27 // Reset |double_elem| and go have a party. 28 double_elem = new Array(10); 29 double_elem[0] = 0.1; 30 31 %OptimizeFunctionOnNextCall(boom); 32 boom(double_elem, double_elem); 33 34 assertEquals(0.3, double_elem[0]); 35 assertEquals(undefined, double_elem[1]); 36