The data contained in this repository can be downloaded to your computer using one of several clients.
Please see the documentation of your version control software client for more information.

Please select the desired protocol below to get the URL.

This URL has Read-Only access.

Statistics
| Branch: | Revision:

main_repo / deps / v8 / src / frames-inl.h @ 40c0f755

History | View | Annotate | Download (6.77 KB)

1 40c0f755 Ryan
// Copyright 2006-2008 the V8 project authors. All rights reserved.
2
// Redistribution and use in source and binary forms, with or without
3
// modification, are permitted provided that the following conditions are
4
// met:
5
//
6
//     * Redistributions of source code must retain the above copyright
7
//       notice, this list of conditions and the following disclaimer.
8
//     * Redistributions in binary form must reproduce the above
9
//       copyright notice, this list of conditions and the following
10
//       disclaimer in the documentation and/or other materials provided
11
//       with the distribution.
12
//     * Neither the name of Google Inc. nor the names of its
13
//       contributors may be used to endorse or promote products derived
14
//       from this software without specific prior written permission.
15
//
16
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28
#ifndef V8_FRAMES_INL_H_
29
#define V8_FRAMES_INL_H_
30
31
#include "frames.h"
32
#ifdef ARM
33
#include "frames-arm.h"
34
#else
35
#include "frames-ia32.h"
36
#endif
37
38
39
namespace v8 { namespace internal {
40
41
42
inline Address StackHandler::address() const {
43
  // NOTE: There's an obvious problem with the address of the NULL
44
  // stack handler. Right now, it benefits us that the subtraction
45
  // leads to a very high address (above everything else on the
46
  // stack), but maybe we should stop relying on it?
47
  const int displacement = StackHandlerConstants::kAddressDisplacement;
48
  Address address = reinterpret_cast<Address>(const_cast<StackHandler*>(this));
49
  return address + displacement;
50
}
51
52
53
inline StackHandler* StackHandler::next() const {
54
  const int offset = StackHandlerConstants::kNextOffset;
55
  return FromAddress(Memory::Address_at(address() + offset));
56
}
57
58
59
inline bool StackHandler::includes(Address address) const {
60
  Address start = this->address();
61
  Address end = start + StackHandlerConstants::kSize;
62
  return start <= address && address <= end;
63
}
64
65
66
inline void StackHandler::Iterate(ObjectVisitor* v) const {
67
  // Stack handlers do not contain any pointers that need to be
68
  // traversed. The only field that have to worry about is the code
69
  // field which is unused and should always be uninitialized.
70
#ifdef DEBUG
71
  const int offset = StackHandlerConstants::kCodeOffset;
72
  Object* code = Memory::Object_at(address() + offset);
73
  ASSERT(Smi::cast(code)->value() == StackHandler::kCodeNotPresent);
74
#endif
75
}
76
77
78
inline StackHandler* StackHandler::FromAddress(Address address) {
79
  return reinterpret_cast<StackHandler*>(address);
80
}
81
82
83
inline StackHandler::State StackHandler::state() const {
84
  const int offset = StackHandlerConstants::kStateOffset;
85
  return static_cast<State>(Memory::int_at(address() + offset));
86
}
87
88
89
inline Address StackHandler::pc() const {
90
  const int offset = StackHandlerConstants::kPCOffset;
91
  return Memory::Address_at(address() + offset);
92
}
93
94
95
inline void StackHandler::set_pc(Address value) {
96
  const int offset = StackHandlerConstants::kPCOffset;
97
  Memory::Address_at(address() + offset) = value;
98
}
99
100
101
inline StackHandler* StackFrame::top_handler() const {
102
  return iterator_->handler();
103
}
104
105
106
inline Object* StandardFrame::GetExpression(int index) const {
107
  return Memory::Object_at(GetExpressionAddress(index));
108
}
109
110
111
inline void StandardFrame::SetExpression(int index, Object* value) {
112
  Memory::Object_at(GetExpressionAddress(index)) = value;
113
}
114
115
116
inline Object* StandardFrame::context() const {
117
  const int offset = StandardFrameConstants::kContextOffset;
118
  return Memory::Object_at(fp() + offset);
119
}
120
121
122
inline Address StandardFrame::caller_sp() const {
123
  return pp();
124
}
125
126
127
inline Address StandardFrame::caller_fp() const {
128
  return Memory::Address_at(fp() + StandardFrameConstants::kCallerFPOffset);
129
}
130
131
132
inline Address StandardFrame::caller_pc() const {
133
  return Memory::Address_at(ComputePCAddress(fp()));
134
}
135
136
137
inline Address StandardFrame::ComputePCAddress(Address fp) {
138
  return fp + StandardFrameConstants::kCallerPCOffset;
139
}
140
141
142
inline bool StandardFrame::IsArgumentsAdaptorFrame(Address fp) {
143
  int context = Memory::int_at(fp + StandardFrameConstants::kContextOffset);
144
  return context == ArgumentsAdaptorFrame::SENTINEL;
145
}
146
147
148
inline bool StandardFrame::IsConstructFrame(Address fp) {
149
  Object* marker =
150
      Memory::Object_at(fp + StandardFrameConstants::kMarkerOffset);
151
  return marker == Smi::FromInt(CONSTRUCT);
152
}
153
154
155
inline Object* JavaScriptFrame::receiver() const {
156
  const int offset = JavaScriptFrameConstants::kReceiverOffset;
157
  return Memory::Object_at(pp() + offset);
158
}
159
160
161
inline void JavaScriptFrame::set_receiver(Object* value) {
162
  const int offset = JavaScriptFrameConstants::kReceiverOffset;
163
  Memory::Object_at(pp() + offset) = value;
164
}
165
166
167
inline bool JavaScriptFrame::has_adapted_arguments() const {
168
  return IsArgumentsAdaptorFrame(caller_fp());
169
}
170
171
172
inline Object* JavaScriptFrame::function() const {
173
  Object* result = function_slot_object();
174
  ASSERT(result->IsJSFunction());
175
  return result;
176
}
177
178
179
template<typename Iterator>
180
inline JavaScriptFrame* JavaScriptFrameIteratorTemp<Iterator>::frame() const {
181
  // TODO(1233797): The frame hierarchy needs to change. It's
182
  // problematic that we can't use the safe-cast operator to cast to
183
  // the JavaScript frame type, because we may encounter arguments
184
  // adaptor frames.
185
  StackFrame* frame = iterator_.frame();
186
  ASSERT(frame->is_java_script() || frame->is_arguments_adaptor());
187
  return static_cast<JavaScriptFrame*>(frame);
188
}
189
190
191
template<typename Iterator>
192
JavaScriptFrameIteratorTemp<Iterator>::JavaScriptFrameIteratorTemp(
193
    StackFrame::Id id) {
194
  while (!done()) {
195
    Advance();
196
    if (frame()->id() == id) return;
197
  }
198
}
199
200
201
template<typename Iterator>
202
void JavaScriptFrameIteratorTemp<Iterator>::Advance() {
203
  do {
204
    iterator_.Advance();
205
  } while (!iterator_.done() && !iterator_.frame()->is_java_script());
206
}
207
208
209
template<typename Iterator>
210
void JavaScriptFrameIteratorTemp<Iterator>::AdvanceToArgumentsFrame() {
211
  if (!frame()->has_adapted_arguments()) return;
212
  iterator_.Advance();
213
  ASSERT(iterator_.frame()->is_arguments_adaptor());
214
}
215
216
217
template<typename Iterator>
218
void JavaScriptFrameIteratorTemp<Iterator>::Reset() {
219
  iterator_.Reset();
220
  if (!done()) Advance();
221
}
222
223
224
} }  // namespace v8::internal
225
226
#endif  // V8_FRAMES_INL_H_