js/src/jit/x86/Bailouts-x86.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 #if defined(_WIN32)
michael@0 17 # pragma pack(push, 1)
michael@0 18 #endif
michael@0 19
michael@0 20 namespace js {
michael@0 21 namespace jit {
michael@0 22
michael@0 23 class BailoutStack
michael@0 24 {
michael@0 25 uintptr_t frameClassId_;
michael@0 26 mozilla::Array<double, FloatRegisters::Total> fpregs_;
michael@0 27 mozilla::Array<uintptr_t, Registers::Total> regs_;
michael@0 28 union {
michael@0 29 uintptr_t frameSize_;
michael@0 30 uintptr_t tableOffset_;
michael@0 31 };
michael@0 32 uintptr_t snapshotOffset_;
michael@0 33
michael@0 34 public:
michael@0 35 FrameSizeClass frameClass() const {
michael@0 36 return FrameSizeClass::FromClass(frameClassId_);
michael@0 37 }
michael@0 38 uintptr_t tableOffset() const {
michael@0 39 JS_ASSERT(frameClass() != FrameSizeClass::None());
michael@0 40 return tableOffset_;
michael@0 41 }
michael@0 42 uint32_t frameSize() const {
michael@0 43 if (frameClass() == FrameSizeClass::None())
michael@0 44 return frameSize_;
michael@0 45 return frameClass().frameSize();
michael@0 46 }
michael@0 47 MachineState machine() {
michael@0 48 return MachineState::FromBailout(regs_, fpregs_);
michael@0 49 }
michael@0 50 SnapshotOffset snapshotOffset() const {
michael@0 51 JS_ASSERT(frameClass() == FrameSizeClass::None());
michael@0 52 return snapshotOffset_;
michael@0 53 }
michael@0 54 uint8_t *parentStackPointer() const {
michael@0 55 if (frameClass() == FrameSizeClass::None())
michael@0 56 return (uint8_t *)this + sizeof(BailoutStack);
michael@0 57 return (uint8_t *)this + offsetof(BailoutStack, snapshotOffset_);
michael@0 58 }
michael@0 59 };
michael@0 60
michael@0 61 } // namespace jit
michael@0 62 } // namespace js
michael@0 63
michael@0 64 #if defined(_WIN32)
michael@0 65 # pragma pack(pop)
michael@0 66 #endif
michael@0 67
michael@0 68 IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations,
michael@0 69 BailoutStack *bailout)
michael@0 70 : JitFrameIterator(activations),
michael@0 71 machine_(bailout->machine())
michael@0 72 {
michael@0 73 uint8_t *sp = bailout->parentStackPointer();
michael@0 74 uint8_t *fp = sp + bailout->frameSize();
michael@0 75
michael@0 76 current_ = fp;
michael@0 77 type_ = JitFrame_IonJS;
michael@0 78 topFrameSize_ = current_ - sp;
michael@0 79 topIonScript_ = script()->ionScript();
michael@0 80
michael@0 81 if (bailout->frameClass() == FrameSizeClass::None()) {
michael@0 82 snapshotOffset_ = bailout->snapshotOffset();
michael@0 83 return;
michael@0 84 }
michael@0 85
michael@0 86 // Compute the snapshot offset from the bailout ID.
michael@0 87 JitActivation *activation = activations.activation()->asJit();
michael@0 88 JSRuntime *rt = activation->compartment()->runtimeFromMainThread();
michael@0 89 JitCode *code = rt->jitRuntime()->getBailoutTable(bailout->frameClass());
michael@0 90 uintptr_t tableOffset = bailout->tableOffset();
michael@0 91 uintptr_t tableStart = reinterpret_cast<uintptr_t>(code->raw());
michael@0 92
michael@0 93 JS_ASSERT(tableOffset >= tableStart &&
michael@0 94 tableOffset < tableStart + code->instructionsSize());
michael@0 95 JS_ASSERT((tableOffset - tableStart) % BAILOUT_TABLE_ENTRY_SIZE == 0);
michael@0 96
michael@0 97 uint32_t bailoutId = ((tableOffset - tableStart) / BAILOUT_TABLE_ENTRY_SIZE) - 1;
michael@0 98 JS_ASSERT(bailoutId < BAILOUT_TABLE_SIZE);
michael@0 99
michael@0 100 snapshotOffset_ = topIonScript_->bailoutToSnapshot(bailoutId);
michael@0 101 }
michael@0 102
michael@0 103 IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations,
michael@0 104 InvalidationBailoutStack *bailout)
michael@0 105 : JitFrameIterator(activations),
michael@0 106 machine_(bailout->machine())
michael@0 107 {
michael@0 108 returnAddressToFp_ = bailout->osiPointReturnAddress();
michael@0 109 topIonScript_ = bailout->ionScript();
michael@0 110 const OsiIndex *osiIndex = topIonScript_->getOsiIndex(returnAddressToFp_);
michael@0 111
michael@0 112 current_ = (uint8_t*) bailout->fp();
michael@0 113 type_ = JitFrame_IonJS;
michael@0 114 topFrameSize_ = current_ - bailout->sp();
michael@0 115 snapshotOffset_ = osiIndex->snapshotOffset();
michael@0 116 }

mercurial