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.

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

mercurial