8000 Revert "mjit.c: use boolean type for boolean variables" · github/ruby@efd99b5 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit efd99b5

Browse files
committed
Revert "mjit.c: use boolean type for boolean variables"
This reverts commit bb1a1ae. We hit something on ci.rvm.jp, reverting until investigation is done. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent bb1a1ae commit efd99b5

File tree

8 files changed

+94
-91
lines changed

8 files changed

+94
-91
lines changed

eval.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ ruby_cleanup(volatile int ex)
233233
}
234234
}
235235

236-
mjit_finish(true); // We still need ISeqs here.
236+
mjit_finish(TRUE); /* We still need ISeqs here. */
237237

238238
ruby_finalize_1();
239239

internal.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,15 +1595,15 @@ VALUE rb_math_sqrt(VALUE);
15951595
/* mjit.c */
15961596

15971597
#if USE_MJIT
1598-
extern bool mjit_enabled;
1599-
VALUE mjit_pause(bool wait_p);
1598+
extern int mjit_enabled;
1599+
VALUE mjit_pause(int wait_p);
16001600
VALUE mjit_resume(void);
1601-
void mjit_finish(bool close_handle_p);
1601+
void mjit_finish(int close_handle_p);
16021602
#else
16031603
#define mjit_enabled 0
1604-
static inline VALUE mjit_pause(bool wait_p){ return Qnil; } /* unreachable */
1604+
static inline VALUE mjit_pause(int wait_p){ return Qnil; } /* unreachable */
16051605
static inline VALUE mjit_resume(void){ return Qnil; } /* unreachable */
1606-
static inline void mjit_finish(bool close_handle_p){}
1606+
static inline void mjit_finish(int close_handle_p){}
16071607
#endif
16081608

16091609
/* newline.c */

mjit.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ mjit_copy_job_handler(void *data)
4848
memcpy(job->is_entries, body->is_entries, sizeof(union iseq_inline_storage_entry) * body->is_size);
4949
}
5050

51-
job->finish_p = true;
51+
job->finish_p = TRUE;
5252
rb_native_cond_broadcast(&mjit_worker_wakeup);
5353
CRITICAL_SECTION_FINISH(3, "in mjit_copy_job_handler");
5454
}
@@ -88,7 +88,7 @@ mjit_gc_start_hook(void)
8888
rb_native_cond_wait(&mjit_client_wakeup, &mjit_engine_mutex);
8989
verbose(4, "Getting wakeup from a worker for GC");
9090
}
91-
in_gc = true;
91+
in_gc = TRUE;
9292
CRITICAL_SECTION_FINISH(4, "mjit_gc_start_hook");
9393
}
9494

