From e3c1c406fc2bf6c4c2d7308562214b00fd9f7ca1 Mon Sep 17 00:00:00 2001 From: k0kubun Date: Sun, 29 Jul 2018 08:04:45 +0000 Subject: [PATCH] mjit.c: keep unit->o_file on --jit-save-temps to use compaction with --jit-save-temps. Prior to this commit, JIT compaction didn't work with --jit-save-temps but it wasn't intentional. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64100 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- mjit.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mjit.c b/mjit.c index ef1a364ddd..c5fb709d92 100644 --- a/mjit.c +++ b/mjit.c @@ -163,11 +163,11 @@ struct rb_mjit_unit { void *handle; const rb_iseq_t *iseq; #ifndef _MSC_VER - /* This is lazily deleted so that it can be used again to create a large so file. */ + /* This value is always set for `compact_all_jit_code`. Also used for lazy deletion. */ char *o_file; #endif #ifdef _WIN32 - /* DLL cannot be removed while loaded on Windows */ + /* DLL cannot be removed while loaded on Windows. If this is set, it'll be lazily deleted. */ char *so_file; #endif /* Only used by unload_units. Flag to check this unit is currently on stack or not. */ @@ -537,7 +537,10 @@ clean_object_files(struct rb_mjit_unit *unit) char *o_file = unit->o_file; unit->o_file = NULL; - remove_file(o_file); + /* For compaction, unit->o_file is always set when compilation succeeds. + So save_temps needs to be checked here. */ + if (!mjit_opts.save_temps) + remove_file(o_file); free(o_file); } #endif @@ -547,6 +550,7 @@ clean_object_files(struct rb_mjit_unit *unit) char *so_file = unit->so_file; unit->so_file = NULL; + /* unit->so_file is set only when mjit_opts.save_temps is FALSE. */ remove_file(so_file); free(so_file); } @@ -1136,8 +1140,8 @@ convert_unit_to_func(struct rb_mjit_unit *unit) const char *o_files[] = { o_file, NULL }; success = link_o_to_so(o_files, so_file); - if (!mjit_opts.save_temps) - unit->o_file = strdup(o_file); /* lazily delete on `clean_object_files()` */ + /* Alwasy set o_file for compaction. The value is also used for lazy deletion. */ + unit->o_file = strdup(o_file); } #endif end_time = real_ms_time();