5 #ifndef V8_FRAMES_INL_H_ 6 #define V8_FRAMES_INL_H_ 8 #include "src/frame-constants.h" 9 #include "src/frames.h" 10 #include "src/isolate.h" 11 #include "src/objects-inl.h" 12 #include "src/v8memory.h" 29 void Flush() { memset(static_cast<void*>(&cache_[0]), 0,
sizeof(cache_)); }
31 InnerPointerToCodeCacheEntry* GetCacheEntry(Address inner_pointer);
34 InnerPointerToCodeCacheEntry* cache(
int index) {
return &cache_[index]; }
38 static const int kInnerPointerToCodeCacheSize = 1024;
39 InnerPointerToCodeCacheEntry cache_[kInnerPointerToCodeCacheSize];
41 DISALLOW_COPY_AND_ASSIGN(InnerPointerToCodeCache);
44 inline Address StackHandler::address()
const {
45 return reinterpret_cast<Address
>(
const_cast<StackHandler*
>(
this));
49 inline StackHandler* StackHandler::next()
const {
50 const int offset = StackHandlerConstants::kNextOffset;
51 return FromAddress(Memory<Address>(address() + offset));
55 inline StackHandler* StackHandler::FromAddress(Address address) {
56 return reinterpret_cast<StackHandler*
>(address);
60 inline StackFrame::StackFrame(StackFrameIteratorBase* iterator)
61 : iterator_(iterator), isolate_(iterator_->isolate()) {
65 inline StackHandler* StackFrame::top_handler()
const {
66 return iterator_->handler();
70 inline Address* StackFrame::ResolveReturnAddressLocation(Address* pc_address) {
71 if (return_address_location_resolver_ ==
nullptr) {
74 return reinterpret_cast<Address*
>(
75 return_address_location_resolver_(
76 reinterpret_cast<uintptr_t>(pc_address)));
80 inline NativeFrame::NativeFrame(StackFrameIteratorBase* iterator)
81 : StackFrame(iterator) {}
83 inline Address NativeFrame::GetCallerStackPointer()
const {
84 return fp() + CommonFrameConstants::kCallerSPOffset;
87 inline EntryFrame::EntryFrame(StackFrameIteratorBase* iterator)
88 : StackFrame(iterator) {}
90 inline ConstructEntryFrame::ConstructEntryFrame(
91 StackFrameIteratorBase* iterator)
92 : EntryFrame(iterator) {}
94 inline ExitFrame::ExitFrame(StackFrameIteratorBase* iterator)
95 : StackFrame(iterator) {}
97 inline BuiltinExitFrame::BuiltinExitFrame(StackFrameIteratorBase* iterator)
98 : ExitFrame(iterator) {}
100 inline Object* BuiltinExitFrame::receiver_slot_object()
const {
106 Object* argc_slot = argc_slot_object();
107 DCHECK(argc_slot->IsSmi());
108 int argc = Smi::ToInt(argc_slot);
110 const int receiverOffset =
111 BuiltinExitFrameConstants::kNewTargetOffset + (argc - 1) * kPointerSize;
112 return Memory<Object*>(fp() + receiverOffset);
115 inline Object* BuiltinExitFrame::argc_slot_object()
const {
116 return Memory<Object*>(fp() + BuiltinExitFrameConstants::kArgcOffset);
119 inline Object* BuiltinExitFrame::target_slot_object()
const {
120 return Memory<Object*>(fp() + BuiltinExitFrameConstants::kTargetOffset);
123 inline Object* BuiltinExitFrame::new_target_slot_object()
const {
124 return Memory<Object*>(fp() + BuiltinExitFrameConstants::kNewTargetOffset);
127 inline StandardFrame::StandardFrame(StackFrameIteratorBase* iterator)
128 : StackFrame(iterator) {
132 inline Object* StandardFrame::GetExpression(
int index)
const {
133 return Memory<Object*>(GetExpressionAddress(index));
137 inline void StandardFrame::SetExpression(
int index, Object* value) {
138 Memory<Object*>(GetExpressionAddress(index)) = value;
142 inline Address StandardFrame::caller_fp()
const {
143 return Memory<Address>(fp() + StandardFrameConstants::kCallerFPOffset);
147 inline Address StandardFrame::caller_pc()
const {
148 return Memory<Address>(ComputePCAddress(fp()));
152 inline Address StandardFrame::ComputePCAddress(Address fp) {
153 return fp + StandardFrameConstants::kCallerPCOffset;
157 inline Address StandardFrame::ComputeConstantPoolAddress(Address fp) {
158 return fp + StandardFrameConstants::kConstantPoolOffset;
162 inline bool StandardFrame::IsArgumentsAdaptorFrame(Address fp) {
163 intptr_t frame_type =
164 Memory<intptr_t>(fp + TypedFrameConstants::kFrameTypeOffset);
165 return frame_type == StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR);
169 inline bool StandardFrame::IsConstructFrame(Address fp) {
170 intptr_t frame_type =
171 Memory<intptr_t>(fp + TypedFrameConstants::kFrameTypeOffset);
172 return frame_type == StackFrame::TypeToMarker(StackFrame::CONSTRUCT);
175 inline JavaScriptFrame::JavaScriptFrame(StackFrameIteratorBase* iterator)
176 : StandardFrame(iterator) {}
178 Address JavaScriptFrame::GetParameterSlot(
int index)
const {
179 int param_count = ComputeParametersCount();
180 DCHECK(-1 <= index &&
181 (index < param_count ||
182 param_count == SharedFunctionInfo::kDontAdaptArgumentsSentinel));
183 int parameter_offset = (param_count - index - 1) * kPointerSize;
184 return caller_sp() + parameter_offset;
187 inline void JavaScriptFrame::set_receiver(Object* value) {
188 Memory<Object*>(GetParameterSlot(-1)) = value;
192 inline bool JavaScriptFrame::has_adapted_arguments()
const {
193 return IsArgumentsAdaptorFrame(caller_fp());
197 inline Object* JavaScriptFrame::function_slot_object()
const {
198 const int offset = JavaScriptFrameConstants::kFunctionOffset;
199 return Memory<Object*>(fp() + offset);
202 inline StubFrame::StubFrame(StackFrameIteratorBase* iterator)
203 : StandardFrame(iterator) {
207 inline OptimizedFrame::OptimizedFrame(StackFrameIteratorBase* iterator)
208 : JavaScriptFrame(iterator) {
212 inline InterpretedFrame::InterpretedFrame(StackFrameIteratorBase* iterator)
213 : JavaScriptFrame(iterator) {}
216 inline ArgumentsAdaptorFrame::ArgumentsAdaptorFrame(
217 StackFrameIteratorBase* iterator) : JavaScriptFrame(iterator) {
220 inline BuiltinFrame::BuiltinFrame(StackFrameIteratorBase* iterator)
221 : JavaScriptFrame(iterator) {}
223 inline WasmCompiledFrame::WasmCompiledFrame(StackFrameIteratorBase* iterator)
224 : StandardFrame(iterator) {}
226 inline WasmInterpreterEntryFrame::WasmInterpreterEntryFrame(
227 StackFrameIteratorBase* iterator)
228 : StandardFrame(iterator) {}
230 inline WasmToJsFrame::WasmToJsFrame(StackFrameIteratorBase* iterator)
231 : StubFrame(iterator) {}
233 inline JsToWasmFrame::JsToWasmFrame(StackFrameIteratorBase* iterator)
234 : StubFrame(iterator) {}
236 inline CWasmEntryFrame::CWasmEntryFrame(StackFrameIteratorBase* iterator)
237 : StubFrame(iterator) {}
239 inline WasmCompileLazyFrame::WasmCompileLazyFrame(
240 StackFrameIteratorBase* iterator)
241 : StandardFrame(iterator) {}
243 inline InternalFrame::InternalFrame(StackFrameIteratorBase* iterator)
244 : StandardFrame(iterator) {
247 inline ConstructFrame::ConstructFrame(StackFrameIteratorBase* iterator)
248 : InternalFrame(iterator) {
251 inline BuiltinContinuationFrame::BuiltinContinuationFrame(
252 StackFrameIteratorBase* iterator)
253 : InternalFrame(iterator) {}
255 inline JavaScriptBuiltinContinuationFrame::JavaScriptBuiltinContinuationFrame(
256 StackFrameIteratorBase* iterator)
257 : JavaScriptFrame(iterator) {}
259 inline JavaScriptBuiltinContinuationWithCatchFrame::
260 JavaScriptBuiltinContinuationWithCatchFrame(
261 StackFrameIteratorBase* iterator)
262 : JavaScriptBuiltinContinuationFrame(iterator) {}
264 inline JavaScriptFrameIterator::JavaScriptFrameIterator(
266 : iterator_(isolate) {
267 if (!done()) Advance();
270 inline JavaScriptFrameIterator::JavaScriptFrameIterator(
271 Isolate* isolate, ThreadLocalTop* top)
272 : iterator_(isolate, top) {
273 if (!done()) Advance();
276 inline JavaScriptFrame* JavaScriptFrameIterator::frame()
const {
281 StackFrame* frame = iterator_.frame();
282 DCHECK(frame->is_java_script() || frame->is_arguments_adaptor());
283 return static_cast<JavaScriptFrame*
>(frame);
286 inline StandardFrame* StackTraceFrameIterator::frame()
const {
287 StackFrame* frame = iterator_.frame();
288 DCHECK(frame->is_java_script() || frame->is_arguments_adaptor() ||
290 return static_cast<StandardFrame*
>(frame);
293 bool StackTraceFrameIterator::is_javascript()
const {
294 return frame()->is_java_script();
297 bool StackTraceFrameIterator::is_wasm()
const {
return frame()->is_wasm(); }
299 JavaScriptFrame* StackTraceFrameIterator::javascript_frame()
const {
300 return JavaScriptFrame::cast(frame());
303 inline StackFrame* SafeStackFrameIterator::frame()
const {
305 DCHECK(frame_->is_java_script() || frame_->is_exit() ||
306 frame_->is_builtin_exit() || frame_->is_wasm());
314 #endif // V8_FRAMES_INL_H_