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

Side by Side Diff: tests/language/src/DeoptimizedFunctionOnStackTest.dart

Issue 10248007: test rename overhaul: step 8 - language tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « tests/language/src/DeoptNoFeedbackTest.dart ('k') | tests/language/src/DisablePrivacyLib.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // This is a test for deoptimization infrastructure and to reproduce the
6 // failure from bug 5442338.
7
8 main() {
9 warmup();
10 runTest();
11 }
12
13 // Create a situation where method 'call' is optimized for using class A
14 // when calling foo.
15 warmup() {
16 List a = [ new A(), new A(), new A(), new A()];
17 var res = 0;
18 for (int i = 0; i < 2000; i++) {
19 res = call(a, 0);
20 }
21 Expect.equals(10, res);
22 }
23
24
25 // Create a situation where several optimized frames of 'call' are on stack
26 // when deoptimization occurs because B.foo is called. After the first
27 // deoptimization, several optimized frames of 'call' are still on stack and
28 // some of them will be deoptimized.
29 runTest() {
30 List a = [ new A(), new A(), new B(), new A(), new B(), new B()];
31 var res = call(a, 0);
32 Expect.equals(35, res);
33 }
34
35 // This method will be optimized for using class A when calling 'foo' and
36 // later will be deoptimized because B.foo is required.
37 call(List a, int n) {
38 if (n < a.length) {
39 var sum = call(a, n + 1);
40 for (int i = n; i < a.length; i++) {
41 sum += a[i].foo();
42 }
43 return sum;
44 }
45 return 0;
46 }
47
48
49 class A {
50 foo() { return 1; }
51 }
52
53
54 class B {
55 foo() { return 2; }
56 }
OLDNEW
« no previous file with comments | « tests/language/src/DeoptNoFeedbackTest.dart ('k') | tests/language/src/DisablePrivacyLib.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698