1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 2 * vim: set ts=8 sts=4 et sw=4 tw=99: 3 * This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #include "jit/Bailouts.h" 8 9 using namespace js; 10 using namespace js::jit; 11 12 namespace js { 13 namespace jit { 14 15 class BailoutStack 16 { 17 RegisterDump::FPUArray fpregs_; 18 RegisterDump::GPRArray regs_; 19 uintptr_t frameSize_; 20 uintptr_t snapshotOffset_; 21 22 public: machineState()23 MachineState machineState() { 24 return MachineState::FromBailout(regs_, fpregs_); 25 } snapshotOffset() const26 uint32_t snapshotOffset() const { 27 return snapshotOffset_; 28 } frameSize() const29 uint32_t frameSize() const { 30 return frameSize_; 31 } parentStackPointer()32 uint8_t* parentStackPointer() { 33 return (uint8_t*)this + sizeof(BailoutStack); 34 } 35 }; 36 37 } // namespace jit 38 } // namespace js 39 BailoutFrameInfo(const JitActivationIterator & activations,BailoutStack * bailout)40BailoutFrameInfo::BailoutFrameInfo(const JitActivationIterator& activations, 41 BailoutStack* bailout) 42 : machine_(bailout->machineState()) 43 { 44 uint8_t* sp = bailout->parentStackPointer(); 45 framePointer_ = sp + bailout->frameSize(); 46 topFrameSize_ = framePointer_ - sp; 47 48 JSScript* script = ScriptFromCalleeToken(((JitFrameLayout*) framePointer_)->calleeToken()); 49 topIonScript_ = script->ionScript(); 50 51 attachOnJitActivation(activations); 52 snapshotOffset_ = bailout->snapshotOffset(); 53 } 54 BailoutFrameInfo(const JitActivationIterator & activations,InvalidationBailoutStack * bailout)55BailoutFrameInfo::BailoutFrameInfo(const JitActivationIterator& activations, 56 InvalidationBailoutStack* bailout) 57 : machine_(bailout->machine()) 58 { 59 framePointer_ = (uint8_t*) bailout->fp(); 60 topFrameSize_ = framePointer_ - bailout->sp(); 61 topIonScript_ = bailout->ionScript(); 62 attachOnJitActivation(activations); 63 64 uint8_t* returnAddressToFp_ = bailout->osiPointReturnAddress(); 65 const OsiIndex* osiIndex = topIonScript_->getOsiIndex(returnAddressToFp_); 66 snapshotOffset_ = osiIndex->snapshotOffset(); 67 } 68