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

Unified Diff: tests/compiler/dart2js/cps_ir/expected/optimize_indexers.js

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 side-by-side diff with in-line comments
Download patch
Index: tests/compiler/dart2js/cps_ir/expected/optimize_indexers.js
diff --git a/tests/compiler/dart2js/cps_ir/expected/optimize_indexers.js b/tests/compiler/dart2js/cps_ir/expected/optimize_indexers.js
index 21c1d71007624ac0a63bdb66c9317bd1023d3397..6451f4bfde7fcf83438e29b3cb216c416b0e4d9f 100644
--- a/tests/compiler/dart2js/cps_ir/expected/optimize_indexers.js
+++ b/tests/compiler/dart2js/cps_ir/expected/optimize_indexers.js
@@ -5,13 +5,16 @@
// // This example illustrates a case we wish to do better in terms of inlining and
// // code generation.
// //
-// // Today this function is compiled without inlining Wrapper.[], JSArray.[] and
-// // Wrapper.[]= because:
+// // Naively this function would be compiled without inlining Wrapper.[],
+// // JSArray.[] and Wrapper.[]= because:
// // JSArray.[] is too big (14 nodes)
// // Wrapper.[] is too big if we force inlining of JSArray (15 nodes)
// // Wrapper.[]= is even bigger (46 nodes)
// //
-// // See #25478 for ideas on how to make this better.
+// // We now do specialization of [] and []= by adding guards and injecting builtin
+// // operators. This made it possible to inline []. We still don't see []= inlined
+// // yet, that might require that we improve the inlining counting heuristics a
+// // bit.
// @NoInline()
// test(data, x) {
// data[x + 1] = data[x];
@@ -33,5 +36,10 @@
// }
function(data, x) {
- data.$indexSet(0, J.$add$ns(x, 1), C.JSArray_methods.$index(data.arr, x));
+ var v0 = J.$add$ns(x, 1), v1 = data.arr, v2 = v1.length;
+ if (typeof x !== "number" || Math.floor(x) !== x)
+ return H.iae(x);
+ if (x < 0 || x >= v2)
+ return H.ioore(v1, x);
+ data.$indexSet(0, v0, v1[x]);
}

Powered by Google App Engine
This is Rietveld 408576698