Skip to content

Commit de89bff

Browse files
committed
INIT_ANCHOR no longer needed usually
1 parent b8f248e commit de89bff

File tree

2 files changed

+1
-41
lines changed

2 files changed

+1
-41
lines changed

compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ do { \
439439
#define DECL_ANCHOR(name) \
440440
LINK_ANCHOR name[1] = {{{ISEQ_ELEMENT_ANCHOR,},&name[0].anchor}}
441441
#define INIT_ANCHOR(name) \
442-
(name->last = &name->anchor)
442+
((name->last = &name->anchor)->next = NULL) /* re-initialize */
443443

444444
static inline VALUE
445445
freeze_hide_obj(VALUE obj)

prism_compile.c

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,6 @@ pm_compile_logical(rb_iseq_t *iseq, LINK_ANCHOR *const ret, pm_node_t *cond, LAB
867867
const pm_node_location_t location = PM_NODE_START_LOCATION(scope_node->parser, cond);
868868

869869
DECL_ANCHOR(seq);
870-
INIT_ANCHOR(seq);
871870

872871
LABEL *label = NEW_LABEL(location.line);
873872
if (!then_label) then_label = label;
@@ -1000,7 +999,6 @@ pm_compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const pm_no
1000999
}
10011000
default: {
10021001
DECL_ANCHOR(cond_seq);
1003-
INIT_ANCHOR(cond_seq);
10041002
pm_compile_node(iseq, cond, cond_seq, false, scope_node);
10051003

10061004
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,
10401038
LABEL *end_label = NULL;
10411039

10421040
DECL_ANCHOR(cond_seq);
1043-
INIT_ANCHOR(cond_seq);
10441041
pm_compile_branch_condition(iseq, cond_seq, predicate, then_label, else_label, false, scope_node);
10451042
PUSH_SEQ(ret, cond_seq);
10461043

@@ -1056,7 +1053,6 @@ pm_compile_conditional(rb_iseq_t *iseq, const pm_node_location_t *node_location,
10561053
PUSH_LABEL(ret, then_label);
10571054

10581055
DECL_ANCHOR(then_seq);
1059-
INIT_ANCHOR(then_seq);
10601056

10611057
if (statements != NULL) {
10621058
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,
10971093
PUSH_LABEL(ret, else_label);
10981094

10991095
DECL_ANCHOR(else_seq);
1100-
INIT_ANCHOR(else_seq);
11011096

11021097
if (subsequent != NULL) {
11031098
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
13891384
bool static_literal = false;
13901385

13911386
DECL_ANCHOR(anchor);
1392-
INIT_ANCHOR(anchor);
13931387

13941388
// Convert pushed elements to a hash, and merge if needed.
13951389
#define FLUSH_CHUNK \
@@ -1933,7 +1927,6 @@ pm_setup_args(const pm_arguments_node_t *arguments_node, const pm_node_t *block,
19331927
}
19341928

19351929
DECL_ANCHOR(block_arg);
1936-
INIT_ANCHOR(block_arg);
19371930
pm_compile_node(iseq, block, block_arg, false, scope_node);
19381931

19391932
*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
28322825

28332826
if (has_keys) {
28342827
DECL_ANCHOR(match_values);
2835-
INIT_ANCHOR(match_values);
28362828

28372829
for (size_t index = 0; index < cast->elements.size; index++) {
28382830
const pm_node_t *element = cast->elements.nodes[index];
@@ -3577,7 +3569,6 @@ retry:;
35773569
// fprintf(stderr, "func_name:%s -> %p\n", builtin_func, bf->func_ptr);
35783570

35793571
DECL_ANCHOR(args_seq);
3580-
INIT_ANCHOR(args_seq);
35813572

35823573
int flags = 0;
35833574
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
41564147
struct iseq_compile_data_ensure_node_stack *prev_enlp = enlp;
41574148
DECL_ANCHOR(ensure);
41584149

4159-
INIT_ANCHOR(ensure);
41604150
while (enlp) {
41614151
if (enlp->erange != NULL) {
41624152
DECL_ANCHOR(ensure_part);
41634153
LABEL *lstart = NEW_LABEL(0);
41644154
LABEL *lend = NEW_LABEL(0);
4165-
INIT_ANCHOR(ensure_part);
41664155

41674156
add_ensure_range(iseq, enlp->erange, lstart, lend);
41684157

@@ -4853,10 +4842,7 @@ pm_compile_for_node_index(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *c
48534842
// owning expression of this target, then retrieve the value, expand it,
48544843
// and then compile the necessary writes.
48554844
DECL_ANCHOR(writes);
4856-
INIT_ANCHOR(writes);
4857-
48584845
DECL_ANCHOR(cleanup);
4859-
INIT_ANCHOR(cleanup);
48604846

48614847
pm_multi_target_state_t state = { 0 };
48624848
state.position = 1;
@@ -4873,10 +4859,7 @@ pm_compile_for_node_index(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *c
48734859
}
48744860
case PM_MULTI_TARGET_NODE: {
48754861
DECL_ANCHOR(writes);
4876-
INIT_ANCHOR(writes);
4877-
48784862
DECL_ANCHOR(cleanup);
4879-
INIT_ANCHOR(cleanup);
48804863

48814864
pm_compile_target_node(iseq, node, ret, writes, cleanup, scope_node, NULL);
48824865

@@ -4994,7 +4977,6 @@ pm_compile_ensure(rb_iseq_t *iseq, const pm_begin_node_t *cast, const pm_node_lo
49944977
struct ensure_range *erange;
49954978

49964979
DECL_ANCHOR(ensr);
4997-
INIT_ANCHOR(ensr);
49984980
if (statements != NULL) {
49994981
pm_compile_node(iseq, (const pm_node_t *) statements, ensr, true, scope_node);
50004982
}
@@ -5329,7 +5311,6 @@ pm_compile_shareable_constant_value(rb_iseq_t *iseq, const pm_node_t *node, cons
53295311
}
53305312
default: {
53315313
DECL_ANCHOR(value_seq);
5332-
INIT_ANCHOR(value_seq);
53335314

53345315
pm_compile_node(iseq, node, value_seq, false, scope_node);
53355316
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_
71257106
// `when` nodes into. If a match is found, they will need to jump into
71267107
// the body_seq anchor to the correct spot.
71277108
DECL_ANCHOR(cond_seq);
7128-
INIT_ANCHOR(cond_seq);
71297109

71307110
// This is the anchor that we will compile the bodies of the various
71317111
// `when` nodes into. We'll make sure that the clauses that are compiled
71327112
// jump into the correct spots within this anchor.
71337113
DECL_ANCHOR(body_seq);
7134-
INIT_ANCHOR(body_seq);
71357114

71367115
// This is the label where all of the when clauses will jump to if they
71377116
// 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
73847363
// `in` nodes into. We'll make sure that the patterns that are compiled
73857364
// jump into the correct spots within this anchor.
73867365
DECL_ANCHOR(body_seq);
7387-
INIT_ANCHOR(body_seq);
73887366

73897367
// This is the anchor that we will compile the patterns of the various
73907368
// `in` nodes into. If a match is found, they will need to jump into the
73917369
// body_seq anchor to the correct spot.
73927370
DECL_ANCHOR(cond_seq);
7393-
INIT_ANCHOR(cond_seq);
73947371

73957372
// This label is used to indicate the end of the entire node. It is
73967373
// 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
75607537
}
75617538

75627539
DECL_ANCHOR(args);
7563-
INIT_ANCHOR(args);
75647540

75657541
struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
75667542
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,
77797755
}
77807756

77817757
DECL_ANCHOR(fail_anchor);
7782-
INIT_ANCHOR(fail_anchor);
77837758

77847759
// Otherwise there is more than one local variable target, so we'll need
77857760
// 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
80157990
// depending on the kind of write being performed.
80167991
if (node->reference) {
80177992
DECL_ANCHOR(writes);
8018-
INIT_ANCHOR(writes);
8019-
80207993
DECL_ANCHOR(cleanup);
8021-
INIT_ANCHOR(cleanup);
80227994

80237995
pm_compile_target_node(iseq, node->reference, ret, writes, cleanup, scope_node, NULL);
80247996
PUSH_GETLOCAL(ret, *location, LVAR_ERRINFO, 0);
@@ -8119,7 +8091,6 @@ static inline void
81198091
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)
81208092
{
81218093
DECL_ANCHOR(args);
8122-
INIT_ANCHOR(args);
81238094

81248095
LABEL *retry_label = NEW_LABEL(location->line);
81258096
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,
85778548
}
85788549
else {
85798550
DECL_ANCHOR(prefix);
8580-
INIT_ANCHOR(prefix);
8581-
85828551
DECL_ANCHOR(body);
8583-
INIT_ANCHOR(body);
85848552

85858553
pm_compile_constant_path(iseq, node, prefix, body, popped, scope_node);
85868554
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,
95039471
const pm_multi_write_node_t *cast = (const pm_multi_write_node_t *) node;
95049472

95059473
DECL_ANCHOR(writes);
9506-
INIT_ANCHOR(writes);
9507-
95089474
DECL_ANCHOR(cleanup);
9509-
INIT_ANCHOR(cleanup);
95109475

95119476
pm_multi_target_state_t state = { 0 };
95129477
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,
96269591
// anchors and then join them in the correct order into the resulting
96279592
// anchor.
96289593
DECL_ANCHOR(inner_pre);
9629-
INIT_ANCHOR(inner_pre);
96309594
scope_node->pre_execution_anchor = inner_pre;
96319595

96329596
DECL_ANCHOR(inner_body);
9633-
INIT_ANCHOR(inner_body);
96349597

96359598
if (cast->statements != NULL) {
96369599
const pm_node_list_t *body = &cast->statements->body;
@@ -10090,22 +10053,19 @@ VALUE
1009010053
pm_iseq_compile_node(rb_iseq_t *iseq, pm_scope_node_t *node)
1009110054
{
1009210055
DECL_ANCHOR(ret);
10093-
INIT_ANCHOR(ret);
1009410056

1009510057
if (pm_iseq_pre_execution_p(iseq)) {
1009610058
// Because these ISEQs can have BEGIN{}, we're going to create two
1009710059
// anchors to compile them, a "pre" and a "body". We'll mark the "pre"
1009810060
// on the scope node so that when BEGIN{} is found, its contents will be
1009910061
// added to the "pre" anchor.
1010010062
DECL_ANCHOR(pre);
10101-
INIT_ANCHOR(pre);
1010210063
node->pre_execution_anchor = pre;
1010310064

1010410065
// Now we'll compile the body as normal. We won't compile directly into
1010510066
// the "ret" anchor yet because we want to add the "pre" anchor to the
1010610067
// beginning of the "ret" anchor first.
1010710068
DECL_ANCHOR(body);
10108-
INIT_ANCHOR(body);
1010910069
pm_compile_node(iseq, (const pm_node_t *) node, body, false, node);
1011010070

1011110071
// Now we'll join both anchors together so that the content is in the

0 commit comments

Comments
 (0)