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 m = (function() {
      8   "use asm";
      9   function f(x) {
     10     return x < 0;
     11   }
     12   function g(x) {
     13     return 0 < x;
     14   }
     15   return { f: f, g: g };
     16 })();
     17 var f = m.f;
     18 var g = m.g;
     19 
     20 var counter = 0;
     21 
     22 function deopt(f) {
     23   return {
     24     toString : function() {
     25       %DeoptimizeFunction(f);
     26       counter++;
     27       return "2";
     28     }
     29   };
     30 }
     31 
     32 assertEquals(false, f(deopt(f)));
     33 assertEquals(1, counter);
     34 
     35 assertEquals(true, g(deopt(g)));
     36 assertEquals(2, counter);
     37 
     38 %OptimizeFunctionOnNextCall(f);
     39 assertEquals(false, f(deopt(f)));
     40 assertEquals(3, counter);
     41 
     42 %OptimizeFunctionOnNextCall(g);
     43 assertEquals(true, g(deopt(g)));
     44 assertEquals(4, counter);
     45