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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/optimize.dart

Issue 11312122: Change List constructors. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Reupload. Adapt code for List.fixedLength. Created 8 years 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 | « sdk/lib/_internal/compiler/implementation/lib/js_helper.dart ('k') | sdk/lib/async/future_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/ssa/optimize.dart
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/optimize.dart b/sdk/lib/_internal/compiler/implementation/ssa/optimize.dart
index 032ba03d6105aadfb44337c0e3e4aaca9576f95d..84e490805f069f4b5bcf8ac2230d83b400c493ff 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/optimize.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/optimize.dart
@@ -219,11 +219,17 @@ class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
DartType defaultClass = compiler.listClass.defaultClass;
// TODO(ngeoffray): make sure that the only reason the List class is
// not resolved is because it's not being used.
- return element.isConstructor()
- && defaultClass != null
- && element.enclosingElement.declaration == defaultClass.element
- && node.inputs.length == 2
- && node.inputs[1].isInteger(types);
+ if (defaultClass == null) return false;
+ if (!element.isConstructor()) return false;
+ // TODO(ngeoffray): cache constructor.
+ if (element.enclosingElement.declaration != defaultClass.element) {
+ return false;
+ }
+ FunctionElement fixedLengthListConstructor =
+ compiler.listClass.lookupConstructor(
+ new Selector.callConstructor(const SourceString("fixedLength"),
+ compiler.listClass.getLibrary()));
+ return element == fixedLengthListConstructor.defaultImplementation;
}
HInstruction visitInvokeStatic(HInvokeStatic node) {
@@ -559,7 +565,7 @@ class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
HInstruction visitFieldGet(HFieldGet node) {
if (node.element == backend.jsArrayLength) {
if (node.receiver is HInvokeStatic) {
- // Try to recognize the length getter with input [:new List(int):].
+ // Try to recognize the length getter with input [:new List.fixedLength(int):].
HInvokeStatic call = node.receiver;
if (isFixedSizeListConstructor(call)) {
return call.inputs[1];
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/lib/js_helper.dart ('k') | sdk/lib/async/future_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698