Bug 899117 - Remove baseline IC for JSOP_REST in favor of a VM call. (r=djvj)
authorShu-yu Guo <shu@rfrn.org>
Fri, 02 Aug 2013 08:24:57 -0700
changeset 141145 0834a49b378d6175315b4e78fb9dc340cb039b7e
parent 141144 80fe42f29748b5f794c1028e02c9c5c34ccfb7dd
child 141146 56364871a2887fce84dcb44be001393e1a1f48c2
push idunknown
push userunknown
push dateunknown
reviewersdjvj
bugs899117
milestone25.0a1
Bug 899117 - Remove baseline IC for JSOP_REST in favor of a VM call. (r=djvj)
js/src/ion/BaselineCompiler.cpp
js/src/ion/BaselineIC.cpp
js/src/ion/BaselineIC.h
--- a/js/src/ion/BaselineCompiler.cpp
+++ b/js/src/ion/BaselineCompiler.cpp
@@ -2739,20 +2739,43 @@ BaselineCompiler::emit_JSOP_RUNONCE()
     prepareVMCall();
 
     masm.movePtr(ImmGCPtr(script), R0.scratchReg());
     pushArg(R0.scratchReg());
 
     return callVM(RunOnceScriptPrologueInfo);
 }
 
+static bool
+DoCreateRestParameter(JSContext *cx, BaselineFrame *frame, MutableHandleValue res)
+{
+    unsigned numFormals = frame->numFormalArgs() - 1;
+    unsigned numActuals = frame->numActualArgs();
+    unsigned numRest = numActuals > numFormals ? numActuals - numFormals : 0;
+    Value *rest = frame->argv() + numFormals;
+
+    JSObject *obj = NewDenseCopiedArray(cx, numRest, rest, NULL);
+    if (!obj)
+        return false;
+    types::FixRestArgumentsType(cx, obj);
+    res.setObject(*obj);
+    return true;
+}
+
+typedef bool(*DoCreateRestParameterFn)(JSContext *cx, BaselineFrame *, MutableHandleValue);
+static const VMFunction DoCreateRestParameterInfo =
+    FunctionInfo<DoCreateRestParameterFn>(DoCreateRestParameter);
+
 bool
 BaselineCompiler::emit_JSOP_REST()
 {
     frame.syncStack(0);
 
-    ICRest_Fallback::Compiler stubCompiler(cx);
-    if (!emitOpIC(stubCompiler.getStub(&stubSpace_)))
+    prepareVMCall();
+    masm.loadBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
+    pushArg(R0.scratchReg());
+
+    if (!callVM(DoCreateRestParameterInfo))
         return false;
 
     frame.push(R0);
     return true;
 }
--- a/js/src/ion/BaselineIC.cpp
+++ b/js/src/ion/BaselineIC.cpp
@@ -8192,55 +8192,16 @@ ICTypeOf_Typed::Compiler::generateStubCo
     masm.tagValue(JSVAL_TYPE_STRING, R0.scratchReg(), R0);
     EmitReturnFromIC(masm);
 
     masm.bind(&failure);
     EmitStubGuardFailure(masm);
     return true;
 }
 
-//
-// Rest_Fallback
-//
-
-static bool
-DoCreateRestParameter(JSContext *cx, BaselineFrame *frame, ICRest_Fallback *stub,
-                      MutableHandleValue res)
-{
-    FallbackICSpew(cx, stub, "Rest");
-
-    unsigned numFormals = frame->numFormalArgs() - 1;
-    unsigned numActuals = frame->numActualArgs();
-    unsigned numRest = numActuals > numFormals ? numActuals - numFormals : 0;
-    Value *rest = frame->argv() + numFormals;
-
-    JSObject *obj = NewDenseCopiedArray(cx, numRest, rest, NULL);
-    if (!obj)
-        return false;
-    types::FixRestArgumentsType(cx, obj);
-    res.setObject(*obj);
-    return true;
-}
-
-typedef bool(*DoCreateRestParameterFn)(JSContext *cx, BaselineFrame *, ICRest_Fallback *,
-                                       MutableHandleValue);
-static const VMFunction DoCreateRestParameterInfo =
-    FunctionInfo<DoCreateRestParameterFn>(DoCreateRestParameter);
-
-bool
-ICRest_Fallback::Compiler::generateStubCode(MacroAssembler &masm)
-{
-    EmitRestoreTailCallReg(masm);
-
-    masm.push(BaselineStubReg); // stub
-    masm.pushBaselineFramePtr(BaselineFrameReg, R0.scratchReg()); // frame pointer
-
-    return tailCallVM(DoCreateRestParameterInfo, masm);
-}
-
 static bool
 DoRetSubFallback(JSContext *cx, BaselineFrame *frame, ICRetSub_Fallback *stub,
                  HandleValue val, uint8_t **resumeAddr)
 {
     FallbackICSpew(cx, stub, "RetSub");
 
     // |val| is the bytecode offset where we should resume.
 
--- a/js/src/ion/BaselineIC.h
+++ b/js/src/ion/BaselineIC.h
@@ -5522,48 +5522,16 @@ class ICTypeOf_Typed : public ICFallback
         { }
 
         ICStub *getStub(ICStubSpace *space) {
             return ICTypeOf_Typed::New(space, getStubCode(), type_);
         }
     };
 };
 
-// Rest
-//      JSOP_REST
-class ICRest_Fallback : public ICFallbackStub
-{
-    friend class ICStubSpace;
-
-    ICRest_Fallback(IonCode *stubCode)
-      : ICFallbackStub(ICStub::Rest_Fallback, stubCode)
-    { }
-
-  public:
-    static inline ICRest_Fallback *New(ICStubSpace *space, IonCode *code) {
-        if (!code)
-            return NULL;
-        return space->allocate<ICRest_Fallback>(code);
-    }
-
-    class Compiler : public ICStubCompiler {
-      protected:
-        bool generateStubCode(MacroAssembler &masm);
-
-      public:
-        Compiler(JSContext *cx)
-          : ICStubCompiler(cx, ICStub::Rest_Fallback)
-        { }
-
-        ICStub *getStub(ICStubSpace *space) {
-            return ICRest_Fallback::New(space, getStubCode());
-        }
-    };
-};
-
 // Stub for JSOP_RETSUB ("returning" from a |finally| block).
 class ICRetSub_Fallback : public ICFallbackStub
 {
     friend class ICStubSpace;
 
     ICRetSub_Fallback(IonCode *stubCode)
       : ICFallbackStub(ICStub::RetSub_Fallback, stubCode)
     { }