Fix GCC warnings

Mostly unused and uninitialized warnings here and there
This commit is contained in:
Alan Wu 2021-03-31 18:27:34 -04:00
parent 9911f486a7
commit d03b7f77d4
5 changed files with 13 additions and 8 deletions

6
mjit.h
View File

@ -141,12 +141,10 @@ mjit_exec_slowpath(rb_execution_context_t *ec, const rb_iseq_t *iseq, struct rb_
static inline VALUE
mjit_exec(rb_execution_context_t *ec)
{
const rb_iseq_t *iseq;
struct rb_iseq_constant_body *body;
const rb_iseq_t *iseq = ec->cfp->iseq;
struct rb_iseq_constant_body *body = iseq->body;
if (mjit_call_p || rb_yjit_enabled_p()) {
iseq = ec->cfp->iseq;
body = iseq->body;
body->total_calls++;
}

View File

@ -175,7 +175,7 @@ void cb_align_pos(codeblock_t* cb, uint32_t multiple)
{
// Compute the pointer modulo the given alignment boundary
uint8_t* ptr = &cb->mem_block[cb->write_pos];
uint32_t rem = ((uint32_t)ptr) % multiple;
uint32_t rem = ((uint32_t)(uintptr_t)ptr) % multiple;
// If the pointer is already aligned, stop
if (rem == 0)

View File

@ -36,7 +36,7 @@ jit_print_loc(jitstate_t* jit, const char* msg)
long len;
VALUE path = rb_iseq_path(jit->iseq);
RSTRING_GETMEM(path, ptr, len);
fprintf(stderr, "%s %s:%u\n", msg, ptr, rb_iseq_line_no(jit->iseq, jit->insn_idx));
fprintf(stderr, "%s %.*s:%u\n", msg, (int)len, ptr, rb_iseq_line_no(jit->iseq, jit->insn_idx));
}
// Get the current instruction's opcode
@ -1825,6 +1825,8 @@ gen_opt_send_without_block(jitstate_t* jit, ctx_t* ctx)
return YJIT_CANT_COMPILE;
// no default case so compiler issues a warning if this is not exhaustive
}
return YJIT_CANT_COMPILE;
}
static codegen_status_t

View File

@ -18,12 +18,12 @@
#if HAVE_LIBCAPSTONE
#include <capstone/capstone.h>
static VALUE cYjitDisasm;
static VALUE cYjitDisasmInsn;
#endif
static VALUE mYjit;
static VALUE cYjitBlock;
static VALUE cYjitDisasm;
static VALUE cYjitDisasmInsn;
#if RUBY_DEBUG
static int64_t vm_insns_count = 0;

View File

@ -7,9 +7,12 @@
#define YJIT_IFACE_H 1
#include "ruby/ruby.h"
#include "ruby/assert.h" // for RUBY_DEBUG
#include "vm_core.h"
#include "yjit_core.h"
#if RUBY_DEBUG
#define YJIT_DECLARE_COUNTERS(...) struct rb_yjit_runtime_counters { \
int64_t __VA_ARGS__; \
}; \
@ -61,6 +64,8 @@ YJIT_DECLARE_COUNTERS(
#undef YJIT_DECLARE_COUNTERS
#endif // if RUBY_DEBUG
RUBY_EXTERN struct rb_yjit_options rb_yjit_opts;
RUBY_EXTERN int64_t rb_compiled_iseq_count;
RUBY_EXTERN struct rb_yjit_runtime_counters yjit_runtime_counters;