Merge revision r14430 to trunk. Do not evaluate arguments of an instance send if that instance send is being inlined. The inliner will take care of evaluating them. Review URL: https://codereview.chromium.org//11275122 git-svn-id: http://dart.googlecode.com/svn/trunk@14458 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/lib/compiler/implementation/ssa/builder.dart b/lib/compiler/implementation/ssa/builder.dart index 2dbd9a3..50b8006 100644 --- a/lib/compiler/implementation/ssa/builder.dart +++ b/lib/compiler/implementation/ssa/builder.dart
@@ -2558,6 +2558,13 @@ return; } + Element element = elements[node]; + if (element != null && compiler.world.hasNoOverridingMember(element)) { + if (tryInlineMethod(element, selector, node.arguments)) { + return; + } + } + if (node.receiver == null) { inputs.add(localsHandler.readThis()); } else { @@ -2566,13 +2573,6 @@ } addDynamicSendArgumentsToList(node, inputs); - - Element element = elements[node]; - if (element != null && compiler.world.hasNoOverridingMember(element)) { - if (tryInlineMethod(element, selector, node.arguments)) { - return; - } - } // The first entry in the inputs list is the receiver. pushWithPosition(new HInvokeDynamicMethod(selector, inputs), node);
diff --git a/tests/language/inline_argument_test.dart b/tests/language/inline_argument_test.dart new file mode 100644 index 0000000..a04786f --- /dev/null +++ b/tests/language/inline_argument_test.dart
@@ -0,0 +1,24 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// Test that when inlining A.foo, we're not evaluating the argument +// twice. + +class A { + var field = 0; + + foo(b) { + Expect.equals(0, b); + Expect.equals(0, b); + } + + bar() { + foo(field++); + } +} + +main() { + var a = new A(); + a.bar(); + Expect.equals(1, a.field); +}
diff --git a/tools/VERSION b/tools/VERSION index 34007a7..91a307d 100644 --- a/tools/VERSION +++ b/tools/VERSION
@@ -1,4 +1,4 @@ MAJOR 0 MINOR 2 BUILD 2 -PATCH 0 +PATCH 1