michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "jit/Bailouts.h" michael@0: michael@0: using namespace js; michael@0: using namespace js::jit; michael@0: michael@0: #if defined(_WIN32) michael@0: # pragma pack(push, 1) michael@0: #endif michael@0: michael@0: namespace js { michael@0: namespace jit { michael@0: michael@0: class BailoutStack michael@0: { michael@0: mozilla::Array fpregs_; michael@0: mozilla::Array regs_; michael@0: uintptr_t frameSize_; michael@0: uintptr_t snapshotOffset_; michael@0: michael@0: public: michael@0: MachineState machineState() { michael@0: return MachineState::FromBailout(regs_, fpregs_); michael@0: } michael@0: uint32_t snapshotOffset() const { michael@0: return snapshotOffset_; michael@0: } michael@0: uint32_t frameSize() const { michael@0: return frameSize_; michael@0: } michael@0: uint8_t *parentStackPointer() { michael@0: return (uint8_t *)this + sizeof(BailoutStack); michael@0: } michael@0: }; michael@0: michael@0: } // namespace jit michael@0: } // namespace js michael@0: michael@0: #if defined(_WIN32) michael@0: # pragma pack(pop) michael@0: #endif michael@0: michael@0: IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations, michael@0: BailoutStack *bailout) michael@0: : JitFrameIterator(activations), michael@0: machine_(bailout->machineState()) michael@0: { michael@0: uint8_t *sp = bailout->parentStackPointer(); michael@0: uint8_t *fp = sp + bailout->frameSize(); michael@0: michael@0: current_ = fp; michael@0: type_ = JitFrame_IonJS; michael@0: topFrameSize_ = current_ - sp; michael@0: topIonScript_ = script()->ionScript(); michael@0: snapshotOffset_ = bailout->snapshotOffset(); michael@0: } michael@0: michael@0: IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations, michael@0: InvalidationBailoutStack *bailout) michael@0: : JitFrameIterator(activations), michael@0: machine_(bailout->machine()) michael@0: { michael@0: returnAddressToFp_ = bailout->osiPointReturnAddress(); michael@0: topIonScript_ = bailout->ionScript(); michael@0: const OsiIndex *osiIndex = topIonScript_->getOsiIndex(returnAddressToFp_); michael@0: michael@0: current_ = (uint8_t*) bailout->fp(); michael@0: type_ = JitFrame_IonJS; michael@0: topFrameSize_ = current_ - bailout->sp(); michael@0: snapshotOffset_ = osiIndex->snapshotOffset(); michael@0: }