From b9007b6c548f91e88fd3f2ffa23de740431fa969 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Wed, 8 Jan 2020 16:14:01 +0900 Subject: Introduce disposable call-cache. This patch contains several ideas: (1) Disposable inline method cache (IMC) for race-free inline method cache * Making call-cache (CC) as a RVALUE (GC target object) and allocate new CC on cache miss. * This technique allows race-free access from parallel processing elements like RCU. (2) Introduce per-Class method cache (pCMC) * Instead of fixed-size global method cache (GMC), pCMC allows flexible cache size. * Caching CCs reduces CC allocation and allow sharing CC's fast-path between same call-info (CI) call-sites. (3) Invalidate an inline method cache by invalidating corresponding method entries (MEs) * Instead of using class serials, we set "invalidated" flag for method entry itself to represent cache invalidation. * Compare with using class serials, the impact of method modification (add/overwrite/delete) is small. * Updating class serials invalidate all method caches of the class and sub-classes. * Proposed approach only invalidate the method cache of only one ME. See [Feature #16614] for more details. --- mjit.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'mjit.h') diff --git a/mjit.h b/mjit.h index bdc186f788..15be560786 100644 --- a/mjit.h +++ b/mjit.h @@ -70,6 +70,35 @@ struct rb_mjit_compile_info { bool disable_inlining; }; +// The unit structure that holds metadata of ISeq for MJIT. +struct rb_mjit_unit { + // Unique order number of unit. + int id; + // Dlopen handle of the loaded object file. + void *handle; + rb_iseq_t *iseq; +#ifndef _MSC_VER + // This value is always set for `compact_all_jit_code`. Also used for lazy deletion. + char *o_file; + // true if it's inherited from parent Ruby process and lazy deletion should be skipped. + // `o_file = NULL` can't be used to skip lazy deletion because `o_file` could be used + // by child for `compact_all_jit_code`. + bool o_file_inherited_p; +#endif +#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. + char used_code_p; + struct list_node unode; + // 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; // size: iseq->body->ci_size +}; + typedef VALUE (*mjit_func_t)(rb_execution_context_t *, rb_control_frame_t *); RUBY_SYMBOL_EXPORT_BEGIN -- cgit v1.2.3