зеркало из https://github.com/github/ruby.git
Clean up OPT_STACK_CACHING (#8132)
This commit is contained in:
Родитель
bf4d64d8d0
Коммит
38be9a9b72
|
@ -1070,7 +1070,7 @@ parse.$(OBJEXT): {$(VPATH)}parse.c
|
|||
miniprelude.$(OBJEXT): {$(VPATH)}miniprelude.c
|
||||
|
||||
# dependencies for optional sources.
|
||||
compile.$(OBJEXT): {$(VPATH)}opt_sc.inc {$(VPATH)}optunifs.inc
|
||||
compile.$(OBJEXT): {$(VPATH)}optunifs.inc
|
||||
|
||||
win32/win32.$(OBJEXT): {$(VPATH)}win32/win32.c {$(VPATH)}win32/file.h \
|
||||
{$(VPATH)}dln.h {$(VPATH)}dln_find.c {$(VPATH)}encindex.h \
|
||||
|
@ -1097,7 +1097,6 @@ INSNS2VMOPT = --srcdir="$(srcdir)"
|
|||
srcs_vpath = {$(VPATH)}
|
||||
|
||||
inc_common_headers = $(tooldir)/ruby_vm/views/_copyright.erb $(tooldir)/ruby_vm/views/_notice.erb
|
||||
$(srcs_vpath)opt_sc.inc: $(tooldir)/ruby_vm/views/opt_sc.inc.erb $(inc_common_headers)
|
||||
$(srcs_vpath)optinsn.inc: $(tooldir)/ruby_vm/views/optinsn.inc.erb $(inc_common_headers)
|
||||
$(srcs_vpath)optunifs.inc: $(tooldir)/ruby_vm/views/optunifs.inc.erb $(inc_common_headers)
|
||||
$(srcs_vpath)insns.inc: $(tooldir)/ruby_vm/views/insns.inc.erb $(inc_common_headers)
|
||||
|
|
169
compile.c
169
compile.c
|
@ -486,7 +486,6 @@ static int iseq_set_local_table(rb_iseq_t *iseq, const rb_ast_id_table_t *tbl);
|
|||
static int iseq_set_exception_local_table(rb_iseq_t *iseq);
|
||||
static int iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const anchor, const NODE *const node);
|
||||
|
||||
static int iseq_set_sequence_stackcaching(rb_iseq_t *iseq, LINK_ANCHOR *const anchor);
|
||||
static int iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor);
|
||||
static int iseq_set_exception_table(rb_iseq_t *iseq);
|
||||
static int iseq_set_optargs_table(rb_iseq_t *iseq);
|
||||
|
@ -1465,13 +1464,6 @@ iseq_setup_insn(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
|
|||
dump_disasm_list(FIRST_ELEMENT(anchor));
|
||||
}
|
||||
|
||||
if (ISEQ_COMPILE_DATA(iseq)->option->stack_caching) {
|
||||
debugs("[compile step 3.3 (iseq_set_sequence_stackcaching)]\n");
|
||||
iseq_set_sequence_stackcaching(iseq, anchor);
|
||||
if (compile_debug > 5)
|
||||
dump_disasm_list(FIRST_ELEMENT(anchor));
|
||||
}
|
||||
|
||||
debugs("[compile step 3.4 (iseq_insert_nop_between_end_and_cont)]\n");
|
||||
iseq_insert_nop_between_end_and_cont(iseq);
|
||||
if (compile_debug > 5)
|
||||
|
@ -3952,167 +3944,6 @@ iseq_insns_unification(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
|
|||
return COMPILE_OK;
|
||||
}
|
||||
|
||||
#if OPT_STACK_CACHING
|
||||
|
||||
#define SC_INSN(insn, stat) sc_insn_info[(insn)][(stat)]
|
||||
#define SC_NEXT(insn) sc_insn_next[(insn)]
|
||||
|
||||
#include "opt_sc.inc"
|
||||
|
||||
static int
|
||||
insn_set_sc_state(rb_iseq_t *iseq, const LINK_ELEMENT *anchor, INSN *iobj, int state)
|
||||
{
|
||||
int nstate;
|
||||
int insn_id;
|
||||
|
||||
insn_id = iobj->insn_id;
|
||||
iobj->insn_id = SC_INSN(insn_id, state);
|
||||
nstate = SC_NEXT(iobj->insn_id);
|
||||
|
||||
if (insn_id == BIN(jump) ||
|
||||
insn_id == BIN(branchif) || insn_id == BIN(branchunless)) {
|
||||
LABEL *lobj = (LABEL *)OPERAND_AT(iobj, 0);
|
||||
|
||||
if (lobj->sc_state != 0) {
|
||||
if (lobj->sc_state != nstate) {
|
||||
BADINSN_DUMP(anchor, iobj, lobj);
|
||||
COMPILE_ERROR(iseq, iobj->insn_info.line_no,
|
||||
"insn_set_sc_state error: %d at "LABEL_FORMAT
|
||||
", %d expected\n",
|
||||
lobj->sc_state, lobj->label_no, nstate);
|
||||
return COMPILE_NG;
|
||||
}
|
||||
}
|
||||
else {
|
||||
lobj->sc_state = nstate;
|
||||
}
|
||||
if (insn_id == BIN(jump)) {
|
||||
nstate = SCS_XX;
|
||||
}
|
||||
}
|
||||
else if (insn_id == BIN(leave)) {
|
||||
nstate = SCS_XX;
|
||||
}
|
||||
|
||||
return nstate;
|
||||
}
|
||||
|
||||
static int
|
||||
label_set_sc_state(LABEL *lobj, int state)
|
||||
{
|
||||
if (lobj->sc_state != 0) {
|
||||
if (lobj->sc_state != state) {
|
||||
state = lobj->sc_state;
|
||||
}
|
||||
}
|
||||
else {
|
||||
lobj->sc_state = state;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
static int
|
||||
iseq_set_sequence_stackcaching(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
|
||||
{
|
||||
#if OPT_STACK_CACHING
|
||||
LINK_ELEMENT *list;
|
||||
int state, insn_id;
|
||||
|
||||
/* initialize */
|
||||
state = SCS_XX;
|
||||
list = FIRST_ELEMENT(anchor);
|
||||
/* dump_disasm_list(list); */
|
||||
|
||||
/* for each list element */
|
||||
while (list) {
|
||||
redo_point:
|
||||
switch (list->type) {
|
||||
case ISEQ_ELEMENT_INSN:
|
||||
{
|
||||
INSN *iobj = (INSN *)list;
|
||||
insn_id = iobj->insn_id;
|
||||
|
||||
/* dump_disasm_list(list); */
|
||||
|
||||
switch (insn_id) {
|
||||
case BIN(nop):
|
||||
{
|
||||
/* exception merge point */
|
||||
if (state != SCS_AX) {
|
||||
NODE dummy_line_node = generate_dummy_line_node(0, -1);
|
||||
INSN *rpobj =
|
||||
new_insn_body(iseq, &dummy_line_node, BIN(reput), 0);
|
||||
|
||||
/* replace this insn */
|
||||
ELEM_REPLACE(list, (LINK_ELEMENT *)rpobj);
|
||||
list = (LINK_ELEMENT *)rpobj;
|
||||
goto redo_point;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BIN(swap):
|
||||
{
|
||||
if (state == SCS_AB || state == SCS_BA) {
|
||||
state = (state == SCS_AB ? SCS_BA : SCS_AB);
|
||||
|
||||
ELEM_REMOVE(list);
|
||||
list = list->next;
|
||||
goto redo_point;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BIN(pop):
|
||||
{
|
||||
switch (state) {
|
||||
case SCS_AX:
|
||||
case SCS_BX:
|
||||
state = SCS_XX;
|
||||
break;
|
||||
case SCS_AB:
|
||||
state = SCS_AX;
|
||||
break;
|
||||
case SCS_BA:
|
||||
state = SCS_BX;
|
||||
break;
|
||||
case SCS_XX:
|
||||
goto normal_insn;
|
||||
default:
|
||||
COMPILE_ERROR(iseq, iobj->insn_info.line_no,
|
||||
"unreachable");
|
||||
return COMPILE_NG;
|
||||
}
|
||||
/* remove useless pop */
|
||||
ELEM_REMOVE(list);
|
||||
list = list->next;
|
||||
goto redo_point;
|
||||
}
|
||||
default:;
|
||||
/* none */
|
||||
} /* end of switch */
|
||||
normal_insn:
|
||||
state = insn_set_sc_state(iseq, anchor, iobj, state);
|
||||
break;
|
||||
}
|
||||
case ISEQ_ELEMENT_LABEL:
|
||||
{
|
||||
LABEL *lobj;
|
||||
lobj = (LABEL *)list;
|
||||
|
||||
state = label_set_sc_state(lobj, state);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
list = list->next;
|
||||
}
|
||||
#endif
|
||||
return COMPILE_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
all_string_result_p(const NODE *node)
|
||||
{
|
||||
|
|
4
iseq.c
4
iseq.c
|
@ -706,7 +706,6 @@ static rb_compile_option_t COMPILE_OPTION_DEFAULT = {
|
|||
OPT_SPECIALISED_INSTRUCTION, /* int specialized_instruction; */
|
||||
OPT_OPERANDS_UNIFICATION, /* int operands_unification; */
|
||||
OPT_INSTRUCTIONS_UNIFICATION, /* int instructions_unification; */
|
||||
OPT_STACK_CACHING, /* int stack_caching; */
|
||||
OPT_FROZEN_STRING_LITERAL,
|
||||
OPT_DEBUG_FROZEN_STRING_LITERAL,
|
||||
TRUE, /* coverage_enabled */
|
||||
|
@ -732,7 +731,6 @@ set_compile_option_from_hash(rb_compile_option_t *option, VALUE opt)
|
|||
SET_COMPILE_OPTION(option, opt, specialized_instruction);
|
||||
SET_COMPILE_OPTION(option, opt, operands_unification);
|
||||
SET_COMPILE_OPTION(option, opt, instructions_unification);
|
||||
SET_COMPILE_OPTION(option, opt, stack_caching);
|
||||
SET_COMPILE_OPTION(option, opt, frozen_string_literal);
|
||||
SET_COMPILE_OPTION(option, opt, debug_frozen_string_literal);
|
||||
SET_COMPILE_OPTION(option, opt, coverage_enabled);
|
||||
|
@ -795,7 +793,6 @@ make_compile_option_value(rb_compile_option_t *option)
|
|||
SET_COMPILE_OPTION(option, opt, specialized_instruction);
|
||||
SET_COMPILE_OPTION(option, opt, operands_unification);
|
||||
SET_COMPILE_OPTION(option, opt, instructions_unification);
|
||||
SET_COMPILE_OPTION(option, opt, stack_caching);
|
||||
SET_COMPILE_OPTION(option, opt, frozen_string_literal);
|
||||
SET_COMPILE_OPTION(option, opt, debug_frozen_string_literal);
|
||||
SET_COMPILE_OPTION(option, opt, coverage_enabled);
|
||||
|
@ -1431,7 +1428,6 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
|
|||
* * +:operands_unification+
|
||||
* * +:peephole_optimization+
|
||||
* * +:specialized_instruction+
|
||||
* * +:stack_caching+
|
||||
* * +:tailcall_optimization+
|
||||
*
|
||||
* Additionally, +:debug_level+ can be set to an integer.
|
||||
|
|
1
iseq.h
1
iseq.h
|
@ -226,7 +226,6 @@ struct rb_compile_option_struct {
|
|||
unsigned int specialized_instruction: 1;
|
||||
unsigned int operands_unification: 1;
|
||||
unsigned int instructions_unification: 1;
|
||||
unsigned int stack_caching: 1;
|
||||
unsigned int frozen_string_literal: 1;
|
||||
unsigned int debug_frozen_string_literal: 1;
|
||||
unsigned int coverage_enabled: 1;
|
||||
|
|
|
@ -35,7 +35,6 @@ builtin_iseq_load(const char *feature_name, const struct rb_builtin_function *ta
|
|||
TRUE, /* unsigned int specialized_instruction; */
|
||||
TRUE, /* unsigned int operands_unification; */
|
||||
TRUE, /* unsigned int instructions_unification; */
|
||||
TRUE, /* unsigned int stack_caching; */
|
||||
TRUE, /* unsigned int frozen_string_literal; */
|
||||
FALSE, /* unsigned int debug_frozen_string_literal; */
|
||||
FALSE, /* unsigned int coverage_enabled; */
|
||||
|
|
|
@ -580,7 +580,7 @@ update-known-errors:
|
|||
errno --list | cut -d' ' -f1 | sort -u - $(srcdir)/defs/known_errors.def | \
|
||||
$(IFCHANGE) $(srcdir)/defs/known_errors.def -
|
||||
|
||||
INSNS = opt_sc.inc optinsn.inc optunifs.inc insns.inc insns_info.inc \
|
||||
INSNS = optinsn.inc optunifs.inc insns.inc insns_info.inc \
|
||||
vmtc.inc vm.inc
|
||||
|
||||
$(INSNS): $(srcdir)/insns.def vm_opts.h \
|
||||
|
@ -620,7 +620,6 @@ $(INSNS): $(srcdir)/insns.def vm_opts.h \
|
|||
$(tooldir)/ruby_vm/views/_trace_instruction.erb \
|
||||
$(tooldir)/ruby_vm/views/insns.inc.erb \
|
||||
$(tooldir)/ruby_vm/views/insns_info.inc.erb \
|
||||
$(tooldir)/ruby_vm/views/opt_sc.inc.erb \
|
||||
$(tooldir)/ruby_vm/views/optinsn.inc.erb \
|
||||
$(tooldir)/ruby_vm/views/optunifs.inc.erb \
|
||||
$(tooldir)/ruby_vm/views/vm.inc.erb \
|
||||
|
|
|
@ -186,7 +186,6 @@ prelude_eval(VALUE code, VALUE name, int line)
|
|||
TRUE, /* unsigned int specialized_instruction; */
|
||||
TRUE, /* unsigned int operands_unification; */
|
||||
TRUE, /* unsigned int instructions_unification; */
|
||||
TRUE, /* unsigned int stack_caching; */
|
||||
TRUE, /* unsigned int frozen_string_literal; */
|
||||
FALSE, /* unsigned int debug_frozen_string_literal; */
|
||||
FALSE, /* unsigned int coverage_enabled; */
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
/* -*- C -*- */
|
||||
|
||||
%# Copyright (c) 2017 Urabe, Shyouhei. All rights reserved.
|
||||
%#
|
||||
%# This file is a part of the programming language Ruby. Permission is hereby
|
||||
%# granted, to either redistribute and/or modify this file, provided that the
|
||||
%# conditions mentioned in the file COPYING are met. Consult the file for
|
||||
%# details.
|
||||
% raise ':FIXME:TBW' if RubyVM::VmOptsH['STACK_CACHING']
|
||||
<%= render 'copyright' %>
|
||||
<%= render 'notice', locals: {
|
||||
this_file: 'is for threaded code',
|
||||
edit: __FILE__,
|
||||
} -%>
|
||||
|
||||
#define SC_STATE_SIZE 6
|
||||
|
||||
#define SCS_XX 1
|
||||
#define SCS_AX 2
|
||||
#define SCS_BX 3
|
||||
#define SCS_AB 4
|
||||
#define SCS_BA 5
|
||||
|
||||
#define SC_ERROR 0xffffffff
|
||||
|
||||
static const VALUE sc_insn_info[][SC_STATE_SIZE] = {
|
||||
#define NO_SC { SC_ERROR, SC_ERROR, SC_ERROR, SC_ERROR, SC_ERROR, SC_ERROR }
|
||||
% RubyVM::Instructions.each_slice 8 do |a|
|
||||
<%= a.map{|i| 'NO_SC' }.join(', ') %>,
|
||||
% end
|
||||
#undef NO_SC
|
||||
};
|
||||
|
||||
static const VALUE sc_insn_next[] = {
|
||||
% RubyVM::Instructions.each_slice 8 do |a|
|
||||
<%= a.map{|i| 'SCS_XX' }.join(', ') %>,
|
||||
% end
|
||||
};
|
||||
|
||||
ASSERT_VM_INSTRUCTION_SIZE(sc_insn_next);
|
|
@ -122,7 +122,6 @@ FILES_NEED_VPATH = %w[
|
|||
miniprelude.c
|
||||
newline.c
|
||||
node_name.inc
|
||||
opt_sc.inc
|
||||
optinsn.inc
|
||||
optunifs.inc
|
||||
parse.c
|
||||
|
|
11
vm.c
11
vm.c
|
@ -2483,11 +2483,7 @@ vm_exec_handle_exception(rb_execution_context_t *ec, enum ruby_tag_type state,
|
|||
}
|
||||
else {
|
||||
/* TAG_BREAK */
|
||||
#if OPT_STACK_CACHING
|
||||
*initial = THROW_DATA_VAL(err);
|
||||
#else
|
||||
*ec->cfp->sp++ = THROW_DATA_VAL(err);
|
||||
#endif
|
||||
ec->errinfo = Qnil;
|
||||
return Qundef;
|
||||
}
|
||||
|
@ -2560,11 +2556,7 @@ vm_exec_handle_exception(rb_execution_context_t *ec, enum ruby_tag_type state,
|
|||
cfp->sp = vm_base_ptr(cfp) + entry->sp;
|
||||
|
||||
if (state != TAG_REDO) {
|
||||
#if OPT_STACK_CACHING
|
||||
*initial = THROW_DATA_VAL(err);
|
||||
#else
|
||||
*ec->cfp->sp++ = THROW_DATA_VAL(err);
|
||||
#endif
|
||||
}
|
||||
ec->errinfo = Qnil;
|
||||
VM_ASSERT(ec->tag->state == TAG_NONE);
|
||||
|
@ -3890,9 +3882,6 @@ Init_VM(void)
|
|||
rb_ary_push(opts, rb_str_new2("call threaded code"));
|
||||
#endif
|
||||
|
||||
#if OPT_STACK_CACHING
|
||||
rb_ary_push(opts, rb_str_new2("stack caching"));
|
||||
#endif
|
||||
#if OPT_OPERANDS_UNIFICATION
|
||||
rb_ary_push(opts, rb_str_new2("operands unification"));
|
||||
#endif
|
||||
|
|
|
@ -182,9 +182,6 @@ void *rb_register_sigaltstack(void *);
|
|||
#if OPT_DIRECT_THREADED_CODE
|
||||
#undef OPT_DIRECT_THREADED_CODE
|
||||
#endif /* OPT_DIRECT_THREADED_CODE */
|
||||
#if OPT_STACK_CACHING
|
||||
#undef OPT_STACK_CACHING
|
||||
#endif /* OPT_STACK_CACHING */
|
||||
#endif /* OPT_CALL_THREADED_CODE */
|
||||
|
||||
void rb_vm_encoded_insn_data_table_init(void);
|
||||
|
@ -1684,11 +1681,7 @@ VALUE rb_proc_dup(VALUE self);
|
|||
/* for debug */
|
||||
extern void rb_vmdebug_stack_dump_raw(const rb_execution_context_t *ec, const rb_control_frame_t *cfp);
|
||||
extern void rb_vmdebug_debug_print_pre(const rb_execution_context_t *ec, const rb_control_frame_t *cfp, const VALUE *_pc);
|
||||
extern void rb_vmdebug_debug_print_post(const rb_execution_context_t *ec, const rb_control_frame_t *cfp
|
||||
#if OPT_STACK_CACHING
|
||||
, VALUE reg_a, VALUE reg_b
|
||||
#endif
|
||||
);
|
||||
extern void rb_vmdebug_debug_print_post(const rb_execution_context_t *ec, const rb_control_frame_t *cfp);
|
||||
|
||||
#define SDR() rb_vmdebug_stack_dump_raw(GET_EC(), GET_EC()->cfp)
|
||||
#define SDR2(cfp) rb_vmdebug_stack_dump_raw(GET_EC(), (cfp))
|
||||
|
|
15
vm_dump.c
15
vm_dump.c
|
@ -422,11 +422,7 @@ rb_vmdebug_debug_print_pre(const rb_execution_context_t *ec, const rb_control_fr
|
|||
}
|
||||
|
||||
void
|
||||
rb_vmdebug_debug_print_post(const rb_execution_context_t *ec, const rb_control_frame_t *cfp
|
||||
#if OPT_STACK_CACHING
|
||||
, VALUE reg_a, VALUE reg_b
|
||||
#endif
|
||||
)
|
||||
rb_vmdebug_debug_print_post(const rb_execution_context_t *ec, const rb_control_frame_t *cfp)
|
||||
{
|
||||
#if VMDEBUG > 9
|
||||
SDR2(cfp);
|
||||
|
@ -442,15 +438,6 @@ rb_vmdebug_debug_print_post(const rb_execution_context_t *ec, const rb_control_f
|
|||
/* stack_dump_thobj(ec); */
|
||||
vm_stack_dump_each(ec, ec->cfp);
|
||||
|
||||
#if OPT_STACK_CACHING
|
||||
{
|
||||
VALUE rstr;
|
||||
rstr = rb_inspect(reg_a);
|
||||
fprintf(stderr, " sc reg A: %s\n", StringValueCStr(rstr));
|
||||
rstr = rb_inspect(reg_b);
|
||||
fprintf(stderr, " sc reg B: %s\n", StringValueCStr(rstr));
|
||||
}
|
||||
#endif
|
||||
printf
|
||||
("--------------------------------------------------------------\n");
|
||||
#endif
|
||||
|
|
|
@ -97,11 +97,6 @@ vm_exec_core(rb_execution_context_t *ec, VALUE initial)
|
|||
reg_cfp = ec->cfp;
|
||||
reg_pc = reg_cfp->pc;
|
||||
|
||||
#if OPT_STACK_CACHING
|
||||
reg_a = initial;
|
||||
reg_b = 0;
|
||||
#endif
|
||||
|
||||
first:
|
||||
INSN_DISPATCH();
|
||||
/*****************/
|
||||
|
|
|
@ -21,11 +21,7 @@ typedef rb_iseq_t *ISEQ;
|
|||
#define DEBUG_ENTER_INSN(insn) \
|
||||
rb_vmdebug_debug_print_pre(ec, GET_CFP(), GET_PC());
|
||||
|
||||
#if OPT_STACK_CACHING
|
||||
#define SC_REGS() , reg_a, reg_b
|
||||
#else
|
||||
#define SC_REGS()
|
||||
#endif
|
||||
|
||||
#define DEBUG_END_INSN() \
|
||||
rb_vmdebug_debug_print_post(ec, GET_CFP() SC_REGS());
|
||||
|
|
|
@ -54,7 +54,6 @@
|
|||
#define OPT_OPERANDS_UNIFICATION 1
|
||||
#define OPT_INSTRUCTIONS_UNIFICATION 0
|
||||
#define OPT_UNIFY_ALL_COMBINATION 0
|
||||
#define OPT_STACK_CACHING 0
|
||||
|
||||
/* misc */
|
||||
#ifndef OPT_SUPPORT_JOKE
|
||||
|
|
|
@ -1365,7 +1365,7 @@ probes.h: {$(VPATH)}probes.dmyh
|
|||
#include "$(*F).dmyh"
|
||||
<<KEEP
|
||||
|
||||
INSNS = opt_sc.inc optinsn.inc optunifs.inc insns.inc insns_info.inc \
|
||||
INSNS = optinsn.inc optunifs.inc insns.inc insns_info.inc \
|
||||
vmtc.inc vm.inc
|
||||
|
||||
!if [exit > insns_rules.mk]
|
||||
|
|
Загрузка…
Ссылка в новой задаче