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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
|
From 175c7bf6fe0ceeb4b5dc08e08837b411ab05ff6b Mon Sep 17 00:00:00 2001
From: Joe Watkins <krakjoe@php.net>
Date: Wed, 12 Jun 2019 20:04:47 +0200
Subject: [PATCH] Revert "micro-optimization"
This reverts commit 374f7699821eb723a3a82a9854d18c0530b9d4e9.
---
Zend/zend_execute.c | 3 +++
Zend/zend_vm_def.h | 18 +++++++++---------
Zend/zend_vm_execute.h | 29 ++++++++++++-----------------
Zend/zend_vm_gen.php | 17 -----------------
4 files changed, 24 insertions(+), 43 deletions(-)
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 677190821946..4c2fef629022 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -3502,6 +3502,9 @@ static zend_always_inline void i_init_func_execute_data(zend_op_array *op_array,
EX(run_time_cache) = RUN_TIME_CACHE(op_array);
EG(current_execute_data) = execute_data;
+#if defined(ZEND_VM_IP_GLOBAL_REG) && ((ZEND_VM_KIND == ZEND_VM_KIND_CALL) || (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID))
+ EX(opline) = opline;
+#endif
}
/* }}} */
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index 2745908ac240..6c8bce1dd12c 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -828,12 +828,12 @@ ZEND_VM_COLD_HELPER(zend_this_not_in_object_context_helper, ANY, ANY)
HANDLE_EXCEPTION();
}
-ZEND_VM_COLD_HELPER(zend_abstract_method_helper, ANY, ANY, zend_function *_fbc)
+ZEND_VM_COLD_HELPER(zend_abstract_method_helper, ANY, ANY, zend_function *fbc)
{
USE_OPLINE
SAVE_OPLINE();
- zend_throw_error(NULL, "Cannot call abstract method %s::%s()", ZSTR_VAL(_fbc->common.scope->name), ZSTR_VAL(_fbc->common.function_name));
+ zend_throw_error(NULL, "Cannot call abstract method %s::%s()", ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
UNDEF_RESULT();
HANDLE_EXCEPTION();
}
@@ -3842,7 +3842,7 @@ ZEND_VM_HOT_HANDLER(130, ZEND_DO_UCALL, ANY, ANY, SPEC(RETVAL))
call->prev_execute_data = execute_data;
execute_data = call;
i_init_func_execute_data(&fbc->op_array, ret, 0 EXECUTE_DATA_CC);
- LOAD_OPLINE_EX();
+ LOAD_OPLINE();
ZEND_VM_ENTER_EX();
}
@@ -3866,7 +3866,7 @@ ZEND_VM_HOT_HANDLER(131, ZEND_DO_FCALL_BY_NAME, ANY, ANY, SPEC(RETVAL))
call->prev_execute_data = execute_data;
execute_data = call;
i_init_func_execute_data(&fbc->op_array, ret, 0 EXECUTE_DATA_CC);
- LOAD_OPLINE_EX();
+ LOAD_OPLINE();
ZEND_VM_ENTER_EX();
} else {
@@ -3934,7 +3934,7 @@ ZEND_VM_HOT_HANDLER(60, ZEND_DO_FCALL, ANY, ANY, SPEC(RETVAL))
EX(call) = call->prev_execute_data;
if (UNEXPECTED((fbc->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED)) != 0)) {
if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_ABSTRACT) != 0)) {
- ZEND_VM_DISPATCH_TO_HELPER(zend_abstract_method_helper, _fbc, fbc);
+ ZEND_VM_DISPATCH_TO_HELPER(zend_abstract_method_helper, fbc, fbc);
} else {
zend_deprecated_function(fbc);
if (UNEXPECTED(EG(exception) != NULL)) {
@@ -3955,11 +3955,11 @@ ZEND_VM_HOT_HANDLER(60, ZEND_DO_FCALL, ANY, ANY, SPEC(RETVAL))
i_init_func_execute_data(&fbc->op_array, ret, 1 EXECUTE_DATA_CC);
if (EXPECTED(zend_execute_ex == execute_ex)) {
- LOAD_OPLINE_EX();
+ LOAD_OPLINE();
ZEND_VM_ENTER_EX();
} else {
execute_data = EX(prev_execute_data);
- SAVE_OPLINE_EX();
+ LOAD_OPLINE();
ZEND_ADD_CALL_FLAG(call, ZEND_CALL_TOP);
zend_execute_ex(call);
}
@@ -7995,11 +7995,11 @@ ZEND_VM_HANDLER(158, ZEND_CALL_TRAMPOLINE, ANY, ANY)
execute_data = call;
i_init_func_execute_data(&fbc->op_array, ret, 0 EXECUTE_DATA_CC);
if (EXPECTED(zend_execute_ex == execute_ex)) {
- LOAD_OPLINE_EX();
+ LOAD_OPLINE();
ZEND_VM_ENTER_EX();
} else {
execute_data = EX(prev_execute_data);
- SAVE_OPLINE_EX();
+ LOAD_OPLINE();
ZEND_ADD_CALL_FLAG(call, ZEND_CALL_TOP);
zend_execute_ex(call);
}
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index dff34587ff50..701087a83238 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -398,24 +398,19 @@ typedef ZEND_OPCODE_HANDLER_RET (ZEND_FASTCALL *opcode_handler_t) (ZEND_OPCODE_H
#undef LOAD_OPLINE
#undef LOAD_OPLINE_EX
#undef SAVE_OPLINE
-#undef SAVE_OPLINE_EX
#define DCL_OPLINE
#ifdef ZEND_VM_IP_GLOBAL_REG
# define OPLINE opline
# define USE_OPLINE
# define LOAD_OPLINE() opline = EX(opline)
-# define LOAD_OPLINE_EX()
# define LOAD_NEXT_OPLINE() opline = EX(opline) + 1
# define SAVE_OPLINE() EX(opline) = opline
-# define SAVE_OPLINE_EX() SAVE_OPLINE()
#else
# define OPLINE EX(opline)
# define USE_OPLINE const zend_op *opline = EX(opline);
# define LOAD_OPLINE()
-# define LOAD_OPLINE_EX()
# define LOAD_NEXT_OPLINE() ZEND_VM_INC_OPCODE()
# define SAVE_OPLINE()
-# define SAVE_OPLINE_EX()
#endif
#undef HANDLE_EXCEPTION
#undef HANDLE_EXCEPTION_LEAVE
@@ -465,12 +460,12 @@ static zend_never_inline ZEND_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_th
HANDLE_EXCEPTION();
}
-static zend_never_inline ZEND_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_abstract_method_helper_SPEC(zend_function *_fbc ZEND_OPCODE_HANDLER_ARGS_DC)
+static zend_never_inline ZEND_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_abstract_method_helper_SPEC(zend_function *fbc ZEND_OPCODE_HANDLER_ARGS_DC)
{
USE_OPLINE
SAVE_OPLINE();
- zend_throw_error(NULL, "Cannot call abstract method %s::%s()", ZSTR_VAL(_fbc->common.scope->name), ZSTR_VAL(_fbc->common.function_name));
+ zend_throw_error(NULL, "Cannot call abstract method %s::%s()", ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
UNDEF_RESULT();
HANDLE_EXCEPTION();
}
@@ -1069,7 +1064,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_UCALL_SPEC_RETV
call->prev_execute_data = execute_data;
execute_data = call;
i_init_func_execute_data(&fbc->op_array, ret, 0 EXECUTE_DATA_CC);
- LOAD_OPLINE_EX();
+ LOAD_OPLINE();
ZEND_VM_ENTER_EX();
}
@@ -1092,7 +1087,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_UCALL_SPEC_RETV
call->prev_execute_data = execute_data;
execute_data = call;
i_init_func_execute_data(&fbc->op_array, ret, 0 EXECUTE_DATA_CC);
- LOAD_OPLINE_EX();
+ LOAD_OPLINE();
ZEND_VM_ENTER_EX();
}
@@ -1116,7 +1111,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_BY_NAME_S
call->prev_execute_data = execute_data;
execute_data = call;
i_init_func_execute_data(&fbc->op_array, ret, 0 EXECUTE_DATA_CC);
- LOAD_OPLINE_EX();
+ LOAD_OPLINE();
ZEND_VM_ENTER_EX();
} else {
@@ -1192,7 +1187,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_BY_NAME_S
call->prev_execute_data = execute_data;
execute_data = call;
i_init_func_execute_data(&fbc->op_array, ret, 0 EXECUTE_DATA_CC);
- LOAD_OPLINE_EX();
+ LOAD_OPLINE();
ZEND_VM_ENTER_EX();
} else {
@@ -1281,11 +1276,11 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_SPEC_RETV
i_init_func_execute_data(&fbc->op_array, ret, 1 EXECUTE_DATA_CC);
if (EXPECTED(zend_execute_ex == execute_ex)) {
- LOAD_OPLINE_EX();
+ LOAD_OPLINE();
ZEND_VM_ENTER_EX();
} else {
execute_data = EX(prev_execute_data);
- SAVE_OPLINE_EX();
+ LOAD_OPLINE();
ZEND_ADD_CALL_FLAG(call, ZEND_CALL_TOP);
zend_execute_ex(call);
}
@@ -1391,11 +1386,11 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_SPEC_RETV
i_init_func_execute_data(&fbc->op_array, ret, 1 EXECUTE_DATA_CC);
if (EXPECTED(zend_execute_ex == execute_ex)) {
- LOAD_OPLINE_EX();
+ LOAD_OPLINE();
ZEND_VM_ENTER_EX();
} else {
execute_data = EX(prev_execute_data);
- SAVE_OPLINE_EX();
+ LOAD_OPLINE();
ZEND_ADD_CALL_FLAG(call, ZEND_CALL_TOP);
zend_execute_ex(call);
}
@@ -2434,11 +2429,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CALL_TRAMPOLINE_SPEC_HANDLER(Z
execute_data = call;
i_init_func_execute_data(&fbc->op_array, ret, 0 EXECUTE_DATA_CC);
if (EXPECTED(zend_execute_ex == execute_ex)) {
- LOAD_OPLINE_EX();
+ LOAD_OPLINE();
ZEND_VM_ENTER_EX();
} else {
execute_data = EX(prev_execute_data);
- SAVE_OPLINE_EX();
+ LOAD_OPLINE();
ZEND_ADD_CALL_FLAG(call, ZEND_CALL_TOP);
zend_execute_ex(call);
}
diff --git a/Zend/zend_vm_gen.php b/Zend/zend_vm_gen.php
index 2e0ad0b2c1c9..d5a27e337177 100755
--- a/Zend/zend_vm_gen.php
+++ b/Zend/zend_vm_gen.php
@@ -1947,24 +1947,19 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
out($f,"#undef LOAD_OPLINE\n");
out($f,"#undef LOAD_OPLINE_EX\n");
out($f,"#undef SAVE_OPLINE\n");
- out($f,"#undef SAVE_OPLINE_EX\n");
out($f,"#define DCL_OPLINE\n");
out($f,"#ifdef ZEND_VM_IP_GLOBAL_REG\n");
out($f,"# define OPLINE opline\n");
out($f,"# define USE_OPLINE\n");
out($f,"# define LOAD_OPLINE() opline = EX(opline)\n");
- out($f,"# define LOAD_OPLINE_EX()\n");
out($f,"# define LOAD_NEXT_OPLINE() opline = EX(opline) + 1\n");
out($f,"# define SAVE_OPLINE() EX(opline) = opline\n");
- out($f,"# define SAVE_OPLINE_EX() SAVE_OPLINE()\n");
out($f,"#else\n");
out($f,"# define OPLINE EX(opline)\n");
out($f,"# define USE_OPLINE const zend_op *opline = EX(opline);\n");
out($f,"# define LOAD_OPLINE()\n");
- out($f,"# define LOAD_OPLINE_EX()\n");
out($f,"# define LOAD_NEXT_OPLINE() ZEND_VM_INC_OPCODE()\n");
out($f,"# define SAVE_OPLINE()\n");
- out($f,"# define SAVE_OPLINE_EX()\n");
out($f,"#endif\n");
out($f,"#undef HANDLE_EXCEPTION\n");
out($f,"#undef HANDLE_EXCEPTION_LEAVE\n");
@@ -2001,10 +1996,8 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
out($f,"#undef DCL_OPLINE\n");
out($f,"#undef USE_OPLINE\n");
out($f,"#undef LOAD_OPLINE\n");
- out($f,"#undef LOAD_OPLINE_EX\n");
out($f,"#undef LOAD_NEXT_OPLINE\n");
out($f,"#undef SAVE_OPLINE\n");
- out($f,"#undef SAVE_OPLINE_EX\n");
out($f,"#define OPLINE opline\n");
out($f,"#ifdef ZEND_VM_IP_GLOBAL_REG\n");
out($f,"# define DCL_OPLINE register const zend_op *opline __asm__(ZEND_VM_IP_GLOBAL_REG);\n");
@@ -2013,10 +2006,8 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
out($f,"#endif\n");
out($f,"#define USE_OPLINE\n");
out($f,"#define LOAD_OPLINE() opline = EX(opline)\n");
- out($f,"# define LOAD_OPLINE_EX() LOAD_OPLINE()\n");
out($f,"#define LOAD_NEXT_OPLINE() opline = EX(opline) + 1\n");
out($f,"#define SAVE_OPLINE() EX(opline) = opline\n");
- out($f,"#define SAVE_OPLINE_EX()\n");
out($f,"#undef HANDLE_EXCEPTION\n");
out($f,"#undef HANDLE_EXCEPTION_LEAVE\n");
out($f,"#define HANDLE_EXCEPTION() LOAD_OPLINE(); ZEND_VM_CONTINUE()\n");
@@ -2037,10 +2028,8 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
out($f,"#undef DCL_OPLINE\n");
out($f,"#undef USE_OPLINE\n");
out($f,"#undef LOAD_OPLINE\n");
- out($f,"#undef LOAD_OPLINE_EX\n");
out($f,"#undef LOAD_NEXT_OPLINE\n");
out($f,"#undef SAVE_OPLINE\n");
- out($f,"#undef SAVE_OPLINE_EX\n");
out($f,"#define OPLINE opline\n");
out($f,"#ifdef ZEND_VM_IP_GLOBAL_REG\n");
out($f,"# define DCL_OPLINE register const zend_op *opline __asm__(ZEND_VM_IP_GLOBAL_REG);\n");
@@ -2049,10 +2038,8 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
out($f,"#endif\n");
out($f,"#define USE_OPLINE\n");
out($f,"#define LOAD_OPLINE() opline = EX(opline)\n");
- out($f,"#define LOAD_OPLINE_EX() LOAD_OPLINE()\n");
out($f,"#define LOAD_NEXT_OPLINE() opline = EX(opline) + 1\n");
out($f,"#define SAVE_OPLINE() EX(opline) = opline\n");
- out($f,"#define SAVE_OPLINE_EX()\n");
out($f,"#undef HANDLE_EXCEPTION\n");
out($f,"#undef HANDLE_EXCEPTION_LEAVE\n");
if (ZEND_VM_SPEC) {
@@ -3072,18 +3059,14 @@ function gen_vm($def, $skel) {
out($f,"#undef DCL_OPLINE\n");
out($f,"#undef USE_OPLINE\n");
out($f,"#undef LOAD_OPLINE\n");
- out($f,"#undef LOAD_OPLINE_EX\n");
out($f,"#undef LOAD_NEXT_OPLINE\n");
out($f,"#undef SAVE_OPLINE\n");
- out($f,"#undef SAVE_OPLINE_EX\n");
out($f,"#define OPLINE EX(opline)\n");
out($f,"#define DCL_OPLINE\n");
out($f,"#define USE_OPLINE const zend_op *opline = EX(opline);\n");
out($f,"#define LOAD_OPLINE()\n");
- out($f,"#define LOAD_OPLINE_EX()\n");
out($f,"#define LOAD_NEXT_OPLINE() ZEND_VM_INC_OPCODE()\n");
out($f,"#define SAVE_OPLINE()\n");
- out($f,"#define SAVE_OPLINE_EX()\n");
out($f,"#undef HANDLE_EXCEPTION\n");
out($f,"#undef HANDLE_EXCEPTION_LEAVE\n");
out($f,"#define HANDLE_EXCEPTION() LOAD_OPLINE(); ZEND_VM_CONTINUE()\n");
|