1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit/arm/Bailouts-arm.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,119 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * vim: set ts=8 sts=4 et sw=4 tw=99: 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#include "jscntxt.h" 1.11 +#include "jscompartment.h" 1.12 + 1.13 +#include "jit/Bailouts.h" 1.14 +#include "jit/JitCompartment.h" 1.15 + 1.16 +using namespace js; 1.17 +using namespace js::jit; 1.18 + 1.19 +namespace js { 1.20 +namespace jit { 1.21 + 1.22 +class BailoutStack 1.23 +{ 1.24 + uintptr_t frameClassId_; 1.25 + // This is pushed in the bailout handler. Both entry points into the handler 1.26 + // inserts their own value int lr, which is then placed onto the stack along 1.27 + // with frameClassId_ above. This should be migrated to ip. 1.28 + public: 1.29 + union { 1.30 + uintptr_t frameSize_; 1.31 + uintptr_t tableOffset_; 1.32 + }; 1.33 + 1.34 + protected: // Silence Clang warning about unused private fields. 1.35 + mozilla::Array<double, FloatRegisters::Total> fpregs_; 1.36 + mozilla::Array<uintptr_t, Registers::Total> regs_; 1.37 + 1.38 + uintptr_t snapshotOffset_; 1.39 + uintptr_t padding_; 1.40 + 1.41 + public: 1.42 + FrameSizeClass frameClass() const { 1.43 + return FrameSizeClass::FromClass(frameClassId_); 1.44 + } 1.45 + uintptr_t tableOffset() const { 1.46 + JS_ASSERT(frameClass() != FrameSizeClass::None()); 1.47 + return tableOffset_; 1.48 + } 1.49 + uint32_t frameSize() const { 1.50 + if (frameClass() == FrameSizeClass::None()) 1.51 + return frameSize_; 1.52 + return frameClass().frameSize(); 1.53 + } 1.54 + MachineState machine() { 1.55 + return MachineState::FromBailout(regs_, fpregs_); 1.56 + } 1.57 + SnapshotOffset snapshotOffset() const { 1.58 + JS_ASSERT(frameClass() == FrameSizeClass::None()); 1.59 + return snapshotOffset_; 1.60 + } 1.61 + uint8_t *parentStackPointer() const { 1.62 + if (frameClass() == FrameSizeClass::None()) 1.63 + return (uint8_t *)this + sizeof(BailoutStack); 1.64 + return (uint8_t *)this + offsetof(BailoutStack, snapshotOffset_); 1.65 + } 1.66 +}; 1.67 + 1.68 +// Make sure the compiler doesn't add extra padding. 1.69 +static_assert((sizeof(BailoutStack) % 8) == 0, "BailoutStack should be 8-byte aligned."); 1.70 + 1.71 +} // namespace jit 1.72 +} // namespace js 1.73 + 1.74 +IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations, 1.75 + BailoutStack *bailout) 1.76 + : JitFrameIterator(activations), 1.77 + machine_(bailout->machine()) 1.78 +{ 1.79 + uint8_t *sp = bailout->parentStackPointer(); 1.80 + uint8_t *fp = sp + bailout->frameSize(); 1.81 + 1.82 + current_ = fp; 1.83 + type_ = JitFrame_IonJS; 1.84 + topFrameSize_ = current_ - sp; 1.85 + topIonScript_ = script()->ionScript(); 1.86 + 1.87 + if (bailout->frameClass() == FrameSizeClass::None()) { 1.88 + snapshotOffset_ = bailout->snapshotOffset(); 1.89 + return; 1.90 + } 1.91 + 1.92 + // Compute the snapshot offset from the bailout ID. 1.93 + JitActivation *activation = activations.activation()->asJit(); 1.94 + JSRuntime *rt = activation->compartment()->runtimeFromMainThread(); 1.95 + JitCode *code = rt->jitRuntime()->getBailoutTable(bailout->frameClass()); 1.96 + uintptr_t tableOffset = bailout->tableOffset(); 1.97 + uintptr_t tableStart = reinterpret_cast<uintptr_t>(code->raw()); 1.98 + 1.99 + JS_ASSERT(tableOffset >= tableStart && 1.100 + tableOffset < tableStart + code->instructionsSize()); 1.101 + JS_ASSERT((tableOffset - tableStart) % BAILOUT_TABLE_ENTRY_SIZE == 0); 1.102 + 1.103 + uint32_t bailoutId = ((tableOffset - tableStart) / BAILOUT_TABLE_ENTRY_SIZE) - 1; 1.104 + JS_ASSERT(bailoutId < BAILOUT_TABLE_SIZE); 1.105 + 1.106 + snapshotOffset_ = topIonScript_->bailoutToSnapshot(bailoutId); 1.107 +} 1.108 + 1.109 +IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations, 1.110 + InvalidationBailoutStack *bailout) 1.111 + : JitFrameIterator(activations), 1.112 + machine_(bailout->machine()) 1.113 +{ 1.114 + returnAddressToFp_ = bailout->osiPointReturnAddress(); 1.115 + topIonScript_ = bailout->ionScript(); 1.116 + const OsiIndex *osiIndex = topIonScript_->getOsiIndex(returnAddressToFp_); 1.117 + 1.118 + current_ = (uint8_t*) bailout->fp(); 1.119 + type_ = JitFrame_IonJS; 1.120 + topFrameSize_ = current_ - bailout->sp(); 1.121 + snapshotOffset_ = osiIndex->snapshotOffset(); 1.122 +}