1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

revert r63988

Due to trunk-mjit CI failures:
http://ci.rvm.jp/results/trunk-mjit@silicon-docker/1130097
http://ci.rvm.jp/results/trunk-mjit@silicon-docker/1130196

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
k0kubun 2018-07-17 16:20:15 +00:00
parent 5aa52587e8
commit 80dac806cc
9 changed files with 35 additions and 112 deletions

View file

@ -43,9 +43,6 @@
* sp_inc: Used to dynamically calculate sp increase in
`insn_stack_increase`.
* handles_stack: If this is true, JIT makes sure that values are
set to VM stack.
- Attributes can access operands, but not stack (push/pop) variables.
- An instruction's body is a pure C block, copied verbatimly into
@ -454,7 +451,7 @@ expandarray
(...)
// attr rb_snum_t sp_inc = num - 1 + (flag & 1 ? 1 : 0);
{
INC_SP(vm_expandarray(GET_SP(), ary, num, (int)flag));
vm_expandarray(GET_CFP(), ary, num, (int)flag);
}
/* concat two arrays */
@ -693,7 +690,6 @@ defineclass
(ID id, ISEQ class_iseq, rb_num_t flags)
(VALUE cbase, VALUE super)
(VALUE val)
// attr bool handles_stack = true;
{
VALUE klass = vm_find_or_create_class_by_id(id, flags, cbase, super);
@ -720,7 +716,6 @@ send
(CALL_INFO ci, CALL_CACHE cc, ISEQ blockiseq)
(...)
(VALUE val)
// attr bool handles_stack = true;
// attr rb_snum_t sp_inc = - (int)(ci->orig_argc + ((ci->flag & VM_CALL_ARGS_BLOCKARG) ? 1 : 0));
{
struct rb_calling_info calling;
@ -776,7 +771,6 @@ opt_send_without_block
(CALL_INFO ci, CALL_CACHE cc)
(...)
(VALUE val)
// attr bool handles_stack = true;
// attr rb_snum_t sp_inc = -ci->orig_argc;
{
struct rb_calling_info calling;
@ -791,7 +785,6 @@ invokesuper
(CALL_INFO ci, CALL_CACHE cc, ISEQ blockiseq)
(...)
(VALUE val)
// attr bool handles_stack = true;
// attr rb_snum_t sp_inc = - (int)(ci->orig_argc + ((ci->flag & VM_CALL_ARGS_BLOCKARG) ? 1 : 0));
{
struct rb_calling_info calling;
@ -809,7 +802,6 @@ invokeblock
(CALL_INFO ci)
(...)
(VALUE val)
// attr bool handles_stack = true;
// attr rb_snum_t sp_inc = 1 - ci->orig_argc;
{
struct rb_calling_info calling;
@ -836,7 +828,6 @@ leave
()
(VALUE val)
(VALUE val)
// attr bool handles_stack = true;
{
if (OPT_CHECKED_RUN) {
const VALUE *const bp = vm_base_ptr(reg_cfp);
@ -998,9 +989,9 @@ opt_plus
val = vm_opt_plus(recv, obj);
if (val == Qundef) {
#ifndef MJIT_HEADER
PUSH(recv);
PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
DISPATCH_ORIGINAL_INSN(opt_send_without_block);
@ -1017,9 +1008,9 @@ opt_minus
val = vm_opt_minus(recv, obj);
if (val == Qundef) {
#ifndef MJIT_HEADER
PUSH(recv);
PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
DISPATCH_ORIGINAL_INSN(opt_send_without_block);
@ -1036,9 +1027,9 @@ opt_mult
val = vm_opt_mult(recv, obj);
if (val == Qundef) {
#ifndef MJIT_HEADER
PUSH(recv);
PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
DISPATCH_ORIGINAL_INSN(opt_send_without_block);
@ -1055,9 +1046,9 @@ opt_div
val = vm_opt_div(recv, obj);
if (val == Qundef) {
#ifndef MJIT_HEADER
PUSH(recv);
PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
DISPATCH_ORIGINAL_INSN(opt_send_without_block);
@ -1074,9 +1065,9 @@ opt_mod
val = vm_opt_mod(recv, obj);
if (val == Qundef) {
#ifndef MJIT_HEADER
PUSH(recv);
PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
DISPATCH_ORIGINAL_INSN(opt_send_without_block);
@ -1093,9 +1084,9 @@ opt_eq
val = opt_eq_func(recv, obj, ci, cc);
if (val == Qundef) {
#ifndef MJIT_HEADER
PUSH(recv);
PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
DISPATCH_ORIGINAL_INSN(opt_send_without_block);
@ -1112,9 +1103,9 @@ opt_neq
val = vm_opt_neq(ci, cc, ci_eq, cc_eq, recv, obj);
if (val == Qundef) {
#ifndef MJIT_HEADER
PUSH(recv);
PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
DISPATCH_ORIGINAL_INSN(opt_send_without_block);
@ -1131,9 +1122,9 @@ opt_lt
val = vm_opt_lt(recv, obj);
if (val == Qundef) {
#ifndef MJIT_HEADER
PUSH(recv);
PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
DISPATCH_ORIGINAL_INSN(opt_send_without_block);
@ -1150,9 +1141,9 @@ opt_le
val = vm_opt_le(recv, obj);
if (val == Qundef) {
#ifndef MJIT_HEADER
PUSH(recv);
PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
DISPATCH_ORIGINAL_INSN(opt_send_without_block);
@ -1169,9 +1160,9 @@ opt_gt
val = vm_opt_gt(recv, obj);
if (val == Qundef) {
#ifndef MJIT_HEADER
PUSH(recv);
PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
DISPATCH_ORIGINAL_INSN(opt_send_without_block);
@ -1188,9 +1179,9 @@ opt_ge
val = vm_opt_ge(recv, obj);
if (val == Qundef) {
#ifndef MJIT_HEADER
PUSH(recv);
PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
DISPATCH_ORIGINAL_INSN(opt_send_without_block);
@ -1207,9 +1198,9 @@ opt_ltlt
val = vm_opt_ltlt(recv, obj);
if (val == Qundef) {
#ifndef MJIT_HEADER
PUSH(recv);
PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
DISPATCH_ORIGINAL_INSN(opt_send_without_block);
@ -1226,9 +1217,9 @@ opt_aref
val = vm_opt_aref(recv, obj);
if (val == Qundef) {
#ifndef MJIT_HEADER
PUSH(recv);
PUSH(obj);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
DISPATCH_ORIGINAL_INSN(opt_send_without_block);
@ -1245,10 +1236,10 @@ opt_aset
val = vm_opt_aset(recv, obj, set);
if (val == Qundef) {
#ifndef MJIT_HEADER
PUSH(recv);
PUSH(obj);
PUSH(set);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
DISPATCH_ORIGINAL_INSN(opt_send_without_block);
@ -1268,10 +1259,12 @@ opt_aset_with
val = tmp;
}
else {
#ifndef MJIT_HEADER
PUSH(recv);
#ifndef MJIT_HEADER
PUSH(rb_str_resurrect(key));
#endif
PUSH(val);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
DISPATCH_ORIGINAL_INSN(opt_send_without_block);
@ -1288,8 +1281,8 @@ opt_aref_with
val = vm_opt_aref_with(recv, key);
if (val == Qundef) {
#ifndef MJIT_HEADER
PUSH(recv);
#ifndef MJIT_HEADER
PUSH(rb_str_resurrect(key));
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
@ -1307,8 +1300,8 @@ opt_length
val = vm_opt_length(recv, BOP_LENGTH);
if (val == Qundef) {
#ifndef MJIT_HEADER
PUSH(recv);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
DISPATCH_ORIGINAL_INSN(opt_send_without_block);
@ -1325,8 +1318,8 @@ opt_size
val = vm_opt_length(recv, BOP_SIZE);
if (val == Qundef) {
#ifndef MJIT_HEADER
PUSH(recv);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
DISPATCH_ORIGINAL_INSN(opt_send_without_block);
@ -1343,8 +1336,8 @@ opt_empty_p
val = vm_opt_empty_p(recv);
if (val == Qundef) {
#ifndef MJIT_HEADER
PUSH(recv);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
DISPATCH_ORIGINAL_INSN(opt_send_without_block);
@ -1361,8 +1354,8 @@ opt_succ
val = vm_opt_succ(recv);
if (val == Qundef) {
#ifndef MJIT_HEADER
PUSH(recv);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
DISPATCH_ORIGINAL_INSN(opt_send_without_block);
@ -1379,8 +1372,8 @@ opt_not
val = vm_opt_not(ci, cc, recv);
if (val == Qundef) {
#ifndef MJIT_HEADER
PUSH(recv);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
DISPATCH_ORIGINAL_INSN(opt_send_without_block);
@ -1407,9 +1400,9 @@ opt_regexpmatch2
val = vm_opt_regexpmatch2(obj2, obj1);
if (val == Qundef) {
#ifndef MJIT_HEADER
PUSH(obj2);
PUSH(obj1);
#ifndef MJIT_HEADER
ADD_PC(-WIDTH_OF_opt_send_without_block);
#endif
DISPATCH_ORIGINAL_INSN(opt_send_without_block);
@ -1422,7 +1415,6 @@ opt_call_c_function
(rb_insn_func_t funcptr)
()
()
// attr bool handles_stack = true;
{
reg_cfp = (funcptr)(ec, reg_cfp);

View file

@ -24,9 +24,6 @@
struct compile_status {
int success; /* has TRUE if compilation has had no issue */
int *stack_size_for_pos; /* stack_size_for_pos[pos] has stack size for the position (otherwise -1) */
/* If TRUE, JIT-ed code will use local variables to store pushed values instead of
using VM's stack and moving stack pointer. */
int local_stack_p;
};
/* Storage to keep data which is consistent in each conditional branch.
@ -175,13 +172,7 @@ compile_insns(FILE *f, const struct rb_iseq_constant_body *body, unsigned int st
static void
compile_cancel_handler(FILE *f, const struct rb_iseq_constant_body *body, struct compile_status *status)
{
unsigned int i;
fprintf(f, "\ncancel:\n");
if (status->local_stack_p) {
for (i = 0; i < body->stack_max; i++) {
fprintf(f, " *((VALUE *)reg_cfp->bp + %d) = stack[%d];\n", i + 1, i);
}
}
fprintf(f, " return Qundef;\n");
}
@ -191,7 +182,6 @@ mjit_compile(FILE *f, const struct rb_iseq_constant_body *body, const char *func
{
struct compile_status status;
status.success = TRUE;
status.local_stack_p = !body->catch_except_p;
status.stack_size_for_pos = ALLOC_N(int, body->iseq_size);
memset(status.stack_size_for_pos, NOT_COMPILED_STACK_SIZE, sizeof(int) * body->iseq_size);
@ -205,12 +195,7 @@ mjit_compile(FILE *f, const struct rb_iseq_constant_body *body, const char *func
fprintf(f, "__declspec(dllexport)\n");
#endif
fprintf(f, "VALUE\n%s(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp)\n{\n", funcname);
if (status.local_stack_p) {
fprintf(f, " VALUE stack[%d];\n", body->stack_max);
}
else {
fprintf(f, " VALUE *stack = reg_cfp->sp;\n");
}
fprintf(f, " VALUE *stack = reg_cfp->sp;\n");
fprintf(f, " static const VALUE *const original_body_iseq = (VALUE *)0x%"PRIxVALUE";\n",
(VALUE)body->iseq_encoded);

View file

@ -101,10 +101,6 @@ class RubyVM::BareInstructions
}.join
end
def handles_stack?
/\b(false|0)\b/ !~ @attrs['handles_stack'].expr.expr
end
def inspect
sprintf "#<%s %s@%s:%d>", self.class.name, @name, @loc[0], @loc[1]
end
@ -129,7 +125,6 @@ class RubyVM::BareInstructions
generate_attribute 'rb_num_t', 'retn', rets.size
generate_attribute 'rb_num_t', 'width', width
generate_attribute 'rb_snum_t', 'sp_inc', rets.size - pops.size
generate_attribute 'bool', 'handles_stack', false
end
def typesplit a

View file

@ -20,16 +20,6 @@
MAYBE_UNUSED(<%= ope.fetch(:decl) %>) = (<%= ope.fetch(:type) %>)operands[<%= i %>];
% end
%
% # JIT: Declare stack_size to be used in some macro of _mjit_compile_insn_body.erb
if (status->local_stack_p) {
% # TODO: can we use some functions to calculate this?
% if insn.name == 'send' || insn.name == 'invokesuper'
fprintf(f, " MAYBE_UNUSED(unsigned int) stack_size = %u;\n", b->stack_size - <%= insn.pops.size %> - ((ci->flag & VM_CALL_ARGS_BLOCKARG) ? 1 : 0));
% else
fprintf(f, " MAYBE_UNUSED(unsigned int) stack_size = %u;\n", b->stack_size - <%= insn.pops.size %>);
% end
}
%
% # JIT: Declare variables for operands, popped values and return values
% insn.declarations.each do |decl|
fprintf(f, " <%= decl %>;\n");

View file

@ -69,28 +69,8 @@
% end
% when /\A\s+DISPATCH_ORIGINAL_INSN\([^)]+\);\s+\z/
% # For `opt_xxx`'s fallbacks.
fprintf(f, " reg_cfp->sp = (VALUE *)reg_cfp->bp + %d;\n", b->stack_size + 1);
fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", pos);
fprintf(f, " goto cancel;\n");
% # If local_stack_p is TRUE, stack values are only available in local variables
% # for stack. So we need to replace those macros if local_stack_p is TRUE here.
% when /\bGET_SP\(\)/
% # reg_cfp->sp
fprintf(f, <%= to_cstr.call(line.sub(/\bGET_SP\(\)/, '%s')) %>, (status->local_stack_p ? "(stack + stack_size)" : "GET_SP()"));
% when /\bSTACK_ADDR_FROM_TOP\((?<num>[^)]+)\)/
% # #define STACK_ADDR_FROM_TOP(n) (GET_SP()-(n))
% num = Regexp.last_match[:num]
fprintf(f, <%= to_cstr.call(line.sub(/\bSTACK_ADDR_FROM_TOP\(([^)]+)\)/, '%s')) %>,
(status->local_stack_p ? "stack + (stack_size - (<%= num %>))" : "STACK_ADDR_FROM_TOP(<%= num %>)"));
% when /\bTOPN\((?<num>[^)]+)\)/
% # #define TOPN(n) (*(GET_SP()-(n)-1))
% num = Regexp.last_match[:num]
fprintf(f, <%= to_cstr.call(line.sub(/\bTOPN\(([^)]+)\)/, '%s')) %>,
(status->local_stack_p ? "*(stack + (stack_size - (<%= num %>) - 1))" : "TOPN(<%= num %>)"));
% when /\bPOPN\([^)]+\)/ # skip sp motion on JIT
fprintf(f, <%= to_cstr.call(line.sub(/\bPOPN\((?<num>[^)]+)\)/) { Regexp.last_match[:num] }) %>);
% when /\bINC_SP\([^)]+\)/ # skip sp motion on JIT
fprintf(f, <%= to_cstr.call(line.sub(/\bINC_SP\((?<num>[^)]+)\)/) { Regexp.last_match[:num] }) %>);
% else
fprintf(f, <%= to_cstr.call(line) %>);
% end

View file

@ -12,19 +12,4 @@
}
%
% # JIT: move sp to use or preserve stack variables
if (status->local_stack_p) {
% # sp motion is optimized away for `handles_frame? #=> false` case.
% # Thus sp should be set properly before `goto cancel`.
% if insn.handles_stack?
% # JIT-only behavior (pushing JIT's local variables to VM's stack):
rb_snum_t i, push_size;
push_size = -<%= insn.call_attribute('sp_inc') %> + <%= insn.rets.size %> - <%= insn.pops.size %>;
fprintf(f, " reg_cfp->sp = (VALUE *)reg_cfp->bp + %d;\n", b->stack_size + 1 - <%= insn.pops.size %>); /* POPN(INSN_ATTR(popn)); */
for (i = 0; i < push_size; i++) { /* TODO: use memcpy? */
fprintf(f, " *(reg_cfp->sp + %ld) = stack[%ld];\n", i - push_size, (rb_snum_t)b->stack_size - push_size + i);
}
% end
}
else {
fprintf(f, " reg_cfp->sp = (VALUE *)reg_cfp->bp + %d;\n", b->stack_size + 1 - <%= insn.pops.size %>); /* POPN(INSN_ATTR(popn)); */
}
fprintf(f, " reg_cfp->sp = (VALUE *)reg_cfp->bp + %d;\n", b->stack_size + 1 - <%= insn.pops.size %>); /* POPN(INSN_ATTR(popn)); */

View file

@ -24,11 +24,6 @@
int param_size = iseq->body->param.size; /* TODO: check calling->argc for argument_arity_error */
fprintf(f, "{\n");
% # JIT: Declare stack_size to be used in some macro of _mjit_compile_insn_body.erb
if (status->local_stack_p) {
/* TODO: can we use some functions to calculate this? */
fprintf(f, " MAYBE_UNUSED(unsigned int) stack_size = %u;\n", b->stack_size - <%= insn.pops.size %> - ((ci->flag & VM_CALL_ARGS_BLOCKARG) ? 1 : 0));
}
% # JIT: Invalidate call cache if it requires vm_search_method. This allows to inline some of following things.
<%= render 'mjit_compile_send_guard' -%>

View file

@ -31,13 +31,13 @@
% # reg_cfp: the second argument of _mjitXXX
% # GET_CFP(): refers to `reg_cfp`
% # GET_EP(): refers to `reg_cfp->ep`
% # GET_SP(): refers to `reg_cfp->sp`, or `(stack + stack_size)` if local_stack_p
% # GET_SP(): refers to `reg_cfp->sp`
% # GET_SELF(): refers to `reg_cfp->self`
% # GET_LEP(): refers to `VM_EP_LEP(reg_cfp->ep)`
% # EXEC_EC_CFP(): refers to `val = vm_exec(ec, TRUE)` with frame setup
% # CALL_METHOD(): using `GET_CFP()` and `EXEC_EC_CFP()`
% # TOPN(): refers to `reg_cfp->sp`, or `*(stack + (stack_size - num - 1))` if local_stack_p
% # STACK_ADDR_FROM_TOP(): refers to `reg_cfp->sp`, or `stack + (stack_size - num)` if local_stack_p
% # TOPN(): refers to `reg_cfp->sp`
% # STACK_ADDR_FROM_TOP(): refers to `reg_cfp->sp`
% # DISPATCH_ORIGINAL_INSN(): expanded in _mjit_compile_insn.erb
% # THROW_EXCEPTION(): specially defined for JIT
% # RESTORE_REGS(): specially defined for `leave`

View file

@ -1236,12 +1236,12 @@ vm_throw(const rb_execution_context_t *ec, rb_control_frame_t *reg_cfp,
}
}
static inline rb_num_t
vm_expandarray(VALUE *sp, VALUE ary, rb_num_t num, int flag)
static inline void
vm_expandarray(rb_control_frame_t *cfp, VALUE ary, rb_num_t num, int flag)
{
int is_splat = flag & 0x01;
rb_num_t space_size = num + is_splat;
VALUE *base = sp;
VALUE *base = cfp->sp;
const VALUE *ptr;
rb_num_t len;
const VALUE obj = ary;
@ -1256,6 +1256,8 @@ vm_expandarray(VALUE *sp, VALUE ary, rb_num_t num, int flag)
len = (rb_num_t)RARRAY_LEN(ary);
}
cfp->sp += space_size;
if (flag & 0x02) {
/* post: ..., nil ,ary[-1], ..., ary[0..-num] # top */
rb_num_t i = 0, j;
@ -1297,7 +1299,6 @@ vm_expandarray(VALUE *sp, VALUE ary, rb_num_t num, int flag)
}
}
RB_GC_GUARD(ary);
return space_size;
}
static VALUE vm_call_general(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc);