Flutter Engine
The Flutter Engine
frame_layout.h
Go to the documentation of this file.
1// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_VM_FRAME_LAYOUT_H_
6#define RUNTIME_VM_FRAME_LAYOUT_H_
7
8#include "platform/assert.h"
9#include "platform/globals.h"
10
11// FrameLayout structure captures configuration specific properties of the
12// frame layout used by the runtime system and compiler.
13//
14// Runtime system uses runtime_frame_layout defined in stack_frame.h.
15// Compiler uses compiler::target::frame_layout defined in runtime_api.h
16
17namespace dart {
18
19// Forward declarations.
20class LocalVariable;
21
23 // The offset (in words) from FP to the first object.
25
26 // The offset (in words) from FP to the last fixed object.
28
29 // The offset (in words) from FP to the slot past the last parameter.
31
32 // The offset (in words) from SP on entry (before frame is setup) to
33 // the last parameter.
35
36 // The offset (in words) from FP to the first local.
38
39 // The fixed size of the frame.
41
42 // The offset (in words) from FP to the saved pool (if applicable).
44
45 // The offset (in words) from FP to the saved FP.
47
48 // The offset (in words) from FP to the saved return address.
50
51 // The offset (in words) from FP to the code object (if applicable).
52 intptr_t code_from_fp;
53
54 // Entry and exit frame layout.
56
57 // The number of fixed slots below the saved PC.
58 intptr_t saved_below_pc() const { return -first_local_from_fp; }
59
60 // Returns the FP-relative index where [variable] can be found (assumes
61 // [variable] is not captured), in words.
62 intptr_t FrameSlotForVariable(const LocalVariable* variable) const;
63
64 // Returns the FP-relative index where [variable_index] can be found (assumes
65 // [variable_index] comes from a [LocalVariable::index()], which is not
66 // captured).
67 intptr_t FrameSlotForVariableIndex(intptr_t index) const;
68
69 // Returns the variable index from a FP-relative index.
70 intptr_t VariableIndexForFrameSlot(intptr_t frame_slot) const {
71 if (frame_slot <= first_local_from_fp) {
72 return frame_slot - first_local_from_fp;
73 } else {
74 ASSERT(frame_slot > param_end_from_fp);
75 return frame_slot - param_end_from_fp;
76 }
77 }
78
79 // Called to initialize the stack frame layout during startup.
80 static void Init();
81};
82
83} // namespace dart
84
85#endif // RUNTIME_VM_FRAME_LAYOUT_H_
#define ASSERT(E)
Definition: dart_vm.cc:33
intptr_t saved_caller_pc_from_fp
Definition: frame_layout.h:49
intptr_t last_fixed_object_from_fp
Definition: frame_layout.h:27
intptr_t param_end_from_fp
Definition: frame_layout.h:30
intptr_t saved_below_pc() const
Definition: frame_layout.h:58
intptr_t last_param_from_entry_sp
Definition: frame_layout.h:34
intptr_t code_from_fp
Definition: frame_layout.h:52
intptr_t saved_caller_fp_from_fp
Definition: frame_layout.h:46
intptr_t first_local_from_fp
Definition: frame_layout.h:37
intptr_t VariableIndexForFrameSlot(intptr_t frame_slot) const
Definition: frame_layout.h:70
intptr_t saved_caller_pp_from_fp
Definition: frame_layout.h:43
intptr_t FrameSlotForVariable(const LocalVariable *variable) const
Definition: stack_frame.cc:83
intptr_t dart_fixed_frame_size
Definition: frame_layout.h:40
intptr_t first_object_from_fp
Definition: frame_layout.h:24
static void Init()
Definition: stack_frame.cc:98
intptr_t exit_link_slot_from_entry_fp
Definition: frame_layout.h:55
intptr_t FrameSlotForVariableIndex(intptr_t index) const
Definition: stack_frame.cc:89