mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* compile.c (FIXNUM_INC, FIXNUM_OR): trivial optimizations.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8a9960a374
commit
47b31a44c7
1 changed files with 12 additions and 10 deletions
22
compile.c
22
compile.c
|
@ -19,6 +19,8 @@
|
||||||
#include "insns_info.inc"
|
#include "insns_info.inc"
|
||||||
|
|
||||||
#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))
|
#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))
|
||||||
|
#define FIXNUM_INC(n, i) ((n)+(INT2FIX(i)&~FIXNUM_FLAG))
|
||||||
|
#define FIXNUM_OR(n, x) ((n)|INT2FIX(i))
|
||||||
|
|
||||||
typedef struct iseq_link_element {
|
typedef struct iseq_link_element {
|
||||||
enum {
|
enum {
|
||||||
|
@ -1772,7 +1774,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
|
||||||
if (piobj->insn_id == BIN(send) &&
|
if (piobj->insn_id == BIN(send) &&
|
||||||
piobj->operands[2] == 0 /* block */
|
piobj->operands[2] == 0 /* block */
|
||||||
) {
|
) {
|
||||||
piobj->operands[3] = INT2FIX(FIX2INT(piobj->operands[3]) | VM_CALL_TAILCALL_BIT);
|
piobj->operands[3] = FIXNUM_OR(piobj->operands[3], VM_CALL_TAILCALL_BIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return COMPILE_OK;
|
return COMPILE_OK;
|
||||||
|
@ -2340,7 +2342,7 @@ compile_massign_lhs(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE *node)
|
||||||
iobj = (INSN *)POP_ELEMENT(ret); /* pop send insn */
|
iobj = (INSN *)POP_ELEMENT(ret); /* pop send insn */
|
||||||
|
|
||||||
dupidx = iobj->operands[1];
|
dupidx = iobj->operands[1];
|
||||||
dupidx = INT2FIX(FIX2INT(dupidx) + 1);
|
dupidx = FIXNUM_INC(dupidx, 1);
|
||||||
iobj->operands[1] = dupidx;
|
iobj->operands[1] = dupidx;
|
||||||
|
|
||||||
ADD_INSN1(ret, nd_line(node), topn, dupidx);
|
ADD_INSN1(ret, nd_line(node), topn, dupidx);
|
||||||
|
@ -3757,7 +3759,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
||||||
else {
|
else {
|
||||||
argc = INT2FIX(0);
|
argc = INT2FIX(0);
|
||||||
}
|
}
|
||||||
ADD_INSN1(ret, nd_line(node), dupn, INT2FIX(FIX2INT(argc)+1));
|
ADD_INSN1(ret, nd_line(node), dupn, FIXNUM_INC(argc, 1));
|
||||||
ADD_SEND_R(ret, nd_line(node), ID2SYM(idAREF), argc, Qfalse, LONG2FIX(flag));
|
ADD_SEND_R(ret, nd_line(node), ID2SYM(idAREF), argc, Qfalse, LONG2FIX(flag));
|
||||||
|
|
||||||
if (id == 0 || id == 1) {
|
if (id == 0 || id == 1) {
|
||||||
|
@ -3795,12 +3797,12 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ADD_SEND_R(ret, nd_line(node), ID2SYM(idASET),
|
ADD_SEND_R(ret, nd_line(node), ID2SYM(idASET),
|
||||||
INT2FIX(FIX2INT(argc) + 1), Qfalse, LONG2FIX(flag));
|
FIXNUM_INC(argc, 1), Qfalse, LONG2FIX(flag));
|
||||||
}
|
}
|
||||||
ADD_INSNL(ret, nd_line(node), jump, lfin);
|
ADD_INSNL(ret, nd_line(node), jump, lfin);
|
||||||
ADD_LABEL(ret, label);
|
ADD_LABEL(ret, label);
|
||||||
ADD_INSN1(ret, nd_line(node), setn, INT2FIX(FIX2INT(argc) + 1));
|
ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 1));
|
||||||
ADD_INSN1(ret, nd_line(node), adjuststack, INT2FIX(FIX2INT(argc) + 1));
|
ADD_INSN1(ret, nd_line(node), adjuststack, FIXNUM_INC(argc, 1));
|
||||||
ADD_LABEL(ret, lfin);
|
ADD_LABEL(ret, lfin);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -3814,7 +3816,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ADD_SEND_R(ret, nd_line(node), ID2SYM(idASET),
|
ADD_SEND_R(ret, nd_line(node), ID2SYM(idASET),
|
||||||
INT2FIX(FIX2INT(argc) + 1), Qfalse, LONG2FIX(flag));
|
FIXNUM_INC(argc, 1), Qfalse, LONG2FIX(flag));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4860,12 +4862,12 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
||||||
|
|
||||||
if (flag & VM_CALL_ARGS_BLOCKARG_BIT) {
|
if (flag & VM_CALL_ARGS_BLOCKARG_BIT) {
|
||||||
ADD_INSN1(ret, nd_line(node), topn, INT2FIX(1));
|
ADD_INSN1(ret, nd_line(node), topn, INT2FIX(1));
|
||||||
ADD_INSN1(ret, nd_line(node), setn, INT2FIX(FIX2INT(argc) + 3));
|
ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 3));
|
||||||
ADD_INSN (ret, nd_line(node), pop);
|
ADD_INSN (ret, nd_line(node), pop);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ADD_INSN1(ret, nd_line(node), setn, INT2FIX(FIX2INT(argc) + 1));
|
ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ADD_SEQ(ret, recv);
|
ADD_SEQ(ret, recv);
|
||||||
|
|
Loading…
Reference in a new issue