assigning void* to a function pointer is a POSIXism
No implicit cast is defined between these types. Should be explicit. Also, NULL is defined to be ((void*)0) so not usable as a function pointer value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
779c18bf23
commit
8427fca49b
18
mjit.c
18
mjit.c
@ -440,7 +440,7 @@ static void
|
|||||||
free_unit(struct rb_mjit_unit *unit)
|
free_unit(struct rb_mjit_unit *unit)
|
||||||
{
|
{
|
||||||
if (unit->iseq) /* ISeq is not GCed */
|
if (unit->iseq) /* ISeq is not GCed */
|
||||||
unit->iseq->body->jit_func = NULL;
|
unit->iseq->body->jit_func = 0;
|
||||||
if (unit->handle) /* handle is NULL if it's in queue */
|
if (unit->handle) /* handle is NULL if it's in queue */
|
||||||
dlclose(unit->handle);
|
dlclose(unit->handle);
|
||||||
xfree(unit);
|
xfree(unit);
|
||||||
@ -682,7 +682,7 @@ load_func_from_so(const char *so_file, const char *funcname, struct rb_mjit_unit
|
|||||||
|
|
||||||
/* Compile ISeq in UNIT and return function pointer of JIT-ed code.
|
/* Compile ISeq in UNIT and return function pointer of JIT-ed code.
|
||||||
It may return NOT_COMPILABLE_JIT_ISEQ_FUNC if something went wrong. */
|
It may return NOT_COMPILABLE_JIT_ISEQ_FUNC if something went wrong. */
|
||||||
static void *
|
static mjit_func_t
|
||||||
convert_unit_to_func(struct rb_mjit_unit *unit)
|
convert_unit_to_func(struct rb_mjit_unit *unit)
|
||||||
{
|
{
|
||||||
char c_file[70], so_file[70], funcname[35];
|
char c_file[70], so_file[70], funcname[35];
|
||||||
@ -744,7 +744,7 @@ convert_unit_to_func(struct rb_mjit_unit *unit)
|
|||||||
if (!success) {
|
if (!success) {
|
||||||
if (!mjit_opts.save_temps)
|
if (!mjit_opts.save_temps)
|
||||||
remove(c_file);
|
remove(c_file);
|
||||||
return (void *)NOT_COMPILABLE_JIT_ISEQ_FUNC;
|
return (mjit_func_t)NOT_COMPILABLE_JIT_ISEQ_FUNC;
|
||||||
}
|
}
|
||||||
|
|
||||||
start_time = real_ms_time();
|
start_time = real_ms_time();
|
||||||
@ -755,7 +755,7 @@ convert_unit_to_func(struct rb_mjit_unit *unit)
|
|||||||
remove(c_file);
|
remove(c_file);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
verbose(2, "Failed to generate so: %s", so_file);
|
verbose(2, "Failed to generate so: %s", so_file);
|
||||||
return (void *)NOT_COMPILABLE_JIT_ISEQ_FUNC;
|
return (mjit_func_t)NOT_COMPILABLE_JIT_ISEQ_FUNC;
|
||||||
}
|
}
|
||||||
|
|
||||||
func = load_func_from_so(so_file, funcname, unit);
|
func = load_func_from_so(so_file, funcname, unit);
|
||||||
@ -771,7 +771,7 @@ convert_unit_to_func(struct rb_mjit_unit *unit)
|
|||||||
RSTRING_PTR(rb_iseq_path(unit->iseq)), FIX2INT(unit->iseq->body->location.first_lineno), c_file);
|
RSTRING_PTR(rb_iseq_path(unit->iseq)), FIX2INT(unit->iseq->body->location.first_lineno), c_file);
|
||||||
CRITICAL_SECTION_FINISH(3, "end of jit");
|
CRITICAL_SECTION_FINISH(3, "end of jit");
|
||||||
}
|
}
|
||||||
return func;
|
return (mjit_func_t)func;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set to TRUE to finish worker. */
|
/* Set to TRUE to finish worker. */
|
||||||
@ -810,7 +810,7 @@ worker(void)
|
|||||||
CRITICAL_SECTION_FINISH(3, "in worker dequeue");
|
CRITICAL_SECTION_FINISH(3, "in worker dequeue");
|
||||||
|
|
||||||
if (node) {
|
if (node) {
|
||||||
void *func = convert_unit_to_func(node->unit);
|
mjit_func_t func = convert_unit_to_func(node->unit);
|
||||||
|
|
||||||
CRITICAL_SECTION_START(3, "in jit func replace");
|
CRITICAL_SECTION_START(3, "in jit func replace");
|
||||||
if (node->unit->iseq) { /* Check whether GCed or not */
|
if (node->unit->iseq) { /* Check whether GCed or not */
|
||||||
@ -985,7 +985,7 @@ unload_units(void)
|
|||||||
/* Unload the worst node. */
|
/* Unload the worst node. */
|
||||||
verbose(2, "Unloading unit %d (calls=%lu)", worst_node->unit->id, worst_node->unit->iseq->body->total_calls);
|
verbose(2, "Unloading unit %d (calls=%lu)", worst_node->unit->id, worst_node->unit->iseq->body->total_calls);
|
||||||
unit = worst_node->unit;
|
unit = worst_node->unit;
|
||||||
unit->iseq->body->jit_func = (void *)NOT_READY_JIT_ISEQ_FUNC;
|
unit->iseq->body->jit_func = (mjit_func_t)NOT_READY_JIT_ISEQ_FUNC;
|
||||||
remove_from_list(worst_node, &active_units);
|
remove_from_list(worst_node, &active_units);
|
||||||
|
|
||||||
assert(unit->handle != NULL);
|
assert(unit->handle != NULL);
|
||||||
@ -1005,7 +1005,7 @@ mjit_add_iseq_to_process(const rb_iseq_t *iseq)
|
|||||||
if (!mjit_init_p)
|
if (!mjit_init_p)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
iseq->body->jit_func = (void *)NOT_READY_JIT_ISEQ_FUNC;
|
iseq->body->jit_func = (mjit_func_t)NOT_READY_JIT_ISEQ_FUNC;
|
||||||
create_unit(iseq);
|
create_unit(iseq);
|
||||||
if (iseq->body->jit_unit == NULL)
|
if (iseq->body->jit_unit == NULL)
|
||||||
/* Failure in creating the unit. */
|
/* Failure in creating the unit. */
|
||||||
@ -1177,7 +1177,7 @@ mjit_init(struct mjit_options *opts)
|
|||||||
/* Initialize worker thread */
|
/* Initialize worker thread */
|
||||||
finish_worker_p = FALSE;
|
finish_worker_p = FALSE;
|
||||||
worker_finished = FALSE;
|
worker_finished = FALSE;
|
||||||
if (rb_thread_create_mjit_thread(child_after_fork, worker) == FALSE) {
|
if (rb_thread_create_mjit_thread(child_after_fork, (void *)worker) == FALSE) {
|
||||||
mjit_init_p = FALSE;
|
mjit_init_p = FALSE;
|
||||||
rb_native_mutex_destroy(&mjit_engine_mutex);
|
rb_native_mutex_destroy(&mjit_engine_mutex);
|
||||||
rb_native_cond_destroy(&mjit_pch_wakeup);
|
rb_native_cond_destroy(&mjit_pch_wakeup);
|
||||||
|
@ -1777,7 +1777,7 @@ rb_nativethread_self(void)
|
|||||||
static void *
|
static void *
|
||||||
mjit_worker(void *arg)
|
mjit_worker(void *arg)
|
||||||
{
|
{
|
||||||
void (*worker_func)(void) = arg;
|
void (*worker_func)(void) = (void(*)(void))arg;
|
||||||
|
|
||||||
if (pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) != 0) {
|
if (pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) != 0) {
|
||||||
fprintf(stderr, "Cannot enable cancelation in MJIT worker\n");
|
fprintf(stderr, "Cannot enable cancelation in MJIT worker\n");
|
||||||
@ -1791,7 +1791,7 @@ mjit_worker(void *arg)
|
|||||||
|
|
||||||
/* Launch MJIT thread. Returns FALSE if it fails to create thread. */
|
/* Launch MJIT thread. Returns FALSE if it fails to create thread. */
|
||||||
int
|
int
|
||||||
rb_thread_create_mjit_thread(void (*child_hook)(void), void (*worker_func)(void))
|
rb_thread_create_mjit_thread(void (*child_hook)(void), void *worker_func)
|
||||||
{
|
{
|
||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
pthread_t worker_pid;
|
pthread_t worker_pid;
|
||||||
|
@ -292,8 +292,9 @@ pathobj_realpath(VALUE pathobj)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A forward declaration */
|
/* Forward declarations */
|
||||||
struct rb_mjit_unit;
|
struct rb_mjit_unit;
|
||||||
|
struct rb_execution_context_struct;
|
||||||
|
|
||||||
struct rb_iseq_constant_body {
|
struct rb_iseq_constant_body {
|
||||||
enum iseq_type {
|
enum iseq_type {
|
||||||
@ -419,7 +420,8 @@ struct rb_iseq_constant_body {
|
|||||||
unsigned int stack_max; /* for stack overflow check */
|
unsigned int stack_max; /* for stack overflow check */
|
||||||
|
|
||||||
/* The following fields are MJIT related info. */
|
/* The following fields are MJIT related info. */
|
||||||
void *jit_func; /* function pointer for loaded native code */
|
VALUE (*jit_func)(struct rb_execution_context_struct *,
|
||||||
|
struct rb_control_frame_struct *); /* function pointer for loaded native code */
|
||||||
long unsigned total_calls; /* number of total calls with `mjit_exec()` */
|
long unsigned total_calls; /* number of total calls with `mjit_exec()` */
|
||||||
struct rb_mjit_unit *jit_unit;
|
struct rb_mjit_unit *jit_unit;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user