summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2021-03-31 18:27:34 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2021-10-20 18:19:32 -0400
commitd03b7f77d45105bfe613b986bfddaaa6c1de6831 (patch)
tree813dfa739f9c9ff573268bc887dfd6e24afd605a
parent9911f486a7d9902a900f91cfa607e8cacdda6494 (diff)
Fix GCC warnings
Mostly unused and uninitialized warnings here and there
-rw-r--r--mjit.h6
-rw-r--r--yjit_asm.c2
-rw-r--r--yjit_codegen.c4
-rw-r--r--yjit_iface.c4
-rw-r--r--yjit_iface.h5
5 files changed, 13 insertions, 8 deletions
diff --git a/mjit.h b/mjit.h
index 3b28f51d1d..e6bf6be8dc 100644
--- a/mjit.h
+++ b/mjit.h
@@ -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++;
}
diff --git a/yjit_asm.c b/yjit_asm.c
index 60873bb476..fc8472f077 100644
--- a/yjit_asm.c
+++ b/yjit_asm.c
@@ -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)
diff --git a/yjit_codegen.c b/yjit_codegen.c
index 1a19c84101..6ccc6afc99 100644
--- a/yjit_codegen.c
+++ b/yjit_codegen.c
@@ -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
diff --git a/yjit_iface.c b/yjit_iface.c
index 24bbaab905..a08ce2bb6f 100644
--- a/yjit_iface.c
+++ b/yjit_iface.c
@@ -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;
diff --git a/yjit_iface.h b/yjit_iface.h
index a70ca90fc7..bc1f1a7ad6 100644
--- a/yjit_iface.h
+++ b/yjit_iface.h
@@ -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;