~ubuntu-branches/ubuntu/vivid/mozjs24/vivid

« back to all changes in this revision

Viewing changes to js/src/jit/IonFrames-inl.h

  • Committer: Package Import Robot
  • Author(s): Tim Lunn
  • Date: 2014-02-11 21:55:34 UTC
  • Revision ID: package-import@ubuntu.com-20140211215534-m1zyq5aj59md3y07
Tags: upstream-24.2.0
ImportĀ upstreamĀ versionĀ 24.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
#ifndef jit_IonFrames_inl_h
 
8
#define jit_IonFrames_inl_h
 
9
 
 
10
#ifdef JS_ION
 
11
 
 
12
#include "jit/IonFrames.h"
 
13
#include "jit/IonFrameIterator.h"
 
14
#include "jit/LIR.h"
 
15
 
 
16
namespace js {
 
17
namespace jit {
 
18
 
 
19
inline void
 
20
SafepointIndex::resolve()
 
21
{
 
22
    JS_ASSERT(!resolved);
 
23
    safepointOffset_ = safepoint_->offset();
 
24
    resolved = true;
 
25
}
 
26
 
 
27
static inline size_t
 
28
SizeOfFramePrefix(FrameType type)
 
29
{
 
30
    switch (type) {
 
31
      case IonFrame_Entry:
 
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();
 
43
      case IonFrame_Exit:
 
44
        return IonExitFrameLayout::Size();
 
45
      case IonFrame_Osr:
 
46
        return IonOsrFrameLayout::Size();
 
47
      default:
 
48
        JS_NOT_REACHED("unknown frame type");
 
49
    }
 
50
    return 0;
 
51
}
 
52
 
 
53
inline IonCommonFrameLayout *
 
54
IonFrameIterator::current() const
 
55
{
 
56
    return (IonCommonFrameLayout *)current_;
 
57
}
 
58
 
 
59
inline uint8_t *
 
60
IonFrameIterator::returnAddress() const
 
61
{
 
62
    IonCommonFrameLayout *current = (IonCommonFrameLayout *) current_;
 
63
    return current->returnAddress();
 
64
}
 
65
 
 
66
inline size_t
 
67
IonFrameIterator::prevFrameLocalSize() const
 
68
{
 
69
    IonCommonFrameLayout *current = (IonCommonFrameLayout *) current_;
 
70
    return current->prevFrameLocalSize();
 
71
}
 
72
 
 
73
inline FrameType
 
74
IonFrameIterator::prevType() const
 
75
{
 
76
    IonCommonFrameLayout *current = (IonCommonFrameLayout *) current_;
 
77
    return current->prevType();
 
78
}
 
79
 
 
80
inline bool
 
81
IonFrameIterator::isFakeExitFrame() const
 
82
{
 
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);
 
87
    return res;
 
88
}
 
89
 
 
90
inline IonExitFrameLayout *
 
91
IonFrameIterator::exitFrame() const
 
92
{
 
93
    JS_ASSERT(type() == IonFrame_Exit);
 
94
    JS_ASSERT(!isFakeExitFrame());
 
95
    return (IonExitFrameLayout *) fp();
 
96
}
 
97
 
 
98
size_t
 
99
IonFrameIterator::frameSize() const
 
100
{
 
101
    JS_ASSERT(type_ != IonFrame_Exit);
 
102
    return frameSize_;
 
103
}
 
104
 
 
105
// Returns the JSScript associated with the topmost Ion frame.
 
106
inline JSScript *
 
107
GetTopIonJSScript(PerThreadData *pt, const SafepointIndex **safepointIndexOut, void **returnAddrOut)
 
108
{
 
109
    IonFrameIterator iter(pt->ionTop);
 
110
    JS_ASSERT(iter.type() == IonFrame_Exit);
 
111
    ++iter;
 
112
 
 
113
    // If needed, grab the safepoint index.
 
114
    if (safepointIndexOut)
 
115
        *safepointIndexOut = iter.safepoint();
 
116
 
 
117
    JS_ASSERT(iter.returnAddressToFp() != NULL);
 
118
    if (returnAddrOut)
 
119
        *returnAddrOut = (void *) iter.returnAddressToFp();
 
120
 
 
121
    if (iter.isBaselineStub()) {
 
122
        ++iter;
 
123
        JS_ASSERT(iter.isBaselineJS());
 
124
    }
 
125
 
 
126
    JS_ASSERT(iter.isScripted());
 
127
    return iter.script();
 
128
}
 
129
 
 
130
 
 
131
inline JSScript *
 
132
GetTopIonJSScript(JSContext *cx, const SafepointIndex **safepointIndexOut, void **returnAddrOut)
 
133
{
 
134
    return GetTopIonJSScript(&cx->mainThread(), safepointIndexOut, returnAddrOut);
 
135
}
 
136
 
 
137
inline BaselineFrame *
 
138
GetTopBaselineFrame(JSContext *cx)
 
139
{
 
140
    IonFrameIterator iter(cx->mainThread().ionTop);
 
141
    JS_ASSERT(iter.type() == IonFrame_Exit);
 
142
    ++iter;
 
143
    if (iter.isBaselineStub())
 
144
        ++iter;
 
145
    JS_ASSERT(iter.isBaselineJS());
 
146
    return iter.baselineFrame();
 
147
}
 
148
 
 
149
} // namespace jit
 
150
} // namespace js
 
151
 
 
152
#endif // JS_ION
 
153
 
 
154
#endif /* jit_IonFrames_inl_h */