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

Side by Side Diff: tests/language/optimize_redundant_array_load_test.dart

Issue 18563006: More tests updated to optimize code (Part 2). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 --no-use-osr
4 5
5 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
6 7
7 // Test optimization of redundant array loads. 8 // Test optimization of redundant array loads.
8 9
9 var A = [0,2,3]; 10 var A = [0,2,3];
10 11
11 test1(a) { 12 test1(a) {
12 int x = a[0]; 13 int x = a[0];
13 int y = a[1]; 14 int y = a[1];
14 ++a[0]; 15 ++a[0];
15 return a[0] + y + a[2]; 16 return a[0] + y + a[2];
16 } 17 }
17 18
18 19
19 int test2(a) { 20 int test2(a) {
20 return a[2] + a[2]; 21 return a[2] + a[2];
21 } 22 }
22 23
23 24
24 main() { 25 main() {
25 for (int i = 0; i < 10000; i++) { 26 for (int i = 0; i < 20; i++) {
26 test1(A); 27 test1(A);
27 test2(A); 28 test2(A);
28 } 29 }
29 Expect.equals(10006, test1(A)); 30 Expect.equals(26, test1(A));
30 Expect.equals(6, test2(A)); 31 Expect.equals(6, test2(A));
31 } 32 }
OLDNEW
« no previous file with comments | « tests/language/optimization_test.dart ('k') | tests/language/optimized_constant_array_string_access_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698