Line data Source code
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 : RegisterDump::FPUArray fpregs_;
22 : RegisterDump::GPRArray regs_;
23 : uintptr_t frameSize_;
24 : uintptr_t snapshotOffset_;
25 :
26 : public:
27 0 : MachineState machineState() {
28 0 : return MachineState::FromBailout(regs_, fpregs_);
29 : }
30 0 : uint32_t snapshotOffset() const {
31 0 : return snapshotOffset_;
32 : }
33 0 : uint32_t frameSize() const {
34 0 : return frameSize_;
35 : }
36 0 : uint8_t* parentStackPointer() {
37 0 : 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 0 : BailoutFrameInfo::BailoutFrameInfo(const JitActivationIterator& activations,
49 0 : BailoutStack* bailout)
50 0 : : machine_(bailout->machineState())
51 : {
52 0 : uint8_t* sp = bailout->parentStackPointer();
53 0 : framePointer_ = sp + bailout->frameSize();
54 0 : topFrameSize_ = framePointer_ - sp;
55 :
56 0 : JSScript* script = ScriptFromCalleeToken(((JitFrameLayout*) framePointer_)->calleeToken());
57 0 : topIonScript_ = script->ionScript();
58 :
59 0 : attachOnJitActivation(activations);
60 0 : snapshotOffset_ = bailout->snapshotOffset();
61 0 : }
62 :
63 0 : BailoutFrameInfo::BailoutFrameInfo(const JitActivationIterator& activations,
64 0 : InvalidationBailoutStack* bailout)
65 0 : : machine_(bailout->machine())
66 : {
67 0 : framePointer_ = (uint8_t*) bailout->fp();
68 0 : topFrameSize_ = framePointer_ - bailout->sp();
69 0 : topIonScript_ = bailout->ionScript();
70 0 : attachOnJitActivation(activations);
71 :
72 0 : uint8_t* returnAddressToFp_ = bailout->osiPointReturnAddress();
73 0 : const OsiIndex* osiIndex = topIonScript_->getOsiIndex(returnAddressToFp_);
74 0 : snapshotOffset_ = osiIndex->snapshotOffset();
75 0 : }
|