summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compile.c2
-rw-r--r--insns.def22
2 files changed, 22 insertions, 2 deletions
diff --git a/compile.c b/compile.c
index ed003772fc..deb403f579 100644
--- a/compile.c
+++ b/compile.c
@@ -2822,7 +2822,6 @@ compile_massign(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE *node, int poped)
ADD_INSN(ret, nd_line(node), swap);
expand = 0;
}
-#if 0
else if (llen > 2 && llen != rlen) {
POP_ELEMENT(ret);
adjust_stack(iseq, ret, nd_line(node), rlen, llen);
@@ -2833,7 +2832,6 @@ compile_massign(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE *node, int poped)
last->insn_id = BIN(reverse);
expand = 0;
}
-#endif
}
}
if (expand) {
diff --git a/insns.def b/insns.def
index 81aca8faae..778999d7db 100644
--- a/insns.def
+++ b/insns.def
@@ -625,6 +625,28 @@ swap
/**
@c stack
+ @e reverse stack top N order.
+ @j スタックトップの n 個の値を逆転する。
+ */
+DEFINE_INSN
+reverse
+(rb_num_t n)
+(...)
+(...) // inc += 0;
+{
+ rb_num_t i;
+ VALUE *sp = STACK_ADDR_FROM_TOP(n);
+
+ for (i=0; i<n/2; i++) {
+ VALUE v0 = sp[i];
+ VALUE v1 = TOPN(i);
+ sp[i] = v1;
+ TOPN(i) = v0;
+ }
+}
+
+/**
+ @c stack
@e for stack caching.
@j スタックキャッシングの状態を調整するために必要な命令。
*/