Bug 757676: implement default parameters in JaegerMonkey, r=bhackett
authorBenjamin Peterson <benjamin@python.org>
Sat, 02 Jun 2012 20:16:24 +0200
changeset 99699 8247bd0ca0379fadc6964ca70453b0d506aee4f1
parent 99698 2f02e08e634c006e7133219ce9c4ceca96ae100e
child 99700 70acf458a32da33d6a703a49f7b3032a8b4308a4
push idunknown
push userunknown
push dateunknown
reviewersbhackett
bugs757676
milestone15.0a1
Bug 757676: implement default parameters in JaegerMonkey, r=bhackett
js/src/jsanalyze.cpp
js/src/methodjit/Compiler.cpp
--- a/js/src/jsanalyze.cpp
+++ b/js/src/jsanalyze.cpp
@@ -584,16 +584,17 @@ ScriptAnalysis::analyzeBytecode(JSContex
           case JSOP_OBJECT:
           case JSOP_UINT24:
           case JSOP_GETXPROP:
           case JSOP_INT8:
           case JSOP_INT32:
           case JSOP_HOLE:
           case JSOP_LOOPHEAD:
           case JSOP_LOOPENTRY:
+          case JSOP_ACTUALSFILLED:
             break;
 
           default:
             if (!(js_CodeSpec[op].format & JOF_DECOMPOSE))
                 isJaegerCompileable = isInlineable = false;
             break;
         }
 
--- a/js/src/methodjit/Compiler.cpp
+++ b/js/src/methodjit/Compiler.cpp
@@ -2248,16 +2248,35 @@ mjit::Compiler::generateMethod()
             if (script->needsArgsObj()) {
                 prepareStubCall(Uses(0));
                 INLINE_STUBCALL(stubs::Arguments, REJOIN_FALLTHROUGH);
                 pushSyncedEntry(0);
             } else {
                 frame.push(MagicValue(JS_OPTIMIZED_ARGUMENTS));
             }
           END_CASE(JSOP_ARGUMENTS)
+          BEGIN_CASE(JSOP_ACTUALSFILLED)
+          {
+
+            // We never inline things with defaults because of the switch.
+            JS_ASSERT(a == outer);
+            RegisterID value = frame.allocReg(), nactual = frame.allocReg();
+            int32_t defstart = GET_UINT16(PC);
+            masm.move(Imm32(defstart), value);
+            masm.load32(Address(JSFrameReg, StackFrame::offsetOfNumActual()), nactual);
+
+            // Best would be a single instruction where available (like
+            // cmovge on x86), but there's no way get that yet, so jump.
+            Jump j = masm.branch32(Assembler::LessThan, nactual, Imm32(defstart));
+            masm.move(nactual, value);
+            j.linkTo(masm.label(), &masm);
+            frame.freeReg(nactual);
+            frame.pushInt32(value);
+          }
+          END_CASE(JSOP_ACTUALSFILLED)
 
           BEGIN_CASE(JSOP_ITERNEXT)
             iterNext(GET_INT8(PC));
           END_CASE(JSOP_ITERNEXT)
 
           BEGIN_CASE(JSOP_DUP)
             frame.dup();
           END_CASE(JSOP_DUP)