js/src/jit/arm/Bailouts-arm.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 * vim: set ts=8 sts=4 et sw=4 tw=99:
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #include "jscntxt.h"
michael@0 8 #include "jscompartment.h"
michael@0 9
michael@0 10 #include "jit/Bailouts.h"
michael@0 11 #include "jit/JitCompartment.h"
michael@0 12
michael@0 13 using namespace js;
michael@0 14 using namespace js::jit;
michael@0 15
michael@0 16 namespace js {
michael@0 17 namespace jit {
michael@0 18
michael@0 19 class BailoutStack
michael@0 20 {
michael@0 21 uintptr_t frameClassId_;
michael@0 22 // This is pushed in the bailout handler. Both entry points into the handler
michael@0 23 // inserts their own value int lr, which is then placed onto the stack along
michael@0 24 // with frameClassId_ above. This should be migrated to ip.
michael@0 25 public:
michael@0 26 union {
michael@0 27 uintptr_t frameSize_;
michael@0 28 uintptr_t tableOffset_;
michael@0 29 };
michael@0 30
michael@0 31 protected: // Silence Clang warning about unused private fields.
michael@0 32 mozilla::Array<double, FloatRegisters::Total> fpregs_;
michael@0 33 mozilla::Array<uintptr_t, Registers::Total> regs_;
michael@0 34
michael@0 35 uintptr_t snapshotOffset_;
michael@0 36 uintptr_t padding_;
michael@0 37
michael@0 38 public:
michael@0 39 FrameSizeClass frameClass() const {
michael@0 40 return FrameSizeClass::FromClass(frameClassId_);
michael@0 41 }
michael@0 42 uintptr_t tableOffset() const {
michael@0 43 JS_ASSERT(frameClass() != FrameSizeClass::None());
michael@0 44 return tableOffset_;
michael@0 45 }
michael@0 46 uint32_t frameSize() const {
michael@0 47 if (frameClass() == FrameSizeClass::None())
michael@0 48 return frameSize_;
michael@0 49 return frameClass().frameSize();
michael@0 50 }
michael@0 51 MachineState machine() {
michael@0 52 return MachineState::FromBailout(regs_, fpregs_);
michael@0 53 }
michael@0 54 SnapshotOffset snapshotOffset() const {
michael@0 55 JS_ASSERT(frameClass() == FrameSizeClass::None());
michael@0 56 return snapshotOffset_;
michael@0 57 }
michael@0 58 uint8_t *parentStackPointer() const {
michael@0 59 if (frameClass() == FrameSizeClass::None())
michael@0 60 return (uint8_t *)this + sizeof(BailoutStack);
michael@0 61 return (uint8_t *)this + offsetof(BailoutStack, snapshotOffset_);
michael@0 62 }
michael@0 63 };
michael@0 64
michael@0 65 // Make sure the compiler doesn't add extra padding.
michael@0 66 static_assert((sizeof(BailoutStack) % 8) == 0, "BailoutStack should be 8-byte aligned.");
michael@0 67
michael@0 68 } // namespace jit
michael@0 69 } // namespace js
michael@0 70
michael@0 71 IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations,
michael@0 72 BailoutStack *bailout)
michael@0 73 : JitFrameIterator(activations),
michael@0 74 machine_(bailout->machine())
michael@0 75 {
michael@0 76 uint8_t *sp = bailout->parentStackPointer();
michael@0 77 uint8_t *fp = sp + bailout->frameSize();
michael@0 78
michael@0 79 current_ = fp;
michael@0 80 type_ = JitFrame_IonJS;
michael@0 81 topFrameSize_ = current_ - sp;
michael@0 82 topIonScript_ = script()->ionScript();
michael@0 83
michael@0 84 if (bailout->frameClass() == FrameSizeClass::None()) {
michael@0 85 snapshotOffset_ = bailout->snapshotOffset();
michael@0 86 return;
michael@0 87 }
michael@0 88
michael@0 89 // Compute the snapshot offset from the bailout ID.
michael@0 90 JitActivation *activation = activations.activation()->asJit();
michael@0 91 JSRuntime *rt = activation->compartment()->runtimeFromMainThread();
michael@0 92 JitCode *code = rt->jitRuntime()->getBailoutTable(bailout->frameClass());
michael@0 93 uintptr_t tableOffset = bailout->tableOffset();
michael@0 94 uintptr_t tableStart = reinterpret_cast<uintptr_t>(code->raw());
michael@0 95
michael@0 96 JS_ASSERT(tableOffset >= tableStart &&
michael@0 97 tableOffset < tableStart + code->instructionsSize());
michael@0 98 JS_ASSERT((tableOffset - tableStart) % BAILOUT_TABLE_ENTRY_SIZE == 0);
michael@0 99
michael@0 100 uint32_t bailoutId = ((tableOffset - tableStart) / BAILOUT_TABLE_ENTRY_SIZE) - 1;
michael@0 101 JS_ASSERT(bailoutId < BAILOUT_TABLE_SIZE);
michael@0 102
michael@0 103 snapshotOffset_ = topIonScript_->bailoutToSnapshot(bailoutId);
michael@0 104 }
michael@0 105
michael@0 106 IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations,
michael@0 107 InvalidationBailoutStack *bailout)
michael@0 108 : JitFrameIterator(activations),
michael@0 109 machine_(bailout->machine())
michael@0 110 {
michael@0 111 returnAddressToFp_ = bailout->osiPointReturnAddress();
michael@0 112 topIonScript_ = bailout->ionScript();
michael@0 113 const OsiIndex *osiIndex = topIonScript_->getOsiIndex(returnAddressToFp_);
michael@0 114
michael@0 115 current_ = (uint8_t*) bailout->fp();
michael@0 116 type_ = JitFrame_IonJS;
michael@0 117 topFrameSize_ = current_ - bailout->sp();
michael@0 118 snapshotOffset_ = osiIndex->snapshotOffset();
michael@0 119 }

mercurial