ruby-changes:60265
From: Nobuyoshi <ko1@a...>
Date: Mon, 2 Mar 2020 16:55:00 +0900 (JST)
Subject: [ruby-changes:60265] 85620ffaa6 (master): Reduced parser stack usage by merging non-result actions
https://git.ruby-lang.org/ruby.git/commit/?id=85620ffaa6 From 85620ffaa634e0a0a8467c5b159819a736b69fad Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Mon, 2 Mar 2020 16:45:35 +0900 Subject: Reduced parser stack usage by merging non-result actions diff --git a/parse.y b/parse.y index 99e11e7..6b1686e 100644 --- a/parse.y +++ b/parse.y @@ -3003,9 +3003,7 @@ primary : literal https://github.com/ruby/ruby/blob/trunk/parse.y#L3003 local_push(p, 0); $<id>$ = p->cur_arg; p->cur_arg = 0; - } - { - $<flags>$ = p->in; + $<flags>1 = p->in; p->in.def = 1; } f_arglist @@ -3013,15 +3011,15 @@ primary : literal https://github.com/ruby/ruby/blob/trunk/parse.y#L3011 k_end { /*%%%*/ - NODE *body = remove_begin($6); + NODE *body = remove_begin($5); reduce_nodes(p, &body); - $$ = NEW_DEFN($2, $5, body, &@$); - nd_set_line($$->nd_defn, @7.end_pos.lineno); + $$ = NEW_DEFN($2, $4, body, &@$); + nd_set_line($$->nd_defn, @6.end_pos.lineno); set_line_body(body, @1.beg_pos.lineno); /*% %*/ - /*% ripper: def!($2, $5, $6) %*/ + /*% ripper: def!($2, $4, $5) %*/ local_pop(p); - p->in.def = $<flags>4.def; + p->in.def = $<flags>1.def; p->cur_arg = $<id>3; } | k_def singleton dot_or_colon {SET_LEX_STATE(EXPR_FNAME);} fname @@ -3810,22 +3808,24 @@ p_case_body : keyword_in https://github.com/ruby/ruby/blob/trunk/parse.y#L3808 p->command_start = FALSE; $<flags>1 = p->in; p->in.kwarg = 1; + $<tbl>$ = push_pvtbl(p); + } + { + $<tbl>$ = push_pktbl(p); } - {$<tbl>$ = push_pvtbl(p);} - {$<tbl>$ = push_pktbl(p);} p_top_expr then - {pop_pktbl(p, $<tbl>4);} - {pop_pvtbl(p, $<tbl>3);} { + pop_pktbl(p, $<tbl>3); + pop_pvtbl(p, $<tbl>2); p->in.kwarg = $<flags>1.kwarg; } compstmt p_cases { /*%%%*/ - $$ = NEW_IN($5, $10, $11, &@$); + $$ = NEW_IN($4, $7, $8, &@$); /*% %*/ - /*% ripper: in!($5, $10, escape_Qundef($11)) %*/ + /*% ripper: in!($4, $7, escape_Qundef($8)) %*/ } ; -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/