|
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/Bailouts.h" |
|
8 |
|
9 using namespace js; |
|
10 using namespace js::jit; |
|
11 |
|
12 #if defined(_WIN32) |
|
13 # pragma pack(push, 1) |
|
14 #endif |
|
15 |
|
16 namespace js { |
|
17 namespace jit { |
|
18 |
|
19 class BailoutStack |
|
20 { |
|
21 mozilla::Array<double, FloatRegisters::Total> fpregs_; |
|
22 mozilla::Array<uintptr_t, Registers::Total> regs_; |
|
23 uintptr_t frameSize_; |
|
24 uintptr_t snapshotOffset_; |
|
25 |
|
26 public: |
|
27 MachineState machineState() { |
|
28 return MachineState::FromBailout(regs_, fpregs_); |
|
29 } |
|
30 uint32_t snapshotOffset() const { |
|
31 return snapshotOffset_; |
|
32 } |
|
33 uint32_t frameSize() const { |
|
34 return frameSize_; |
|
35 } |
|
36 uint8_t *parentStackPointer() { |
|
37 return (uint8_t *)this + sizeof(BailoutStack); |
|
38 } |
|
39 }; |
|
40 |
|
41 } // namespace jit |
|
42 } // namespace js |
|
43 |
|
44 #if defined(_WIN32) |
|
45 # pragma pack(pop) |
|
46 #endif |
|
47 |
|
48 IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations, |
|
49 BailoutStack *bailout) |
|
50 : JitFrameIterator(activations), |
|
51 machine_(bailout->machineState()) |
|
52 { |
|
53 uint8_t *sp = bailout->parentStackPointer(); |
|
54 uint8_t *fp = sp + bailout->frameSize(); |
|
55 |
|
56 current_ = fp; |
|
57 type_ = JitFrame_IonJS; |
|
58 topFrameSize_ = current_ - sp; |
|
59 topIonScript_ = script()->ionScript(); |
|
60 snapshotOffset_ = bailout->snapshotOffset(); |
|
61 } |
|
62 |
|
63 IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations, |
|
64 InvalidationBailoutStack *bailout) |
|
65 : JitFrameIterator(activations), |
|
66 machine_(bailout->machine()) |
|
67 { |
|
68 returnAddressToFp_ = bailout->osiPointReturnAddress(); |
|
69 topIonScript_ = bailout->ionScript(); |
|
70 const OsiIndex *osiIndex = topIonScript_->getOsiIndex(returnAddressToFp_); |
|
71 |
|
72 current_ = (uint8_t*) bailout->fp(); |
|
73 type_ = JitFrame_IonJS; |
|
74 topFrameSize_ = current_ - bailout->sp(); |
|
75 snapshotOffset_ = osiIndex->snapshotOffset(); |
|
76 } |