ruby-changes:72558
From: Takashi <ko1@a...>
Date: Fri, 15 Jul 2022 14:54:39 +0900 (JST)
Subject: [ruby-changes:72558] 6c2cad835a (master): MJIT: Share rb_mjit_unit through mjit_unit.h
https://git.ruby-lang.org/ruby.git/commit/?id=6c2cad835a From 6c2cad835a0d7d73a00a5048babb113c4afa388b Mon Sep 17 00:00:00 2001 From: Takashi Kokubun <takashikkbn@g...> Date: Thu, 14 Jul 2022 21:53:41 -0700 Subject: MJIT: Share rb_mjit_unit through mjit_unit.h mjit_compile.c should be able to access this more easily. --- common.mk | 2 ++ mjit.c | 31 +------------------------------ mjit_compile.c | 5 ++--- mjit_unit.h | 29 +++++++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 33 deletions(-) create mode 100644 mjit_unit.h diff --git a/common.mk b/common.mk index d99d52f357..f1764ef9ea 100644 --- a/common.mk +++ b/common.mk @@ -9658,6 +9658,7 @@ mjit.$(OBJEXT): {$(VPATH)}mjit.h https://github.com/ruby/ruby/blob/trunk/common.mk#L9658 mjit.$(OBJEXT): {$(VPATH)}mjit.rb mjit.$(OBJEXT): {$(VPATH)}mjit.rbinc mjit.$(OBJEXT): {$(VPATH)}mjit_config.h +mjit.$(OBJEXT): {$(VPATH)}mjit_unit.h mjit.$(OBJEXT): {$(VPATH)}node.h mjit.$(OBJEXT): {$(VPATH)}onigmo.h mjit.$(OBJEXT): {$(VPATH)}oniguruma.h @@ -9865,6 +9866,7 @@ mjit_compile.$(OBJEXT): {$(VPATH)}missing.h https://github.com/ruby/ruby/blob/trunk/common.mk#L9866 mjit_compile.$(OBJEXT): {$(VPATH)}mjit.h mjit_compile.$(OBJEXT): {$(VPATH)}mjit_compile.c mjit_compile.$(OBJEXT): {$(VPATH)}mjit_compile.inc +mjit_compile.$(OBJEXT): {$(VPATH)}mjit_unit.h mjit_compile.$(OBJEXT): {$(VPATH)}node.h mjit_compile.$(OBJEXT): {$(VPATH)}ruby_assert.h mjit_compile.$(OBJEXT): {$(VPATH)}ruby_atomic.h diff --git a/mjit.c b/mjit.c index b52c5fad9f..da3fd9d61e 100644 --- a/mjit.c +++ b/mjit.c @@ -87,6 +87,7 @@ https://github.com/ruby/ruby/blob/trunk/mjit.c#L87 #include "vm_core.h" #include "vm_callinfo.h" #include "mjit.h" +#include "mjit_unit.h" #include "gc.h" #include "ruby_assert.h" #include "ruby/debug.h" @@ -149,29 +150,6 @@ typedef intptr_t pid_t; https://github.com/ruby/ruby/blob/trunk/mjit.c#L150 # define USE_JIT_COMPACTION 1 #endif -// The unit structure that holds metadata of ISeq for MJIT. -struct rb_mjit_unit { - struct ccan_list_node unode; - // Unique order number of unit. - int id; - // Dlopen handle of the loaded object file. - void *handle; - rb_iseq_t *iseq; -#if defined(_WIN32) - // 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. - bool used_code_p; - // True if it's a unit for JIT compaction - bool compact_p; - // mjit_compile's optimization switches - struct rb_mjit_compile_info compile_info; - // captured CC values, they should be marked with iseq. - const struct rb_callcache **cc_entries; - unsigned int cc_entries_size; // ISEQ_BODY(iseq)->ci_size + ones of inlined iseqs -}; - // Linked list of struct rb_mjit_unit. struct rb_mjit_unit_list { struct ccan_list_head head; @@ -1138,13 +1116,6 @@ convert_unit_to_func(struct rb_mjit_unit *unit) https://github.com/ruby/ruby/blob/trunk/mjit.c#L1116 } #endif -// To see cc_entries using index returned by `mjit_capture_cc_entries` in mjit_compile.c -const struct rb_callcache ** -mjit_iseq_cc_entries(const struct rb_iseq_constant_body *const body) -{ - return body->jit_unit->cc_entries; -} - // Capture cc entries of `captured_iseq` and append them to `compiled_iseq->jit_unit->cc_entries`. // This is needed when `captured_iseq` is inlined by `compiled_iseq` and GC needs to mark inlined cc. // diff --git a/mjit_compile.c b/mjit_compile.c index 985c3caba6..66deaa9a65 100644 --- a/mjit_compile.c +++ b/mjit_compile.c @@ -20,6 +20,7 @@ https://github.com/ruby/ruby/blob/trunk/mjit_compile.c#L20 #include "internal/object.h" #include "internal/variable.h" #include "mjit.h" +#include "mjit_unit.h" #include "vm_core.h" #include "vm_callinfo.h" #include "vm_exec.h" @@ -87,8 +88,6 @@ call_data_index(CALL_DATA cd, const struct rb_iseq_constant_body *body) https://github.com/ruby/ruby/blob/trunk/mjit_compile.c#L88 return cd - body->call_data; } -const struct rb_callcache ** mjit_iseq_cc_entries(const struct rb_iseq_constant_body *const body); - // Using this function to refer to cc_entries allocated by `mjit_capture_cc_entries` // instead of storing cc_entries in status directly so that we always refer to a new address // returned by `realloc` inside it. @@ -96,7 +95,7 @@ static const struct rb_callcache ** https://github.com/ruby/ruby/blob/trunk/mjit_compile.c#L95 captured_cc_entries(const struct compile_status *status) { VM_ASSERT(status->cc_entries_index != -1); - return mjit_iseq_cc_entries(status->compiled_iseq) + status->cc_entries_index; + return status->compiled_iseq->jit_unit->cc_entries + status->cc_entries_index; } // Returns true if call cache is still not obsoleted and vm_cc_cme(cc)->def->type is available. diff --git a/mjit_unit.h b/mjit_unit.h new file mode 100644 index 0000000000..2e23a8d5fc --- /dev/null +++ b/mjit_unit.h @@ -0,0 +1,29 @@ https://github.com/ruby/ruby/blob/trunk/mjit_unit.h#L1 +#ifndef INTERNAL_MJIT_H +#define INTERNAL_MJIT_H + +#include "ccan/list/list.h" + +// The unit structure that holds metadata of ISeq for MJIT. +struct rb_mjit_unit { + struct ccan_list_node unode; + // Unique order number of unit. + int id; + // Dlopen handle of the loaded object file. + void *handle; + rb_iseq_t *iseq; +#if defined(_WIN32) + // 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. + bool used_code_p; + // True if it's a unit for JIT compaction + bool compact_p; + // mjit_compile's optimization switches + struct rb_mjit_compile_info compile_info; + // captured CC values, they should be marked with iseq. + const struct rb_callcache **cc_entries; + unsigned int cc_entries_size; // ISEQ_BODY(iseq)->ci_size + ones of inlined iseqs +}; + +#endif /* INTERNAL_MJIT_H */ -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/