Home | History | Annotate | Download | only in compiler
      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 var f = (function() {
      8   "use asm";
      9   function f(x, y) {
     10     return x << y;
     11   }
     12   return f;
     13 })();
     14 
     15 var counter = 0;
     16 
     17 var deopt = { toString : function() {
     18   %DeoptimizeFunction(f);
     19   counter++;
     20   return "2";
     21 } };
     22 
     23 var o = { toString : function() {
     24   counter++;
     25   return "1";
     26 } };
     27 
     28 counter = 0;
     29 assertEquals(4, f(deopt, o));
     30 assertEquals(2, counter);
     31 
     32 %OptimizeFunctionOnNextCall(f);
     33 counter = 0;
     34 assertEquals(4, f(o, deopt));
     35 assertEquals(2, counter);
     36 
     37 %OptimizeFunctionOnNextCall(f);
     38 counter = 0;
     39 assertEquals(8, f(deopt, deopt));
     40 assertEquals(2, counter);
     41