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

Unified Diff: pkg/compiler/lib/src/ssa/optimize.dart

Issue 1315523012: dart2js ssa: Open coding of removeLast should use -1 as index (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « pkg/compiler/lib/src/ssa/nodes.dart ('k') | sdk/lib/_internal/js_runtime/lib/js_array.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/optimize.dart
diff --git a/pkg/compiler/lib/src/ssa/optimize.dart b/pkg/compiler/lib/src/ssa/optimize.dart
index 977900c2242fe466ffe89008300ffc8f52f6ba37..795b510fbc31ae0b60e76390e1eb499b5c97612b 100644
--- a/pkg/compiler/lib/src/ssa/optimize.dart
+++ b/pkg/compiler/lib/src/ssa/optimize.dart
@@ -1029,8 +1029,13 @@ class SsaCheckInserter extends HBaseVisitor implements OptimizationPhase {
if (node.isInterceptedCall) return;
if (element != backend.jsArrayRemoveLast) return;
if (boundsChecked.contains(node)) return;
- insertBoundsCheck(
+ // `0` is the index we want to check, but we want to report `-1`, as if we
+ // executed `a[a.length-1]`
+ HBoundsCheck check = insertBoundsCheck(
node, node.receiver, graph.addConstantInt(0, backend.compiler));
+ HInstruction minusOne = graph.addConstantInt(-1, backend.compiler);
+ check.inputs.add(minusOne);
+ minusOne.usedBy.add(check);
}
}
« no previous file with comments | « pkg/compiler/lib/src/ssa/nodes.dart ('k') | sdk/lib/_internal/js_runtime/lib/js_array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698