Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: test/mjsunit/compiler/osr-manual1.js

Issue 906243002: Make it easier to test OSR with %OptimizeOsr() runtime call. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/compiler/optimized-for-in.js ('k') | test/mjsunit/compiler/osr-manual2.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --allow-natives-syntax --use-osr --turbo-osr 5 // Flags: --allow-natives-syntax --use-osr --turbo-osr
6 6
7 var counter = 188; 7 var counter = 111;
8 8
9 function gen() { // defeat compiler cache. 9 function gen(w) { // defeat compiler cache.
10 var num = counter++; 10 var num = counter++;
11 var src = 11 var Z = [ "", "", "", ];
12 "function f" + num + "(Z,a,b,c) {" + 12 Z[w] = "%OptimizeOsr()";
13 " var x = 0;" + 13 var src =
14 " var y = 0;" + 14 "function f" + num + "(a,b,c) {" +
15 " var z = 0;" + 15 " var x = 0;" +
16 " while (a > 0) { Z(0); x += 19; a--; }" + 16 " var y = 0;" +
17 " while (b > 0) { Z(1); y += 23; b--; }" + 17 " var z = 0;" +
18 " while (c > 0) { Z(2); z += 29; c--; }" + 18 " while (a > 0) { " + Z[0] + "; x += 19; a--; }" +
19 " return x + y + z;" + 19 " while (b > 0) { " + Z[1] + "; y += 23; b--; }" +
20 "} f" + num; 20 " while (c > 0) { " + Z[2] + "; z += 29; c--; }" +
21 21 " return x + y + z;" +
22 "} f" + num;
22 return eval(src); 23 return eval(src);
23 } 24 }
24 25
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) { 26 function check(x,a,b,c) {
36 function none(l) { }
37
38 for (var i = 0; i < 3; i++) { 27 for (var i = 0; i < 3; i++) {
39 var f = gen(); 28 var f = gen(i);
40 assertEquals(x, f(compiler(i), a, b, c)); 29 assertEquals(x, f(a, b, c));
41 assertEquals(x, f(none, a, b, c));
42 } 30 }
43 } 31 }
44 32
45 check(213, 3,3,3); 33 check(213, 3,3,3);
46 check(365, 4,5,6); 34 check(365, 4,5,6);
47 check(6948, 99,98,97); 35 check(6948, 99,98,97);
OLDNEW
« no previous file with comments | « test/mjsunit/compiler/optimized-for-in.js ('k') | test/mjsunit/compiler/osr-manual2.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698