summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-07-03 16:56:44 +0900
committerGitHub <noreply@github.com>2020-07-03 16:56:44 +0900
commita0f12a0258e4020bd657ee80b7d8f22bd33ea223 (patch)
treef6ebafa85cba2bddddc090f8d3c3b74c2c9f374b /compile.c
parent8655c2e69041cc812d30c2e951a8ac9ea7a60c47 (diff)
Use ID instead of GENTRY for gvars. (#3278)
Use ID instead of GENTRY for gvars. Global variables are compiled into GENTRY (a pointer to struct rb_global_entry). This patch replace this GENTRY to ID and make the code simple. We need to search GENTRY from ID every time (st_lookup), so additional overhead will be introduced. However, the performance of accessing global variables is not important now a day and this simplicity helps Ractor development.
Notes
Notes: Merged-By: ko1 <ko1@atdot.net>
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c50
1 files changed, 4 insertions, 46 deletions
diff --git a/compile.c b/compile.c
index ccb079c5e0..dfa3802579 100644
--- a/compile.c
+++ b/compile.c
@@ -2318,13 +2318,6 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
case TS_ID: /* ID */
generated_iseq[code_index + 1 + j] = SYM2ID(operands[j]);
break;
- case TS_GENTRY:
- {
- struct rb_global_entry *entry =
- (struct rb_global_entry *)(operands[j] & (~1));
- generated_iseq[code_index + 1 + j] = (VALUE)entry;
- }
- break;
case TS_FUNCPTR:
generated_iseq[code_index + 1 + j] = operands[j];
break;
@@ -4875,7 +4868,7 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
case NODE_GVAR:
ADD_INSN(ret, line, putnil);
ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_GVAR),
- ID2SYM(node->nd_entry->id), needstr);
+ ID2SYM(node->nd_entry), needstr);
return;
case NODE_CVAR:
@@ -5262,7 +5255,7 @@ compile_named_capture_assign(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE
LABEL *fail_label = NEW_LABEL(line), *end_label = NEW_LABEL(line);
#if !(defined(NAMED_CAPTURE_BY_SVAR) && NAMED_CAPTURE_BY_SVAR-0)
- ADD_INSN1(ret, line, getglobal, ((VALUE)rb_global_entry(idBACKREF) | 1));
+ ADD_INSN1(ret, line, getglobal, ID2SYM(idBACKREF));
#else
ADD_INSN2(ret, line, getspecial, INT2FIX(1) /* '~' */, INT2FIX(0));
#endif
@@ -7599,8 +7592,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
if (!popped) {
ADD_INSN(ret, line, dup);
}
- ADD_INSN1(ret, line, setglobal,
- ((VALUE)node->nd_entry | 1));
+ ADD_INSN1(ret, line, setglobal, ID2SYM(node->nd_entry));
break;
}
case NODE_IASGN:{
@@ -8212,8 +8204,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
break;
}
case NODE_GVAR:{
- ADD_INSN1(ret, line, getglobal,
- ((VALUE)node->nd_entry | 1));
+ ADD_INSN1(ret, line, getglobal, ID2SYM(node->nd_entry));
if (popped) {
ADD_INSN(ret, line, pop);
}
@@ -8980,13 +8971,6 @@ insn_data_to_s_detail(INSN *iobj)
case TS_ID: /* ID */
rb_str_concat(str, opobj_inspect(OPERAND_AT(iobj, j)));
break;
- case TS_GENTRY:
- {
- struct rb_global_entry *entry = (struct rb_global_entry *)
- (OPERAND_AT(iobj, j) & (~1));
- rb_str_append(str, rb_id2str(entry->id));
- break;
- }
case TS_IC: /* inline cache */
case TS_IVC: /* inline ivar cache */
case TS_ISE: /* inline storage entry */
@@ -9376,10 +9360,6 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
}
}
break;
- case TS_GENTRY:
- op = rb_to_symbol_type(op);
- argv[j] = (VALUE)rb_global_entry(SYM2ID(op));
- break;
case TS_ISE:
FL_SET((VALUE)iseq, ISEQ_MARKABLE_ISEQ);
/* fall through */
@@ -10136,19 +10116,6 @@ ibf_dump_iseq(struct ibf_dump *dump, const rb_iseq_t *iseq)
}
}
-static VALUE
-ibf_dump_gentry(struct ibf_dump *dump, const struct rb_global_entry *entry)
-{
- return (VALUE)ibf_dump_id(dump, entry->id);
-}
-
-static VALUE
-ibf_load_gentry(const struct ibf_load *load, const struct rb_global_entry *entry)
-{
- ID gid = ibf_load_id(load, (ID)(VALUE)entry);
- return (VALUE)rb_global_entry(gid);
-}
-
static unsigned char
ibf_load_byte(const struct ibf_load *load, ibf_offset_t *offset)
{
@@ -10316,9 +10283,6 @@ ibf_dump_code(struct ibf_dump *dump, const rb_iseq_t *iseq)
case TS_ID:
wv = ibf_dump_id(dump, (ID)op);
break;
- case TS_GENTRY:
- wv = ibf_dump_gentry(dump, (const struct rb_global_entry *)op);
- break;
case TS_FUNCPTR:
rb_raise(rb_eRuntimeError, "TS_FUNCPTR is not supported");
goto skip_wv;
@@ -10403,12 +10367,6 @@ ibf_load_code(const struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t bytecod
code[code_index] = ibf_load_id(load, (ID)(VALUE)op);
}
break;
- case TS_GENTRY:
- {
- VALUE op = ibf_load_small_value(load, &reading_pos);
- code[code_index] = ibf_load_gentry(load, (const struct rb_global_entry *)(VALUE)op);
- }
- break;
case TS_FUNCPTR:
rb_raise(rb_eRuntimeError, "TS_FUNCPTR is not supported");
break;