Bug 613732 - Fix bug in f.apply(x, arguments) optimization (r=dvander, a=b8+)
authorLuke Wagner <lw@mozilla.com>
Tue, 23 Nov 2010 18:20:56 -0800
changeset 58124 64c4716a72dd8d53e09b25b99c3540c8b98caaeb
parent 58123 9c3babe383e147c4ec8e1fb11462fd0425d49c42
child 58125 66d88ee2623736105f7da1add40adb871fb33208
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersdvander, b8
bugs613732
milestone2.0b8pre
Bug 613732 - Fix bug in f.apply(x, arguments) optimization (r=dvander, a=b8+)
js/src/jit-test/tests/basic/testApplyAtJoinPoint.js
js/src/methodjit/Compiler.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/testApplyAtJoinPoint.js
@@ -0,0 +1,12 @@
+var isTrue = true;
+
+function g(x) {
+    return x;
+}
+
+function f() {
+    return g.apply(null, isTrue ? ["happy"] : arguments);
+}
+
+for (var i = 0; i < HOTLOOP + 10; ++i)
+    assertEq(f("sad"), "happy");
--- a/js/src/methodjit/Compiler.cpp
+++ b/js/src/methodjit/Compiler.cpp
@@ -2469,16 +2469,17 @@ mjit::Compiler::checkCallApplySpeculatio
 /* This predicate must be called before the current op mutates the FrameState. */
 bool
 mjit::Compiler::canUseApplyTricks()
 {
     JS_ASSERT(*PC == JSOP_ARGUMENTS);
     jsbytecode *nextpc = PC + JSOP_ARGUMENTS_LENGTH;
     return *nextpc == JSOP_FUNAPPLY &&
            IsLowerableFunCallOrApply(nextpc) &&
+           !analysis->jumpTarget(nextpc) &&
            !debugMode();
 }
 
 /* See MonoIC.cpp, CallCompiler for more information on call ICs. */
 void
 mjit::Compiler::inlineCallHelper(uint32 callImmArgc, bool callingNew)
 {
     /* Check for interrupts on function call */