Skip to content

Commit bf8b3b1

Browse files
committed
Fix clangd for jit
1 parent aee5fce commit bf8b3b1

File tree

6 files changed

+528
-243
lines changed

6 files changed

+528
-243
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,8 @@ zend_jit_globals jit_globals;
5454
#endif
5555

5656
//#define CONTEXT_THREADED_JIT
57-
#define ZEND_JIT_USE_RC_INFERENCE
58-
59-
#ifdef ZEND_JIT_USE_RC_INFERENCE
60-
# define ZEND_SSA_RC_INFERENCE_FLAG ZEND_SSA_RC_INFERENCE
61-
# define RC_MAY_BE_1(info) (((info) & (MAY_BE_RC1|MAY_BE_REF)) != 0)
62-
# define RC_MAY_BE_N(info) (((info) & (MAY_BE_RCN|MAY_BE_REF)) != 0)
63-
#else
64-
# define ZEND_SSA_RC_INFERENCE_FLAG 0
65-
# define RC_MAY_BE_1(info) 1
66-
# define RC_MAY_BE_N(info) 1
67-
#endif
6857

6958
#define JIT_PREFIX "JIT$"
70-
#define JIT_STUB_PREFIX "JIT$$"
71-
#define TRACE_PREFIX "TRACE-"
7259

7360
bool zend_jit_startup_ok = false;
7461

@@ -82,10 +69,6 @@ const zend_op *zend_jit_halt_op = NULL;
8269
static int zend_write_protect = 1;
8370
#endif
8471

85-
static void *dasm_buf = NULL;
86-
static void *dasm_end = NULL;
87-
static void **dasm_ptr = NULL;
88-
8972
static size_t dasm_size = 0;
9073

9174
static zend_long jit_bisect_pos = 0;
@@ -94,25 +77,10 @@ static zend_vm_opcode_handler_t zend_jit_runtime_jit_handler = NULL;
9477
static zend_vm_opcode_handler_t zend_jit_profile_jit_handler = NULL;
9578
static zend_vm_opcode_handler_t zend_jit_func_hot_counter_handler = NULL;
9679
static zend_vm_opcode_handler_t zend_jit_loop_hot_counter_handler = NULL;
97-
static zend_vm_opcode_handler_t zend_jit_func_trace_counter_handler = NULL;
98-
static zend_vm_opcode_handler_t zend_jit_ret_trace_counter_handler = NULL;
99-
static zend_vm_opcode_handler_t zend_jit_loop_trace_counter_handler = NULL;
100-
101-
#if ZEND_VM_KIND == ZEND_VM_KIND_CALL || ZEND_VM_KIND == ZEND_VM_KIND_TAILCALL
102-
static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV zend_runtime_jit(ZEND_OPCODE_HANDLER_ARGS);
103-
#else
104-
static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV zend_runtime_jit(ZEND_OPCODE_HANDLER_ARGS);
105-
#endif
10680

10781
static int zend_jit_trace_op_len(const zend_op *opline);
108-
static int zend_jit_trace_may_exit(const zend_op_array *op_array, const zend_op *opline);
109-
static uint32_t _zend_jit_trace_get_exit_point(const zend_op *to_opline, uint32_t flags ZEND_FILE_LINE_DC);
110-
#define zend_jit_trace_get_exit_point(to_opline, flags) _zend_jit_trace_get_exit_point(to_opline, flags ZEND_FILE_LINE_CC)
111-
static const void *zend_jit_trace_get_exit_addr(uint32_t n);
112-
static void zend_jit_trace_add_code(const void *start, uint32_t size);
11382
static zend_string *zend_jit_func_name(const zend_op_array *op_array);
11483

115-
static bool zend_jit_needs_arg_dtor(const zend_function *func, uint32_t arg_num, zend_call_info *call_info);
11684
static bool zend_jit_supported_binary_op(uint8_t op, uint32_t op1_info, uint32_t op2_info);
11785

