Bug 904827 - Part 1: Rename OOLNativeGetterExitFrame to OOLNativeExitFrame. (r=djvj)
authorEric Faust <efaustbmo@gmail.com>
Fri, 30 Aug 2013 18:50:36 -0700
changeset 153137 587ec77a2373eb139f94141d76b6229f602ae5e4
parent 153136 c59d6e7fdee5310c270e82ecde0ed62fb8de1e80
child 153138 6f82c0e76f2d2039a5c85b1f51f8efec767d0f32
push idunknown
push userunknown
push dateunknown
reviewersdjvj
bugs904827
milestone26.0a1
Bug 904827 - Part 1: Rename OOLNativeGetterExitFrame to OOLNativeExitFrame. (r=djvj)
js/src/jit/IonCaches.cpp
js/src/jit/IonFrameIterator.h
js/src/jit/IonFrames.cpp
js/src/jit/arm/IonFrames-arm.h
js/src/jit/shared/IonFrames-shared.h
js/src/jit/shared/IonFrames-x86-shared.h
--- a/js/src/jit/IonCaches.cpp
+++ b/js/src/jit/IonCaches.cpp
@@ -849,18 +849,16 @@ EmitGetterCall(JSContext *cx, MacroAssem
 
     // Shape has a getter function.
     bool callNative = IsCacheableGetPropCallNative(obj, holder, shape);
     JS_ASSERT_IF(!callNative, IsCacheableGetPropCallPropertyOp(obj, holder, shape));
 
     // TODO: ensure stack is aligned?
     DebugOnly<uint32_t> initialStack = masm.framePushed();
 
-    attacher.pushStubCodePointer(masm);
-
     if (callNative) {
         JS_ASSERT(shape->hasGetterValue() && shape->getterValue().isObject() &&
                   shape->getterValue().toObject().is<JSFunction>());
         JSFunction *target = &shape->getterValue().toObject().as<JSFunction>();
 
         JS_ASSERT(target);
         JS_ASSERT(target->isNative());
 
@@ -875,40 +873,48 @@ EmitGetterCall(JSContext *cx, MacroAssem
         // Push callee/outparam.
         masm.Push(ObjectValue(*target));
 
         // Preload arguments into registers.
         masm.loadJSContext(argJSContextReg);
         masm.move32(Imm32(0), argUintNReg);
         masm.movePtr(StackPointer, argVpReg);
 
+        // Push marking data for later use.
+        masm.Push(argUintNReg);
+        attacher.pushStubCodePointer(masm);
+
         if (!masm.buildOOLFakeExitFrame(returnAddr))
             return false;
-        masm.enterFakeExitFrame(ION_FRAME_OOL_NATIVE_GETTER);
+        masm.enterFakeExitFrame(ION_FRAME_OOL_NATIVE);
 
         // Construct and execute call.
         masm.setupUnalignedABICall(3, scratchReg);
         masm.passABIArg(argJSContextReg);
         masm.passABIArg(argUintNReg);
         masm.passABIArg(argVpReg);
         masm.callWithABI(JS_FUNC_TO_DATA_PTR(void *, target->native()));
 
         // Test for failure.
         masm.branchIfFalseBool(ReturnReg, masm.exceptionLabel());
 
         // Load the outparam vp[0] into output register(s).
         masm.loadValue(
-            Address(StackPointer, IonOOLNativeGetterExitFrameLayout::offsetOfResult()),
+            Address(StackPointer, IonOOLNativeExitFrameLayout::offsetOfResult()),
             JSReturnOperand);
     } else {
         Register argObjReg       = argUintNReg;
         Register argIdReg        = regSet.takeGeneral();
 
         PropertyOp target = shape->getterOp();
         JS_ASSERT(target);
+
+        // Push stubCode for marking.
+        attacher.pushStubCodePointer(masm);
+
         // JSPropertyOp: bool fn(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue vp)
 
         // Push args on stack first so we can take pointers to make handles.
         masm.Push(UndefinedValue());
         masm.movePtr(StackPointer, argVpReg);
 
         // push canonical jsid from shape instead of propertyname.
         RootedId propId(cx);
@@ -947,17 +953,17 @@ EmitGetterCall(JSContext *cx, MacroAssem
     // to MIRType_Value.
     masm.storeCallResultValue(output);
 
     // The next instruction is removing the footer of the exit frame, so there
     // is no need for leaveFakeExitFrame.
 
     // Move the StackPointer back to its original location, unwinding the native exit frame.
     if (callNative)
-        masm.adjustStack(IonOOLNativeGetterExitFrameLayout::Size());
+        masm.adjustStack(IonOOLNativeExitFrameLayout::Size(0));
     else
         masm.adjustStack(IonOOLPropertyOpExitFrameLayout::Size());
     JS_ASSERT(masm.framePushed() == initialStack);
 
     // restoreLive()
     masm.PopRegsInMask(liveRegs);
 
     return true;
--- a/js/src/jit/IonFrameIterator.h
+++ b/js/src/jit/IonFrameIterator.h
@@ -138,17 +138,17 @@ class IonFrameIterator
     }
     bool isOptimizedJS() const {
         return type_ == IonFrame_OptimizedJS;
     }
     bool isBaselineStub() const {
         return type_ == IonFrame_BaselineStub;
     }
     bool isNative() const;
-    bool isOOLNativeGetter() const;
+    bool isOOLNative() const;
     bool isOOLPropertyOp() const;
     bool isOOLProxyGet() const;
     bool isDOMExit() const;
     bool isEntry() const {
         return type_ == IonFrame_Entry;
     }
     bool isFunctionFrame() const;
     bool isParallelFunctionFrame() const;
--- a/js/src/jit/IonFrames.cpp
+++ b/js/src/jit/IonFrames.cpp
@@ -112,21 +112,21 @@ bool
 IonFrameIterator::isNative() const
 {
     if (type_ != IonFrame_Exit || isFakeExitFrame())
         return false;
     return exitFrame()->footer()->ionCode() == NULL;
 }
 
 bool
-IonFrameIterator::isOOLNativeGetter() const
+IonFrameIterator::isOOLNative() const
 {
     if (type_ != IonFrame_Exit)
         return false;
-    return exitFrame()->footer()->ionCode() == ION_FRAME_OOL_NATIVE_GETTER;
+    return exitFrame()->footer()->ionCode() == ION_FRAME_OOL_NATIVE;
 }
 
 bool
 IonFrameIterator::isOOLPropertyOp() const
 {
     if (type_ != IonFrame_Exit)
         return false;
     return exitFrame()->footer()->ionCode() == ION_FRAME_OOL_PROPERTY_OP;
@@ -901,21 +901,22 @@ MarkIonExitFrame(JSTracer *trc, const Io
     if (frame.isNative()) {
         IonNativeExitFrameLayout *native = frame.exitFrame()->nativeExit();
         size_t len = native->argc() + 2;
         Value *vp = native->vp();
         gc::MarkValueRootRange(trc, len, vp, "ion-native-args");
         return;
     }
 
-    if (frame.isOOLNativeGetter()) {
-        IonOOLNativeGetterExitFrameLayout *oolgetter = frame.exitFrame()->oolNativeGetterExit();
-        gc::MarkIonCodeRoot(trc, oolgetter->stubCode(), "ion-ool-getter-code");
-        gc::MarkValueRoot(trc, oolgetter->vp(), "ion-ool-getter-callee");
-        gc::MarkValueRoot(trc, oolgetter->thisp(), "ion-ool-getter-this");
+    if (frame.isOOLNative()) {
+        IonOOLNativeExitFrameLayout *oolnative = frame.exitFrame()->oolNativeExit();
+        gc::MarkIonCodeRoot(trc, oolnative->stubCode(), "ion-ool-native-code");
+        gc::MarkValueRoot(trc, oolnative->vp(), "iol-ool-native-vp");
+        size_t len = oolnative->argc() + 1;
+        gc::MarkValueRootRange(trc, len, oolnative->thisp(), "ion-ool-native-thisargs");
         return;
     }
 
     if (frame.isOOLPropertyOp()) {
         IonOOLPropertyOpExitFrameLayout *oolgetter = frame.exitFrame()->oolPropertyOpExit();
         gc::MarkIonCodeRoot(trc, oolgetter->stubCode(), "ion-ool-property-op-code");
         gc::MarkValueRoot(trc, oolgetter->vp(), "ion-ool-property-op-vp");
         gc::MarkIdRoot(trc, oolgetter->id(), "ion-ool-property-op-id");
--- a/js/src/jit/arm/IonFrames-arm.h
+++ b/js/src/jit/arm/IonFrames-arm.h
@@ -185,17 +185,17 @@ class IonBaselineStubFrameLayout : publi
 
     inline ICStub *maybeStubPtr() {
         uint8_t *fp = reinterpret_cast<uint8_t *>(this);
         return *reinterpret_cast<ICStub **>(fp + reverseOffsetOfStubPtr());
     }
 };
 
 class IonNativeExitFrameLayout;
-class IonOOLNativeGetterExitFrameLayout;
+class IonOOLNativeExitFrameLayout;
 class IonOOLPropertyOpExitFrameLayout;
 class IonOOLProxyGetExitFrameLayout;
 class IonDOMExitFrameLayout;
 
 // this is the frame layout when we are exiting ion code, and about to enter EABI code
 class IonExitFrameLayout : public IonCommonFrameLayout
 {
     inline uint8_t *top() {
@@ -224,18 +224,18 @@ class IonExitFrameLayout : public IonCom
     }
 
     inline bool isWrapperExit() {
         return footer()->function() != NULL;
     }
     inline bool isNativeExit() {
         return footer()->ionCode() == NULL;
     }
-    inline bool isOOLNativeGetterExit() {
-        return footer()->ionCode() == ION_FRAME_OOL_NATIVE_GETTER;
+    inline bool isOOLNativeExit() {
+        return footer()->ionCode() == ION_FRAME_OOL_NATIVE;
     }
     inline bool isOOLPropertyOpExit() {
         return footer()->ionCode() == ION_FRAME_OOL_PROPERTY_OP;
     }
     inline bool isOOLProxyGetExit() {
         return footer()->ionCode() == ION_FRAME_OOL_PROXY_GET;
     }
     inline bool isDomExit() {
@@ -246,19 +246,19 @@ class IonExitFrameLayout : public IonCom
             code == ION_FRAME_DOMMETHOD;
     }
 
     inline IonNativeExitFrameLayout *nativeExit() {
         // see CodeGenerator::visitCallNative
         JS_ASSERT(isNativeExit());
         return reinterpret_cast<IonNativeExitFrameLayout *>(footer());
     }
-    inline IonOOLNativeGetterExitFrameLayout *oolNativeGetterExit() {
-        JS_ASSERT(isOOLNativeGetterExit());
-        return reinterpret_cast<IonOOLNativeGetterExitFrameLayout *>(footer());
+    inline IonOOLNativeExitFrameLayout *oolNativeExit() {
+        JS_ASSERT(isOOLNativeExit());
+        return reinterpret_cast<IonOOLNativeExitFrameLayout *>(footer());
     }
     inline IonOOLPropertyOpExitFrameLayout *oolPropertyOpExit() {
         JS_ASSERT(isOOLPropertyOpExit());
         return reinterpret_cast<IonOOLPropertyOpExitFrameLayout *>(footer());
     }
     inline IonOOLProxyGetExitFrameLayout *oolProxyGetExit() {
         JS_ASSERT(isOOLProxyGetExit());
         return reinterpret_cast<IonOOLProxyGetExitFrameLayout *>(footer());
@@ -293,53 +293,56 @@ class IonNativeExitFrameLayout
     inline Value *vp() {
         return reinterpret_cast<Value*>(&loCalleeResult_);
     }
     inline uintptr_t argc() const {
         return argc_;
     }
 };
 
-class IonOOLNativeGetterExitFrameLayout
+class IonOOLNativeExitFrameLayout
 {
     IonExitFooterFrame footer_;
     IonExitFrameLayout exit_;
 
+    // pointer to root the stub's IonCode
+    IonCode *stubCode_;
+
+    uintptr_t argc_;
+
     // We need to split the Value into 2 fields of 32 bits, otherwise the C++
     // compiler may add some padding between the fields.
     uint32_t loCalleeResult_;
     uint32_t hiCalleeResult_;
 
-    // The frame includes the object argument.
+    // Split Value for |this| and args above.
     uint32_t loThis_;
     uint32_t hiThis_;
 
-    // pointer to root the stub's IonCode
-    IonCode *stubCode_;
-
   public:
-    static inline size_t Size() {
-        return sizeof(IonOOLNativeGetterExitFrameLayout);
+    static inline size_t Size(size_t argc) {
+        // The frame accounts for the callee/result and |this|, so we only need args.
+        return sizeof(IonOOLNativeExitFrameLayout) + (argc * sizeof(Value));
     }
 
     static size_t offsetOfResult() {
-        return offsetof(IonOOLNativeGetterExitFrameLayout, loCalleeResult_);
+        return offsetof(IonOOLNativeExitFrameLayout, loCalleeResult_);
     }
 
     inline IonCode **stubCode() {
         return &stubCode_;
     }
     inline Value *vp() {
         return reinterpret_cast<Value*>(&loCalleeResult_);
     }
     inline Value *thisp() {
         return reinterpret_cast<Value*>(&loThis_);
     }
     inline uintptr_t argc() const {
-        return 0;
+        return argc_;
     }
 };
 
 class IonOOLPropertyOpExitFrameLayout
 {
     IonExitFooterFrame footer_;
     IonExitFrameLayout exit_;
 
--- a/js/src/jit/shared/IonFrames-shared.h
+++ b/js/src/jit/shared/IonFrames-shared.h
@@ -5,13 +5,13 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef jit_shared_IonFrames_shared_h
 #define jit_shared_IonFrames_shared_h
 
 #define ION_FRAME_DOMGETTER ((IonCode *)0x1)
 #define ION_FRAME_DOMSETTER ((IonCode *)0x2)
 #define ION_FRAME_DOMMETHOD ((IonCode *)0x3)
-#define ION_FRAME_OOL_NATIVE_GETTER ((IonCode *)0x4)
+#define ION_FRAME_OOL_NATIVE        ((IonCode *)0x4)
 #define ION_FRAME_OOL_PROPERTY_OP   ((IonCode *)0x5)
 #define ION_FRAME_OOL_PROXY_GET     ((IonCode *)0x6)
 
 #endif /* jit_shared_IonFrames_shared_h */
--- a/js/src/jit/shared/IonFrames-x86-shared.h
+++ b/js/src/jit/shared/IonFrames-x86-shared.h
@@ -151,17 +151,17 @@ class IonExitFooterFrame
     // This should only be called for function()->outParam == Type_Handle
     template <typename T>
     T *outParam() {
         return reinterpret_cast<T *>(reinterpret_cast<char *>(this) - sizeof(T));
     }
 };
 
 class IonNativeExitFrameLayout;
-class IonOOLNativeGetterExitFrameLayout;
+class IonOOLNativeExitFrameLayout;
 class IonOOLPropertyOpExitFrameLayout;
 class IonOOLProxyGetExitFrameLayout;
 class IonDOMExitFrameLayout;
 
 class IonExitFrameLayout : public IonCommonFrameLayout
 {
     inline uint8_t *top() {
         return reinterpret_cast<uint8_t *>(this + 1);
@@ -189,18 +189,18 @@ class IonExitFrameLayout : public IonCom
     }
 
     inline bool isWrapperExit() {
         return footer()->function() != NULL;
     }
     inline bool isNativeExit() {
         return footer()->ionCode() == NULL;
     }
-    inline bool isOOLNativeGetterExit() {
-        return footer()->ionCode() == ION_FRAME_OOL_NATIVE_GETTER;
+    inline bool isOOLNativeExit() {
+        return footer()->ionCode() == ION_FRAME_OOL_NATIVE;
     }
     inline bool isOOLPropertyOpExit() {
         return footer()->ionCode() == ION_FRAME_OOL_PROPERTY_OP;
     }
     inline bool isOOLProxyGetExit() {
         return footer()->ionCode() == ION_FRAME_OOL_PROXY_GET;
     }
     inline bool isDomExit() {
@@ -211,19 +211,19 @@ class IonExitFrameLayout : public IonCom
             code == ION_FRAME_DOMMETHOD;
     }
 
     inline IonNativeExitFrameLayout *nativeExit() {
         // see CodeGenerator::visitCallNative
         JS_ASSERT(isNativeExit());
         return reinterpret_cast<IonNativeExitFrameLayout *>(footer());
     }
-    inline IonOOLNativeGetterExitFrameLayout *oolNativeGetterExit() {
-        JS_ASSERT(isOOLNativeGetterExit());
-        return reinterpret_cast<IonOOLNativeGetterExitFrameLayout *>(footer());
+    inline IonOOLNativeExitFrameLayout *oolNativeExit() {
+        JS_ASSERT(isOOLNativeExit());
+        return reinterpret_cast<IonOOLNativeExitFrameLayout *>(footer());
     }
     inline IonOOLPropertyOpExitFrameLayout *oolPropertyOpExit() {
         JS_ASSERT(isOOLPropertyOpExit());
         return reinterpret_cast<IonOOLPropertyOpExitFrameLayout *>(footer());
     }
     inline IonOOLProxyGetExitFrameLayout *oolProxyGetExit() {
         JS_ASSERT(isOOLProxyGetExit());
         return reinterpret_cast<IonOOLProxyGetExitFrameLayout *>(footer());
@@ -257,55 +257,57 @@ class IonNativeExitFrameLayout
     inline Value *vp() {
         return reinterpret_cast<Value*>(&loCalleeResult_);
     }
     inline uintptr_t argc() const {
         return argc_;
     }
 };
 
-class IonOOLNativeGetterExitFrameLayout
+class IonOOLNativeExitFrameLayout
 {
   protected: // only to silence a clang warning about unused private fields
     IonExitFooterFrame footer_;
     IonExitFrameLayout exit_;
 
+    // pointer to root the stub's IonCode
+    IonCode *stubCode_;
+
+    uintptr_t argc_;
+
     // We need to split the Value into 2 fields of 32 bits, otherwise the C++
     // compiler may add some padding between the fields.
     uint32_t loCalleeResult_;
     uint32_t hiCalleeResult_;
 
-    // The frame includes the object argument.
+    // Split Value for |this| and args above.
     uint32_t loThis_;
     uint32_t hiThis_;
 
-    // pointer to root the stub's IonCode
-    IonCode *stubCode_;
-
   public:
-    static inline size_t Size() {
-        return sizeof(IonOOLNativeGetterExitFrameLayout);
+    static inline size_t Size(size_t argc) {
+        // The Frame accounts for the callee/result and |this|, so we only needs args.
+        return sizeof(IonOOLNativeExitFrameLayout) + (argc * sizeof(Value));
     }
 
     static size_t offsetOfResult() {
-        return offsetof(IonOOLNativeGetterExitFrameLayout, loCalleeResult_);
+        return offsetof(IonOOLNativeExitFrameLayout, loCalleeResult_);
     }
 
     inline IonCode **stubCode() {
         return &stubCode_;
     }
     inline Value *vp() {
         return reinterpret_cast<Value*>(&loCalleeResult_);
     }
     inline Value *thisp() {
         return reinterpret_cast<Value*>(&loThis_);
     }
-
     inline uintptr_t argc() const {
-        return 0;
+        return argc_;
     }
 };
 
 class IonOOLPropertyOpExitFrameLayout
 {
   protected: // only to silence a clang warning about unused private fields
     IonExitFooterFrame footer_;
     IonExitFrameLayout exit_;