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 #if defined(_WIN32) 13 # pragma pack(push, 1) 14 #endif 15 16 namespace js { 17 namespace jit { 18 19 class BailoutStack 20 { 21 RegisterDump::FPUArray fpregs_; 22 RegisterDump::GPRArray regs_; 23 uintptr_t frameSize_; 24 uintptr_t snapshotOffset_; 25 26 public: machineState()27 MachineState machineState() { 28 return MachineState::FromBailout(regs_, fpregs_); 29 } snapshotOffset() const30 uint32_t snapshotOffset() const { 31 return snapshotOffset_; 32 } frameSize() const33 uint32_t frameSize() const { 34 return frameSize_; 35 } parentStackPointer()36 uint8_t* parentStackPointer() { 37 return (uint8_t*)this + sizeof(BailoutStack); 38 } 39 }; 40 41 } // namespace jit 42 } // namespace js 43 44 #if defined(_WIN32) 45 # pragma pack(pop) 46 #endif 47 BailoutFrameInfo(const JitActivationIterator & activations,BailoutStack * bailout)48BailoutFrameInfo::BailoutFrameInfo(const JitActivationIterator& activations, 49 BailoutStack* bailout) 50 : machine_(bailout->machineState()) 51 { 52 uint8_t* sp = bailout->parentStackPointer(); 53 framePointer_ = sp + bailout->frameSize(); 54 topFrameSize_ = framePointer_ - sp; 55 56 JSScript* script = ScriptFromCalleeToken(((JitFrameLayout*) framePointer_)->calleeToken()); 57 topIonScript_ = script->ionScript(); 58 59 attachOnJitActivation(activations); 60 snapshotOffset_ = bailout->snapshotOffset(); 61 } 62 BailoutFrameInfo(const JitActivationIterator & activations,InvalidationBailoutStack * bailout)63BailoutFrameInfo::BailoutFrameInfo(const JitActivationIterator& activations, 64 InvalidationBailoutStack* bailout) 65 : machine_(bailout->machine()) 66 { 67 framePointer_ = (uint8_t*) bailout->fp(); 68 topFrameSize_ = framePointer_ - bailout->sp(); 69 topIonScript_ = bailout->ionScript(); 70 attachOnJitActivation(activations); 71 72 uint8_t* returnAddressToFp_ = bailout->osiPointReturnAddress(); 73 const OsiIndex* osiIndex = topIonScript_->getOsiIndex(returnAddressToFp_); 74 snapshotOffset_ = osiIndex->snapshotOffset(); 75 } 76