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

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

Issue 1431513012: Fix for 23806 - don't optimize out Array allocation that may throw (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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/ssa/builder.dart
diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart
index 35cf64c929b681008251d77a87edd86be31f7a14..cf1783f05db488c3a973e7e801b78189c7eb2711 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -5159,12 +5159,15 @@ class SsaBuilder extends ast.Visitor
js.Template code = js.js.parseForeignJS('new Array(#)');
var behavior = new native.NativeBehavior();
behavior.typesReturned.add(expectedType);
- // The allocation can throw only if the given length is a double
- // or negative.
+ // The allocation can throw only if the given length is a double or
+ // outside the unsigned 32 bit range.
+ // TODO(sra): Array allocation should be an instruction so that canThrow
+ // can depend on a length type discovered in optimization.
bool canThrow = true;
if (inputs[0].isInteger(compiler) && inputs[0] is HConstant) {
var constant = inputs[0];
- if (constant.constant.primitiveValue >= 0) canThrow = false;
+ int value = constant.constant.primitiveValue;
+ if (0 <= value && value < 0x100000000) canThrow = false;
}
HForeignCode foreign = new HForeignCode(code, elementType, inputs,
nativeBehavior: behavior,
« 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