Home | History | Annotate | Download | only in mjsunit
      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 f1(a, i) {
      8   return a[i] + 0.5;
      9 }
     10 var arr = [,0.0,2.5];
     11 assertEquals(0.5, f1(arr, 1));
     12 assertEquals(0.5, f1(arr, 1));
     13 %OptimizeFunctionOnNextCall(f1);
     14 assertEquals(0.5, f1(arr, 1));
     15 
     16 // Trick crankshaft into accepting feedback with the array prototype
     17 // map even though a call on that map was never made. optopush should
     18 // refuse to inline the push call based on the danger that it's modifying
     19 // the array prototype.
     20 var push = Array.prototype.push;
     21 var array_prototype = Array.prototype;
     22 
     23 function optopush(a) {
     24   push.call(a, 1);
     25 }
     26 
     27 function foo() {
     28   optopush(array_prototype);
     29 }
     30 
     31 optopush([]);
     32 optopush([]);
     33 optopush([]);
     34 %OptimizeFunctionOnNextCall(foo);
     35 foo();
     36 assertEquals(1.5, f1(arr, 0));
     37