forked from facebook/hhvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabi.h
More file actions
197 lines (164 loc) · 5.34 KB
/
Copy pathabi.h
File metadata and controls
197 lines (164 loc) · 5.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#ifndef incl_HPHP_JIT_ABI_H
#define incl_HPHP_JIT_ABI_H
#include "hphp/runtime/vm/jit/types.h"
#include "hphp/runtime/vm/jit/abi-regs.h"
#include "hphp/runtime/vm/jit/phys-reg.h"
namespace HPHP { namespace jit {
///////////////////////////////////////////////////////////////////////////////
/*
* Return a suitable ABI for the targeted architecture and `kind'.
*/
const Abi& abi(CodeKind kind = CodeKind::Trace);
///////////////////////////////////////////////////////////////////////////////
// Principal reserved registers.
//
// These registers have special purposes both during and between traces.
/*
* Frame pointer.
*
* When mid-trace, points to the ActRec for the function currently executing.
*/
PhysReg rvmfp();
/*
* Stack pointer.
*
* When mid-trace, points to the top of the eval stack (lowest valid address)
* at the start of the current tracelet.
*/
PhysReg rvmsp();
/*
* RDS base pointer.
*
* Always points to the base of the RDS block for the current request.
*/
PhysReg rvmtl();
/*
* Native stack pointer.
*/
PhysReg rsp();
///////////////////////////////////////////////////////////////////////////////
// Calling convention registers.
/*
* PHP return value registers.
*/
PhysReg rret_data();
PhysReg rret_type();
/*
* Native return value registers.
*/
PhysReg rret(size_t i = 0);
PhysReg rret_simd(size_t i);
/*
* Native argument registers.
*/
PhysReg rarg(size_t i);
PhysReg rarg_simd(size_t i);
PhysReg rarg_ind_ret(size_t i);
/*
* Number of available argument registers.
*/
size_t num_arg_regs();
size_t num_arg_regs_simd();
size_t num_arg_regs_ind_ret();
/*
* RegSet for a call with `n' arguments.
*/
RegSet arg_regs(size_t n);
RegSet arg_regs_simd(size_t n);
RegSet arg_regs_ind_ret(size_t n);
/*
* Service request argument registers.
*/
PhysReg r_svcreq_req();
PhysReg r_svcreq_stub();
PhysReg r_svcreq_sf();
PhysReg r_svcreq_arg(size_t i);
/*
* PHP call registers (used by Call IR).
*
* - r_php_call_flags: see struct CallFlags
* - r_php_call_func: the func being called
* - r_php_call_num_args: the number of arguments being passed
* - r_php_call_ctx: the $this/static:class context (TCtx)
*/
inline PhysReg r_php_call_flags() { return rarg(0); }
inline PhysReg r_php_call_func() { return rarg(1); }
inline PhysReg r_php_call_num_args() { return rarg(2); }
inline PhysReg r_php_call_ctx() { return rarg(3); }
///////////////////////////////////////////////////////////////////////////////
// JIT and TC boundary ABI registers.
//
// These registers should not be used for scratch purposes between tracelets,
// and have to be specially handled if we are returning to the interpreter or
// invoking the translator.
/*
* VM register sets. The other sets are defined relative to these.
*/
RegSet vm_regs_with_sp();
RegSet vm_regs_no_sp();
/*
* Registers that need to be preserved across enterTC. Should not
* include rvmfp, or anything else that is "naturally" preserved.
*/
RegSet cross_jit_save();
/*
* Registers that are live between tracelets, in two flavors, depending whether
* we are between tracelets in a resumed function.
*/
inline RegSet cross_trace_regs() { return vm_regs_no_sp(); }
inline RegSet cross_trace_regs_resumed() { return vm_regs_with_sp(); }
/*
* Registers that are live when we reenter the JIT from the TC (e.g., via
* service requests).
*/
inline RegSet leave_trace_regs() { return vm_regs_with_sp(); }
/*
* Registers that are live between the caller and the callee when making a PHP
* function call.
*/
inline RegSet php_call_regs(bool withCtx) {
auto regs =
vm_regs_with_sp() |
r_php_call_flags() |
r_php_call_func() |
r_php_call_num_args();
if (withCtx) regs |= r_php_call_ctx();
return regs;
}
/*
* Registers that are live after a PHP function return.
*
* TODO(#2288359): We don't want this to include rvmsp() eventually.
*/
inline RegSet php_return_regs() {
return vm_regs_with_sp() | rret_data() | rret_type();
}
/*
* Registers that are live on entry to fcallUnpackHelper.
*
* TODO(#2288359): We don't want this to include rvmsp() eventually.
*/
inline RegSet fcall_unpack_regs() { return vm_regs_with_sp(); }
///////////////////////////////////////////////////////////////////////////////
/*
* Return the status flags that must be set when testing 'cc'.
*/
Vflags required_flags(ConditionCode cc);
///////////////////////////////////////////////////////////////////////////////
}}
#endif