Bug 1360211: Rename JitActivation::exitFP to JitActivation::packedExitFP; r=jandem
authorBenjamin Bouvier <benj@benj.me>
Wed, 27 Sep 2017 20:49:38 +0200
changeset 426765 aac9140f624f704bb34b146ce738da4803469d69
parent 426764 64c4a8859b6cdaf04a1be21800473f0775b4fd30
child 426766 12639b7cafe8b389c6109945eb7cfab3e3d60ead
push id97
push userfmarier@mozilla.com
push dateSat, 14 Oct 2017 01:12:59 +0000
reviewersjandem
bugs1360211
milestone58.0a1
Bug 1360211: Rename JitActivation::exitFP to JitActivation::packedExitFP; r=jandem MozReview-Commit-ID: B4KunBt6UCx
js/src/gdb/mozilla/unwind.py
js/src/jit/Bailouts.cpp
js/src/jit/JSJitFrameIter.cpp
js/src/jit/JitFrames.cpp
js/src/jit/MacroAssembler.cpp
js/src/jit/MacroAssembler.h
js/src/jit/VMFunctions.cpp
js/src/vm/GeckoProfiler.cpp
js/src/vm/Stack.cpp
js/src/vm/Stack.h
js/src/wasm/WasmBuiltins.cpp
js/src/wasm/WasmStubs.cpp
--- a/js/src/gdb/mozilla/unwind.py
+++ b/js/src/gdb/mozilla/unwind.py
@@ -433,23 +433,23 @@ class UnwinderState(object):
             # Reached the end of the list.
             return None
         elif self.activation is None:
             cx = self.get_tls_context()
             self.activation = cx['jitActivation']
         else:
             self.activation = self.activation['prevJitActivation_']
 
-        exitFP = self.activation['exitFP_']
-        if exitFP == 0:
+        packedExitFP = self.activation['packedExitFP_']
+        if packedExitFP == 0:
             return None
 
         exit_sp = pending_frame.read_register(self.SP_REGISTER)
         frame_type = self.typecache.JitFrame_Exit
-        return self.create_frame(pc, exit_sp, exitFP, frame_type, pending_frame)
+        return self.create_frame(pc, exit_sp, packedExitFP, frame_type, pending_frame)
 
     # A wrapper for unwind_entry_frame_registers that handles
     # architecture-independent boilerplate.
     def unwind_entry_frame(self, pc, pending_frame):
         sp = self.next_sp
         # Notify the frame filter.
         self.add_frame(sp, name = 'JitFrame_Entry')
         # Make an unwind_info for the per-architecture code to fill in.