11886
static bool dominates(const zend_basic_block *blocks, int a, int b) {
@@ -771,35 +739,16 @@ static bool zend_jit_may_be_modified(const zend_function *func, const zend_op_ar
771739
return 1;
772740
}
773741

774-
#define OP_RANGE(ssa_op, opN) \
775-
(((opline->opN##_type & (IS_TMP_VAR|IS_VAR|IS_CV)) && \
776-
ssa->var_info && \
777-
(ssa_op)->opN##_use >= 0 && \
778-
ssa->var_info[(ssa_op)->opN##_use].has_range) ? \
779-
&ssa->var_info[(ssa_op)->opN##_use].range : NULL)
780-
781-
#define OP1_RANGE() OP_RANGE(ssa_op, op1)
782-
#define OP2_RANGE() OP_RANGE(ssa_op, op2)
783-
#define OP1_DATA_RANGE() OP_RANGE(ssa_op + 1, op1)
784-
785742
#include "jit/zend_jit_helpers.c"
786743
#include "Zend/zend_cpuinfo.h"
787744

788-
#ifdef HAVE_GCC_GLOBAL_REGS
789-
# define GCC_GLOBAL_REGS 1
790-
#else
791-
# define GCC_GLOBAL_REGS 0
792-
#endif
793-
794745
/* By default avoid JITing inline handlers if it does not seem profitable due to lack of
795746
* type information. Disabling this option allows testing some JIT handlers in the
796747
* presence of try/catch blocks, which prevent SSA construction. */
797748
#ifndef PROFITABILITY_CHECKS
798749
# define PROFITABILITY_CHECKS 1
799750
#endif
800751

801-
#define BP_JIT_IS 6 /* Used for ISSET_ISEMPTY_DIM_OBJ. see BP_VAR_*defines in Zend/zend_compile.h */
802-
803752
/* The generated code may contain tautological comparisons, ignore them. */
804753
#if defined(__clang__)
805754
# pragma clang diagnostic push

ext/opcache/jit/zend_jit.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
#ifndef HAVE_JIT_H
2020
#define HAVE_JIT_H
2121

22+
#include <stdbool.h>
23+
#include <stdint.h>
24+
#include "ext/opcache/ZendAccelerator.h"
25+
2226
#if defined(__x86_64__) || defined(i386) || defined(ZEND_WIN32)
2327
# define ZEND_JIT_TARGET_X86 1
2428
# define ZEND_JIT_TARGET_ARM64 0

ext/opcache/jit/zend_jit_helpers.h

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/*
2+
* +----------------------------------------------------------------------+
3+
* | Zend JIT |
4+
* +----------------------------------------------------------------------+
5+
* | Copyright (c) The PHP Group |
6+
* +----------------------------------------------------------------------+
7+
* | This source file is subject to version 3.01 of the PHP license, |
8+
* | that is bundled with this package in the file LICENSE, and is |
9+
* | available through the world-wide-web at the following url: |
10+
* | https://www.php.net/license/3_01.txt |
11+
* | If you did not receive a copy of the PHP license and are unable to |
12+
* | obtain it through the world-wide-web, please send a note to |
13+
* | license@php.net so we can mail you a copy immediately. |
14+
* +----------------------------------------------------------------------+
15+
*/
16+
17+
#ifndef ZEND_JIT_HELPERS_H
18+
#define ZEND_JIT_HELPERS_H
19+
20+
#include "zend_compile.h"
21+
22+
static zend_never_inline zend_op_array* ZEND_FASTCALL zend_jit_init_func_run_time_cache_helper(zend_op_array *op_array);;
23+
static zend_function* ZEND_FASTCALL zend_jit_find_func_helper(zend_string *name, void **cache_slot);
24+
static uint32_t ZEND_FASTCALL zend_jit_jmp_frameless_helper(zval *func_name, void **cache_slot);
25+
static zend_function* ZEND_FASTCALL zend_jit_find_ns_func_helper(zval *func_name, void **cache_slot);
26+
static ZEND_COLD void ZEND_FASTCALL zend_jit_invalid_method_call(zval *object);
27+
static ZEND_COLD void ZEND_FASTCALL zend_jit_invalid_method_call_tmp(zval *object);
28+
static void ZEND_FASTCALL zend_jit_unref_helper(zval *zv);
29+
static zend_function* ZEND_FASTCALL zend_jit_find_method_helper(zend_object *obj, zval *function_name, zend_object **obj_ptr);
30+
static zend_function* ZEND_FASTCALL zend_jit_find_method_tmp_helper(zend_object *obj, zval *function_name, zend_object **obj_ptr);
31+
static zend_class_entry* ZEND_FASTCALL zend_jit_find_class_helper(zend_execute_data *execute_data);
32+
static zend_function* ZEND_FASTCALL zend_jit_find_static_method_helper(zend_execute_data *execute_data, zend_class_entry *ce);
33+
static zend_execute_data* ZEND_FASTCALL zend_jit_push_this_method_call_frame(zend_class_entry *scope, zend_function *fbc, uint32_t num_args);
34+
static zend_execute_data* ZEND_FASTCALL zend_jit_push_static_method_call_frame(zend_object *obj, zend_function *fbc, uint32_t num_args);
35+
static zend_execute_data* ZEND_FASTCALL zend_jit_push_static_method_call_frame_tmp(zend_object *obj, zend_function *fbc, uint32_t num_args);
36+
static zend_execute_data* ZEND_FASTCALL zend_jit_extend_stack_helper(uint32_t used_stack, zend_function *fbc);
37+
static zend_execute_data* ZEND_FASTCALL zend_jit_int_extend_stack_helper(uint32_t used_stack);
38+
static zval* ZEND_FASTCALL zend_jit_symtable_find(HashTable *ht, zend_string *str);
39+
static zval* ZEND_FASTCALL zend_jit_hash_index_lookup_rw_no_packed(HashTable *ht, zend_long idx);
40+
static zval* ZEND_FASTCALL zend_jit_hash_index_lookup_rw(HashTable *ht, zend_long idx);
41+
static zval* ZEND_FASTCALL zend_jit_hash_lookup_rw(HashTable *ht, zend_string *str);
42+
static zval* ZEND_FASTCALL zend_jit_symtable_lookup_rw(HashTable *ht, zend_string *str);
43+
static zval* ZEND_FASTCALL zend_jit_symtable_lookup_w(HashTable *ht, zend_string *str);
44+
static int ZEND_FASTCALL zend_jit_undefined_op_helper(uint32_t var);
45+
static int ZEND_FASTCALL zend_jit_undefined_op_helper_write(HashTable *ht, uint32_t var);
46+
static void ZEND_FASTCALL zend_jit_fetch_dim_r_helper(zend_array *ht, zval *dim, zval *result);
47+
static void ZEND_FASTCALL zend_jit_fetch_dim_is_helper(zend_array *ht, zval *dim, zval *result);
48+
static int ZEND_FASTCALL zend_jit_fetch_dim_isset_helper(zend_array *ht, zval *dim);
49+
static zval* ZEND_FASTCALL zend_jit_fetch_dim_rw_helper(zend_array *ht, zval *dim);
50+
static zval* ZEND_FASTCALL zend_jit_fetch_dim_w_helper(zend_array *ht, zval *dim);
51+
static zend_string* ZEND_FASTCALL zend_jit_fetch_dim_str_offset_r_helper(zend_string *str, zend_long offset);
52+
static zend_string* ZEND_FASTCALL zend_jit_fetch_dim_str_r_helper(zend_string *str, zval *dim);
53+
static void ZEND_FASTCALL zend_jit_fetch_dim_str_is_helper(zend_string *str, zval *dim, zval *result);
54+
static void ZEND_FASTCALL zend_jit_fetch_dim_obj_r_helper(zval *container, zval *dim, zval *result);
55+
static void ZEND_FASTCALL zend_jit_fetch_dim_obj_is_helper(zval *container, zval *dim, zval *result);
56+
static zend_always_inline void ZEND_FASTCALL zend_jit_fetch_dim_obj_helper(zval *object_ptr, zval *dim, zval *result, int type);
57+
static void ZEND_FASTCALL zend_jit_fetch_dim_obj_w_helper(zval *object_ptr, zval *dim, zval *result);
58+
static void ZEND_FASTCALL zend_jit_fetch_dim_obj_rw_helper(zval *object_ptr, zval *dim, zval *result);
59+
static void ZEND_FASTCALL zend_jit_assign_dim_helper(zval *object_ptr, zval *dim, zval *value, zval *result);
60+
static void ZEND_FASTCALL zend_jit_assign_dim_op_helper(zval *container, zval *dim, zval *value, binary_op_type binary_op);
61+
static void ZEND_FASTCALL zend_jit_fast_assign_concat_helper(zval *op1, zval *op2);
62+
static void ZEND_FASTCALL zend_jit_fast_concat_helper(zval *result, zval *op1, zval *op2);
63+
static void ZEND_FASTCALL zend_jit_fast_concat_tmp_helper(zval *result, zval *op1, zval *op2);
64+
static int ZEND_FASTCALL zend_jit_isset_dim_helper(zval *container, zval *offset);
65+
static void ZEND_FASTCALL zend_jit_free_call_frame(zend_execute_data *call);
66+
static zend_reference* ZEND_FASTCALL zend_jit_fetch_global_helper(zend_string *varname, void **cache_slot);
67+
static bool ZEND_FASTCALL zend_jit_verify_arg_slow(zval *arg, zend_arg_info *arg_info);
68+
static void ZEND_FASTCALL zend_jit_verify_return_slow(zval *arg, const zend_op_array *op_array, zend_arg_info *arg_info);
69+
static void ZEND_FASTCALL zend_jit_fetch_obj_r_slow(zend_object *zobj);
70+
static void ZEND_FASTCALL zend_jit_fetch_obj_r_dynamic(zend_object *zobj, intptr_t prop_offset);
71+
static void ZEND_FASTCALL zend_jit_fetch_obj_is_slow(zend_object *zobj);
72+
static void ZEND_FASTCALL zend_jit_fetch_obj_is_dynamic(zend_object *zobj, intptr_t prop_offset);
73+
static zval* ZEND_FASTCALL zend_jit_fetch_obj_r_slow_ex(zend_object *zobj);
74+
static zval* ZEND_FASTCALL zend_jit_fetch_obj_r_dynamic_ex(zend_object *zobj, intptr_t prop_offset);
75+
static zval* ZEND_FASTCALL zend_jit_fetch_obj_is_slow_ex(zend_object *zobj);
76+
static zval* ZEND_FASTCALL zend_jit_fetch_obj_is_dynamic_ex(zend_object *zobj, intptr_t prop_offset);
77+
static void ZEND_FASTCALL zend_jit_fetch_obj_w_slow(zend_object *zobj);
78+
static void ZEND_FASTCALL zend_jit_check_array_promotion(zval *val, zend_property_info *prop);
79+
static void ZEND_FASTCALL zend_jit_create_typed_ref(zval *val, zend_property_info *prop, zval *result);
80+
static void ZEND_FASTCALL zend_jit_extract_helper(zend_refcounted *garbage);
81+
static void ZEND_FASTCALL zend_jit_vm_stack_free_args_helper(zend_execute_data *call);
82+
static zval* ZEND_FASTCALL zend_jit_assign_const_to_typed_ref(zend_reference *ref, zval *value);
83+
static zval* ZEND_FASTCALL zend_jit_assign_tmp_to_typed_ref(zend_reference *ref, zval *value);
84+
static zval* ZEND_FASTCALL zend_jit_assign_var_to_typed_ref(zend_reference *ref, zval *value);
85+
static zval* ZEND_FASTCALL zend_jit_assign_cv_to_typed_ref(zend_reference *ref, zval *value);
86+
static zval* ZEND_FASTCALL zend_jit_assign_const_to_typed_ref2(zend_reference *ref, zval *value, zval *result);
87+
static zval* ZEND_FASTCALL zend_jit_assign_tmp_to_typed_ref2(zend_reference *ref, zval *value, zval *result);
88+
static zval* ZEND_FASTCALL zend_jit_assign_var_to_typed_ref2(zend_reference *ref, zval *value, zval *result);
89+
static zval* ZEND_FASTCALL zend_jit_assign_cv_to_typed_ref2(zend_reference *ref, zval *value, zval *result);
90+
static void ZEND_FASTCALL zend_jit_pre_inc_typed_ref(zend_reference *ref, zval *ret);
91+
static void ZEND_FASTCALL zend_jit_pre_dec_typed_ref(zend_reference *ref, zval *ret);
92+
static void ZEND_FASTCALL zend_jit_post_inc_typed_ref(zend_reference *ref, zval *ret);
93+
static void ZEND_FASTCALL zend_jit_post_dec_typed_ref(zend_reference *ref, zval *ret);
94+
static void ZEND_FASTCALL zend_jit_assign_op_to_typed_ref(zend_reference *ref, zval *val, binary_op_type binary_op);
95+
static void ZEND_FASTCALL zend_jit_assign_op_to_typed_ref_tmp(zend_reference *ref, zval *val, binary_op_type binary_op);
96+
static void ZEND_FASTCALL zend_jit_only_vars_by_reference(zval *arg);
97+
static void ZEND_FASTCALL zend_jit_invalid_array_use(const zval *container);
98+
static void ZEND_FASTCALL zend_jit_invalid_array_access(zval *container);
99+
static void ZEND_FASTCALL zend_jit_nan_coerced_to_type_warning(void);
100+
static void ZEND_FASTCALL zend_jit_invalid_property_read(zval *container, const char *property_name);
101+
static void ZEND_FASTCALL zend_jit_invalid_property_write(zval *container, const char *property_name);
102+
static void ZEND_FASTCALL zend_jit_invalid_property_incdec(zval *container, const char *property_name);
103+
static void ZEND_FASTCALL zend_jit_invalid_property_assign(zval *container, const char *property_name);
104+
static void ZEND_FASTCALL zend_jit_invalid_property_assign_op(zval *container, const char *property_name);
105+
static zval * ZEND_FASTCALL zend_jit_prepare_assign_dim_ref(zval *ref);
106+
static void ZEND_FASTCALL zend_jit_pre_inc(zval *var_ptr, zval *ret);
107+
static void ZEND_FASTCALL zend_jit_pre_dec(zval *var_ptr, zval *ret);
108+
static zend_never_inline void ZEND_FASTCALL _zend_hash_iterators_remove(HashTable *ht);
109+
static void ZEND_FASTCALL zend_jit_array_free(HashTable *ht);
110+
static HashTable *ZEND_FASTCALL zend_jit_zval_array_dup(zval *arr);
111+
static zend_array *ZEND_FASTCALL zend_jit_add_arrays_helper(zend_array *op1, zend_array *op2);
112+
static void ZEND_FASTCALL zend_jit_assign_obj_helper(zend_object *zobj, zend_string *name, zval *value, void **cache_slot, zval *result);
113+
static void ZEND_FASTCALL zend_jit_assign_to_typed_prop(zval *property_val, zend_property_info *info, zval *value, zval *result);
114+
static void ZEND_FASTCALL zend_jit_assign_op_to_typed_prop(zval *zptr, zend_property_info *prop_info, zval *value, binary_op_type binary_op);
115+
static void ZEND_FASTCALL zend_jit_assign_obj_op_helper(zend_object *zobj, zend_string *name, zval *value, void **cache_slot, binary_op_type binary_op);
116+
static void ZEND_FASTCALL zend_jit_inc_typed_prop(zval *var_ptr, zend_property_info *prop_info);
117+
static void ZEND_FASTCALL zend_jit_dec_typed_prop(zval *var_ptr, zend_property_info *prop_info);
118+
static void ZEND_FASTCALL zend_jit_pre_inc_typed_prop(zval *var_ptr, zend_property_info *prop_info, zval *result);
119+
static void ZEND_FASTCALL zend_jit_pre_dec_typed_prop(zval *var_ptr, zend_property_info *prop_info, zval *result);
120+
static void ZEND_FASTCALL zend_jit_post_inc_typed_prop(zval *var_ptr, zend_property_info *prop_info, zval *result);
121+
static void ZEND_FASTCALL zend_jit_post_dec_typed_prop(zval *var_ptr, zend_property_info *prop_info, zval *result);
122+
static void ZEND_FASTCALL zend_jit_pre_inc_obj_helper(zend_object *zobj, zend_string *name, void **cache_slot, zval *result);
123+
static void ZEND_FASTCALL zend_jit_pre_dec_obj_helper(zend_object *zobj, zend_string *name, void **cache_slot, zval *result);
124+
static void ZEND_FASTCALL zend_jit_post_inc_obj_helper(zend_object *zobj, zend_string *name, void **cache_slot, zval *result);
125+
static void ZEND_FASTCALL zend_jit_post_dec_obj_helper(zend_object *zobj, zend_string *name, void **cache_slot, zval *result);
126+
static void ZEND_FASTCALL zend_jit_uninit_static_prop(void);
127+
static void ZEND_FASTCALL zend_jit_free_trampoline_helper(zend_function *func);
128+
static void ZEND_FASTCALL zend_jit_exception_in_interrupt_handler_helper(void);
129+
static zend_string* ZEND_FASTCALL zend_jit_rope_end(zend_string **rope, uint32_t count);
130+
static zend_never_inline bool zend_handle_fetch_obj_flags(zval *result, zval *ptr, zend_object *obj, zend_property_info *prop_info, uint32_t flags);
131+
132+
#endif

0 commit comments

Comments
 (0)