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
#ifndef jit_IonFrames_inl_h
8
#define jit_IonFrames_inl_h
12
#include "jit/IonFrames.h"
13
#include "jit/IonFrameIterator.h"
20
SafepointIndex::resolve()
23
safepointOffset_ = safepoint_->offset();
28
SizeOfFramePrefix(FrameType type)
32
return IonEntryFrameLayout::Size();
33
case IonFrame_BaselineJS:
34
case IonFrame_OptimizedJS:
35
case IonFrame_Unwound_OptimizedJS:
36
return IonJSFrameLayout::Size();
37
case IonFrame_BaselineStub:
38
return IonBaselineStubFrameLayout::Size();
39
case IonFrame_Rectifier:
40
return IonRectifierFrameLayout::Size();
41
case IonFrame_Unwound_Rectifier:
42
return IonUnwoundRectifierFrameLayout::Size();
44
return IonExitFrameLayout::Size();
46
return IonOsrFrameLayout::Size();
48
JS_NOT_REACHED("unknown frame type");
53
inline IonCommonFrameLayout *
54
IonFrameIterator::current() const
56
return (IonCommonFrameLayout *)current_;
60
IonFrameIterator::returnAddress() const
62
IonCommonFrameLayout *current = (IonCommonFrameLayout *) current_;
63
return current->returnAddress();
67
IonFrameIterator::prevFrameLocalSize() const
69
IonCommonFrameLayout *current = (IonCommonFrameLayout *) current_;
70
return current->prevFrameLocalSize();
74
IonFrameIterator::prevType() const
76
IonCommonFrameLayout *current = (IonCommonFrameLayout *) current_;
77
return current->prevType();
81
IonFrameIterator::isFakeExitFrame() const
83
bool res = (prevType() == IonFrame_Unwound_Rectifier ||
84
prevType() == IonFrame_Unwound_OptimizedJS ||
85
prevType() == IonFrame_Unwound_BaselineStub);
86
JS_ASSERT_IF(res, type() == IonFrame_Exit || type() == IonFrame_BaselineJS);
90
inline IonExitFrameLayout *
91
IonFrameIterator::exitFrame() const
93
JS_ASSERT(type() == IonFrame_Exit);
94
JS_ASSERT(!isFakeExitFrame());
95
return (IonExitFrameLayout *) fp();
99
IonFrameIterator::frameSize() const
101
JS_ASSERT(type_ != IonFrame_Exit);
105
// Returns the JSScript associated with the topmost Ion frame.
107
GetTopIonJSScript(PerThreadData *pt, const SafepointIndex **safepointIndexOut, void **returnAddrOut)
109
IonFrameIterator iter(pt->ionTop);
110
JS_ASSERT(iter.type() == IonFrame_Exit);
113
// If needed, grab the safepoint index.
114
if (safepointIndexOut)
115
*safepointIndexOut = iter.safepoint();
117
JS_ASSERT(iter.returnAddressToFp() != NULL);
119
*returnAddrOut = (void *) iter.returnAddressToFp();
121
if (iter.isBaselineStub()) {
123
JS_ASSERT(iter.isBaselineJS());
126
JS_ASSERT(iter.isScripted());
127
return iter.script();
132
GetTopIonJSScript(JSContext *cx, const SafepointIndex **safepointIndexOut, void **returnAddrOut)
134
return GetTopIonJSScript(&cx->mainThread(), safepointIndexOut, returnAddrOut);
137
inline BaselineFrame *
138
GetTopBaselineFrame(JSContext *cx)
140
IonFrameIterator iter(cx->mainThread().ionTop);
141
JS_ASSERT(iter.type() == IonFrame_Exit);
143
if (iter.isBaselineStub())
145
JS_ASSERT(iter.isBaselineJS());
146
return iter.baselineFrame();
154
#endif /* jit_IonFrames_inl_h */