# HG changeset patch # Parent 7c3cd4824f94609d4ad714bea9c687227c641e63 # User Benjamin Peterson Bug 757676: implement default parameters in JaegerMonkey, r=bhackett diff --git a/js/src/jsanalyze.cpp b/js/src/jsanalyze.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; } diff --git a/js/src/methodjit/Compiler.cpp b/js/src/methodjit/Compiler.cpp --- 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)