summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2021-09-09 23:21:06 +0900
committerNobuyoshi Nakada <[email protected]>2021-09-11 08:41:32 +0900
commitcd829bb078e6a3486d9b5ea57fc5111d289c1860 ()
treef1c903880d0ed454250f95d95a6e6d765a899796
parent967b9743faac0b55a3d8deb176a08fdff449bba8 (diff)
Remove printf family from the mjit header
Linking printf family functions makes mjit objects to link unnecessary code.
Notes: Merged: https://.com/ruby/ruby/pull/4820
-rw-r--r--gc.h6
-rw-r--r--include/ruby/internal/core/rstring.h24
-rw-r--r--internal.h4
-rw-r--r--ractor_core.h14
-rw-r--r--string.c10
-rw-r--r--vm.c20
-rw-r--r--vm_args.c2
-rw-r--r--vm_callinfo.h6
-rw-r--r--vm_exec.h16
-rw-r--r--vm_insnhelper.c27
10 files changed, 72 insertions, 57 deletions
@@ -35,7 +35,7 @@ extern int ruby_gc_debug_indent;
static inline void
rb_gc_debug_indent(void)
{
- printf("%*s", ruby_gc_debug_indent, "");
}
static inline void
@@ -45,7 +45,7 @@ rb_gc_debug_body(const char *mode, const char *msg, int st, void *ptr)
ruby_gc_debug_indent--;
}
rb_gc_debug_indent();
- printf("%s: %s %s (%p)\n", mode, st ? "->" : "<-", msg, ptr);
if (st) {
ruby_gc_debug_indent++;
@@ -58,7 +58,7 @@ rb_gc_debug_body(const char *mode, const char *msg, int st, void *ptr)
#define RUBY_MARK_LEAVE(msg) rb_gc_debug_body("mark", (msg), 0, ptr)
#define RUBY_FREE_ENTER(msg) rb_gc_debug_body("free", (msg), 1, ptr)
#define RUBY_FREE_LEAVE(msg) rb_gc_debug_body("free", (msg), 0, ptr)
-#define RUBY_GC_INFO rb_gc_debug_indent(); printf
#else
#define RUBY_MARK_ENTER(msg)
@@ -371,6 +371,16 @@ void rb_check_safe_str(VALUE);
* only. You can safely forget about it.
*/
#define Check_SafeStr(v) rb_check_safe_str(RBIMPL_CAST((VALUE)(v)))
RBIMPL_SYMBOL_EXPORT_END()
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
@@ -476,12 +486,7 @@ RSTRING_PTR(VALUE str)
* Also, this is not rb_warn() because RSTRING_PTR() can be called
* during GC (see what obj_info() does). rb_warn() needs to allocate
* Ruby objects. That is not possible at this moment. */
- fprintf(stderr, "%s\n",
- "RSTRING_PTR is returning NULL!! "
- "SIGSEGV is highly expected to follow immediately. "
- "If you could reproduce, attach your debugger here, "
- "and look at the passed string."
- );
}
return ptr;
@@ -502,12 +507,7 @@ RSTRING_END(VALUE str)
if (RB_UNLIKELY(! buf.as.heap.ptr)) {
/* Ditto. */
- fprintf(stderr, "%s\n",
- "RSTRING_END is returning NULL!! "
- "SIGSEGV is highly expected to follow immediately. "
- "If you could reproduce, attach your debugger here, "
- "and look at the passed string."
- );
}
return &buf.as.heap.ptr[buf.as.heap.len];
@@ -95,8 +95,8 @@ RUBY_SYMBOL_EXPORT_END
// same as rp, but add message header
#define rp_m(msg, obj) do { \
- fprintf(stderr, "%s", (msg)); \
- rb_obj_info_dump((VALUE)obj); \
} while (0)
// `ruby_debug_breakpoint()` does nothing,
@@ -237,9 +237,11 @@ rb_ractor_sleeper_thread_num(rb_ractor_t *r)
static inline void
rb_ractor_thread_switch(rb_ractor_t *cr, rb_thread_t *th)
{
- if (cr->threads.running_ec != th->ec) {
- if (0) fprintf(stderr, "rb_ractor_thread_switch ec:%p->%p\n",
- (void *)cr->threads.running_ec, (void *)th->ec);
}
else {
return;
@@ -268,8 +270,10 @@ rb_ractor_set_current_ec(rb_ractor_t *cr, rb_execution_context_t *ec)
#endif
if (cr->threads.running_ec != ec) {
- if (0) fprintf(stderr, "rb_ractor_set_current_ec ec:%p->%p\n",
- (void *)cr->threads.running_ec, (void *)ec);
}
else {
VM_ASSERT(0); // should be different
@@ -223,6 +223,16 @@ rb_str_make_independent(VALUE str)
}
}
/* symbols for [up|down|swap]case/capitalize options */
static VALUE sym_ascii, sym_turkic, sym_lithuanian, sym_fold;
@@ -315,10 +315,10 @@ rb_vm_cref_new_toplevel(void)
static void
vm_cref_dump(const char *mesg, const rb_cref_t *cref)
{
- fprintf(stderr, "vm_cref_dump: %s (%p)\n", mesg, (void *)cref);
while (cref) {
- fprintf(stderr, "= cref| klass: %s\n", RSTRING_PTR(rb_class_path(CREF_CLASS(cref))));
cref = CREF_NEXT(cref);
}
}
@@ -686,15 +686,15 @@ static VALUE check_env_value(const rb_env_t *env);
static int
check_env(const rb_env_t *env)
{
- fprintf(stderr, "---\n");
- fprintf(stderr, "envptr: %p\n", (void *)&env->ep[0]);
- fprintf(stderr, "envval: %10p ", (void *)env->ep[1]);
dp(env->ep[1]);
- fprintf(stderr, "ep: %10p\n", (void *)env->ep);
if (rb_vm_env_prev_env(env)) {
- fprintf(stderr, ">>\n");
check_env_value(rb_vm_env_prev_env(env));
- fprintf(stderr, "<<\n");
}
return 1;
}
@@ -2719,7 +2719,7 @@ get_param(const char *name, size_t default_value, size_t min_value)
}
result = (size_t)(((val -1 + RUBY_VM_SIZE_ALIGN) / RUBY_VM_SIZE_ALIGN) * RUBY_VM_SIZE_ALIGN);
}
- if (0) fprintf(stderr, "%s: %"PRIuSIZE"\n", name, result); /* debug print */
return result;
}
@@ -3706,7 +3706,7 @@ Init_BareVM(void)
rb_vm_t * vm = ruby_mimmalloc(sizeof(*vm));
rb_thread_t * th = ruby_mimmalloc(sizeof(*th));
if (!vm || !th) {
- fprintf(stderr, "[FATAL] failed to allocate memory\n");
exit(EXIT_FAILURE);
}
MEMZERO(th, rb_thread_t, 1);
@@ -701,7 +701,7 @@ setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * co
{
int i;
for (i=0; i<iseq->body->param.size; i++) {
- fprintf(stderr, "local[%d] = %p\n", i, (void *)locals[i]);
}
}
#endif
@@ -168,8 +168,8 @@ static inline void
vm_ci_dump(const struct rb_callinfo *ci)
{
if (vm_ci_packed_p(ci)) {
- fprintf(stderr, "packed_ci ID:%s flag:%x argc:%u\n",
- rb_id2name(vm_ci_mid(ci)), vm_ci_flag(ci), vm_ci_argc(ci));
}
else {
rp(ci);
@@ -204,7 +204,7 @@ vm_ci_new_(ID mid, unsigned int flag, unsigned int argc, const struct rb_callinf
#endif
const bool debug = 0;
- if (debug) fprintf(stderr, "%s:%d ", file, line);
// TODO: dedup
const struct rb_callinfo *ci = (const struct rb_callinfo *)
@@ -37,8 +37,8 @@ typedef rb_iseq_t *ISEQ;
#define DEBUG_END_INSN()
#endif
-#define throwdebug if(0)printf
-/* #define throwdebug printf */
#ifndef USE_INSNS_COUNTER
#define USE_INSNS_COUNTER 0
@@ -74,11 +74,13 @@ error !
#define LABEL_PTR(x) RB_GNUC_EXTENSION(&&LABEL(x))
#define INSN_ENTRY_SIG(insn) \
- if (0) fprintf(stderr, "exec: %s@(%"PRIdPTRDIFF", %"PRIdPTRDIFF")@%s:%u\n", #insn, \
- (reg_pc - reg_cfp->iseq->body->iseq_encoded), \
- (reg_cfp->pc - reg_cfp->iseq->body->iseq_encoded), \
- RSTRING_PTR(rb_iseq_path(reg_cfp->iseq)), \
- rb_iseq_line_no(reg_cfp->iseq, reg_pc - reg_cfp->iseq->body->iseq_encoded)); \
if (USE_INSNS_COUNTER) vm_insns_counter_count_insn(BIN(insn));
#define INSN_DIS_SIG(insn)
@@ -275,7 +275,7 @@ rb_vm_check_canary(const rb_execution_context_t *ec, VALUE *sp)
/* rb_bug() is not capable of outputting this large contents. It
is designed to run form a SIGSEGV handler, which tends to be
very restricted. */
- fprintf(stderr,
"We are killing the stack canary set by %s, "
"at %s@pc=%"PRIdPTR"\n"
"watch out the C stack trace.\n"
@@ -1690,7 +1690,7 @@ vm_ccs_push(VALUE klass, struct rb_class_cc_entries *ccs, const struct rb_callin
void
rb_vm_ccs_dump(struct rb_class_cc_entries *ccs)
{
- fprintf(stderr, "ccs:%p (%d,%d)\n", (void *)ccs, ccs->len, ccs->capa);
for (int i=0; i<ccs->len; i++) {
vm_ci_dump(ccs->entries[i].ci);
rp(ccs->entries[i].cc);
@@ -2164,7 +2164,7 @@ vm_base_ptr(const rb_control_frame_t *cfp)
}
#if VM_DEBUG_BP_CHECK
if (bp != cfp->bp_check) {
- fprintf(stderr, "bp_check: %ld, bp: %ld\n",
(long)(cfp->bp_check - GET_EC()->vm_stack),
(long)(bp - GET_EC()->vm_stack));
rb_bug("vm_base_ptr: unreachable");
@@ -2328,7 +2328,7 @@ static void
opt_hist_show_results_at_exit(void)
{
for (int i=0; i<OPT_HIST_MAX; i++) {
- fprintf(stderr, "opt_hist\t%d\t%d\n", i, opt_hist[i]);
}
}
#endif
@@ -5428,12 +5428,12 @@ vm_trace(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp)
rb_hook_list_t *global_hooks = rb_ec_ractor_hooks(ec);
if (0) {
- fprintf(stderr, "vm_trace>>%4d (%4x) - %s:%d %s\n",
- (int)pos,
- (int)pc_events,
- RSTRING_PTR(rb_iseq_path(iseq)),
- (int)rb_iseq_line_no(iseq, pos),
- RSTRING_PTR(rb_iseq_label(iseq)));
}
VM_ASSERT(reg_cfp->pc == pc);
VM_ASSERT(pc_events != 0);
@@ -5666,12 +5666,11 @@ static VALUE
vm_invoke_builtin_delegate(rb_execution_context_t *ec, rb_control_frame_t *cfp, const struct rb_builtin_function *bf, unsigned int start_index)
{
if (0) { // debug print
- fprintf(stderr, "vm_invoke_builtin_delegate: passing -> ");
for (int i=0; i<bf->argc; i++) {
- fprintf(stderr, ":%s ", rb_id2name(cfp->iseq->body->local_table[i+start_index]));
}
- fprintf(stderr, "\n");
- fprintf(stderr, "%s %s(%d):%p\n", RUBY_FUNCTION_NAME_STRING, bf->name, bf->argc, bf->func_ptr);
}
if (bf->argc == 0) {