Guest User

Untitled

a guest
Dec 13th, 2017
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.81 KB | None | 0 0
  1. From ad69876f1cb22a7330e19a73fe5760c06ef92d32 Mon Sep 17 00:00:00 2001
  2. From: "Urabe, Shyouhei" <shyouhei@ruby-lang.org>
  3. Date: Mon, 11 Dec 2017 16:25:23 +0900
  4. Subject: [PATCH] R.I.P OPT_CALL_THREADED_CODE (2005-2017)
  5.  
  6. Not me, but revision r60763 killed this feature. It seems no one
  7. has bothered that silent breakage so far. I cannot but conclude
  8. that it has no practical usage. Let us delete the macro and
  9. related codes to make things simpler.
  10.  
  11. Signed-off-by: Urabe, Shyouhei <shyouhei@ruby-lang.org>
  12. ---
  13. compile.c | 6 +++---
  14. insns.def | 5 -----
  15. iseq.c | 4 ++--
  16. vm.c | 5 -----
  17. vm_core.h | 15 ---------------
  18. vm_exec.c | 39 ---------------------------------------
  19. vm_exec.h | 22 ----------------------
  20. vm_opts.h | 1 -
  21. 8 files changed, 5 insertions(+), 92 deletions(-)
  22.  
  23. diff --git a/compile.c b/compile.c
  24. index 1b7158979a..a75d7f7bcd 100644
  25. --- a/compile.c
  26. +++ b/compile.c
  27. @@ -724,7 +724,7 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node)
  28. int
  29. rb_iseq_translate_threaded_code(rb_iseq_t *iseq)
  30. {
  31. -#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
  32. +#if OPT_DIRECT_THREADED_CODE
  33. const void * const *table = rb_vm_get_insns_address_table();
  34. unsigned int i;
  35. VALUE *encoded = (VALUE *)iseq->body->iseq_encoded;
  36. @@ -739,7 +739,7 @@ rb_iseq_translate_threaded_code(rb_iseq_t *iseq)
  37. return COMPILE_OK;
  38. }
  39.  
  40. -#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
  41. +#if OPT_DIRECT_THREADED_CODE
  42. static int
  43. rb_vm_insn_addr2insn(const void *addr) /* cold path */
  44. {
  45. @@ -764,7 +764,7 @@ rb_iseq_original_iseq(const rb_iseq_t *iseq) /* cold path */
  46. original_code = ISEQ_ORIGINAL_ISEQ_ALLOC(iseq, iseq->body->iseq_size);
  47. MEMCPY(original_code, iseq->body->iseq_encoded, VALUE, iseq->body->iseq_size);
  48.  
  49. -#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
  50. +#if OPT_DIRECT_THREADED_CODE
  51. {
  52. unsigned int i;
  53.  
  54. diff --git a/insns.def b/insns.def
  55. index 1c20573254..7248c45b42 100644
  56. --- a/insns.def
  57. +++ b/insns.def
  58. @@ -979,12 +979,7 @@ leave
  59. RUBY_VM_CHECK_INTS(ec);
  60.  
  61. if (vm_pop_frame(ec, GET_CFP(), GET_EP())) {
  62. -#if OPT_CALL_THREADED_CODE
  63. - rb_ec_thread_ptr(ec)->retval = val;
  64. - return 0;
  65. -#else
  66. return val;
  67. -#endif
  68. }
  69. else {
  70. RESTORE_REGS();
  71. diff --git a/iseq.c b/iseq.c
  72. index 998639eafc..7d78f3929a 100644
  73. --- a/iseq.c
  74. +++ b/iseq.c
  75. @@ -2335,7 +2335,7 @@ rb_iseq_defined_string(enum defined_type type)
  76. }
  77.  
  78.  
  79. -#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
  80. +#if OPT_DIRECT_THREADED_CODE
  81. #define INSN_CODE(insn) ((VALUE)table[insn])
  82. #define TRACE_INSN_P(insn, insn_encoded) ((VALUE)table[insn] != insn_encoded)
  83. #else
  84. @@ -2358,7 +2358,7 @@ rb_iseq_trace_set(const rb_iseq_t *iseq, rb_event_flag_t turnon_events)
  85. else {
  86. unsigned int i;
  87. VALUE *iseq_encoded = (VALUE *)iseq->body->iseq_encoded;
  88. -#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
  89. +#if OPT_DIRECT_THREADED_CODE
  90. VALUE *code = rb_iseq_original_iseq(iseq);
  91. const void * const *table = rb_vm_get_insns_address_table();
  92. #else
  93. diff --git a/vm.c b/vm.c
  94. index 7783758c79..2aeb846128 100644
  95. --- a/vm.c
  96. +++ b/vm.c
  97. @@ -2512,9 +2512,6 @@ th_init(rb_thread_t *th, VALUE self)
  98. th->thread_id_string[0] = '\0';
  99. #endif
  100.  
  101. -#if OPT_CALL_THREADED_CODE
  102. - th->retval = Qundef;
  103. -#endif
  104. th->name = Qnil;
  105. }
  106.  
  107. @@ -2978,8 +2975,6 @@ Init_VM(void)
  108. rb_ary_push(opts, rb_str_new2("direct threaded code"));
  109. #elif OPT_TOKEN_THREADED_CODE
  110. rb_ary_push(opts, rb_str_new2("token threaded code"));
  111. -#elif OPT_CALL_THREADED_CODE
  112. - rb_ary_push(opts, rb_str_new2("call threaded code"));
  113. #endif
  114.  
  115. #if OPT_STACK_CACHING
  116. diff --git a/vm_core.h b/vm_core.h
  117. index f458da7203..a412a8ee30 100644
  118. --- a/vm_core.h
  119. +++ b/vm_core.h
  120. @@ -119,16 +119,6 @@
  121. #endif
  122. #endif
  123.  
  124. -/* call threaded code */
  125. -#if OPT_CALL_THREADED_CODE
  126. -#if OPT_DIRECT_THREADED_CODE
  127. -#undef OPT_DIRECT_THREADED_CODE
  128. -#endif /* OPT_DIRECT_THREADED_CODE */
  129. -#if OPT_STACK_CACHING
  130. -#undef OPT_STACK_CACHING
  131. -#endif /* OPT_STACK_CACHING */
  132. -#endif /* OPT_CALL_THREADED_CODE */
  133. -
  134. typedef unsigned long rb_num_t;
  135.  
  136. enum ruby_tag_type {
  137. @@ -814,11 +804,6 @@ typedef struct rb_thread_struct {
  138. VALUE thgroup;
  139. VALUE value;
  140.  
  141. - /* temporary place of retval on OPT_CALL_THREADED_CODE */
  142. -#if OPT_CALL_THREADED_CODE
  143. - VALUE retval;
  144. -#endif
  145. -
  146. /* async errinfo queue */
  147. VALUE pending_interrupt_queue;
  148. VALUE pending_interrupt_mask_stack;
  149. diff --git a/vm_exec.c b/vm_exec.c
  150. index ce47ab2cc3..ce979da790 100644
  151. --- a/vm_exec.c
  152. +++ b/vm_exec.c
  153. @@ -43,7 +43,6 @@ vm_stack_overflow_for_insn(void)
  154. }
  155. #endif
  156.  
  157. -#if !OPT_CALL_THREADED_CODE
  158. static VALUE
  159. vm_exec_core(rb_execution_context_t *ec, VALUE initial)
  160. {
  161. @@ -127,41 +126,3 @@ rb_vm_get_insns_address_table(void)
  162. {
  163. return (const void **)vm_exec_core(0, 0);
  164. }
  165. -
  166. -#else /* OPT_CALL_THREADED_CODE */
  167. -
  168. -#include "vm.inc"
  169. -#include "vmtc.inc"
  170. -
  171. -const void **
  172. -rb_vm_get_insns_address_table(void)
  173. -{
  174. - return (const void **)insns_address_table;
  175. -}
  176. -
  177. -static VALUE
  178. -vm_exec_core(rb_execution_context_t *ec, VALUE initial)
  179. -{
  180. - register rb_control_frame_t *reg_cfp = ec->cfp;
  181. - rb_thread_t *th = rb_ec_thread_ptr(ec);
  182. -
  183. - while (1) {
  184. - reg_cfp = ((rb_insn_func_t) (*GET_PC()))(ec, reg_cfp);
  185. -
  186. - if (UNLIKELY(reg_cfp == 0)) {
  187. - break;
  188. - }
  189. - }
  190. -
  191. - if (rb_ec_thread_ptr(ec)->retval != Qundef) {
  192. - VALUE ret = th->retval;
  193. - rb_ec_thread_ptr(ec)->retval = Qundef;
  194. - return ret;
  195. - }
  196. - else {
  197. - VALUE err = ec->errinfo;
  198. - ec->errinfo = Qnil;
  199. - return err;
  200. - }
  201. -}
  202. -#endif
  203. diff --git a/vm_exec.h b/vm_exec.h
  204. index 3bfdd569d1..767e8e41e1 100644
  205. --- a/vm_exec.h
  206. +++ b/vm_exec.h
  207. @@ -51,21 +51,6 @@ typedef rb_iseq_t *ISEQ;
  208. /************************************************/
  209. #if defined(DISPATCH_XXX)
  210. error !
  211. -/************************************************/
  212. -#elif OPT_CALL_THREADED_CODE
  213. -
  214. -#define LABEL(x) insn_func_##x
  215. -#define ELABEL(x)
  216. -#define LABEL_PTR(x) &LABEL(x)
  217. -
  218. -#define INSN_ENTRY(insn) \
  219. - static rb_control_frame_t * \
  220. - FUNC_FASTCALL(LABEL(insn))(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp) {
  221. -
  222. -#define END_INSN(insn) return reg_cfp;}
  223. -
  224. -#define NEXT_INSN() return reg_cfp;
  225. -
  226. /************************************************/
  227. #elif OPT_TOKEN_THREADED_CODE || OPT_DIRECT_THREADED_CODE
  228. /* threaded code with gcc */
  229. @@ -163,14 +148,7 @@ default: \
  230.  
  231. #define VM_SP_CNT(ec, sp) ((sp) - (ec)->vm_stack)
  232.  
  233. -#if OPT_CALL_THREADED_CODE
  234. -#define THROW_EXCEPTION(exc) do { \
  235. - ec->errinfo = (VALUE)(exc); \
  236. - return 0; \
  237. -} while (0)
  238. -#else
  239. #define THROW_EXCEPTION(exc) return (VALUE)(exc)
  240. -#endif
  241.  
  242. #define SCREG(r) (reg_##r)
  243.  
  244. diff --git a/vm_opts.h b/vm_opts.h
  245. index 3fedf1d6e2..6ef3999c6b 100644
  246. --- a/vm_opts.h
  247. +++ b/vm_opts.h
  248. @@ -33,7 +33,6 @@
  249. /* C compiler dependent */
  250. #define OPT_DIRECT_THREADED_CODE 1
  251. #define OPT_TOKEN_THREADED_CODE 0
  252. -#define OPT_CALL_THREADED_CODE 0
  253.  
  254. /* VM running option */
  255. #define OPT_CHECKED_RUN 1
  256. --
  257. 2.15.1
Add Comment
Please, Sign In to add comment