| Index: pkg/compiler/lib/src/cps_ir/finalize.dart
|
| diff --git a/pkg/compiler/lib/src/cps_ir/finalize.dart b/pkg/compiler/lib/src/cps_ir/finalize.dart
|
| index 1406a58829e55089964079d6f78ddaf9c8749228..7e3b6e15b2658daed66b59f6aa07e64ac74521d4 100644
|
| --- a/pkg/compiler/lib/src/cps_ir/finalize.dart
|
| +++ b/pkg/compiler/lib/src/cps_ir/finalize.dart
|
| @@ -5,6 +5,7 @@ import 'cps_fragment.dart';
|
| import 'optimizers.dart' show Pass;
|
| import '../js_backend/js_backend.dart' show JavaScriptBackend;
|
| import '../js_backend/backend_helpers.dart';
|
| +import '../js/js.dart' as js;
|
|
|
| /// A transformation pass that must run immediately before the tree IR builder.
|
| ///
|
| @@ -78,4 +79,18 @@ class Finalize extends TrampolineRecursiveVisitor implements Pass {
|
| node..witness.unlink()..witness = null;
|
| }
|
| }
|
| +
|
| + void visitForeignCode(ForeignCode node) {
|
| + if (js.isIdentityTemplate(node.codeTemplate)) {
|
| + // The CPS builder replaces identity templates with refinements, except
|
| + // when the refined type is an array type. Some optimizations assume the
|
| + // type of an object is immutable, but the type of an array can change
|
| + // after allocation. After the finalize pass, this assumption is no
|
| + // longer needed, so we can replace the remaining idenitity templates.
|
| + Refinement refinement = new Refinement(
|
| + node.arguments.single.definition,
|
| + node.type)..type = node.type;
|
| + node.replaceWith(refinement);
|
| + }
|
| + }
|
| }
|
|
|