vendor/tracemonkey/liveconnect/nsCLiveconnect.cpp in johnson-2.0.0.pre0 vs vendor/tracemonkey/liveconnect/nsCLiveconnect.cpp in johnson-2.0.0.pre1
- old
+ new
@@ -175,20 +175,41 @@
"", 0, "", 1);
JSPRINCIPALS_DROP(cx, jsprinc);
if (fun)
{
+ uintN nslots = 2 + JS_GetFunctionArity(fun);
+
JSScript *script = JS_GetFunctionScript(cx, fun);
- mFrame.fun = fun;
+ nslots += script->nslots;
+
+ jsval *argv;
+ argv = (jsval *) cx->malloc(nslots * sizeof(jsval));
+ if (!argv)
+ {
+ mPushResult = NS_ERROR_OUT_OF_MEMORY;
+ return;
+ }
+
+ JSObject *closure = JS_GetFunctionObject(fun);
+ argv[0] = OBJECT_TO_JSVAL(closure);
+ argv[1] = JSVAL_NULL;
+ memset(argv + 2, 0, (nslots - 2) * sizeof(jsval));
+
mFrame.script = script;
- mFrame.callee = JS_GetFunctionObject(fun);
- mFrame.scopeChain = JS_GetParent(cx, mFrame.callee);
- mFrame.down = cx->fp;
+ mFrame.fun = fun;
+ mFrame.argv = argv + 2;
+ mFrame.down = js_GetTopStackFrame(cx);
+ mFrame.scopeChain = OBJ_GET_PARENT(cx, closure);
+ if (script->nslots)
+ mFrame.slots = argv + nslots - 2;
+ // NB: JSOP_STOP_LENGTH == 1.
mRegs.pc = script->code + script->length - 1;
JS_ASSERT(static_cast<JSOp>(*mRegs.pc) == JSOP_STOP);
mRegs.sp = NULL;
mFrame.regs = &mRegs;
+
cx->fp = &mFrame;
}
else
mPushResult = NS_ERROR_OUT_OF_MEMORY;
}
@@ -211,9 +232,14 @@
mContext->fp = mFrame.down;
JS_EndRequest(mContext);
}
+extern "C" void
+jsj_LeaveTrace(JSContext *cx)
+{
+ js_LeaveTrace(cx);
+}
////////////////////////////////////////////////////////////////////////////
// from nsISupports and AggregatedQueryInterface:
// Thes macro expands to the aggregated query interface scheme.