summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-03-25 20:29:09 +0900
committerGitHub <noreply@github.com>2022-03-25 20:29:09 +0900
commit69967ee64eac9ce65b83533a566d69d12a6046d0 (patch)
treeb7012ba8b7ad5b1c99d7b1f9b2345ecd8117f433 /iseq.c
parent7ee26740e41f99d3da37df36b956237fbf36868e (diff)
Revert "Finer-grained inline constant cache invalidation"
This reverts commits for [Feature #18589]: * 8008fb7352abc6fba433b99bf20763cf0d4adb38 "Update formatting per feedback" * 8f6eaca2e19828e92ecdb28b0fe693d606a03f96 "Delete ID from constant cache table if it becomes empty on ISEQ free" * 629908586b4bead1103267652f8b96b1083573a8 "Finer-grained inline constant cache invalidation" MSWin builds on AppVeyor have been crashing since the merger.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5715 Merged-By: nobu <nobu@ruby-lang.org>
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c90
1 files changed, 0 insertions, 90 deletions
diff --git a/iseq.c b/iseq.c
index 5d294e9d31..ffbe9859c3 100644
--- a/iseq.c
+++ b/iseq.c
@@ -102,69 +102,12 @@ compile_data_free(struct iseq_compile_data *compile_data)
}
}
-struct iseq_clear_ic_references_data {
- IC ic;
-};
-
-// This iterator is used to walk through the instructions and clean any
-// references to ICs that are contained within this ISEQ out of the VM's
-// constant cache table. It passes around a struct that holds the current IC
-// we're looking for, which can be NULL (if we haven't hit an opt_getinlinecache
-// instruction yet) or set to an IC (if we've hit an opt_getinlinecache and
-// haven't yet hit the associated opt_setinlinecache).
-static bool
-iseq_clear_ic_references_i(VALUE *code, VALUE insn, size_t index, void *data)
-{
- struct iseq_clear_ic_references_data *ic_data = (struct iseq_clear_ic_references_data *) data;
-
- switch (insn) {
- case BIN(opt_getinlinecache): {
- ic_data->ic = (IC) code[index + 2];
- return true;
- }
- case BIN(getconstant): {
- ID id = (ID) code[index + 1];
- rb_vm_t *vm = GET_VM();
- st_table *ics;
-
- if (rb_id_table_lookup(vm->constant_cache, id, (VALUE *) &ics)) {
- st_delete(ics, (st_data_t *) &ic_data->ic, (st_data_t *) NULL);
-
- if (ics->num_entries == 0) {
- rb_id_table_delete(vm->constant_cache, id);
- st_free_table(ics);
- }
- }
-
- return true;
- }
- case BIN(opt_setinlinecache): {
- ic_data->ic = NULL;
- return true;
- }
- default:
- return true;
- }
-}
-
-// When an ISEQ is being freed, all of its associated ICs are going to go away
-// as well. Because of this, we need to walk through the ISEQ, find any
-// opt_getinlinecache calls, and clear out the VM's constant cache of associated
-// ICs.
-static void
-iseq_clear_ic_references(const rb_iseq_t *iseq)
-{
- struct iseq_clear_ic_references_data data = { .ic = NULL };
- rb_iseq_each(iseq, 0, iseq_clear_ic_references_i, (void *) &data);
-}
-
void
rb_iseq_free(const rb_iseq_t *iseq)
{
RUBY_FREE_ENTER("iseq");
if (iseq && ISEQ_BODY(iseq)) {
- iseq_clear_ic_references(iseq);
struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
mjit_free_iseq(iseq); /* Notify MJIT */
rb_yjit_iseq_free(body);
@@ -307,39 +250,6 @@ rb_iseq_each_value(const rb_iseq_t *iseq, iseq_value_itr_t * func, void *data)
}
}
-// Similar to rb_iseq_each_value, except that this walks through each
-// instruction instead of the associated VALUEs. The provided iterator should
-// return a boolean that indicates whether or not to continue iterating.
-void
-rb_iseq_each(const rb_iseq_t *iseq, size_t start_index, rb_iseq_each_i iterator, void *data)
-{
- unsigned int size;
- VALUE *code;
- size_t index;
-
- rb_vm_insns_translator_t *const translator =
-#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
- (FL_TEST((VALUE)iseq, ISEQ_TRANSLATED)) ? rb_vm_insn_addr2insn2 :
-#endif
- rb_vm_insn_null_translator;
-
- const struct rb_iseq_constant_body *const body = iseq->body;
-
- size = body->iseq_size;
- code = body->iseq_encoded;
-
- for (index = start_index; index < size;) {
- void *addr = (void *) code[index];
- VALUE insn = translator(addr);
-
- if (!iterator(code, insn, index, data)) {
- break;
- }
-
- index += insn_len(insn);
- }
-}
-
static VALUE
update_each_insn_value(void *ctx, VALUE obj)
{