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

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

Issue 1126063002: Recognize unmodifiable lists (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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/compiler/js_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 752019abf06d6f730440ce4dd66bdc66532e82d7..1529104454cef20120ba4ec7e4c021b412f22844 100644
--- a/pkg/compiler/lib/src/ssa/optimize.dart
+++ b/pkg/compiler/lib/src/ssa/optimize.dart
@@ -99,15 +99,22 @@ class SsaOptimizerTask extends CompilerTask {
}
}
+/// Returns `true` if [mask] represents only types that have a length that
+/// cannot change. The current implementation is conservative for the purpose
+/// of identifying gvn-able lengths and mis-identifies some unions of fixed
+/// length indexables (see TODO) as not fixed length.
bool isFixedLength(mask, Compiler compiler) {
ClassWorld classWorld = compiler.world;
JavaScriptBackend backend = compiler.backend;
if (mask.isContainer && mask.length != null) {
// A container on which we have inferred the length.
return true;
- } else if (mask.containsOnly(backend.jsFixedArrayClass)
- || mask.containsOnlyString(classWorld)
- || backend.isTypedArray(mask)) {
+ }
+ // TODO(sra): Recognize any combination of fixed length indexables.
+ if (mask.containsOnly(backend.jsFixedArrayClass) ||
+ mask.containsOnly(backend.jsUnmodifiableArrayClass) ||
+ mask.containsOnlyString(classWorld) ||
+ backend.isTypedArray(mask)) {
return true;
}
return false;
« no previous file with comments | « pkg/compiler/lib/src/ssa/nodes.dart ('k') | sdk/lib/_internal/compiler/js_lib/js_array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698