From deb1c7b97d204016256a11bfa069ddb3e8fab9ea Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sat, 14 Mar 2020 20:50:53 -0700 Subject: Revert "Use a human-readable funcname with --jit-debug" This reverts commit cecebf55c476ae936f3e880477dfb62149143c46. debugging test failure... --- mjit_worker.c | 43 ++++--------------------------------------- 1 file changed, 4 insertions(+), 39 deletions(-) (limited to 'mjit_worker.c') diff --git a/mjit_worker.c b/mjit_worker.c index 9df7bc68e0..e7350454b7 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -92,7 +92,6 @@ #include "ruby_assert.h" #include "ruby/debug.h" #include "ruby/thread.h" -#include "ruby/version.h" #ifdef _WIN32 #include @@ -689,40 +688,6 @@ remove_so_file(const char *so_file, struct rb_mjit_unit *unit) #endif } -// Print _mjitX, but make a human-readable funcname when --jit-debug is used -static void -sprint_funcname(char *funcname, const struct rb_mjit_unit *unit) -{ - const rb_iseq_t *iseq = unit->iseq; - if (iseq == NULL || (!mjit_opts.debug && !mjit_opts.debug_flags)) { - sprintf(funcname, "_mjit%d", unit->id); - return; - } - - // Generate a short path - const char *path = RSTRING_PTR(rb_iseq_path(iseq)); - const char *lib = "/lib/"; - const char *version = "/" STRINGIZE(RUBY_API_VERSION_MAJOR) "." STRINGIZE(RUBY_API_VERSION_MINOR) "." STRINGIZE(RUBY_API_VERSION_TEENY) "/"; - while (strstr(path, lib)) // skip "/lib/" - path = strstr(path, lib) + strlen(lib); - while (strstr(path, version)) // skip "/x.y.z/" - path = strstr(path, version) + strlen(version); - - // Annotate all-normalized method names - const char *method = RSTRING_PTR(iseq->body->location.label); - if (!strcmp(method, "[]")) method = "AREF"; - if (!strcmp(method, "[]=")) method = "ASET"; - - // Print and normalize - sprintf(funcname, "_mjit%d_%s_%s", unit->id, path, method); - for (size_t i = 0; i < strlen(funcname); i++) { - char c = funcname[i]; - if (!(('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || c == '_')) { - funcname[i] = '_'; - } - } -} - #define append_str2(p, str, len) ((char *)memcpy((p), str, (len))+(len)) #define append_str(p, str) append_str2(p, str, sizeof(str)-1) #define append_lit(p, str) append_str2(p, str, rb_strlen_lit(str)) @@ -947,8 +912,8 @@ compact_all_jit_code(void) CRITICAL_SECTION_START(3, "in compact_all_jit_code to read list"); list_for_each(&active_units.head, cur, unode) { void *func; - char funcname[MAXPATHLEN]; - sprint_funcname(funcname, unit); + char funcname[35]; // TODO: reconsider `35` + sprintf(funcname, "_mjit%d", cur->id); if ((func = dlsym(handle, funcname)) == NULL) { mjit_warning("skipping to reload '%s' from '%s': %s", funcname, so_file, dlerror()); @@ -1036,7 +1001,7 @@ compile_prelude(FILE *f) static mjit_func_t convert_unit_to_func(struct rb_mjit_unit *unit) { - char c_file_buff[MAXPATHLEN], *c_file = c_file_buff, *so_file, funcname[MAXPATHLEN]; + char c_file_buff[MAXPATHLEN], *c_file = c_file_buff, *so_file, funcname[35]; // TODO: reconsider `35` int fd; FILE *f; void *func; @@ -1071,7 +1036,7 @@ convert_unit_to_func(struct rb_mjit_unit *unit) memcpy(so_file, c_file, c_file_len - sizeof(c_ext)); memcpy(&so_file[c_file_len - sizeof(c_ext)], so_ext, sizeof(so_ext)); - sprint_funcname(funcname, unit); + sprintf(funcname, "_mjit%d", unit->id); fd = rb_cloexec_open(c_file, access_mode, 0600); if (fd < 0 || (f = fdopen(fd, "w")) == NULL) { -- cgit v1.2.3