INIT_ANCHOR no longer needed usually

This commit is contained in:
Nobuyoshi Nakada 2024-11-28 19:02:56 +09:00
parent b8f248ee5a
commit de89bff122
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
Notes: git 2024-11-28 10:56:06 +00:00
2 changed files with 1 additions and 41 deletions

View File

@ -439,7 +439,7 @@ do { \
#define DECL_ANCHOR(name) \ #define DECL_ANCHOR(name) \
LINK_ANCHOR name[1] = {{{ISEQ_ELEMENT_ANCHOR,},&name[0].anchor}} LINK_ANCHOR name[1] = {{{ISEQ_ELEMENT_ANCHOR,},&name[0].anchor}}
#define INIT_ANCHOR(name) \ #define INIT_ANCHOR(name) \
(name->last = &name->anchor) ((name->last = &name->anchor)->next = NULL) /* re-initialize */
static inline VALUE static inline VALUE
freeze_hide_obj(VALUE obj) freeze_hide_obj(VALUE obj)

View File

@ -867,7 +867,6 @@ pm_compile_logical(rb_iseq_t *iseq, LINK_ANCHOR *const ret, pm_node_t *cond, LAB
const pm_node_location_t location = PM_NODE_START_LOCATION(scope_node->parser, cond); const pm_node_location_t location = PM_NODE_START_LOCATION(scope_node->parser, cond);
DECL_ANCHOR(seq); DECL_ANCHOR(seq);
INIT_ANCHOR(seq);
LABEL *label = NEW_LABEL(location.line); LABEL *label = NEW_LABEL(location.line);
if (!then_label) then_label = label; if (!then_label) then_label = label;
@ -1000,7 +999,6 @@ again:
} }
default: { default: {
DECL_ANCHOR(cond_seq); DECL_ANCHOR(cond_seq);
INIT_ANCHOR(cond_seq);
pm_compile_node(iseq, cond, cond_seq, false, scope_node); pm_compile_node(iseq, cond, cond_seq, false, scope_node);
if (LIST_INSN_SIZE_ONE(cond_seq)) { if (LIST_INSN_SIZE_ONE(cond_seq)) {
@ -1040,7 +1038,6 @@ pm_compile_conditional(rb_iseq_t *iseq, const pm_node_location_t *node_location,
LABEL *end_label = NULL; LABEL *end_label = NULL;
DECL_ANCHOR(cond_seq); DECL_ANCHOR(cond_seq);
INIT_ANCHOR(cond_seq);
pm_compile_branch_condition(iseq, cond_seq, predicate, then_label, else_label, false, scope_node); pm_compile_branch_condition(iseq, cond_seq, predicate, then_label, else_label, false, scope_node);
PUSH_SEQ(ret, cond_seq); PUSH_SEQ(ret, cond_seq);
@ -1056,7 +1053,6 @@ pm_compile_conditional(rb_iseq_t *iseq, const pm_node_location_t *node_location,
PUSH_LABEL(ret, then_label); PUSH_LABEL(ret, then_label);
DECL_ANCHOR(then_seq); DECL_ANCHOR(then_seq);
INIT_ANCHOR(then_seq);
if (statements != NULL) { if (statements != NULL) {
pm_compile_node(iseq, (const pm_node_t *) statements, then_seq, popped, scope_node); pm_compile_node(iseq, (const pm_node_t *) statements, then_seq, popped, scope_node);
@ -1097,7 +1093,6 @@ pm_compile_conditional(rb_iseq_t *iseq, const pm_node_location_t *node_location,
PUSH_LABEL(ret, else_label); PUSH_LABEL(ret, else_label);
DECL_ANCHOR(else_seq); DECL_ANCHOR(else_seq);
INIT_ANCHOR(else_seq);
if (subsequent != NULL) { if (subsequent != NULL) {
pm_compile_node(iseq, subsequent, else_seq, popped, scope_node); pm_compile_node(iseq, subsequent, else_seq, popped, scope_node);
@ -1389,7 +1384,6 @@ pm_compile_hash_elements(rb_iseq_t *iseq, const pm_node_t *node, const pm_node_l
bool static_literal = false; bool static_literal = false;
DECL_ANCHOR(anchor); DECL_ANCHOR(anchor);
INIT_ANCHOR(anchor);
// Convert pushed elements to a hash, and merge if needed. // Convert pushed elements to a hash, and merge if needed.
#define FLUSH_CHUNK \ #define FLUSH_CHUNK \
@ -1933,7 +1927,6 @@ pm_setup_args(const pm_arguments_node_t *arguments_node, const pm_node_t *block,
} }
DECL_ANCHOR(block_arg); DECL_ANCHOR(block_arg);
INIT_ANCHOR(block_arg);
pm_compile_node(iseq, block, block_arg, false, scope_node); pm_compile_node(iseq, block, block_arg, false, scope_node);
*flags |= VM_CALL_ARGS_BLOCKARG; *flags |= VM_CALL_ARGS_BLOCKARG;
@ -2832,7 +2825,6 @@ pm_compile_pattern(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_node_t
if (has_keys) { if (has_keys) {
DECL_ANCHOR(match_values); DECL_ANCHOR(match_values);
INIT_ANCHOR(match_values);
for (size_t index = 0; index < cast->elements.size; index++) { for (size_t index = 0; index < cast->elements.size; index++) {
const pm_node_t *element = cast->elements.nodes[index]; const pm_node_t *element = cast->elements.nodes[index];
@ -3577,7 +3569,6 @@ retry:;
// fprintf(stderr, "func_name:%s -> %p\n", builtin_func, bf->func_ptr); // fprintf(stderr, "func_name:%s -> %p\n", builtin_func, bf->func_ptr);
DECL_ANCHOR(args_seq); DECL_ANCHOR(args_seq);
INIT_ANCHOR(args_seq);
int flags = 0; int flags = 0;
struct rb_callinfo_kwarg *keywords = NULL; struct rb_callinfo_kwarg *keywords = NULL;
@ -4156,13 +4147,11 @@ pm_add_ensure_iseq(LINK_ANCHOR *const ret, rb_iseq_t *iseq, int is_return, pm_sc
struct iseq_compile_data_ensure_node_stack *prev_enlp = enlp; struct iseq_compile_data_ensure_node_stack *prev_enlp = enlp;
DECL_ANCHOR(ensure); DECL_ANCHOR(ensure);
INIT_ANCHOR(ensure);
while (enlp) { while (enlp) {
if (enlp->erange != NULL) { if (enlp->erange != NULL) {
DECL_ANCHOR(ensure_part); DECL_ANCHOR(ensure_part);
LABEL *lstart = NEW_LABEL(0); LABEL *lstart = NEW_LABEL(0);
LABEL *lend = NEW_LABEL(0); LABEL *lend = NEW_LABEL(0);
INIT_ANCHOR(ensure_part);
add_ensure_range(iseq, enlp->erange, lstart, lend); add_ensure_range(iseq, enlp->erange, lstart, lend);
@ -4853,10 +4842,7 @@ pm_compile_for_node_index(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *c
// owning expression of this target, then retrieve the value, expand it, // owning expression of this target, then retrieve the value, expand it,
// and then compile the necessary writes. // and then compile the necessary writes.
DECL_ANCHOR(writes); DECL_ANCHOR(writes);
INIT_ANCHOR(writes);
DECL_ANCHOR(cleanup); DECL_ANCHOR(cleanup);
INIT_ANCHOR(cleanup);
pm_multi_target_state_t state = { 0 }; pm_multi_target_state_t state = { 0 };
state.position = 1; state.position = 1;
@ -4873,10 +4859,7 @@ pm_compile_for_node_index(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *c
} }
case PM_MULTI_TARGET_NODE: { case PM_MULTI_TARGET_NODE: {
DECL_ANCHOR(writes); DECL_ANCHOR(writes);
INIT_ANCHOR(writes);
DECL_ANCHOR(cleanup); DECL_ANCHOR(cleanup);
INIT_ANCHOR(cleanup);
pm_compile_target_node(iseq, node, ret, writes, cleanup, scope_node, NULL); pm_compile_target_node(iseq, node, ret, writes, cleanup, scope_node, NULL);
@ -4994,7 +4977,6 @@ pm_compile_ensure(rb_iseq_t *iseq, const pm_begin_node_t *cast, const pm_node_lo
struct ensure_range *erange; struct ensure_range *erange;
DECL_ANCHOR(ensr); DECL_ANCHOR(ensr);
INIT_ANCHOR(ensr);
if (statements != NULL) { if (statements != NULL) {
pm_compile_node(iseq, (const pm_node_t *) statements, ensr, true, scope_node); pm_compile_node(iseq, (const pm_node_t *) statements, ensr, true, scope_node);
} }
@ -5329,7 +5311,6 @@ pm_compile_shareable_constant_value(rb_iseq_t *iseq, const pm_node_t *node, cons
} }
default: { default: {
DECL_ANCHOR(value_seq); DECL_ANCHOR(value_seq);
INIT_ANCHOR(value_seq);
pm_compile_node(iseq, node, value_seq, false, scope_node); pm_compile_node(iseq, node, value_seq, false, scope_node);
if (PM_NODE_TYPE_P(node, PM_INTERPOLATED_STRING_NODE)) { if (PM_NODE_TYPE_P(node, PM_INTERPOLATED_STRING_NODE)) {
@ -7125,13 +7106,11 @@ pm_compile_case_node(rb_iseq_t *iseq, const pm_case_node_t *cast, const pm_node_
// `when` nodes into. If a match is found, they will need to jump into // `when` nodes into. If a match is found, they will need to jump into
// the body_seq anchor to the correct spot. // the body_seq anchor to the correct spot.
DECL_ANCHOR(cond_seq); DECL_ANCHOR(cond_seq);
INIT_ANCHOR(cond_seq);
// This is the anchor that we will compile the bodies of the various // This is the anchor that we will compile the bodies of the various
// `when` nodes into. We'll make sure that the clauses that are compiled // `when` nodes into. We'll make sure that the clauses that are compiled
// jump into the correct spots within this anchor. // jump into the correct spots within this anchor.
DECL_ANCHOR(body_seq); DECL_ANCHOR(body_seq);
INIT_ANCHOR(body_seq);
// This is the label where all of the when clauses will jump to if they // This is the label where all of the when clauses will jump to if they
// have matched and are done executing their bodies. // have matched and are done executing their bodies.
@ -7384,13 +7363,11 @@ pm_compile_case_match_node(rb_iseq_t *iseq, const pm_case_match_node_t *node, co
// `in` nodes into. We'll make sure that the patterns that are compiled // `in` nodes into. We'll make sure that the patterns that are compiled
// jump into the correct spots within this anchor. // jump into the correct spots within this anchor.
DECL_ANCHOR(body_seq); DECL_ANCHOR(body_seq);
INIT_ANCHOR(body_seq);
// This is the anchor that we will compile the patterns of the various // This is the anchor that we will compile the patterns of the various
// `in` nodes into. If a match is found, they will need to jump into the // `in` nodes into. If a match is found, they will need to jump into the
// body_seq anchor to the correct spot. // body_seq anchor to the correct spot.
DECL_ANCHOR(cond_seq); DECL_ANCHOR(cond_seq);
INIT_ANCHOR(cond_seq);
// This label is used to indicate the end of the entire node. It is // This label is used to indicate the end of the entire node. It is
// jumped to after the entire stack is cleaned up. // jumped to after the entire stack is cleaned up.
@ -7560,7 +7537,6 @@ pm_compile_forwarding_super_node(rb_iseq_t *iseq, const pm_forwarding_super_node
} }
DECL_ANCHOR(args); DECL_ANCHOR(args);
INIT_ANCHOR(args);
struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq); struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
const rb_iseq_t *local_iseq = body->local_iseq; const rb_iseq_t *local_iseq = body->local_iseq;
@ -7779,7 +7755,6 @@ pm_compile_match_write_node(rb_iseq_t *iseq, const pm_match_write_node_t *node,
} }
DECL_ANCHOR(fail_anchor); DECL_ANCHOR(fail_anchor);
INIT_ANCHOR(fail_anchor);
// Otherwise there is more than one local variable target, so we'll need // Otherwise there is more than one local variable target, so we'll need
// to do some bookkeeping. // to do some bookkeeping.
@ -8015,10 +7990,7 @@ pm_compile_rescue_node(rb_iseq_t *iseq, const pm_rescue_node_t *node, const pm_n
// depending on the kind of write being performed. // depending on the kind of write being performed.
if (node->reference) { if (node->reference) {
DECL_ANCHOR(writes); DECL_ANCHOR(writes);
INIT_ANCHOR(writes);
DECL_ANCHOR(cleanup); DECL_ANCHOR(cleanup);
INIT_ANCHOR(cleanup);
pm_compile_target_node(iseq, node->reference, ret, writes, cleanup, scope_node, NULL); pm_compile_target_node(iseq, node->reference, ret, writes, cleanup, scope_node, NULL);
PUSH_GETLOCAL(ret, *location, LVAR_ERRINFO, 0); PUSH_GETLOCAL(ret, *location, LVAR_ERRINFO, 0);
@ -8119,7 +8091,6 @@ static inline void
pm_compile_super_node(rb_iseq_t *iseq, const pm_super_node_t *node, const pm_node_location_t *location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node) pm_compile_super_node(rb_iseq_t *iseq, const pm_super_node_t *node, const pm_node_location_t *location, LINK_ANCHOR *const ret, bool popped, pm_scope_node_t *scope_node)
{ {
DECL_ANCHOR(args); DECL_ANCHOR(args);
INIT_ANCHOR(args);
LABEL *retry_label = NEW_LABEL(location->line); LABEL *retry_label = NEW_LABEL(location->line);
LABEL *retry_end_l = NEW_LABEL(location->line); LABEL *retry_end_l = NEW_LABEL(location->line);
@ -8577,10 +8548,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
} }
else { else {
DECL_ANCHOR(prefix); DECL_ANCHOR(prefix);
INIT_ANCHOR(prefix);
DECL_ANCHOR(body); DECL_ANCHOR(body);
INIT_ANCHOR(body);
pm_compile_constant_path(iseq, node, prefix, body, popped, scope_node); pm_compile_constant_path(iseq, node, prefix, body, popped, scope_node);
if (LIST_INSN_SIZE_ZERO(prefix)) { if (LIST_INSN_SIZE_ZERO(prefix)) {
@ -9503,10 +9471,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
const pm_multi_write_node_t *cast = (const pm_multi_write_node_t *) node; const pm_multi_write_node_t *cast = (const pm_multi_write_node_t *) node;
DECL_ANCHOR(writes); DECL_ANCHOR(writes);
INIT_ANCHOR(writes);
DECL_ANCHOR(cleanup); DECL_ANCHOR(cleanup);
INIT_ANCHOR(cleanup);
pm_multi_target_state_t state = { 0 }; pm_multi_target_state_t state = { 0 };
state.position = popped ? 0 : 1; state.position = popped ? 0 : 1;
@ -9626,11 +9591,9 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
// anchors and then join them in the correct order into the resulting // anchors and then join them in the correct order into the resulting
// anchor. // anchor.
DECL_ANCHOR(inner_pre); DECL_ANCHOR(inner_pre);
INIT_ANCHOR(inner_pre);
scope_node->pre_execution_anchor = inner_pre; scope_node->pre_execution_anchor = inner_pre;
DECL_ANCHOR(inner_body); DECL_ANCHOR(inner_body);
INIT_ANCHOR(inner_body);
if (cast->statements != NULL) { if (cast->statements != NULL) {
const pm_node_list_t *body = &cast->statements->body; const pm_node_list_t *body = &cast->statements->body;
@ -10090,7 +10053,6 @@ VALUE
pm_iseq_compile_node(rb_iseq_t *iseq, pm_scope_node_t *node) pm_iseq_compile_node(rb_iseq_t *iseq, pm_scope_node_t *node)
{ {
DECL_ANCHOR(ret); DECL_ANCHOR(ret);
INIT_ANCHOR(ret);
if (pm_iseq_pre_execution_p(iseq)) { if (pm_iseq_pre_execution_p(iseq)) {
// Because these ISEQs can have BEGIN{}, we're going to create two // Because these ISEQs can have BEGIN{}, we're going to create two
@ -10098,14 +10060,12 @@ pm_iseq_compile_node(rb_iseq_t *iseq, pm_scope_node_t *node)
// on the scope node so that when BEGIN{} is found, its contents will be // on the scope node so that when BEGIN{} is found, its contents will be
// added to the "pre" anchor. // added to the "pre" anchor.
DECL_ANCHOR(pre); DECL_ANCHOR(pre);
INIT_ANCHOR(pre);
node->pre_execution_anchor = pre; node->pre_execution_anchor = pre;
// Now we'll compile the body as normal. We won't compile directly into // Now we'll compile the body as normal. We won't compile directly into
// the "ret" anchor yet because we want to add the "pre" anchor to the // the "ret" anchor yet because we want to add the "pre" anchor to the
// beginning of the "ret" anchor first. // beginning of the "ret" anchor first.
DECL_ANCHOR(body); DECL_ANCHOR(body);
INIT_ANCHOR(body);
pm_compile_node(iseq, (const pm_node_t *) node, body, false, node); pm_compile_node(iseq, (const pm_node_t *) node, body, false, node);
// Now we'll join both anchors together so that the content is in the // Now we'll join both anchors together so that the content is in the