| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 // Copyright 2014 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 --use-osr --turbo-osr | 
|  | 6 | 
|  | 7 var counter = 188; | 
|  | 8 | 
|  | 9 function gen() {  // defeat compiler cache. | 
|  | 10  var num = counter++; | 
|  | 11  var src = | 
|  | 12   "function f" + num + "(Z,a,b,c) {" + | 
|  | 13   "  var x = 0;" + | 
|  | 14   "  var y = 0;" + | 
|  | 15   "  var z = 0;" + | 
|  | 16   "  while (a > 0) { Z(0); x += 19; a--; var j=2; while(j--); }" + | 
|  | 17   "  while (b > 0) { Z(1); y += 23; b--; var j=2; while(j--); }" + | 
|  | 18   "  while (c > 0) { Z(2); z += 29; c--; var j=2; while(j--); }" + | 
|  | 19   "  return x + y + z;" + | 
|  | 20   "} f" + num; | 
|  | 21 | 
|  | 22   return eval(src); | 
|  | 23 } | 
|  | 24 | 
|  | 25 function compiler(a) {  // manual control of OSR compiles. | 
|  | 26   var x = 0; | 
|  | 27   function count(l) { | 
|  | 28     if (l == a && (x++) > 0) { | 
|  | 29       %OptimizeFunctionOnNextCall(count.caller, "osr"); | 
|  | 30     } | 
|  | 31   } | 
|  | 32   return count; | 
|  | 33 } | 
|  | 34 | 
|  | 35 function check(x,a,b,c) { | 
|  | 36   function none(l) { } | 
|  | 37 | 
|  | 38   for (var i = 0; i < 3; i++) { | 
|  | 39     var f = gen(); | 
|  | 40     assertEquals(x, f(compiler(i), a, b, c)); | 
|  | 41     assertEquals(x, f(none, a, b, c)); | 
|  | 42   } | 
|  | 43 } | 
|  | 44 | 
|  | 45 check(213, 3,3,3); | 
|  | 46 check(365, 4,5,6); | 
|  | 47 check(6948, 99,98,97); | 
| OLD | NEW | 
|---|