29
29
which is global during one `mjit_compile` call. Ones conditional
30
30
in each branch should be stored in `compile_branch`. */
31
31
struct compile_status {
32
- bool success ; // has true if compilation has had no issue
33
- int * stack_size_for_pos ; // stack_size_for_pos[pos] has stack size for the position (otherwise -1)
34
- // If true , JIT-ed code will use local variables to store pushed values instead of
35
- // using VM's stack and moving stack pointer.
36
- bool local_stack_p ;
37
- // Safely-accessible cache entries copied from main thread.
32
+ int success ; /* has TRUE if compilation has had no issue */
33
+ int * stack_size_for_pos ; /* stack_size_for_pos[pos] has stack size for the position (otherwise -1) */
34
+ /* If TRUE , JIT-ed code will use local variables to store pushed values instead of
35
+ using VM's stack and moving stack pointer. */
36
+ int local_stack_p ;
37
+ /* Safely-accessible cache entries copied from main thread. */
38
38
union iseq_inline_storage_entry * is_entries ;
39
39
struct rb_call_cache * cc_entries ;
40
40
};
@@ -43,8 +43,8 @@ struct compile_status {
43
43
This is created and used for one `compile_insns` call and its values
44
44
should be copied for extra `compile_insns` call. */
45
45
struct compile_branch {
46
- unsigned int stack_size ; // this simulates sp (stack pointer) of YARV
47
- bool finish_p ; // if true , compilation in this branch should stop and let another branch to be compiled
46
+ unsigned int stack_size ; /* this simulates sp (stack pointer) of YARV */
47
+ int finish_p ; /* if TRUE , compilation in this branch should stop and let another branch to be compiled */
48
48
};
49
49
50
50
struct case_dispatch_var {
@@ -53,21 +53,21 @@ struct case_dispatch_var {
53
53
VALUE last_value ;
54
54
};
55
55
56
- // Returns true if call cache is still not obsoleted and cc->me->def->type is available.
57
- static bool
56
+ /* Returns TRUE if call cache is still not obsoleted and cc->me->def->type is available. */
57
+ static int
58
58
has_valid_method_type (CALL_CACHE cc )
59
59
{
60
- extern bool mjit_valid_class_serial_p (rb_serial_t class_serial );
60
+ extern int mjit_valid_class_serial_p (rb_serial_t class_serial );
61
61
return GET_GLOBAL_METHOD_STATE () == cc -> method_state
62
62
&& mjit_valid_class_serial_p (cc -> class_serial ) && cc -> me ;
63
63
}
64
64
65
- // Returns true if iseq is inlinable, otherwise NULL. This becomes true in the same condition
66
- // as CC_SET_FASTPATH (in vm_callee_setup_arg) is called from vm_call_iseq_setup.
67
- static bool
65
+ /* Returns TRUE if iseq is inlinable, otherwise NULL. This becomes TRUE in the same condition
66
+ as CC_SET_FASTPATH (in vm_callee_setup_arg) is called from vm_call_iseq_setup. */
67
+ static int
68
68
inlinable_iseq_p (CALL_INFO ci , CALL_CACHE cc , const rb_iseq_t * iseq )
69
69
{
70
- extern bool rb_simple_iseq_p (const rb_iseq_t * iseq );
70
+ extern int rb_simple_iseq_p (const rb_iseq_t * iseq );
71
71
return iseq != NULL
72
72
&& rb_simple_iseq_p (iseq ) && !(ci -> flag & VM_CALL_KW_SPLAT ) /* Top of vm_callee_setup_arg. In this case, opt_pc is 0. */
73
73
&& (!IS_ARGS_SPLAT (ci ) && !IS_ARGS_KEYWORD (ci ) && !(METHOD_ENTRY_VISI (cc -> me ) == METHOD_VISI_PROTECTED )); /* CC_SET_FASTPATH */
@@ -143,7 +143,7 @@ compile_insn(FILE *f, const struct rb_iseq_constant_body *body, const int insn,
143
143
if (mjit_opts .warnings || mjit_opts .verbose )
144
144
fprintf (stderr , "MJIT warning: JIT stack assumption is not the same between branches (%d != %u)\n" ,
145
145
status -> stack_size_for_pos [next_pos ], b -> stack_size );
146
- status -> success = false ;
146
+ status -> success = FALSE ;
147
147
}
148
148
}
149
149
@@ -160,7 +160,7 @@ compile_insns(FILE *f, const struct rb_iseq_constant_body *body, unsigned int st
160
160
struct compile_branch branch ;
161
161
162
162
branch .stack_size = stack_size ;
163
- branch .finish_p = false ;
163
+ branch .finish_p = FALSE ;
164
164
165
165
while (pos < body -> iseq_size && !ALREADY_COMPILED_P (status , pos ) && !branch .finish_p ) {
166
166
#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
@@ -175,7 +175,7 @@ compile_insns(FILE *f, const struct rb_iseq_constant_body *body, unsigned int st
175
175
if (status -> success && branch .stack_size > body -> stack_max ) {
176
176
if (mjit_opts .warnings || mjit_opts .verbose )
177
177
fprintf (stderr , "MJIT warning: JIT stack size (%d) exceeded its max size (%d)\n" , branch .stack_size , body -> stack_max );
178
- status -> success = false ;
178
+ status -> success = FALSE ;
179
179
}
180
180
if (!status -> success )
181
181
break ;
@@ -196,16 +196,16 @@ compile_cancel_handler(FILE *f, const struct rb_iseq_constant_body *body, struct
196
196
fprintf (f , " return Qundef;\n" );
197
197
}
198
198
199
- // Compile ISeq to C code in `f`. It returns true if it succeeds to compile.
200
- bool
199
+ /* Compile ISeq to C code in F. It returns 1 if it succeeds to compile. */
200
+ int
201
201
mjit_compile (FILE * f , const struct rb_iseq_constant_body * body , const char * funcname , struct rb_call_cache * cc_entries , union iseq_inline_storage_entry * is_entries )
202
202
{
203
203
struct compile_status status ;
204
- status .success = false ;
204
+ status .success = TRUE ;
205
205
status .local_stack_p = !body -> catch_except_p ;
206
206
status .stack_size_for_pos = (int * )malloc (sizeof (int ) * body -> iseq_size );
207
207
if (status .stack_size_for_pos == NULL )
208
- return false ;
208
+ return FALSE ;
209
209
memset (status .stack_size_for_pos , NOT_COMPILED_STACK_SIZE , sizeof (int ) * body -> iseq_size );
210
210
status .cc_entries = cc_entries ;
211
211
status .is_entries = is_entries ;
0 commit comments