OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 15 matching lines...) Expand all Loading... |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 // Flags: --allow-natives-syntax --expose-gc | 28 // Flags: --allow-natives-syntax --expose-gc |
29 // Flags: --parallel-recompilation --parallel-recompilation-delay=50 | 29 // Flags: --parallel-recompilation --parallel-recompilation-delay=50 |
30 | 30 |
31 if (!%IsParallelRecompilationSupported()) { | 31 if (!%IsParallelRecompilationSupported()) { |
32 print("Parallel recompilation is disabled. Skipping this test."); | 32 print("Parallel recompilation is disabled. Skipping this test."); |
33 quit(); | 33 quit(); |
34 } | 34 } |
35 | 35 |
36 function assertUnoptimized(fun) { | |
37 assertTrue(%GetOptimizationStatus(fun) != 1); | |
38 } | |
39 | |
40 function assertOptimized(fun) { | |
41 assertTrue(%GetOptimizationStatus(fun) != 2); | |
42 } | |
43 | |
44 function f(x) { | 36 function f(x) { |
45 var xx = x * x; | 37 var xx = x * x; |
46 var xxstr = xx.toString(); | 38 var xxstr = xx.toString(); |
47 return xxstr.length; | 39 return xxstr.length; |
48 } | 40 } |
49 | 41 |
50 function g(x) { | 42 function g(x) { |
51 var xxx = Math.sqrt(x) | 0; | 43 var xxx = Math.sqrt(x) | 0; |
52 var xxxstr = xxx.toString(); | 44 var xxxstr = xxx.toString(); |
53 return xxxstr.length; | 45 return xxxstr.length; |
54 } | 46 } |
55 | 47 |
56 function k(x) { | 48 function k(x) { |
57 return x * x; | 49 return x * x; |
58 } | 50 } |
59 | 51 |
60 f(g(1)); | 52 f(g(1)); |
61 assertUnoptimized(f); | 53 assertUnoptimized(f); |
62 assertUnoptimized(g); | 54 assertUnoptimized(g); |
63 | 55 |
64 %OptimizeFunctionOnNextCall(f, "parallel"); | 56 %OptimizeFunctionOnNextCall(f, "parallel"); |
65 %OptimizeFunctionOnNextCall(g, "parallel"); | 57 %OptimizeFunctionOnNextCall(g, "parallel"); |
66 f(g(2)); // Trigger optimization. | 58 f(g(2)); // Trigger optimization. |
67 | 59 |
68 assertUnoptimized(f); // Not yet optimized. | 60 assertUnoptimized(f, "no sync"); // Not yet optimized while parallel thread |
69 assertUnoptimized(g); | 61 assertUnoptimized(g, "no sync"); // is running. |
70 | 62 |
71 %CompleteOptimization(f); // Wait till optimized code is installed. | 63 assertOptimized(f, "sync"); // Optimized once we sync with the parallel thread. |
72 %CompleteOptimization(g); | 64 assertOptimized(g, "sync"); |
73 | |
74 assertOptimized(f); // Optimized now. | |
75 assertOptimized(g); | |
OLD | NEW |