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

Unified Diff: pkg/compiler/lib/src/cps_ir/type_propagation.dart

Issue 1328093004: dart2js cps: Insert bounds check for removeLast() -> pop() optimization. (Closed) Base URL: git@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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/type_propagation.dart
diff --git a/pkg/compiler/lib/src/cps_ir/type_propagation.dart b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
index 1ac163ee538b0732f31819e3dfb1f7c485a61acb..b185bc70b8cc801ba4e71076c7322d04c8898d98 100644
--- a/pkg/compiler/lib/src/cps_ir/type_propagation.dart
+++ b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
@@ -1230,6 +1230,14 @@ class TransformingVisitor extends LeafVisitor {
}
if (!isExtendable) return false;
CpsFragment cps = new CpsFragment(sourceInfo);
+ Primitive length = cps.letPrim(new GetLength(list));
+ Primitive isEmpty = cps.applyBuiltin(
+ BuiltinOperator.StrictEq,
+ [length, cps.makeZero()]);
+ CpsFragment fail = cps.ifTruthy(isEmpty);
+ fail.invokeStaticThrower(
+ backend.getThrowIndexOutOfBoundsError(),
+ [list, fail.makeConstant(new IntConstantValue(-1))]);
Primitive removedItem = cps.invokeBuiltin(BuiltinMethod.Pop,
list,
<Primitive>[],
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698