|
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/. */ |
|
6 |
|
7 #include "jit/mips/Bailouts-mips.h" |
|
8 |
|
9 #include "jscntxt.h" |
|
10 #include "jscompartment.h" |
|
11 |
|
12 using namespace js; |
|
13 using namespace js::jit; |
|
14 |
|
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(); |
|
22 |
|
23 current_ = fp; |
|
24 type_ = JitFrame_IonJS; |
|
25 topFrameSize_ = current_ - sp; |
|
26 topIonScript_ = script()->ionScript(); |
|
27 |
|
28 if (bailout->frameClass() == FrameSizeClass::None()) { |
|
29 snapshotOffset_ = bailout->snapshotOffset(); |
|
30 return; |
|
31 } |
|
32 |
|
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()); |
|
39 |
|
40 MOZ_ASSERT(tableOffset >= tableStart && |
|
41 tableOffset < tableStart + code->instructionsSize()); |
|
42 MOZ_ASSERT((tableOffset - tableStart) % BAILOUT_TABLE_ENTRY_SIZE == 0); |
|
43 |
|
44 uint32_t bailoutId = ((tableOffset - tableStart) / BAILOUT_TABLE_ENTRY_SIZE) - 1; |
|
45 MOZ_ASSERT(bailoutId < BAILOUT_TABLE_SIZE); |
|
46 |
|
47 snapshotOffset_ = topIonScript_->bailoutToSnapshot(bailoutId); |
|
48 } |
|
49 |
|
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_); |
|
58 |
|
59 current_ = (uint8_t*) bailout->fp(); |
|
60 type_ = JitFrame_IonJS; |
|
61 topFrameSize_ = current_ - bailout->sp(); |
|
62 snapshotOffset_ = osiIndex->snapshotOffset(); |
|
63 } |