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

Side by Side Diff: tests/compiler/dart2js/cps_ir/input/optimize_indexers.dart

Issue 1685893002: cpsir: insert guard and force specialization for [] and []= (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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 | « tests/compiler/dart2js/cps_ir/expected/redundant_condition.js ('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 // Method to test: function(test) 1 // Method to test: function(test)
2 import 'package:expect/expect.dart'; 2 import 'package:expect/expect.dart';
3 3
4 // This example illustrates a case we wish to do better in terms of inlining and 4 // This example illustrates a case we wish to do better in terms of inlining and
5 // code generation. 5 // code generation.
6 // 6 //
7 // Today this function is compiled without inlining Wrapper.[], JSArray.[] and 7 // Naively this function would be compiled without inlining Wrapper.[],
8 // Wrapper.[]= because: 8 // JSArray.[] and Wrapper.[]= because:
9 // JSArray.[] is too big (14 nodes) 9 // JSArray.[] is too big (14 nodes)
10 // Wrapper.[] is too big if we force inlining of JSArray (15 nodes) 10 // Wrapper.[] is too big if we force inlining of JSArray (15 nodes)
11 // Wrapper.[]= is even bigger (46 nodes) 11 // Wrapper.[]= is even bigger (46 nodes)
12 // 12 //
13 // See #25478 for ideas on how to make this better. 13 // We now do specialization of [] and []= by adding guards and injecting builtin
14 // operators. This made it possible to inline []. We still don't see []= inlined
15 // yet, that might require that we improve the inlining counting heuristics a
16 // bit.
14 @NoInline() 17 @NoInline()
15 test(data, x) { 18 test(data, x) {
16 data[x + 1] = data[x]; 19 data[x + 1] = data[x];
17 } 20 }
18 21
19 main() { 22 main() {
20 var wrapper = new Wrapper(); 23 var wrapper = new Wrapper();
21 wrapper[33] = wrapper[1]; // make Wrapper.[]= and [] used more than once. 24 wrapper[33] = wrapper[1]; // make Wrapper.[]= and [] used more than once.
22 print(test(new Wrapper(), int.parse('2'))); 25 print(test(new Wrapper(), int.parse('2')));
23 } 26 }
24 27
25 class Wrapper { 28 class Wrapper {
26 final List arr = <bool>[true, false, false, true]; 29 final List arr = <bool>[true, false, false, true];
27 operator[](int i) => this.arr[i]; 30 operator[](int i) => this.arr[i];
28 operator[]=(int i, v) { 31 operator[]=(int i, v) {
29 if (i > arr.length - 1) arr.length = i + 1; 32 if (i > arr.length - 1) arr.length = i + 1;
30 return arr[i] = v; 33 return arr[i] = v;
31 } 34 }
32 } 35 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/cps_ir/expected/redundant_condition.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698