Bug 715656: Rename js::StackFrame::markFunctionEpilogueDone to updateEpilogueFlags, to be less misleading r=luke
authorJim Blandy <jimb@mozilla.com>
Fri, 06 Jan 2012 11:06:48 -0800
changeset 85180 f0eab7fd20af5570670f3f048846a5536cac0cfe
parent 85179 89c6efec31a704c07a40af3fb1d4b68f36115257
child 85181 ebd93b75749b5002faa67194b1b58a12d8a8c04e
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs715656
milestone12.0a1
Bug 715656: Rename js::StackFrame::markFunctionEpilogueDone to updateEpilogueFlags, to be less misleading r=luke
js/src/methodjit/Compiler.cpp
js/src/methodjit/MethodJIT.cpp
js/src/vm/Stack-inl.h
js/src/vm/Stack.h
--- a/js/src/methodjit/Compiler.cpp
+++ b/js/src/methodjit/Compiler.cpp
@@ -3337,24 +3337,28 @@ mjit::Compiler::emitReturn(FrameEntry *f
             a->returnJumps->append(masm.jump());
 
         if (a->returnSet)
             frame.freeReg(a->returnRegister);
         return;
     }
 
     /*
-     * Outside the mjit, activation objects are put by ContextStack::pop*
-     * members. For JSOP_RETURN, the interpreter only calls popInlineFrame if
-     * fp != entryFrame since the VM protocol is that Invoke/Execute are
-     * responsible for pushing/popping the initial frame. The mjit does not
-     * perform this branch (by instead using a trampoline at the return address
-     * to handle exiting mjit code) and thus always puts activation objects,
-     * even on the entry frame. To avoid double-putting, EnterMethodJIT clears
-     * out the entry frame's activation objects.
+     * Outside the mjit, activation objects (call objects and arguments objects) are put
+     * by ContextStack::pop* members. For JSOP_RETURN, the interpreter only calls
+     * popInlineFrame if fp != entryFrame since the VM protocol is that Invoke/Execute are
+     * responsible for pushing/popping the initial frame. However, an mjit function
+     * epilogue doesn't treat the initial StackFrame of its VMFrame specially: it always
+     * puts activation objects. And furthermore, if the last mjit frame throws, the mjit
+     * does *not* put the activation objects. So we can't assume any particular state of
+     * puttedness upon exit from the mjit.
+     *
+     * To avoid double-putting, EnterMethodJIT calls updateEpilogueFlags to clear the
+     * entry frame's hasArgsObj() and hasCallObj() flags if the given objects have already
+     * been put.
      */
     if (script->function()) {
         types::TypeScriptNesting *nesting = script->nesting();
         if (script->function()->isHeavyweight() || (nesting && nesting->children)) {
             prepareStubCall(Uses(fe ? 1 : 0));
             INLINE_STUBCALL(stubs::FunctionFrameEpilogue, REJOIN_NONE);
         } else {
             /* if (hasCallObj() || hasArgsObj()) */
--- a/js/src/methodjit/MethodJIT.cpp
+++ b/js/src/methodjit/MethodJIT.cpp
@@ -1085,17 +1085,17 @@ mjit::EnterMethodJIT(JSContext *cx, Stac
 
     if (ok) {
         /* The trampoline wrote the return value but did not set the HAS_RVAL flag. */
         fp->markReturnValue();
     }
 
     /* See comment in mjit::Compiler::emitReturn. */
     if (fp->isFunctionFrame())
-        fp->markFunctionEpilogueDone();
+        fp->updateEpilogueFlags();
 
     return ok ? Jaeger_Returned : Jaeger_Throwing;
 }
 
 static inline JaegerStatus
 CheckStackAndEnterMethodJIT(JSContext *cx, StackFrame *fp, void *code, bool partial)
 {
     JS_CHECK_RECURSION(cx, return Jaeger_Throwing);
--- a/js/src/vm/Stack-inl.h
+++ b/js/src/vm/Stack-inl.h
@@ -456,17 +456,17 @@ StackFrame::functionEpilogue()
             js_PutArgsObject(this);
     }
 
     if (maintainNestingState())
         types::NestingEpilogue(this);
 }
 
 inline void
-StackFrame::markFunctionEpilogueDone()
+StackFrame::updateEpilogueFlags()
 {
     if (flags_ & (HAS_ARGS_OBJ | HAS_CALL_OBJ)) {
         if (hasArgsObj() && !argsObj().maybeStackFrame()) {
             args.nactual = args.obj->initialLength();
             flags_ &= ~HAS_ARGS_OBJ;
         }
         if (hasCallObj() && !callObj().maybeStackFrame()) {
             /*
--- a/js/src/vm/Stack.h
+++ b/js/src/vm/Stack.h
@@ -868,25 +868,25 @@ class StackFrame
      * functions, and maintain type nesting invariants.
      */
     inline bool functionPrologue(JSContext *cx);
 
     /*
      * Epilogue for function frames: put any args or call object for the frame
      * which may still be live, and maintain type nesting invariants. Note:
      * this does not mark the epilogue as having been completed, since the
-     * frame is about to be popped. Use markFunctionEpilogueDone for this.
+     * frame is about to be popped. Use updateEpilogueFlags for this.
      */
     inline void functionEpilogue();
 
     /*
-     * Mark any work needed in the function's epilogue as done. This call must
-     * be followed by a later functionEpilogue.
+     * If callObj() or argsObj() have already been put, update our flags
+     * accordingly. This call must be followed by a later functionEpilogue.
      */
-    inline void markFunctionEpilogueDone();
+    inline void updateEpilogueFlags();
 
     inline bool maintainNestingState() const;
 
     /*
      * Variables object
      *
      * Given that a (non-dummy) StackFrame corresponds roughly to a ES5
      * Execution Context (ES5 10.3), StackFrame::varObj corresponds to the