@@ -100,7 +100,7 @@ mjit_gc_finish_hook(void)
100100
if (!mjit_enabled)
101101
return;
102102
CRITICAL_SECTION_START(4, "mjit_gc_finish_hook");
103-
in_gc = false;
103+
in_gc = FALSE;
104104
verbose(4, "Sending wakeup signal to workers after GC");
105105
rb_native_cond_broadcast(&mjit_gc_wakeup);
106106
CRITICAL_SECTION_FINISH(4, "mjit_gc_finish_hook");
@@ -126,7 +126,7 @@ mjit_free_iseq(const rb_iseq_t *iseq)
126126
because node of unit_queue and one of active_units may have the same unit
127127
during proceeding unit. */
128128
static void
129-
free_list(struct rb_mjit_unit_list *list, bool close_handle_p)
129+
free_list(struct rb_mjit_unit_list *list, int close_handle_p)
130130
{
131131
struct rb_mjit_unit *unit = 0, *next;
132132

@@ -572,11 +572,11 @@ system_tmpdir(void)
572572
#define MIN_CACHE_SIZE 10
573573

574574
/* Start MJIT worker. Return TRUE if worker is sucessfully started. */
575-
static bool
575+
static int
576576
start_worker(void)
577577
{
578-
stop_worker_p = false;
579-
worker_stopped = true;
578+
stop_worker_p = FALSE;
579+
worker_stopped = FALSE;
580580

581581
if (!rb_thread_create_mjit_thread(mjit_worker)) {
582582
mjit_enabled = FALSE;
@@ -586,9 +586,9 @@ start_worker(void)
586586
rb_native_cond_destroy(&mjit_worker_wakeup);
587587
rb_native_cond_destroy(&mjit_gc_wakeup);
588588
verbose(1, "Failure in MJIT thread initialization\n");
589-
return false;
589+
return FALSE;
590590
}
591-
return true;
591+
return TRUE;
592592
}
593593

594594
/* Initialize MJIT. Start a thread creating the precompiled header and
@@ -598,8 +598,8 @@ void
598598
mjit_init(struct mjit_options *opts)
599599
{
600600
mjit_opts = *opts;
601-
mjit_enabled = true;
602-
mjit_call_p = true;
601+
mjit_enabled = TRUE;
602+
mjit_call_p = TRUE;
603603

604604
/* Normalize options */
605605
if (mjit_opts.min_calls == 0)
@@ -635,7 +635,7 @@ mjit_init(struct mjit_options *opts)
635635
verbose(2, "MJIT: tmp_dir is %s", tmp_dir);
636636

637637
if (!init_header_filename()) {
638-
mjit_enabled = false;
638+
mjit_enabled = FALSE;
639639
verbose(1, "Failure in MJIT header file name initialization\n");
640640
return;
641641
}
@@ -670,7 +670,7 @@ stop_worker(void)
670670
while (!worker_stopped) {
671671
verbose(3, "Sending cancel signal to worker");
672672
CRITICAL_SECTION_START(3, "in stop_worker");
673-
stop_worker_p = true; /* Setting this inside loop because RUBY_VM_CHECK_INTS may make this FALSE. */
673+
stop_worker_p = TRUE; /* Setting this inside loop because RUBY_VM_CHECK_INTS may make this FALSE. */
674674
rb_native_cond_broadcast(&mjit_worker_wakeup);
675675
CRITICAL_SECTION_FINISH(3, "in stop_worker");
676676
RUBY_VM_CHECK_INTS(ec);
@@ -679,7 +679,7 @@ stop_worker(void)
679679

680680
/* Stop JIT-compiling methods but compiled code is kept available. */
681681
VALUE
682-
mjit_pause(bool wait_p)
682+
mjit_pause(int wait_p)
683683
{
684684
if (!mjit_enabled) {
685685
rb_raise(rb_eRuntimeError, "MJIT is not enabled");
@@ -775,10 +775,10 @@ mjit_child_after_fork(void)
775775
and free MJIT data. It should be called last during MJIT
776776
life.
777777
778-
If close_handle_p is true, it calls dlclose() for JIT-ed code. So it should be false
778+
If close_handle_p is TRUE, it calls dlclose() for JIT-ed code. So it should be FALSE
779779
if the code can still be on stack. ...But it means to leak JIT-ed handle forever (FIXME). */
780780
void
781-
mjit_finish(bool close_handle_p)
781+
mjit_finish(int close_handle_p)
782782
{
783783
if (!mjit_enabled)
784784
return;
@@ -816,13 +816,13 @@ mjit_finish(bool close_handle_p)
816816
xfree(tmp_dir); tmp_dir = NULL;
817817
xfree(pch_file); pch_file = NULL;
818818

819-
mjit_call_p = true;
819+
mjit_call_p = FALSE;
820820
free_list(&unit_queue, close_handle_p);
821821
free_list(&active_units, close_handle_p);
822822
free_list(&compact_units, close_handle_p);
823823
finish_conts();
824824

825-
mjit_enabled = false;
825+
mjit_enabled = FALSE;
826826
verbose(1, "Successful MJIT finish");
827827
}
828828

mjit.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ typedef VALUE (*mjit_func_t)(rb_execution_context_t *, rb_control_frame_t *);
5858

5959
RUBY_SYMBOL_EXPORT_BEGIN
6060
RUBY_EXTERN struct mjit_options mjit_opts;
61-
RUBY_EXTERN bool mjit_call_p;
61+
RUBY_EXTERN int mjit_call_p;
6262

6363
extern void mjit_add_iseq_to_process(const rb_iseq_t *iseq);
6464
extern VALUE mjit_wait_call(rb_execution_context_t *ec, struct rb_iseq_constant_body *body);
6565
RUBY_SYMBOL_EXPORT_END
6666

67-
extern bool 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);
67+
extern int 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);
6868
extern void mjit_init(struct mjit_options *opts);
6969
extern void mjit_postponed_job_register_start_hook(void);
7070
extern void mjit_postponed_job_register_finish_hook(void);

mjit_compile.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
which is global during one `mjit_compile` call. Ones conditional
3030
in each branch should be stored in `compile_branch`. */
3131
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. */
3838
union iseq_inline_storage_entry *is_entries;
3939
struct rb_call_cache *cc_entries;
4040
};
@@ -43,8 +43,8 @@ struct compile_status {
4343
This is created and used for one `compile_insns` call and its values
4444
should be copied for extra `compile_insns` call. */
4545
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 */
4848
};
4949

5050
struct case_dispatch_var {
@@ -53,21 +53,21 @@ struct case_dispatch_var {
5353
VALUE last_value;
5454
};
5555

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
5858
has_valid_method_type(CALL_CACHE cc)
5959
{
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);
6161
return GET_GLOBAL_METHOD_STATE() == cc->method_state
6262
&& mjit_valid_class_serial_p(cc->class_serial) && cc->me;
6363
}
6464

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
6868
inlinable_iseq_p(CALL_INFO ci, CALL_CACHE cc, const rb_iseq_t *iseq)
6969
{
70-
extern bool rb_simple_iseq_p(const rb_iseq_t *iseq);
70+
extern int rb_simple_iseq_p(const rb_iseq_t *iseq);
7171
return iseq != NULL
7272
&& rb_simple_iseq_p(iseq) && !(ci->flag & VM_CALL_KW_SPLAT) /* Top of vm_callee_setup_arg. In this case, opt_pc is 0. */
7373
&& (!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,
143143
if (mjit_opts.warnings || mjit_opts.verbose)
144144
fprintf(stderr, "MJIT warning: JIT stack assumption is not the same between branches (%d != %u)\n",
145145
status->stack_size_for_pos[next_pos], b->stack_size);
146-
status->success = false;
146+
status->success = FALSE;
147147
}
148148
}
149149

@@ -160,7 +160,7 @@ compile_insns(FILE *f, const struct rb_iseq_constant_body *body, unsigned int st
160160
struct compile_branch branch;
161161

162162
branch.stack_size = stack_size;
163-
branch.finish_p = false;
163+
branch.finish_p = FALSE;
164164

165165
while (pos < body->iseq_size && !ALREADY_COMPILED_P(status, pos) && !branch.finish_p) {
166166
#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
175175
if (status->success && branch.stack_size > body->stack_max) {
176176
if (mjit_opts.warnings || mjit_opts.verbose)
177177
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;
179179
}
180180
if (!status->success)
181181
break;
@@ -196,16 +196,16 @@ compile_cancel_handler(FILE *f, const struct rb_iseq_constant_body *body, struct
196196
fprintf(f, " return Qundef;\n");
197197
}
198198

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
201201
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)
202202
{
203203
struct compile_status status;
204-
status.success = false;
204+
status.success = TRUE;
205205
status.local_stack_p = !body->catch_except_p;
206206
status.stack_size_for_pos = (int *)malloc(sizeof(int) * body->iseq_size);
207207
if (status.stack_size_for_pos == NULL)
208-
return false;
208+
return FALSE;
209209
memset(status.stack_size_for_pos, NOT_COMPILED_STACK_SIZE, sizeof(int) * body->iseq_size);
210210
status.cc_entries = cc_entries;
211211
status.is_entries = is_entries;

0 commit comments

Comments
 (0)
0