aboutsummaryrefslogtreecommitdiffstats
path: root/vm_core.h
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2022-03-31 11:04:25 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2022-04-01 14:48:22 -0400
commit6068da8937d7e4358943f95e7450dae7179a7763 (patch)
tree68ad7d95ec12f1dec4b1b745725c9579ab2f10ec /vm_core.h
parent20c190f95a28dd4e57cb96f939ff314dfb88b1f4 (diff)
downloadruby-6068da8937d7e4358943f95e7450dae7179a7763.tar.gz
Finer-grained constant cache invalidation (take 2)
This commit reintroduces finer-grained constant cache invalidation. After 8008fb7 got merged, it was causing issues on token-threaded builds (such as on Windows). The issue was that when you're iterating through instruction sequences and using the translator functions to get back the instruction structs, you're either using `rb_vm_insn_null_translator` or `rb_vm_insn_addr2insn2` depending if it's a direct-threading build. `rb_vm_insn_addr2insn2` does some normalization to always return to you the non-trace version of whatever instruction you're looking at. `rb_vm_insn_null_translator` does not do that normalization. This means that when you're looping through the instructions if you're trying to do an opcode comparison, it can change depending on the type of threading that you're using. This can be very confusing. So, this commit creates a new translator function `rb_vm_insn_normalizing_translator` to always return the non-trace version so that opcode comparisons don't have to worry about different configurations. [Feature #18589]
Diffstat (limited to 'vm_core.h')
-rw-r--r--vm_core.h40
1 files changed, 8 insertions, 32 deletions
diff --git a/vm_core.h b/vm_core.h
index 56013cf492..bb917a971f 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -229,44 +229,14 @@ struct iseq_inline_constant_cache_entry {
VALUE flags;
VALUE value; // v0
- union ic_serial_entry ic_serial; // v1, v2
+ VALUE _unused1; // v1
+ VALUE _unused2; // v2
const rb_cref_t *ic_cref; // v3
};
STATIC_ASSERT(sizeof_iseq_inline_constant_cache_entry,
(offsetof(struct iseq_inline_constant_cache_entry, ic_cref) +
sizeof(const rb_cref_t *)) <= sizeof(struct RObject));
-#if SIZEOF_SERIAL_T <= SIZEOF_VALUE
-
-#define GET_IC_SERIAL(ice) (ice)->ic_serial.raw
-#define SET_IC_SERIAL(ice, v) (ice)->ic_serial.raw = (v)
-
-#else
-
-static inline rb_serial_t
-get_ic_serial(const struct iseq_inline_constant_cache_entry *ice)
-{
- union ic_serial_entry tmp;
- tmp.data[0] = ice->ic_serial.data[0];
- tmp.data[1] = ice->ic_serial.data[1];
- return tmp.raw;
-}
-
-#define GET_IC_SERIAL(ice) get_ic_serial(ice)
-
-static inline void
-set_ic_serial(struct iseq_inline_constant_cache_entry *ice, rb_serial_t v)
-{
- union ic_serial_entry tmp;
- tmp.raw = v;
- ice->ic_serial.data[0] = tmp.data[0];
- ice->ic_serial.data[1] = tmp.data[1];
-}
-
-#define SET_IC_SERIAL(ice, v) set_ic_serial((ice), (v))
-
-#endif
-
struct iseq_inline_constant_cache {
struct iseq_inline_constant_cache_entry *entry;
// For YJIT: the index to the opt_getinlinecache instruction in the same iseq.
@@ -722,6 +692,12 @@ typedef struct rb_vm_struct {
struct rb_id_table *negative_cme_table;
st_table *overloaded_cme_table; // cme -> overloaded_cme
+ // This id table contains a mapping from ID to ICs. It does this with ID
+ // keys and nested st_tables as values. The nested tables have ICs as keys
+ // and Qtrue as values. It is used when inline constant caches need to be
+ // invalidated or ISEQs are being freed.
+ struct rb_id_table *constant_cache;
+
#ifndef VM_GLOBAL_CC_CACHE_TABLE_SIZE
#define VM_GLOBAL_CC_CACHE_TABLE_SIZE 1023
#endif