Version 1.1.2 (stable)

svn merge -c 31844 https://dart.googlecode.com/svn/branches/bleeding_edge 1.1
svn merge -c 31858 https://dart.googlecode.com/svn/branches/bleeding_edge 1.1
svn merge -c 31862 https://dart.googlecode.com/svn/branches/bleeding_edge 1.1

R=kasperl@google.com

Review URL: https://codereview.chromium.org//137143015

git-svn-id: http://dart.googlecode.com/svn/branches/1.1@32062 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/runtime/vm/code_generator.cc b/runtime/vm/code_generator.cc
index d838eff..f2290dd 100644
--- a/runtime/vm/code_generator.cc
+++ b/runtime/vm/code_generator.cc
@@ -1412,6 +1412,9 @@
   ASSERT(function.HasCode());
 
   if (CanOptimizeFunction(function, isolate)) {
+    // Reset usage counter for reoptimization before calling optimizer to
+    // prevent recursive triggering of function optimization.
+    function.set_usage_counter(0);
     const Error& error =
         Error::Handle(Compiler::CompileOptimizedFunction(function));
     if (!error.IsNull()) {
@@ -1419,8 +1422,6 @@
     }
     const Code& optimized_code = Code::Handle(function.CurrentCode());
     ASSERT(!optimized_code.IsNull());
-    // Reset usage counter for reoptimization.
-    function.set_usage_counter(0);
   }
   arguments.SetReturn(Code::Handle(function.CurrentCode()));
 }
diff --git a/runtime/vm/flow_graph_optimizer.cc b/runtime/vm/flow_graph_optimizer.cc
index d488c48..55d37bc 100644
--- a/runtime/vm/flow_graph_optimizer.cc
+++ b/runtime/vm/flow_graph_optimizer.cc
@@ -369,6 +369,10 @@
         curr_instr->ReplaceWith(div_mod, current_iterator());
         other_binop->ReplaceUsesWith(div_mod);
         other_binop->RemoveFromGraph();
+        // Only one merge possible. Because canonicalization happens later,
+        // more candidates are possible.
+        // TODO(srdjan): Allow merging of trunc-div/mod into truncDivMod.
+        break;
       }
     }
   }
@@ -415,14 +419,18 @@
         ZoneGrowableArray<Value*>* args = new ZoneGrowableArray<Value*>(1);
         args->Add(new Value(curr_instr->value()->definition()));
 
-        // Replace with TruncDivMod.
-        MergedMathInstr* div_mod = new MergedMathInstr(
+        // Replace with SinCos.
+        MergedMathInstr* sin_cos = new MergedMathInstr(
             args,
             curr_instr->DeoptimizationTarget(),
             MergedMathInstr::kSinCos);
-        curr_instr->ReplaceWith(div_mod, current_iterator());
-        other_op->ReplaceUsesWith(div_mod);
+        curr_instr->ReplaceWith(sin_cos, current_iterator());
+        other_op->ReplaceUsesWith(sin_cos);
         other_op->RemoveFromGraph();
+        // Only one merge possible. Because canonicalization happens later,
+        // more candidates are possible.
+        // TODO(srdjan): Allow merging of sin/cos into sincos.
+        break;
       }
     }
   }
diff --git a/tests/language/arithmetic_test.dart b/tests/language/arithmetic_test.dart
index e43dc4a..64ab133 100644
--- a/tests/language/arithmetic_test.dart
+++ b/tests/language/arithmetic_test.dart
@@ -435,10 +435,15 @@
   
   static double sinCosSub(double a) => sin(a) - cos(a);
   
+  static double sinCosAddCos(double a)  => sin(a) * cos(a) + cos(a);
+
   static void testSinCos() {
     var e = sin(1.234) - cos(1.234);
+    var f = sin(1.234) * cos(1.234) + cos(1.234);
+    
     for (var i = 0; i < 20; i++) {
       Expect.approxEquals(e, sinCosSub(1.234));
+      Expect.approxEquals(f, sinCosAddCos(1.234));
     }
     Expect.approxEquals(1.0, sinCosSub(3.14159265));
     Expect.approxEquals(1.0, sinCosSub(3.14159265 / 2.0));
diff --git a/tests/language/modulo_test.dart b/tests/language/modulo_test.dart
index 6dc22cf..f14d3c5 100644
--- a/tests/language/modulo_test.dart
+++ b/tests/language/modulo_test.dart
@@ -24,7 +24,7 @@
     } else {
       Expect.equals(i ~/ 10, noDom(i));
     }
-    Expect.equals((i ~/ 10) + (i ~/ 10) + (i % 10), threeOp(i));
+    Expect.equals((i ~/ 10) + (i % 10) + (i % 10), threeOp(i));
     Expect.equals((i ~/ 10) + (i ~/ 12) + (i % 10) + (i % 12), fourOp(i));
     
     // Zero test is done outside the loop.
@@ -60,7 +60,7 @@
 
 threeOp(a) {
   var x = a ~/ 10;
-  var y = a ~/ 10;
+  var y = a % 10;
   var z = a % 10;
   return x + y + z;
 }
diff --git a/tools/VERSION b/tools/VERSION
index 2d6a7b4..d0a7398 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -26,6 +26,6 @@
 CHANNEL stable
 MAJOR 1
 MINOR 1
-PATCH 1
+PATCH 2
 PRERELEASE 0
 PRERELEASE_PATCH 0