1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

process.c: finish MJIT prior to #exec

to prevent ruby from leaving MJIT-related files.

test_jit.rb: add a test to prevent that

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
k0kubun 2018-11-26 13:39:53 +00:00
parent a3bb9f1093
commit 08e1705eec
4 changed files with 15 additions and 3 deletions

View file

@ -1634,10 +1634,12 @@ VALUE rb_math_sqrt(VALUE);
extern int mjit_enabled; extern int mjit_enabled;
VALUE mjit_pause(int wait_p); VALUE mjit_pause(int wait_p);
VALUE mjit_resume(void); VALUE mjit_resume(void);
void mjit_finish(void);
#else #else
#define mjit_enabled 0 #define mjit_enabled 0
static inline VALUE mjit_pause(int wait_p){ return Qnil; } /* unreachable */ static inline VALUE mjit_pause(int wait_p){ return Qnil; } /* unreachable */
static inline VALUE mjit_resume(void){ return Qnil; } /* unreachable */ static inline VALUE mjit_resume(void){ return Qnil; } /* unreachable */
static inline void mjit_finish(void){}
#endif #endif
/* newline.c */ /* newline.c */

2
mjit.h
View file

@ -66,7 +66,6 @@ RUBY_SYMBOL_EXPORT_END
extern int mjit_compile(FILE *f, const struct rb_iseq_constant_body *body, const char *funcname, struct rb_call_cache *cc_entries, union iseq_inline_storage_entry *is_entries); extern int mjit_compile(FILE *f, const struct rb_iseq_constant_body *body, const char *funcname, struct rb_call_cache *cc_entries, union iseq_inline_storage_entry *is_entries);
extern void mjit_init(struct mjit_options *opts); extern void mjit_init(struct mjit_options *opts);
extern void mjit_finish(void);
extern void mjit_gc_start_hook(void); extern void mjit_gc_start_hook(void);
extern void mjit_gc_finish_hook(void); extern void mjit_gc_finish_hook(void);
extern void mjit_free_iseq(const rb_iseq_t *iseq); extern void mjit_free_iseq(const rb_iseq_t *iseq);
@ -132,7 +131,6 @@ void mjit_child_after_fork(void);
#else /* USE_MJIT */ #else /* USE_MJIT */
static inline struct mjit_cont *mjit_cont_new(rb_execution_context_t *ec){return NULL;} static inline struct mjit_cont *mjit_cont_new(rb_execution_context_t *ec){return NULL;}
static inline void mjit_cont_free(struct mjit_cont *cont){} static inline void mjit_cont_free(struct mjit_cont *cont){}
static inline void mjit_finish(void){}
static inline void mjit_gc_start_hook(void){} static inline void mjit_gc_start_hook(void){}
static inline void mjit_gc_finish_hook(void){} static inline void mjit_gc_finish_hook(void){}
static inline void mjit_free_iseq(const rb_iseq_t *iseq){} static inline void mjit_free_iseq(const rb_iseq_t *iseq){}

View file

@ -2944,7 +2944,7 @@ rb_f_exec(int argc, const VALUE *argv)
execarg_obj = rb_execarg_new(argc, argv, TRUE, FALSE); execarg_obj = rb_execarg_new(argc, argv, TRUE, FALSE);
eargp = rb_execarg_get(execarg_obj); eargp = rb_execarg_get(execarg_obj);
if (mjit_enabled) mjit_pause(FALSE); /* do not leak children */ if (mjit_enabled) mjit_finish(); /* do not leave files or leak children */
before_exec(); /* stop timer thread before redirects */ before_exec(); /* stop timer thread before redirects */
rb_execarg_parent_start(execarg_obj); rb_execarg_parent_start(execarg_obj);
fail_str = eargp->use_shell ? eargp->invoke.sh.shell_script : eargp->invoke.cmd.command_name; fail_str = eargp->use_shell ? eargp->invoke.sh.shell_script : eargp->invoke.cmd.command_name;

View file

@ -776,6 +776,18 @@ class TestJIT < Test::Unit::TestCase
end end
end end
def test_clean_objects_on_exec
Dir.mktmpdir("jit_test_clean_objects_on_exec_") do |dir|
eval_with_jit({"TMPDIR"=>dir}, "#{<<~"begin;"}\n#{<<~"end;"}", min_calls: 1)
begin;
def a; end; a
exec "true"
end;
error_message = "Undeleted files:\n #{Dir.glob("#{dir}/*").join("\n ")}\n"
assert_send([Dir, :empty?, dir], error_message)
end
end if system("which true")
def test_lambda_longjmp def test_lambda_longjmp
assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '5', success_count: 1) assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '5', success_count: 1)
begin; begin;