[前][次][番号順一覧][スレッド一覧]

ruby-changes:62592

From: Kazuhiro <ko1@a...>
Date: Mon, 17 Aug 2020 09:29:11 +0900 (JST)
Subject: [ruby-changes:62592] 5849309c5a (master): Revert "Refactor to reduce "swap" instruction of pattern matching"

https://git.ruby-lang.org/ruby.git/commit/?id=5849309c5a

From 5849309c5a3754c3a9b0d1e42a34e82b94a5104b Mon Sep 17 00:00:00 2001
From: Kazuhiro NISHIYAMA <zn@m...>
Date: Mon, 17 Aug 2020 09:26:30 +0900
Subject: Revert "Refactor to reduce "swap" instruction of pattern matching"

This reverts commit 3a4be429b50062122d1616256de38649464d3146.

To fix following warning:

```
compiling ../compile.c
../compile.c:6336:20: warning: variable 'line' is uninitialized when used here [-Wuninitialized]
    ADD_INSN(head, line, putnil); /* allocate stack for cached #deconstruct value */
                   ^~~~
../compile.c:220:57: note: expanded from macro 'ADD_INSN'
  ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_body(iseq, (line), BIN(insn), 0))
                                                        ^~~~
../compile.c:6327:13: note: initialize the variable 'line' to silence this warning
    int line;
            ^
             = 0
1 warning generated.
```

diff --git a/compile.c b/compile.c
index 519e12f..f2ab7c3 100644
--- a/compile.c
+++ b/compile.c
@@ -6333,7 +6333,6 @@ compile_case3(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no https://github.com/ruby/ruby/blob/trunk/compile.c#L6333
     INIT_ANCHOR(body_seq);
     INIT_ANCHOR(cond_seq);
 
-    ADD_INSN(head, line, putnil); /* allocate stack for cached #deconstruct value */
     CHECK(COMPILE(head, "case base", node->nd_head));
 
     branches = decl_branch_base(iseq, node, "case");
@@ -6346,6 +6345,8 @@ compile_case3(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no https://github.com/ruby/ruby/blob/trunk/compile.c#L6345
     endlabel = NEW_LABEL(line);
     elselabel = NEW_LABEL(line);
 
+    ADD_INSN(head, line, putnil); /* allocate stack for cached #deconstruct value */
+    ADD_INSN(head, line, swap);
     ADD_SEQ(ret, head);	/* case VAL */
 
     while (type == NODE_IN) {
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]