Bug 826262 - Compile JSOP_DEFFUN. r=djvj
authorJan de Mooij <jdemooij@mozilla.com>
Tue, 08 Jan 2013 14:00:25 +0100
changeset 118180 dbf51649364fe4f8587446b28c356a29f52111dc
parent 118179 34491ef80d4c8bd669f47dbf79079150b2ca25de
child 118181 618c1544ac42ef06b182634a8e2de4506d260797
push id1430
push userjandemooij@gmail.com
push dateTue, 08 Jan 2013 13:16:47 +0000
reviewersdjvj
bugs826262
milestone21.0a1
Bug 826262 - Compile JSOP_DEFFUN. r=djvj
js/src/ion/BaselineCompiler.cpp
js/src/ion/BaselineCompiler.h
--- a/js/src/ion/BaselineCompiler.cpp
+++ b/js/src/ion/BaselineCompiler.cpp
@@ -1166,16 +1166,36 @@ BaselineCompiler::emit_JSOP_DEFVAR()
 }
 
 bool
 BaselineCompiler::emit_JSOP_DEFCONST()
 {
     return emit_JSOP_DEFVAR();
 }
 
+typedef bool (*DefFunOperationFn)(JSContext *, HandleScript, HandleObject, HandleFunction);
+static const VMFunction DefFunOperationInfo = FunctionInfo<DefFunOperationFn>(DefFunOperation);
+
+bool
+BaselineCompiler::emit_JSOP_DEFFUN()
+{
+    RootedFunction fun(cx, script->getFunction(GET_UINT32_INDEX(pc)));
+
+    frame.syncStack(0);
+    masm.loadPtr(frame.addressOfScopeChain(), R0.scratchReg());
+
+    prepareVMCall();
+
+    pushArg(ImmGCPtr(fun));
+    pushArg(R0.scratchReg());
+    pushArg(ImmGCPtr(script));
+
+    return callVM(DefFunOperationInfo);
+}
+
 bool
 BaselineCompiler::emit_JSOP_GETLOCAL()
 {
     uint32_t local = GET_SLOTNO(pc);
 
     if (local >= frame.nlocals()) {
         // Destructuring assignments may use GETLOCAL to access stack values.
         frame.syncStack(0);
--- a/js/src/ion/BaselineCompiler.h
+++ b/js/src/ion/BaselineCompiler.h
@@ -95,16 +95,17 @@ namespace ion {
     _(JSOP_SETGNAME)           \
     _(JSOP_SETNAME)            \
     _(JSOP_GETPROP)            \
     _(JSOP_SETPROP)            \
     _(JSOP_CALLPROP)           \
     _(JSOP_LENGTH)             \
     _(JSOP_DEFVAR)             \
     _(JSOP_DEFCONST)           \
+    _(JSOP_DEFFUN)             \
     _(JSOP_GETLOCAL)           \
     _(JSOP_CALLLOCAL)          \
     _(JSOP_SETLOCAL)           \
     _(JSOP_GETARG)             \
     _(JSOP_CALLARG)            \
     _(JSOP_SETARG)             \
     _(JSOP_CALL)               \
     _(JSOP_FUNCALL)            \