From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS63949 64.71.152.0/24 X-Spam-Status: No, score=-1.5 required=3.0 tests=AWL,BAYES_00,BODY_8BITS, RCVD_IN_DNSWL_NONE,RDNS_NONE,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 Received: from 80x24.org (unknown [64.71.152.64]) by dcvr.yhbt.net (Postfix) with ESMTP id 471BC202A0 for ; Wed, 15 Nov 2017 07:01:09 +0000 (UTC) From: Eric Wong To: spew@80x24.org Subject: [PATCH] remove joke instructions from the VM Date: Wed, 15 Nov 2017 07:01:08 +0000 Message-Id: <20171115070108.3264-1-e@80x24.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: It is needless bloat in main VM and we've already dropped iseq compatibility with r60763 ("remove `trace` instruction") * insns.def (bitblt, answer): remove instructions * vm_opts.h: remove SUPPORT_JOKE define * compile.c (rb_iseq_compile_node): remove #ifdef SUPPORT_JOKE * compile.c (iseq_compile_each0): ditto * eval.c (exc_setup_cause): ditto * iseq.h (struct iseq_compile_data): ditto --- compile.c | 71 --------------------------------------------------------------- eval.c | 14 ------------- insns.def | 29 -------------------------- iseq.h | 3 --- vm_opts.h | 3 --- 5 files changed, 120 deletions(-) diff --git a/compile.c b/compile.c index c270308acc..54115a0baa 100644 --- a/compile.c +++ b/compile.c @@ -723,13 +723,6 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node) ADD_INSN(ret, ISEQ_COMPILE_DATA(iseq)->last_line, leave); } -#if SUPPORT_JOKE - if (ISEQ_COMPILE_DATA(iseq)->labels_table) { - st_table *labels_table = ISEQ_COMPILE_DATA(iseq)->labels_table; - ISEQ_COMPILE_DATA(iseq)->labels_table = 0; - validate_labels(iseq, labels_table); - } -#endif return iseq_setup(iseq, ret); } @@ -5967,71 +5960,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in INIT_ANCHOR(recv); INIT_ANCHOR(args); -#if SUPPORT_JOKE - if (nd_type(node) == NODE_VCALL) { - ID id_bitblt; - ID id_answer; - CONST_ID(id_bitblt, "bitblt"); - CONST_ID(id_answer, "the_answer_to_life_the_universe_and_everything"); - - if (mid == id_bitblt) { - ADD_INSN(ret, line, bitblt); - break; - } - else if (mid == id_answer) { - ADD_INSN(ret, line, answer); - break; - } - } - /* only joke */ - { - ID goto_id; - ID label_id; - - CONST_ID(goto_id, "__goto__"); - CONST_ID(label_id, "__label__"); - - if (nd_type(node) == NODE_FCALL && - (mid == goto_id || mid == label_id)) { - LABEL *label; - st_data_t data; - st_table *labels_table = ISEQ_COMPILE_DATA(iseq)->labels_table; - VALUE label_name; - - if (!labels_table) { - labels_table = st_init_numtable(); - ISEQ_COMPILE_DATA(iseq)->labels_table = labels_table; - } - if (nd_type(node->nd_args->nd_head) == NODE_LIT && - SYMBOL_P(node->nd_args->nd_head->nd_lit)) { - - label_name = node->nd_args->nd_head->nd_lit; - if (!st_lookup(labels_table, (st_data_t)label_name, &data)) { - label = NEW_LABEL(line); - label->position = line; - st_insert(labels_table, (st_data_t)label_name, (st_data_t)label); - } - else { - label = (LABEL *)data; - } - } - else { - COMPILE_ERROR(ERROR_ARGS "invalid goto/label format"); - goto ng; - } - - - if (mid == goto_id) { - ADD_INSNL(ret, line, jump, label); - } - else { - ADD_LABEL(ret, label); - } - break; - } - } -#endif /* receiver */ if (type == NODE_CALL || type == NODE_OPCALL || type == NODE_QCALL) { CHECK(COMPILE(recv, "recv", node->nd_recv)); diff --git a/eval.c b/eval.c index 582a605f9b..75509e61ee 100644 --- a/eval.c +++ b/eval.c @@ -449,20 +449,6 @@ static VALUE get_ec_errinfo(const rb_execution_context_t *ec); static VALUE exc_setup_cause(VALUE exc, VALUE cause) { -#if SUPPORT_JOKE - if (NIL_P(cause)) { - ID id_true_cause; - CONST_ID(id_true_cause, "true_cause"); - - cause = rb_attr_get(rb_eFatal, id_true_cause); - if (NIL_P(cause)) { - cause = rb_exc_new_cstr(rb_eFatal, "because using such Ruby"); - rb_ivar_set(cause, id_cause, INT2FIX(42)); /* the answer */ - OBJ_FREEZE(cause); - rb_ivar_set(rb_eFatal, id_true_cause, cause); - } - } -#endif if (!NIL_P(cause) && cause != exc) { rb_ivar_set(exc, id_cause, cause); if (!rb_ivar_defined(cause, id_cause)) { diff --git a/insns.def b/insns.def index 64ff057485..ff158eb542 100644 --- a/insns.def +++ b/insns.def @@ -1668,32 +1668,3 @@ opt_call_c_function RESTORE_REGS(); NEXT_INSN(); } - -/** - @c joke - @e BLT - @j BLT - */ -DEFINE_INSN -bitblt -() -() -(VALUE ret) -{ - ret = rb_str_new2("a bit of bacon, lettuce and tomato"); -} - -/** - @c joke - @e The Answer to Life, the Universe, and Everything - @j 人生、宇宙、すべての答え。 - */ -DEFINE_INSN -answer -() -() -(VALUE ret) -{ - ret = INT2FIX(42); -} - diff --git a/iseq.h b/iseq.h index 78272c07ae..fda96e3cc3 100644 --- a/iseq.h +++ b/iseq.h @@ -238,9 +238,6 @@ struct iseq_compile_data { unsigned int ci_kw_index; const rb_compile_option_t *option; struct rb_id_table *ivar_cache_table; -#if SUPPORT_JOKE - st_table *labels_table; -#endif }; /* defined? */ diff --git a/vm_opts.h b/vm_opts.h index 3fedf1d6e2..db5c87c819 100644 --- a/vm_opts.h +++ b/vm_opts.h @@ -47,9 +47,6 @@ #define OPT_UNIFY_ALL_COMBINATION 0 #define OPT_STACK_CACHING 0 -/* misc */ -#define SUPPORT_JOKE 0 - #ifndef VM_COLLECT_USAGE_DETAILS #define VM_COLLECT_USAGE_DETAILS 0 #endif -- EW