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

Side by Side Diff: tests/lib/mirrors/hot_get_field_test.dart

Issue 1247733005: Fix getField optimization when the selector is an operator. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
« no previous file with comments | « runtime/lib/mirrors_impl.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 4
5 library test.hot_get_field; 5 library test.hot_get_field;
6 6
7 import 'dart:mirrors'; 7 import 'dart:mirrors';
8 import 'package:expect/expect.dart'; 8 import 'package:expect/expect.dart';
9 9
10 class C { 10 class C {
11 var field; 11 var field;
12 var _field; 12 var _field;
13 operator +(other) => field + other;
13 } 14 }
14 15
15 const int optimizationThreshold = 20; 16 const int optimizationThreshold = 20;
16 17
17 testPublic() { 18 testPublic() {
18 var c = new C(); 19 var c = new C();
19 var im = reflect(c); 20 var im = reflect(c);
20 21
21 for (int i = 0; i < (2 * optimizationThreshold); i++) { 22 for (int i = 0; i < (2 * optimizationThreshold); i++) {
22 c.field = i; 23 c.field = i;
(...skipping 14 matching lines...) Expand all
37 testPrivateWrongLibrary() { 38 testPrivateWrongLibrary() {
38 var c = new C(); 39 var c = new C();
39 var im = reflect(c); 40 var im = reflect(c);
40 var selector = MirrorSystem.getSymbol('_field', reflectClass(Mirror).owner); 41 var selector = MirrorSystem.getSymbol('_field', reflectClass(Mirror).owner);
41 42
42 for (int i = 0; i < (2 * optimizationThreshold); i++) { 43 for (int i = 0; i < (2 * optimizationThreshold); i++) {
43 Expect.throws(() => im.getField(selector), (e) => e is NoSuchMethodError); 44 Expect.throws(() => im.getField(selector), (e) => e is NoSuchMethodError);
44 } 45 }
45 } 46 }
46 47
48 testOperator() {
49 var plus = const Symbol("+");
50 var c = new C();
51 var im = reflect(c);
52
53 for (int i = 0; i < (2 * optimizationThreshold); i++) {
54 c.field = i;
55 var closurizedPlus = im.getField(plus).reflectee;
56 Expect.isTrue(closurizedPlus is Function);
57 Expect.equals(2 * i, closurizedPlus(i));
58 }
59 }
60
47 main() { 61 main() {
48 testPublic(); 62 testPublic();
49 testPrivate(); 63 testPrivate();
50 testPrivateWrongLibrary(); 64 testPrivateWrongLibrary();
65 testOperator();
51 } 66 }
OLDNEW
« no previous file with comments | « runtime/lib/mirrors_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698