--- a/js/src/jit/Bailouts.cpp
+++ b/js/src/jit/Bailouts.cpp
@@ -32,17 +32,17 @@ jit::Bailout(BailoutStack* sp, BaselineB
     JSContext* cx = TlsContext.get();
     MOZ_ASSERT(bailoutInfo);
 
     // We don't have an exit frame.
     MOZ_ASSERT(IsInRange(FAKE_EXITFP_FOR_BAILOUT, 0, 0x1000) &&
                IsInRange(FAKE_EXITFP_FOR_BAILOUT + sizeof(CommonFrameLayout), 0, 0x1000),
                "Fake exitfp pointer should be within the first page.");
 
-    cx->activation()->asJit()->setExitFP(FAKE_EXITFP_FOR_BAILOUT);
+    cx->activation()->asJit()->setJSExitFP(FAKE_EXITFP_FOR_BAILOUT);
 
     JitActivationIterator jitActivations(cx);
     BailoutFrameInfo bailoutData(jitActivations, sp);
     JSJitFrameIter frame(jitActivations->asJit());
     MOZ_ASSERT(!frame.ionScript()->invalidated());
     CommonFrameLayout* currentFramePtr = frame.current();
 
     TraceLoggerThread* logger = TraceLoggerForCurrentThread(cx);
@@ -104,17 +104,17 @@ uint32_t
 jit::InvalidationBailout(InvalidationBailoutStack* sp, size_t* frameSizeOut,
                          BaselineBailoutInfo** bailoutInfo)
 {
     sp->checkInvariants();
 
     JSContext* cx = TlsContext.get();
 
     // We don't have an exit frame.
-    cx->activation()->asJit()->setExitFP(FAKE_EXITFP_FOR_BAILOUT);
+    cx->activation()->asJit()->setJSExitFP(FAKE_EXITFP_FOR_BAILOUT);
 
     JitActivationIterator jitActivations(cx);
     BailoutFrameInfo bailoutData(jitActivations, sp);
     JSJitFrameIter frame(jitActivations->asJit());
     CommonFrameLayout* currentFramePtr = frame.current();
 
     TraceLoggerThread* logger = TraceLoggerForCurrentThread(cx);
     TraceLogTimestamp(logger, TraceLogger_Invalidation);
@@ -190,19 +190,19 @@ jit::ExceptionHandlerBailout(JSContext* 
                              bool* overrecursed)
 {
     // We can be propagating debug mode exceptions without there being an
     // actual exception pending. For instance, when we return false from an
     // operation callback like a timeout handler.
     MOZ_ASSERT_IF(!excInfo.propagatingIonExceptionForDebugMode(), cx->isExceptionPending());
 
     JitActivation* act = cx->activation()->asJit();
-    uint8_t* prevExitFP = act->exitFP();
-    auto restoreExitFP = mozilla::MakeScopeExit([&]() { act->setExitFP(prevExitFP); });
-    act->setExitFP(FAKE_EXITFP_FOR_BAILOUT);
+    uint8_t* prevExitFP = act->jsExitFP();
+    auto restoreExitFP = mozilla::MakeScopeExit([&]() { act->setJSExitFP(prevExitFP); });
+    act->setJSExitFP(FAKE_EXITFP_FOR_BAILOUT);
 
     gc::AutoSuppressGC suppress(cx);
 
     JitActivationIterator jitActivations(cx);
     BailoutFrameInfo bailoutData(jitActivations, frame.frame());
     JSJitFrameIter frameView(jitActivations->asJit());
     CommonFrameLayout* currentFramePtr = frameView.current();
 
@@ -301,17 +301,17 @@ jit::CheckFrequentBailouts(JSContext* cx
             Invalidate(cx, script);
         }
     }
 }
 
 void
 BailoutFrameInfo::attachOnJitActivation(const JitActivationIterator& jitActivations)
 {
-    MOZ_ASSERT(jitActivations.exitFP() == FAKE_EXITFP_FOR_BAILOUT);
+    MOZ_ASSERT(jitActivations->asJit()->jsExitFP() == FAKE_EXITFP_FOR_BAILOUT);
     activation_ = jitActivations->asJit();
     activation_->setBailoutData(this);
 }
 
 BailoutFrameInfo::~BailoutFrameInfo()
 {
     activation_->cleanBailoutData();
 }
--- a/js/src/jit/JSJitFrameIter.cpp
+++ b/js/src/jit/JSJitFrameIter.cpp
@@ -9,17 +9,17 @@
 #include "jit/BaselineIC.h"
 #include "jit/JitcodeMap.h"
 #include "jit/JitFrames.h"
 
 using namespace js;
 using namespace js::jit;
 
 JSJitFrameIter::JSJitFrameIter(const JitActivation* activation)
-  : current_(activation->exitFP()),
+  : current_(activation->jsExitFP()),
     type_(JitFrame_Exit),
     returnAddressToFp_(nullptr),
     frameSize_(0),
     cachedSafepointIndex_(nullptr),
     activation_(activation)
 {
     if (activation_->bailoutData()) {
         current_ = activation_->bailoutData()->fp();
--- a/js/src/jit/JitFrames.cpp
+++ b/js/src/jit/JitFrames.cpp
@@ -723,21 +723,21 @@ HandleException(ResumeFromException* rfe
                 return;
         }
 
         JitFrameLayout* current = frame.isScripted() ? frame.jsFrame() : nullptr;
 
         ++iter;
 
         if (current) {
-            // Unwind the frame by updating exitFP. This is necessary so that
-            // (1) debugger exception unwind and leave frame hooks don't see this
-            // frame when they use ScriptFrameIter, and (2) ScriptFrameIter does
-            // not crash when accessing an IonScript that's destroyed by the
-            // ionScript->decref call.
+            // Unwind the frame by updating packedExitFP. This is necessary so
+            // that (1) debugger exception unwind and leave frame hooks don't
+            // see this frame when they use ScriptFrameIter, and (2)
+            // ScriptFrameIter does not crash when accessing an IonScript
+            // that's destroyed by the ionScript->decref call.
             EnsureBareExitFrame(cx, current);
         }
 
         if (overrecursed) {
             // We hit an overrecursion error during bailout. Report it now.
             ReportOverRecursed(cx);
         }
     }
@@ -747,35 +747,35 @@ HandleException(ResumeFromException* rfe
 
 // Turns a JitFrameLayout into an ExitFrameLayout. Note that it has to be a
 // bare exit frame so it's ignored by TraceJitExitFrame.
 void
 EnsureBareExitFrame(JSContext* cx, JitFrameLayout* frame)
 {
     ExitFrameLayout* exitFrame = reinterpret_cast<ExitFrameLayout*>(frame);
 
-    if (cx->activation()->asJit()->exitFP() == (uint8_t*)frame) {
+    if (cx->activation()->asJit()->jsExitFP() == (uint8_t*)frame) {
         // If we already called this function for the current frame, do
         // nothing.
         MOZ_ASSERT(exitFrame->isBareExit());
         return;
     }
 
 #ifdef DEBUG
     JSJitFrameIter iter(cx);
     while (!iter.isScripted())
         ++iter;
     MOZ_ASSERT(iter.current() == frame, "|frame| must be the top JS frame");
 
-    MOZ_ASSERT(!!cx->activation()->asJit()->exitFP());
-    MOZ_ASSERT((uint8_t*)exitFrame->footer() >= cx->activation()->asJit()->exitFP(),
-               "Must have space for ExitFooterFrame before exitFP");
+    MOZ_ASSERT(!!cx->activation()->asJit()->jsExitFP());
+    MOZ_ASSERT((uint8_t*)exitFrame->footer() >= cx->activation()->asJit()->jsExitFP(),
+               "Must have space for ExitFooterFrame before jsExitFP");
 #endif
 
-    cx->activation()->asJit()->setExitFP((uint8_t*)frame);
+    cx->activation()->asJit()->setJSExitFP((uint8_t*)frame);
     *exitFrame->footer()->addressOfJitCode() = ExitFrameLayout::BareToken();
     MOZ_ASSERT(exitFrame->isBareExit());
 }
 
 CalleeToken
 TraceCalleeToken(JSTracer* trc, CalleeToken token)
 {
     switch (CalleeTokenTag tag = GetCalleeTokenTag(token)) {
--- a/js/src/jit/MacroAssembler.cpp
+++ b/js/src/jit/MacroAssembler.cpp
@@ -2856,17 +2856,17 @@ MacroAssembler::callWithABI(wasm::Byteco
 
 // ===============================================================
 // Exit frame footer.
 
 void
 MacroAssembler::linkExitFrame(Register cxreg, Register scratch)
 {
     loadPtr(Address(cxreg, JSContext::offsetOfActivation()), scratch);
-    storeStackPtr(Address(scratch, JitActivation::offsetOfExitFP()));
+    storeStackPtr(Address(scratch, JitActivation::offsetOfPackedExitFP()));
 }
 
 void
 MacroAssembler::linkSelfReference(JitCode* code)
 {
     // If this code can transition to C++ code and witness a GC, then we need to store
     // the JitCode onto the stack in order to GC it correctly.  exitCodePatch should
     // be unset if the code never needed to push its JitCode*.
--- a/js/src/jit/MacroAssembler.h
+++ b/js/src/jit/MacroAssembler.h
@@ -719,18 +719,18 @@ class MacroAssembler : public MacroAssem
 
     // Push an exit frame token for a native call.
     inline void enterFakeExitFrameForNative(Register cxreg, Register scratch, bool isConstructing);
 
     // Pop ExitFrame footer in addition to the extra frame.
     inline void leaveExitFrame(size_t extraFrame = 0);
 
   private:
-    // Save the top of the stack into JitActivation::exitFP of the current
-    // thread, which should be the location of the latest exit frame.
+    // Save the top of the stack into JitActivation::packedExitFP of the
+    // current thread, which should be the location of the latest exit frame.
     void linkExitFrame(Register cxreg, Register scratch);
 
     // Patch the value of PushStubCode with the pointer to the finalized code.
     void linkSelfReference(JitCode* code);
 
     // If the JitCode that created this assembler needs to transition into the VM,
     // we want to store the JitCode on the stack in order to mark it during a GC.
     // This is a reference to a patch location where the JitCode* will be written.
--- a/js/src/jit/VMFunctions.cpp
+++ b/js/src/jit/VMFunctions.cpp
@@ -817,18 +817,18 @@ DebugPrologue(JSContext* cx, BaselineFra
         MOZ_CRASH("bad Debugger::onEnterFrame status");
     }
 }
 
 bool
 DebugEpilogueOnBaselineReturn(JSContext* cx, BaselineFrame* frame, jsbytecode* pc)
 {
     if (!DebugEpilogue(cx, frame, pc, true)) {
-        // DebugEpilogue popped the frame by updating exitFP, so run the stop
-        // event here before we enter the exception handler.
+        // DebugEpilogue popped the frame by updating packedExitFP, so run the
+        // stop event here before we enter the exception handler.
         TraceLoggerThread* logger = TraceLoggerForCurrentThread(cx);
         TraceLogStopEvent(logger, TraceLogger_Baseline);
         TraceLogStopEvent(logger, TraceLogger_Scripts);
         return false;
     }
 
     return true;
 }
@@ -844,18 +844,18 @@ DebugEpilogue(JSContext* cx, BaselineFra
     // Unwind to the outermost environment and set pc to the end of the
     // script, regardless of error.
     EnvironmentIter ei(cx, frame, pc);
     UnwindAllEnvironmentsInFrame(cx, ei);
     JSScript* script = frame->script();
     frame->setOverridePc(script->lastPC());
 
     if (!ok) {
-        // Pop this frame by updating exitFP, so that the exception handling
-        // code will start at the previous frame.
+        // Pop this frame by updating packedExitFP, so that the exception
+        // handling code will start at the previous frame.
         JitFrameLayout* prefix = frame->framePrefix();
         EnsureBareExitFrame(cx, prefix);
         return false;
     }
 
     // Clear the override pc. This is not necessary for correctness: the frame
     // will return immediately, but this simplifies the check we emit in debug
     // builds after each callVM, to ensure this flag is not set.
--- a/js/src/vm/GeckoProfiler.cpp
+++ b/js/src/vm/GeckoProfiler.cpp
@@ -57,29 +57,29 @@ GeckoProfilerThread::setProfilingStack(P
 }
 
 void
 GeckoProfilerRuntime::setEventMarker(void (*fn)(const char*))
 {
     eventMarker_ = fn;
 }
 
-/* Get a pointer to the top-most profiling frame, given the exit frame pointer. */
+// Get a pointer to the top-most profiling frame, given the exit frame pointer.
 static void*
 GetTopProfilingJitFrame(Activation* act)
 {
     if (!act || !act->isJit())
         return nullptr;
 
     // For null exitFrame, there is no previous exit frame, just return.
-    uint8_t* exitFP = act->asJit()->exitFP();
-    if (!exitFP)
+    uint8_t* jsExitFP = act->asJit()->jsExitFP();
+    if (!jsExitFP)
         return nullptr;
 
-    jit::JitProfilingFrameIterator iter(exitFP);
+    jit::JitProfilingFrameIterator iter(jsExitFP);
     MOZ_ASSERT(!iter.done());
     return iter.fp();
 }
 
 void
 GeckoProfilerRuntime::enable(bool enabled)
 {
 #ifdef DEBUG
--- a/js/src/vm/Stack.cpp
+++ b/js/src/vm/Stack.cpp
@@ -1485,17 +1485,17 @@ ActivationEntryMonitor::ActivationEntryM
             entryMonitor_->Entry(cx_, jit::CalleeTokenToScript(entryToken), stack, asyncCause);
     }
 }
 
 /*****************************************************************************/
 
 jit::JitActivation::JitActivation(JSContext* cx, bool active)
   : Activation(cx, Jit),
-    exitFP_(nullptr),
+    packedExitFP_(nullptr),
     prevJitActivation_(cx->jitActivation),
     active_(active),
     rematerializedFrames_(nullptr),
     ionRecovery_(cx),
     bailoutData_(nullptr),
     lastProfilingFrame_(nullptr),
     lastProfilingCallSite_(nullptr)
 {
--- a/js/src/vm/Stack.h
+++ b/js/src/vm/Stack.h
@@ -1488,23 +1488,23 @@ namespace jit {
 
 class BailoutFrameInfo;
 
 // A JitActivation is used for frames running in Baseline or Ion.
 class JitActivation : public Activation
 {
     // If Baseline or Ion code is on the stack, and has called into C++, this
     // will be aligned to an ExitFrame.
-    uint8_t* exitFP_;
+    uint8_t* packedExitFP_;
 
     JitActivation* prevJitActivation_;
     bool active_;
 
     // Rematerialized Ion frames which has info copied out of snapshots. Maps
-    // frame pointers (i.e. exitFP_) to a vector of rematerializations of all
+    // frame pointers (i.e. packedExitFP_) to a vector of rematerializations of all
     // inline frames associated with that frame.
     //
     // This table is lazily initialized by calling getRematerializedFrame.
     typedef GCVector<RematerializedFrame*> RematerializedFrameVector;
     typedef HashMap<uint8_t*, RematerializedFrameVector> RematerializedFrameTable;
     RematerializedFrameTable* rematerializedFrames_;
 
     // This vector is used to remember the outcome of the evaluation of recover
@@ -1558,24 +1558,28 @@ class JitActivation : public Activation
 
     JitActivation* prevJitActivation() const {
         return prevJitActivation_;
     }
     static size_t offsetOfPrevJitActivation() {
         return offsetof(JitActivation, prevJitActivation_);
     }
 
-    void setExitFP(uint8_t* fp) {
-        exitFP_ = fp;
+    uint8_t* packedExitFP() const {
+        return packedExitFP_;
+    }
+    static size_t offsetOfPackedExitFP() {
+        return offsetof(JitActivation, packedExitFP_);
     }
-    uint8_t* exitFP() const {
-        return exitFP_;
+
+    uint8_t* jsExitFP() const {
+        return packedExitFP_;
     }
-    static size_t offsetOfExitFP() {
-        return offsetof(JitActivation, exitFP_);
+    void setJSExitFP(uint8_t* fp) {
+        packedExitFP_ = fp;
     }
 
     static size_t offsetOfActiveUint8() {
         MOZ_ASSERT(sizeof(bool) == 1);
         return offsetof(JitActivation, active_);
     }
 
 #ifdef CHECK_OSIPOINT_REGISTERS
@@ -1680,21 +1684,16 @@ class JitActivationIterator : public Act
         settle();
     }
 
     JitActivationIterator& operator++() {
         ActivationIterator::operator++();
         settle();
         return *this;
     }
-
-    uint8_t* exitFP() const {
-        MOZ_ASSERT(activation_->isJit());
-        return activation_->asJit()->exitFP();
-    }
 };
 
 } // namespace jit
 
 // Iterates over the frames of a single InterpreterActivation.
 class InterpreterFrameIterator
 {
     InterpreterActivation* activation_;
@@ -1880,23 +1879,23 @@ class FrameIter
         INTERP,    // interpreter activation on the stack
         JIT        // jit or wasm activations on the stack
     };
 
     // Unlike ScriptFrameIter itself, ScriptFrameIter::Data can be allocated on
     // the heap, so this structure should not contain any GC things.
     struct Data
     {
-        JSContext * cx_;
+        JSContext* cx_;
         DebuggerEvalOption  debuggerEvalOption_;
-        JSPrincipals *      principals_;
+        JSPrincipals*       principals_;
 
         State               state_;
 
-        jsbytecode *        pc_;
+        jsbytecode*         pc_;
 
         InterpreterFrameIterator interpFrames_;
         ActivationIterator activations_;
 
         JitFrameIter jitFrames_;
         unsigned ionInlineFrameNo_;
 
         Data(JSContext* cx, DebuggerEvalOption debuggerEvalOption, JSPrincipals* principals);
--- a/js/src/wasm/WasmBuiltins.cpp
+++ b/js/src/wasm/WasmBuiltins.cpp
@@ -164,22 +164,22 @@ WasmHandleDebugTrap()
 // register before executing a return instruction.
 static void*
 WasmHandleThrow()
 {
     WasmActivation* activation = CallingActivation();
     JSContext* cx = activation->cx();
 
     // WasmFrameIter iterates down wasm frames in the activation starting at
-    // WasmActivation::exitFP. Pass Unwind::True to pop WasmActivation::exitFP
-    // once each time WasmFrameIter is incremented, ultimately leaving exitFP
-    // null when the WasmFrameIter is done().  This is necessary to prevent a
-    // DebugFrame from being observed again after we just called onLeaveFrame
-    // (which would lead to the frame being re-added to the map of live frames,
-    // right as it becomes trash).
+    // JitActivation::wasmExitFP(). Pass Unwind::True to pop
+    // JitActivation::wasmExitFP() once each time WasmFrameIter is incremented,
+    // ultimately leaving exit FP null when the WasmFrameIter is done().  This
+    // is necessary to prevent a DebugFrame from being observed again after we
+    // just called onLeaveFrame (which would lead to the frame being re-added
+    // to the map of live frames, right as it becomes trash).
     //
     // TODO(bug 1360211): when JitActivation and WasmActivation get merged,
     // we'll be able to switch to ion / other wasm state from here, and we'll
     // need to do things differently.
 
     WasmFrameIter iter(activation, WasmFrameIter::Unwind::True);
     MOZ_ASSERT(!iter.done());
 
--- a/js/src/wasm/WasmStubs.cpp
+++ b/js/src/wasm/WasmStubs.cpp
@@ -1046,21 +1046,21 @@ GenerateTrapExit(MacroAssembler& masm, T
     GenerateExitEpilogue(masm, framePushed, ExitReason::Fixed::Trap, offsets);
 
     return FinishOffsets(masm, offsets);
 }
 
 // Generate a stub which is only used by the signal handlers to handle out of
 // bounds access by experimental SIMD.js and Atomics and unaligned accesses on
 // ARM. This stub is executed by direct PC transfer from the faulting memory
-// access and thus the stack depth is unknown. Since WasmActivation::exitFP is
-// not set before calling the error reporter, the current wasm activation will
-// be lost. This stub should be removed when SIMD.js and Atomics are moved to
-// wasm and given proper traps and when we use a non-faulting strategy for
-// unaligned ARM access.
+// access and thus the stack depth is unknown. Since
+// JitActivation::packedExitFP() is not set before calling the error reporter,
+// the current wasm activation will be lost. This stub should be removed when
+// SIMD.js and Atomics are moved to wasm and given proper traps and when we use
+// a non-faulting strategy for unaligned ARM access.
 static bool
 GenerateGenericMemoryAccessTrap(MacroAssembler& masm, SymbolicAddress reporter, Label* throwLabel,
                                 Offsets* offsets)
 {
     masm.haltingAlign(CodeAlignment);
 
     offsets->begin = masm.currentOffset();