Created
December 11, 2017 09:58
-
-
Save shyouhei/d4c1dc62e27e0f71b4c1b58ee436932d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From ad69876f1cb22a7330e19a73fe5760c06ef92d32 Mon Sep 17 00:00:00 2001 | |
From: "Urabe, Shyouhei" <[email protected]> | |
Date: Mon, 11 Dec 2017 16:25:23 +0900 | |
Subject: [PATCH] R.I.P OPT_CALL_THREADED_CODE (2005-2017) | |
Not me, but revision r60763 killed this feature. It seems no one | |
has bothered that silent breakage so far. I cannot but conclude | |
that it has no practical usage. Let us delete the macro and | |
related codes to make things simpler. | |
Signed-off-by: Urabe, Shyouhei <[email protected]> | |
--- | |
compile.c | 6 +++--- | |
insns.def | 5 ----- | |
iseq.c | 4 ++-- | |
vm.c | 5 ----- | |
vm_core.h | 15 --------------- | |
vm_exec.c | 39 --------------------------------------- | |
vm_exec.h | 22 ---------------------- | |
vm_opts.h | 1 - | |
8 files changed, 5 insertions(+), 92 deletions(-) | |
diff --git a/compile.c b/compile.c | |
index 1b7158979a..a75d7f7bcd 100644 | |
--- a/compile.c | |
+++ b/compile.c | |
@@ -724,7 +724,7 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node) | |
int | |
rb_iseq_translate_threaded_code(rb_iseq_t *iseq) | |
{ | |
-#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE | |
+#if OPT_DIRECT_THREADED_CODE | |
const void * const *table = rb_vm_get_insns_address_table(); | |
unsigned int i; | |
VALUE *encoded = (VALUE *)iseq->body->iseq_encoded; | |
@@ -739,7 +739,7 @@ rb_iseq_translate_threaded_code(rb_iseq_t *iseq) | |
return COMPILE_OK; | |
} | |
-#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE | |
+#if OPT_DIRECT_THREADED_CODE | |
static int | |
rb_vm_insn_addr2insn(const void *addr) /* cold path */ | |
{ | |
@@ -764,7 +764,7 @@ rb_iseq_original_iseq(const rb_iseq_t *iseq) /* cold path */ | |
original_code = ISEQ_ORIGINAL_ISEQ_ALLOC(iseq, iseq->body->iseq_size); | |
MEMCPY(original_code, iseq->body->iseq_encoded, VALUE, iseq->body->iseq_size); | |
-#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE | |
+#if OPT_DIRECT_THREADED_CODE | |
{ | |
unsigned int i; | |
diff --git a/insns.def b/insns.def | |
index 1c20573254..7248c45b42 100644 | |
--- a/insns.def | |
+++ b/insns.def | |
@@ -979,12 +979,7 @@ leave | |
RUBY_VM_CHECK_INTS(ec); | |
if (vm_pop_frame(ec, GET_CFP(), GET_EP())) { | |
-#if OPT_CALL_THREADED_CODE | |
- rb_ec_thread_ptr(ec)->retval = val; | |
- return 0; | |
-#else | |
return val; | |
-#endif | |
} | |
else { | |
RESTORE_REGS(); | |
diff --git a/iseq.c b/iseq.c | |
index 998639eafc..7d78f3929a 100644 | |
--- a/iseq.c | |
+++ b/iseq.c | |
@@ -2335,7 +2335,7 @@ rb_iseq_defined_string(enum defined_type type) | |
} | |
-#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE | |
+#if OPT_DIRECT_THREADED_CODE | |
#define INSN_CODE(insn) ((VALUE)table[insn]) | |
#define TRACE_INSN_P(insn, insn_encoded) ((VALUE)table[insn] != insn_encoded) | |
#else | |
@@ -2358,7 +2358,7 @@ rb_iseq_trace_set(const rb_iseq_t *iseq, rb_event_flag_t turnon_events) | |
else { | |
unsigned int i; | |
VALUE *iseq_encoded = (VALUE *)iseq->body->iseq_encoded; | |
-#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE | |
+#if OPT_DIRECT_THREADED_CODE | |
VALUE *code = rb_iseq_original_iseq(iseq); | |
const void * const *table = rb_vm_get_insns_address_table(); | |
#else | |
diff --git a/vm.c b/vm.c | |
index 7783758c79..2aeb846128 100644 | |
--- a/vm.c | |
+++ b/vm.c | |
@@ -2512,9 +2512,6 @@ th_init(rb_thread_t *th, VALUE self) | |
th->thread_id_string[0] = '\0'; | |
#endif | |
-#if OPT_CALL_THREADED_CODE | |
- th->retval = Qundef; | |
-#endif | |
th->name = Qnil; | |
} | |
@@ -2978,8 +2975,6 @@ Init_VM(void) | |
rb_ary_push(opts, rb_str_new2("direct threaded code")); | |
#elif OPT_TOKEN_THREADED_CODE | |
rb_ary_push(opts, rb_str_new2("token threaded code")); | |
-#elif OPT_CALL_THREADED_CODE | |
- rb_ary_push(opts, rb_str_new2("call threaded code")); | |
#endif | |
#if OPT_STACK_CACHING | |
diff --git a/vm_core.h b/vm_core.h | |
index f458da7203..a412a8ee30 100644 | |
--- a/vm_core.h | |
+++ b/vm_core.h | |
@@ -119,16 +119,6 @@ | |
#endif | |
#endif | |
-/* call threaded code */ | |
-#if OPT_CALL_THREADED_CODE | |
-#if OPT_DIRECT_THREADED_CODE | |
-#undef OPT_DIRECT_THREADED_CODE | |
-#endif /* OPT_DIRECT_THREADED_CODE */ | |
-#if OPT_STACK_CACHING | |
-#undef OPT_STACK_CACHING | |
-#endif /* OPT_STACK_CACHING */ | |
-#endif /* OPT_CALL_THREADED_CODE */ | |
- | |
typedef unsigned long rb_num_t; | |
enum ruby_tag_type { | |
@@ -814,11 +804,6 @@ typedef struct rb_thread_struct { | |
VALUE thgroup; | |
VALUE value; | |
- /* temporary place of retval on OPT_CALL_THREADED_CODE */ | |
-#if OPT_CALL_THREADED_CODE | |
- VALUE retval; | |
-#endif | |
- | |
/* async errinfo queue */ | |
VALUE pending_interrupt_queue; | |
VALUE pending_interrupt_mask_stack; | |
diff --git a/vm_exec.c b/vm_exec.c | |
index ce47ab2cc3..ce979da790 100644 | |
--- a/vm_exec.c | |
+++ b/vm_exec.c | |
@@ -43,7 +43,6 @@ vm_stack_overflow_for_insn(void) | |
} | |
#endif | |
-#if !OPT_CALL_THREADED_CODE | |
static VALUE | |
vm_exec_core(rb_execution_context_t *ec, VALUE initial) | |
{ | |
@@ -127,41 +126,3 @@ rb_vm_get_insns_address_table(void) | |
{ | |
return (const void **)vm_exec_core(0, 0); | |
} | |
- | |
-#else /* OPT_CALL_THREADED_CODE */ | |
- | |
-#include "vm.inc" | |
-#include "vmtc.inc" | |
- | |
-const void ** | |
-rb_vm_get_insns_address_table(void) | |
-{ | |
- return (const void **)insns_address_table; | |
-} | |
- | |
-static VALUE | |
-vm_exec_core(rb_execution_context_t *ec, VALUE initial) | |
-{ | |
- register rb_control_frame_t *reg_cfp = ec->cfp; | |
- rb_thread_t *th = rb_ec_thread_ptr(ec); | |
- | |
- while (1) { | |
- reg_cfp = ((rb_insn_func_t) (*GET_PC()))(ec, reg_cfp); | |
- | |
- if (UNLIKELY(reg_cfp == 0)) { | |
- break; | |
- } | |
- } | |
- | |
- if (rb_ec_thread_ptr(ec)->retval != Qundef) { | |
- VALUE ret = th->retval; | |
- rb_ec_thread_ptr(ec)->retval = Qundef; | |
- return ret; | |
- } | |
- else { | |
- VALUE err = ec->errinfo; | |
- ec->errinfo = Qnil; | |
- return err; | |
- } | |
-} | |
-#endif | |
diff --git a/vm_exec.h b/vm_exec.h | |
index 3bfdd569d1..767e8e41e1 100644 | |
--- a/vm_exec.h | |
+++ b/vm_exec.h | |
@@ -51,21 +51,6 @@ typedef rb_iseq_t *ISEQ; | |
/************************************************/ | |
#if defined(DISPATCH_XXX) | |
error ! | |
-/************************************************/ | |
-#elif OPT_CALL_THREADED_CODE | |
- | |
-#define LABEL(x) insn_func_##x | |
-#define ELABEL(x) | |
-#define LABEL_PTR(x) &LABEL(x) | |
- | |
-#define INSN_ENTRY(insn) \ | |
- static rb_control_frame_t * \ | |
- FUNC_FASTCALL(LABEL(insn))(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp) { | |
- | |
-#define END_INSN(insn) return reg_cfp;} | |
- | |
-#define NEXT_INSN() return reg_cfp; | |
- | |
/************************************************/ | |
#elif OPT_TOKEN_THREADED_CODE || OPT_DIRECT_THREADED_CODE | |
/* threaded code with gcc */ | |
@@ -163,14 +148,7 @@ default: \ | |
#define VM_SP_CNT(ec, sp) ((sp) - (ec)->vm_stack) | |
-#if OPT_CALL_THREADED_CODE | |
-#define THROW_EXCEPTION(exc) do { \ | |
- ec->errinfo = (VALUE)(exc); \ | |
- return 0; \ | |
-} while (0) | |
-#else | |
#define THROW_EXCEPTION(exc) return (VALUE)(exc) | |
-#endif | |
#define SCREG(r) (reg_##r) | |
diff --git a/vm_opts.h b/vm_opts.h | |
index 3fedf1d6e2..6ef3999c6b 100644 | |
--- a/vm_opts.h | |
+++ b/vm_opts.h | |
@@ -33,7 +33,6 @@ | |
/* C compiler dependent */ | |
#define OPT_DIRECT_THREADED_CODE 1 | |
#define OPT_TOKEN_THREADED_CODE 0 | |
-#define OPT_CALL_THREADED_CODE 0 | |
/* VM running option */ | |
#define OPT_CHECKED_RUN 1 | |
-- | |
2.15.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment