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

Side by Side Diff: tests/language_strong/deoptimized_function_on_stack_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // VMOptions=--optimization-counter-threshold=10 4 // VMOptions=--optimization-counter-threshold=10
5 5
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 7
8 // This is a test for deoptimization infrastructure and to reproduce the 8 // This is a test for deoptimization infrastructure and to reproduce the
9 // failure from bug 5442338. 9 // failure from bug 5442338.
10 10
11 main() { 11 main() {
12 warmup(); 12 warmup();
13 runTest(); 13 runTest();
14 } 14 }
15 15
16 // Create a situation where method 'call' is optimized for using class A 16 // Create a situation where method 'call' is optimized for using class A
17 // when calling foo. 17 // when calling foo.
18 warmup() { 18 warmup() {
19 List a = [ new A(), new A(), new A(), new A()]; 19 List a = [new A(), new A(), new A(), new A()];
20 var res = 0; 20 var res = 0;
21 for (int i = 0; i < 20; i++) { 21 for (int i = 0; i < 20; i++) {
22 res = call(a, 0); 22 res = call(a, 0);
23 } 23 }
24 Expect.equals(10, res); 24 Expect.equals(10, res);
25 } 25 }
26 26
27
28 // Create a situation where several optimized frames of 'call' are on stack 27 // Create a situation where several optimized frames of 'call' are on stack
29 // when deoptimization occurs because B.foo is called. After the first 28 // when deoptimization occurs because B.foo is called. After the first
30 // deoptimization, several optimized frames of 'call' are still on stack and 29 // deoptimization, several optimized frames of 'call' are still on stack and
31 // some of them will be deoptimized. 30 // some of them will be deoptimized.
32 runTest() { 31 runTest() {
33 List a = [ new A(), new A(), new B(), new A(), new B(), new B()]; 32 List a = [new A(), new A(), new B(), new A(), new B(), new B()];
34 var res = call(a, 0); 33 var res = call(a, 0);
35 Expect.equals(35, res); 34 Expect.equals(35, res);
36 } 35 }
37 36
38 // This method will be optimized for using class A when calling 'foo' and 37 // This method will be optimized for using class A when calling 'foo' and
39 // later will be deoptimized because B.foo is required. 38 // later will be deoptimized because B.foo is required.
40 call(List a, int n) { 39 call(List a, int n) {
41 if (n < a.length) { 40 if (n < a.length) {
42 var sum = call(a, n + 1); 41 var sum = call(a, n + 1);
43 for (int i = n; i < a.length; i++) { 42 for (int i = n; i < a.length; i++) {
44 sum += a[i].foo(); 43 sum += a[i].foo();
45 } 44 }
46 return sum; 45 return sum;
47 } 46 }
48 return 0; 47 return 0;
49 } 48 }
50 49
51
52 class A { 50 class A {
53 foo() { return 1; } 51 foo() {
52 return 1;
53 }
54 } 54 }
55 55
56
57 class B { 56 class B {
58 foo() { return 2; } 57 foo() {
58 return 2;
59 }
59 } 60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698