Wed, 31 Dec 2014 06:09:35 +0100
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 "jit/mips/Bailouts-mips.h"
9 #include "jscntxt.h"
10 #include "jscompartment.h"
12 using namespace js;
13 using namespace js::jit;
15 IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations,
16 BailoutStack *bailout)
17 : IonFrameIterator(activations),
18 machine_(bailout->machine())
19 {
20 uint8_t *sp = bailout->parentStackPointer();
21 uint8_t *fp = sp + bailout->frameSize();
23 current_ = fp;
24 type_ = JitFrame_IonJS;
25 topFrameSize_ = current_ - sp;
26 topIonScript_ = script()->ionScript();
28 if (bailout->frameClass() == FrameSizeClass::None()) {
29 snapshotOffset_ = bailout->snapshotOffset();
30 return;
31 }
33 // Compute the snapshot offset from the bailout ID.
34 JitActivation *activation = activations.activation()->asJit();
35 JSRuntime *rt = activation->compartment()->runtimeFromMainThread();
36 JitCode *code = rt->jitRuntime()->getBailoutTable(bailout->frameClass());
37 uintptr_t tableOffset = bailout->tableOffset();
38 uintptr_t tableStart = reinterpret_cast<uintptr_t>(code->raw());
40 MOZ_ASSERT(tableOffset >= tableStart &&
41 tableOffset < tableStart + code->instructionsSize());
42 MOZ_ASSERT((tableOffset - tableStart) % BAILOUT_TABLE_ENTRY_SIZE == 0);
44 uint32_t bailoutId = ((tableOffset - tableStart) / BAILOUT_TABLE_ENTRY_SIZE) - 1;
45 MOZ_ASSERT(bailoutId < BAILOUT_TABLE_SIZE);
47 snapshotOffset_ = topIonScript_->bailoutToSnapshot(bailoutId);
48 }
50 IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations,
51 InvalidationBailoutStack *bailout)
52 : IonFrameIterator(activations),
53 machine_(bailout->machine())
54 {
55 returnAddressToFp_ = bailout->osiPointReturnAddress();
56 topIonScript_ = bailout->ionScript();
57 const OsiIndex *osiIndex = topIonScript_->getOsiIndex(returnAddressToFp_);
59 current_ = (uint8_t*) bailout->fp();
60 type_ = JitFrame_IonJS;
61 topFrameSize_ = current_ - bailout->sp();
62 snapshotOffset_ = osiIndex->snapshotOffset();
63 }