2 * Copyright (C) 2024 Mikulas Patocka
4 * This file is part of Ajla.
6 * Ajla is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, either version 3 of the License, or (at your option) any later
11 * Ajla is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along with
16 * Ajla. If not, see <https://www.gnu.org/licenses/>.
25 #define eval_both name(eval_both)
26 #define ipret_fill_function_reference_from_slot name(ipret_fill_function_reference_from_slot)
27 #define thunk_fixed_operator name(thunk_fixed_operator)
28 #define is_thunk_operator name(is_thunk_operator)
29 #define thunk_get_param name(thunk_get_param)
30 #define ipret_system_property name(ipret_system_property)
31 #define ipret_get_system_property name(ipret_get_system_property)
32 #define thunk_int_binary_operator name(thunk_int_binary_operator)
33 #define thunk_int_binary_logical_operator name(thunk_int_binary_logical_operator)
34 #define thunk_int_unary_operator name(thunk_int_unary_operator)
35 #define ipret_int_ldc_long name(ipret_int_ldc_long)
36 #define convert_fixed_to_mpint name(convert_fixed_to_mpint)
37 #define convert_real_to_mpint name(convert_real_to_mpint)
38 #define thunk_convert name(thunk_convert)
39 #define thunk_bool_operator name(thunk_bool_operator)
40 #define thunk_bool_jump name(thunk_bool_jump)
41 #define ipret_copy_variable name(ipret_copy_variable)
42 #define ipret_copy_variable_to_pointer name(ipret_copy_variable_to_pointer)
43 #define ipret_call_cache name(ipret_call_cache)
44 #define ipret_get_index name(ipret_get_index)
45 #define ipret_record_load_create_thunk name(ipret_record_load_create_thunk)
46 #define ipret_option_load_create_thunk name(ipret_option_load_create_thunk)
47 #define ipret_array_load_create_thunk name(ipret_array_load_create_thunk)
48 #define thunk_option_test name(thunk_option_test)
49 #define thunk_option_ord name(thunk_option_ord)
50 #define ipret_array_len name(ipret_array_len)
51 #define ipret_array_len_greater_than name(ipret_array_len_greater_than)
52 #define ipret_array_sub name(ipret_array_sub)
53 #define ipret_array_skip name(ipret_array_skip)
54 #define ipret_array_append name(ipret_array_append)
55 #define ipret_array_append_one_flat name(ipret_array_append_one_flat)
56 #define ipret_array_append_one name(ipret_array_append_one)
57 #define ipret_array_flatten name(ipret_array_flatten)
58 #define ipret_prefetch_functions name(ipret_prefetch_functions)
59 #define ipret_break_waiting_chain name(ipret_break_waiting_chain)
60 #define ipret_tick name(ipret_tick)
61 #define upcall_vector name(upcall_vector)
65 #define max_param_size(n) ((n) * 2)
66 #define get_max_param(ip, n) get_unaligned_32(&(ip)[(n) * 2])
68 #define max_param_size(n) (n)
69 #define get_max_param(ip, n) ((ip)[n])
71 #define get_max_i_param(ip, n) get_max_param(ip + 1, n)
74 extern bool ipret_strict_calls
;
75 extern bool ipret_is_privileged
;
76 extern bool ipret_compile
;
78 void eval_both(frame_s
*fp
, const code_t
*ip
, frame_t slot_1
, frame_t slot_2
);
80 void attr_hot_fastcall
ipret_fill_function_reference_from_slot(struct data
*function_reference
, arg_t a
, frame_s
*fp
, frame_t slot
, bool deref
);
82 void * attr_hot_fastcall
thunk_fixed_operator(frame_s
*fp
, const code_t
*ip
, frame_t slot_1
, frame_t slot_2
, frame_t slot_r
, unsigned strict_flag
);
83 void * attr_hot_fastcall
is_thunk_operator(frame_s
*fp
, const code_t
*ip
, frame_t slot_1
, frame_t slot_r
, unsigned strict_flag
);
84 void * attr_hot_fastcall
thunk_get_param(frame_s
*fp
, const code_t
*ip
, frame_t slot_1
, frame_t slot_r
, unsigned strict_flag
, unsigned mode
);
85 int_default_t
ipret_system_property(int_default_t idx
);
86 void * attr_hot_fastcall
ipret_get_system_property(frame_s
*fp
, const code_t
*ip
, frame_t slot_1
, frame_t slot_r
);
88 void * attr_hot_fastcall
thunk_int_binary_operator(frame_s
*fp
, const code_t
*ip
, frame_t slot_1
, frame_t slot_2
, frame_t slot_r
, unsigned strict_flag
, bool (attr_fastcall
*do_op
)(const mpint_t
*op1
, const mpint_t
*op2
, mpint_t
*res
, ajla_error_t
*err
));
89 void * attr_hot_fastcall
thunk_int_binary_logical_operator(frame_s
*fp
, const code_t
*ip
, frame_t slot_1
, frame_t slot_2
, frame_t slot_r
, unsigned strict_flag
, bool (attr_fastcall
*do_op
)(const mpint_t
*op1
, const mpint_t
*op2
, ajla_flat_option_t
*res
, ajla_error_t
*err
));
90 void * attr_hot_fastcall
thunk_int_unary_operator(frame_s
*fp
, const code_t
*ip
, frame_t slot_1
, frame_t slot_r
, unsigned strict_flag
, bool (attr_fastcall
*do_op
)(const mpint_t
*op1
, mpint_t
*res
, ajla_error_t
*err
));
91 ip_t attr_hot_fastcall
ipret_int_ldc_long(frame_s
*fp
, frame_t slot
, const code_t
*ip
);
92 pointer_t attr_fastcall
convert_fixed_to_mpint(uintbig_t val
, bool uns
);
93 pointer_t attr_fastcall
convert_real_to_mpint(frame_s
*fp
, frame_t src_slot
, const struct type
*src_type
);
94 void * attr_hot_fastcall
thunk_convert(frame_s
*fp
, const code_t
*ip
, frame_t src_slot
, frame_t dest_slot
, unsigned strict_flag
);
96 void * attr_hot_fastcall
thunk_bool_operator(frame_s
*fp
, const code_t
*ip
, frame_t slot_1
, frame_t slot_2
, frame_t slot_r
, unsigned strict_flag
);
97 void * attr_hot_fastcall
thunk_bool_jump(frame_s
*fp
, const code_t
*ip
, frame_t slot
);
99 void attr_fastcall
ipret_copy_variable(frame_s
*src_fp
, frame_t src_slot
, frame_s
*dst_fp
, frame_t dst_slot
, bool deref
);
100 pointer_t
ipret_copy_variable_to_pointer(frame_s
*src_fp
, frame_t src_slot
, bool deref
);
102 struct ipret_call_cache_arg
{
103 struct function_argument
*f_arg
;
109 void * attr_fastcall
ipret_call_cache(frame_s
*fp
, const code_t
*ip
, pointer_t
*direct_function
, struct ipret_call_cache_arg
*arguments
, frame_t
*return_values
, frame_t free_fn_slot
);
111 void * attr_hot_fastcall
ipret_get_index(frame_s
*fp
, const code_t
*ip
, frame_s
*fp_slot
, frame_t slot
, bool *is_negative
, array_index_t
*idx
, pointer_t
*thunk argument_position
);
113 void * attr_hot_fastcall
ipret_record_load_create_thunk(frame_s
*fp
, const code_t
*ip
, frame_t record
, frame_t record_slot
, frame_t result_slot
);
114 void * attr_hot_fastcall
ipret_option_load_create_thunk(frame_s
*fp
, const code_t
*ip
, frame_t option
, frame_t option_idx
, frame_t result_slot
);
115 void * attr_hot_fastcall
thunk_option_test(frame_s
*fp
, const code_t
*ip
, frame_t slot_1
, ajla_option_t option
, frame_t slot_r
);
116 void * attr_hot_fastcall
thunk_option_ord(frame_s
*fp
, const code_t
*ip
, frame_t slot_1
, frame_t slot_r
);
117 void * attr_hot_fastcall
ipret_array_load_create_thunk(frame_s
*fp
, const code_t
*ip
, frame_t array
, frame_t index
, frame_t result_slot
);
118 void * attr_hot_fastcall
ipret_array_len(frame_s
*fp
, const code_t
*ip
, frame_t slot_r
, frame_t slot_a
, unsigned flags
);
119 void * attr_hot_fastcall
ipret_array_len_greater_than(frame_s
*fp
, const code_t
*ip
, frame_t slot_r
, frame_t slot_a
, frame_t l
, unsigned flags
);
120 void * attr_hot_fastcall
ipret_array_sub(frame_s
*fp
, const code_t
*ip
, frame_t slot_r
, frame_t slot_a
, frame_t slot_start
, frame_t slot_end
, unsigned flags
);
121 void * attr_hot_fastcall
ipret_array_skip(frame_s
*fp
, const code_t
*ip
, frame_t slot_r
, frame_t slot_a
, frame_t slot_start
, unsigned flags
);
122 void * attr_hot_fastcall
ipret_array_append(frame_s
*fp
, const code_t
*ip
, frame_t slot_r
, frame_t slot_1
, frame_t slot_2
, unsigned flags
);
123 void * attr_hot_fastcall
ipret_array_append_one_flat(frame_s
*fp
, const code_t
*ip
, frame_t slot_r
, frame_t slot_1
, frame_t slot_2
, unsigned flags
);
124 void * attr_hot_fastcall
ipret_array_append_one(frame_s
*fp
, const code_t
*ip
, frame_t slot_r
, frame_t slot_1
, frame_t slot_2
, unsigned flags
);
125 void * attr_fastcall
ipret_array_flatten(frame_s
*fp
, const code_t
*ip
, frame_t slot_r
, frame_t slot_1
, unsigned flags
);
127 void attr_fastcall
ipret_prefetch_functions(struct data
*function
);
128 bool attr_fastcall
ipret_break_waiting_chain(frame_s
*fp
, ip_t ip
);
129 void * attr_hot_fastcall
ipret_tick(frame_s
*fp
, const code_t
*ip
);