Bug 798946 - Confer with TI about the return type of Math.random(). r=dvander, a=bajaj
authorSean Stangl <sstangl@mozilla.com>
Wed, 10 Oct 2012 17:07:53 -0700
changeset 116234 dbcf231295069fe5cc95e6411a3912127f6c85a6
parent 116233 e1ac6983fa36fb062e35c5073837681b7d9e1e6d
child 116235 6f7d1e8c941bbbd1bb4e826d95ab52f8a9bad5d8
push id1708
push userakeybl@mozilla.com
push dateMon, 19 Nov 2012 21:10:21 +0000
treeherdermozilla-beta@27b14fe50103 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander, bajaj
bugs798946
milestone18.0a2
Bug 798946 - Confer with TI about the return type of Math.random(). r=dvander, a=bajaj
js/src/ion/MCallOptimize.cpp
js/src/jit-test/tests/ion/bug798946.js
--- a/js/src/ion/MCallOptimize.cpp
+++ b/js/src/ion/MCallOptimize.cpp
@@ -621,16 +621,19 @@ IonBuilder::inlineMathPow(uint32 argc, b
 }
 
 IonBuilder::InliningStatus
 IonBuilder::inlineMathRandom(uint32 argc, bool constructing)
 {
     if (constructing)
         return InliningStatus_NotInlined;
 
+    if (getInlineReturnType() != MIRType_Double)
+        return InliningStatus_NotInlined;
+
     MDefinitionVector argv;
     if (!discardCall(argc, argv, current))
         return InliningStatus_Error;
 
     MRandom *rand = MRandom::New();
     current->add(rand);
     current->push(rand);
     return InliningStatus_Inlined;
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/ion/bug798946.js
@@ -0,0 +1,16 @@
+// Don't assert with --ion-eager.
+function RandBool() { var x = Math.random() >= 0.5; return x; }
+var CHARS = "aaa";
+function RandStr() {
+  var c = Math.floor(Math.random() * CHARS.length);
+}
+function RandVal() { 
+  return RandBool() ? RandStr() : RandStr(); 
+}
+function GenerateSpecPermutes(matchVals, resultArray) {
+    var maxPermuteBody = (1 << matchVals.length) - 1;
+    for(var bod_pm = 0; bod_pm <= maxPermuteBody; bod_pm++)
+      for(var k = 0; k < matchVals.length; k++)
+        var body = ((bod_pm & (1 << k)) > 0) ? null : RandVal();
+}
+GenerateSpecPermutes(["foo", "bar", "zing"]);