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/mips/Bailouts-mips.h" michael@0: michael@0: #include "jscntxt.h" michael@0: #include "jscompartment.h" michael@0: michael@0: using namespace js; michael@0: using namespace js::jit; michael@0: michael@0: IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations, michael@0: BailoutStack *bailout) michael@0: : IonFrameIterator(activations), michael@0: machine_(bailout->machine()) 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: michael@0: if (bailout->frameClass() == FrameSizeClass::None()) { michael@0: snapshotOffset_ = bailout->snapshotOffset(); michael@0: return; michael@0: } michael@0: michael@0: // Compute the snapshot offset from the bailout ID. michael@0: JitActivation *activation = activations.activation()->asJit(); michael@0: JSRuntime *rt = activation->compartment()->runtimeFromMainThread(); michael@0: JitCode *code = rt->jitRuntime()->getBailoutTable(bailout->frameClass()); michael@0: uintptr_t tableOffset = bailout->tableOffset(); michael@0: uintptr_t tableStart = reinterpret_cast(code->raw()); michael@0: michael@0: MOZ_ASSERT(tableOffset >= tableStart && michael@0: tableOffset < tableStart + code->instructionsSize()); michael@0: MOZ_ASSERT((tableOffset - tableStart) % BAILOUT_TABLE_ENTRY_SIZE == 0); michael@0: michael@0: uint32_t bailoutId = ((tableOffset - tableStart) / BAILOUT_TABLE_ENTRY_SIZE) - 1; michael@0: MOZ_ASSERT(bailoutId < BAILOUT_TABLE_SIZE); michael@0: michael@0: snapshotOffset_ = topIonScript_->bailoutToSnapshot(bailoutId); michael@0: } michael@0: michael@0: IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations, michael@0: InvalidationBailoutStack *bailout) michael@0: : IonFrameIterator(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: }