зеркало из https://github.com/github/ruby.git
* compile.c, compile.h (DECL_ANCHOR, INIT_ANCHOR): split not to
initialize aggregations with dynamic values. [ruby-talk:259306] * eval.c (rb_protect): not to initialize aggregations with dynamic values. [ruby-talk:259306] * gc.c (mark_current_machine_context): ditto. * thread.c (thgroup_list, call_trace_func): ditto. * vm.c (vm_init_redefined_flag): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
98a54d46f7
Коммит
39c56c3349
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
Fri Jul 20 16:11:33 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* compile.c, compile.h (DECL_ANCHOR, INIT_ANCHOR): split not to
|
||||
initialize aggregations with dynamic values. [ruby-talk:259306]
|
||||
|
||||
* eval.c (rb_protect): not to initialize aggregations with dynamic
|
||||
values. [ruby-talk:259306]
|
||||
|
||||
* gc.c (mark_current_machine_context): ditto.
|
||||
|
||||
* thread.c (thgroup_list, call_trace_func): ditto.
|
||||
|
||||
* vm.c (vm_init_redefined_flag): ditto.
|
||||
|
||||
Fri Jul 20 15:22:51 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/openssl/ossl_config.c (ossl_config_set_section): do not
|
||||
|
|
46
compile.c
46
compile.c
|
@ -139,6 +139,7 @@ iseq_compile(VALUE self, NODE *node)
|
|||
{
|
||||
DECL_ANCHOR(ret);
|
||||
rb_iseq_t *iseq;
|
||||
INIT_ANCHOR(ret);
|
||||
GetISeqPtr(self, iseq);
|
||||
|
||||
if (node == 0) {
|
||||
|
@ -1827,6 +1828,7 @@ compile_array_(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE* node_root,
|
|||
int len = node->nd_alen, line = nd_line(node), i=0;
|
||||
DECL_ANCHOR(anchor);
|
||||
|
||||
INIT_ANCHOR(anchor);
|
||||
if (nd_type(node) != NODE_ZARRAY) {
|
||||
while (node) {
|
||||
if (nd_type(node) != NODE_ARRAY) {
|
||||
|
@ -1951,6 +1953,7 @@ make_masgn_lhs(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE *node)
|
|||
}
|
||||
default: {
|
||||
DECL_ANCHOR(anchor);
|
||||
INIT_ANCHOR(anchor);
|
||||
COMPILE_POPED(anchor, "masgn lhs", node);
|
||||
/* dump_disasm_list(FIRST_ELEMENT(anchor)); */
|
||||
REMOVE_ELEM(FIRST_ELEMENT(anchor));
|
||||
|
@ -2060,6 +2063,7 @@ compile_massign(rb_iseq_t *iseq, LINK_ANCHOR *ret,
|
|||
while (n) {
|
||||
DECL_ANCHOR(lhs);
|
||||
|
||||
INIT_ANCHOR(lhs);
|
||||
COMPILE_POPED(lhs, "post", n->nd_head);
|
||||
|
||||
if (nd_type(n->nd_head) != NODE_MASGN) {
|
||||
|
@ -2416,10 +2420,13 @@ add_ensure_iseq(LINK_ANCHOR *ret, rb_iseq_t *iseq)
|
|||
struct iseq_compile_data_ensure_node_stack *prev_enlp = enlp;
|
||||
DECL_ANCHOR(ensure);
|
||||
|
||||
INIT_ANCHOR(ensure);
|
||||
while (enlp) {
|
||||
DECL_ANCHOR(ensure_part);
|
||||
LABEL *lstart = NEW_LABEL(0);
|
||||
LABEL *lend = NEW_LABEL(0);
|
||||
|
||||
INIT_ANCHOR(ensure_part);
|
||||
add_ensure_range(iseq, enlp->erange, lstart, lend);
|
||||
|
||||
iseq->compile_data->ensure_node_stack = enlp->prev;
|
||||
|
@ -2442,6 +2449,8 @@ setup_args(rb_iseq_t *iseq, LINK_ANCHOR *args, NODE *argn, unsigned long *flag)
|
|||
DECL_ANCHOR(arg_block);
|
||||
DECL_ANCHOR(args_splat);
|
||||
|
||||
INIT_ANCHOR(arg_block);
|
||||
INIT_ANCHOR(args_splat);
|
||||
if (argn && nd_type(argn) == NODE_BLOCK_PASS) {
|
||||
COMPILE(arg_block, "block", argn->nd_body);
|
||||
*flag |= VM_CALL_ARGS_BLOCKARG_BIT;
|
||||
|
@ -2463,6 +2472,7 @@ setup_args(rb_iseq_t *iseq, LINK_ANCHOR *args, NODE *argn, unsigned long *flag)
|
|||
int next_is_array = (nd_type(argn->nd_head) == NODE_ARRAY);
|
||||
DECL_ANCHOR(tmp);
|
||||
|
||||
INIT_ANCHOR(tmp);
|
||||
COMPILE(tmp, "args (cat: splat)", argn->nd_body);
|
||||
if (next_is_array && nsplat == 0) {
|
||||
/* none */
|
||||
|
@ -2565,6 +2575,9 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
DECL_ANCHOR(else_seq);
|
||||
LABEL *then_label, *else_label, *end_label;
|
||||
|
||||
INIT_ANCHOR(cond_seq);
|
||||
INIT_ANCHOR(then_seq);
|
||||
INIT_ANCHOR(else_seq);
|
||||
then_label = NEW_LABEL(nd_line(node));
|
||||
else_label = NEW_LABEL(nd_line(node));
|
||||
end_label = NEW_LABEL(nd_line(node));
|
||||
|
@ -2596,6 +2609,9 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
DECL_ANCHOR(cond_seq);
|
||||
VALUE special_literals = rb_ary_new();
|
||||
|
||||
INIT_ANCHOR(head);
|
||||
INIT_ANCHOR(body_seq);
|
||||
INIT_ANCHOR(cond_seq);
|
||||
if (node->nd_head == 0) {
|
||||
COMPILE_(ret, "when", node->nd_body, poped);
|
||||
break;
|
||||
|
@ -2692,6 +2708,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
LABEL *endlabel;
|
||||
DECL_ANCHOR(body_seq);
|
||||
|
||||
INIT_ANCHOR(body_seq);
|
||||
endlabel = NEW_LABEL(nd_line(node));
|
||||
|
||||
while (node && nd_type(node) == NODE_WHEN) {
|
||||
|
@ -3075,14 +3092,16 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
LABEL *lstart = NEW_LABEL(nd_line(node));
|
||||
LABEL *lend = NEW_LABEL(nd_line(node));
|
||||
LABEL *lcont = NEW_LABEL(nd_line(node));
|
||||
struct ensure_range er = { lstart, lend, 0 };
|
||||
struct iseq_compile_data_ensure_node_stack enl = {
|
||||
node->nd_ensr,
|
||||
iseq->compile_data->ensure_node_stack, /* prev */
|
||||
&er,
|
||||
};
|
||||
struct ensure_range er = { 0 };
|
||||
struct iseq_compile_data_ensure_node_stack enl;
|
||||
struct ensure_range *erange;
|
||||
|
||||
INIT_ANCHOR(ensr);
|
||||
er.begin = lstart;
|
||||
er.end = lend;
|
||||
enl.ensure_node = node->nd_ensr;
|
||||
enl.prev = iseq->compile_data->ensure_node_stack; /* prev */
|
||||
enl.erange = &er;
|
||||
COMPILE_POPED(ensr, "ensure ensr", node->nd_ensr);
|
||||
|
||||
iseq->compile_data->ensure_node_stack = &enl;
|
||||
|
@ -3256,6 +3275,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
* nd_mid
|
||||
*/
|
||||
|
||||
INIT_ANCHOR(args);
|
||||
COMPILE(ret, "NODE_OP_ASGN1 recv", node->nd_recv);
|
||||
argc = compile_array(iseq, args, node->nd_args->nd_body, Qfalse);
|
||||
POP_ELEMENT(args);
|
||||
|
@ -3448,6 +3468,8 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
VALUE parent_block = iseq->compile_data->current_block;
|
||||
iseq->compile_data->current_block = Qfalse;
|
||||
|
||||
INIT_ANCHOR(recv);
|
||||
INIT_ANCHOR(args);
|
||||
#if SUPPORT_JOKE
|
||||
if (nd_type(node) == NODE_VCALL) {
|
||||
if (mid == idBitblt) {
|
||||
|
@ -3543,8 +3565,9 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
VALUE argc;
|
||||
unsigned long flag = 0;
|
||||
VALUE parent_block = iseq->compile_data->current_block;
|
||||
iseq->compile_data->current_block = Qfalse;
|
||||
|
||||
INIT_ANCHOR(args);
|
||||
iseq->compile_data->current_block = Qfalse;
|
||||
if (nd_type(node) == NODE_SUPER) {
|
||||
argc = setup_args(iseq, args, node->nd_args, &flag);
|
||||
}
|
||||
|
@ -3647,6 +3670,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
VALUE size = 0;
|
||||
int type = node->nd_head ? nd_type(node->nd_head) : NODE_ZARRAY;
|
||||
|
||||
INIT_ANCHOR(list);
|
||||
switch (type) {
|
||||
case NODE_ARRAY:{
|
||||
compile_array(iseq, list, node->nd_head, Qfalse);
|
||||
|
@ -3704,6 +3728,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
VALUE argc;
|
||||
unsigned long flag = 0;
|
||||
|
||||
INIT_ANCHOR(args);
|
||||
if (iseq->type == ISEQ_TYPE_TOP || iseq->type == ISEQ_TYPE_CLASS) {
|
||||
COMPILE_ERROR((ERROR_ARGS "Illegal yield"));
|
||||
}
|
||||
|
@ -3813,6 +3838,8 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
DECL_ANCHOR(recv);
|
||||
DECL_ANCHOR(val);
|
||||
|
||||
INIT_ANCHOR(recv);
|
||||
INIT_ANCHOR(val);
|
||||
switch(nd_type(node)) {
|
||||
case NODE_MATCH:
|
||||
ADD_INSN1(recv, nd_line(node), putobject, node->nd_lit);
|
||||
|
@ -4081,6 +4108,8 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
DECL_ANCHOR(pref);
|
||||
DECL_ANCHOR(body);
|
||||
|
||||
INIT_ANCHOR(pref);
|
||||
INIT_ANCHOR(body);
|
||||
compile_colon2(iseq, node, pref, body);
|
||||
if (LIST_SIZE_ZERO(pref)) {
|
||||
if (iseq->compile_data->option->inline_const_cache) {
|
||||
|
@ -4278,6 +4307,8 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
unsigned long flag = 0;
|
||||
VALUE argc;
|
||||
|
||||
INIT_ANCHOR(recv);
|
||||
INIT_ANCHOR(args);
|
||||
argc = setup_args(iseq, args, node->nd_args, &flag);
|
||||
|
||||
if (node->nd_recv == (NODE *) 1) {
|
||||
|
@ -4717,6 +4748,7 @@ iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args,
|
|||
|
||||
DECL_ANCHOR(anchor);
|
||||
|
||||
INIT_ANCHOR(anchor);
|
||||
if (iseq->type == ISEQ_TYPE_METHOD ||
|
||||
iseq->type == ISEQ_TYPE_TOP ||
|
||||
iseq->type == ISEQ_TYPE_CLASS) {
|
||||
|
|
|
@ -211,8 +211,12 @@ r_value(VALUE value)
|
|||
#define COMPILE_OK 1
|
||||
#define COMPILE_NG 0
|
||||
|
||||
|
||||
/* leave name uninitialized so that compiler warn if INIT_ANCHOR is
|
||||
* missing */
|
||||
#define DECL_ANCHOR(name) \
|
||||
LINK_ANCHOR name##_body__ = {{0,}, &name##_body__.anchor}; \
|
||||
LINK_ANCHOR *name = & name##_body__
|
||||
LINK_ANCHOR *name, name##_body__ = {{0,},}
|
||||
#define INIT_ANCHOR(name) \
|
||||
(name##_body__.last = &name##_body__.anchor, name = &name##_body__)
|
||||
|
||||
#endif /* RUBY_COMPILE_H */
|
||||
|
|
6
eval.c
6
eval.c
|
@ -1146,9 +1146,9 @@ rb_protect(VALUE (*proc) (VALUE), VALUE data, int *state)
|
|||
int status;
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
rb_control_frame_t *cfp = th->cfp;
|
||||
struct rb_vm_trap_tag trap_tag = {
|
||||
th->trap_tag,
|
||||
};
|
||||
struct rb_vm_trap_tag trap_tag;
|
||||
|
||||
trap_tag.prev = th->trap_tag;
|
||||
|
||||
PUSH_TAG();
|
||||
th->trap_tag = &trap_tag;
|
||||
|
|
37
gc.c
37
gc.c
|
@ -1403,41 +1403,18 @@ mark_current_machine_context(rb_thread_t *th)
|
|||
FLUSH_REGISTER_WINDOWS;
|
||||
/* This assumes that all registers are saved into the jmp_buf (and stack) */
|
||||
setjmp(save_regs_gc_mark);
|
||||
mark_locations_array((VALUE*)save_regs_gc_mark,
|
||||
sizeof(save_regs_gc_mark) / sizeof(VALUE));
|
||||
|
||||
{
|
||||
struct { VALUE *start; VALUE *end; } regions[] = {
|
||||
{ (VALUE*)save_regs_gc_mark,
|
||||
(VALUE*)save_regs_gc_mark +
|
||||
sizeof(save_regs_gc_mark) / sizeof(VALUE *) },
|
||||
{ stack_start, stack_end }
|
||||
mark_locations_array(stack_start, stack_end - stack_start);
|
||||
#ifdef __ia64
|
||||
, { th->machine_register_stack_start,
|
||||
th->machine_register_stack_end }
|
||||
mark_locations_array(th->machine_register_stack_start,
|
||||
th->machine_register_stack_end - th->machine_register_stack_start);
|
||||
#endif
|
||||
#if defined(__human68k__) || defined(__mc68000__)
|
||||
, { (VALUE*)((char*)STACK_END + 2),
|
||||
(VALUE*)((char*)STACK_START + 2) }
|
||||
mark_locations_array((VALUE*)((char*)STACK_END + 2),
|
||||
(STACK_START - STACK_END));
|
||||
#endif
|
||||
};
|
||||
int i;
|
||||
for (i = 0; i < sizeof(regions)/sizeof(*regions); i++) {
|
||||
/* stack scanning code is inlined here
|
||||
* because function call grows stack.
|
||||
* don't call mark_locations_array,
|
||||
* rb_gc_mark_locations, etc. */
|
||||
VALUE *x, n, v;
|
||||
x = regions[i].start;
|
||||
n = regions[i].end - x;
|
||||
while (n--) {
|
||||
v = *x;
|
||||
VALGRIND_MAKE_MEM_DEFINED(&v, sizeof(v));
|
||||
if (is_pointer_to_heap((void *)v)) {
|
||||
gc_mark(v, 0);
|
||||
}
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
15
thread.c
15
thread.c
|
@ -1964,9 +1964,10 @@ static VALUE
|
|||
thgroup_list(VALUE group)
|
||||
{
|
||||
VALUE ary = rb_ary_new();
|
||||
struct thgroup_list_params param = {
|
||||
ary, group,
|
||||
};
|
||||
struct thgroup_list_params param;
|
||||
|
||||
param.ary = ary;
|
||||
param.group = group;
|
||||
st_foreach(GET_THREAD()->vm->living_threads, thgroup_list_i, (st_data_t) & param);
|
||||
return ary;
|
||||
}
|
||||
|
@ -2808,7 +2809,13 @@ call_trace_proc(VALUE args)
|
|||
static void
|
||||
call_trace_func(rb_event_flag_t event, VALUE proc, VALUE self, ID id, VALUE klass)
|
||||
{
|
||||
struct call_trace_func_args args = {event, proc, self, id, klass};
|
||||
struct call_trace_func_args args;
|
||||
|
||||
args.event = event;
|
||||
args.proc = proc;
|
||||
args.self = self;
|
||||
args.id = id;
|
||||
args.klass = klass;
|
||||
ruby_suppress_tracing(call_trace_proc, (VALUE)&args);
|
||||
}
|
||||
|
||||
|
|
50
vm.c
50
vm.c
|
@ -1009,36 +1009,30 @@ add_opt_method(VALUE klass, ID mid, VALUE bop)
|
|||
static void
|
||||
vm_init_redefined_flag(void)
|
||||
{
|
||||
const VALUE register_info[] = {
|
||||
idPLUS, BOP_PLUS, rb_cFixnum, rb_cFloat, rb_cString, rb_cArray, 0,
|
||||
idMINUS, BOP_MINUS, rb_cFixnum, 0,
|
||||
idMULT, BOP_MULT, rb_cFixnum, rb_cFloat, 0,
|
||||
idDIV, BOP_DIV, rb_cFixnum, rb_cFloat, 0,
|
||||
idMOD, BOP_MOD, rb_cFixnum, rb_cFloat, 0,
|
||||
idEq, BOP_EQ, rb_cFixnum, rb_cFloat, rb_cString, 0,
|
||||
idLT, BOP_LT, rb_cFixnum, 0,
|
||||
idLE, BOP_LE, rb_cFixnum, 0,
|
||||
idLTLT, BOP_LTLT, rb_cString, rb_cArray, 0,
|
||||
idAREF, BOP_AREF, rb_cArray, rb_cHash, 0,
|
||||
idASET, BOP_ASET, rb_cArray, rb_cHash, 0,
|
||||
idLength, BOP_LENGTH, rb_cArray, rb_cString, rb_cHash, 0,
|
||||
idSucc, BOP_SUCC, rb_cFixnum, rb_cString, rb_cTime, 0,
|
||||
idGT, BOP_GT, rb_cFixnum, 0,
|
||||
idGE, BOP_GE, rb_cFixnum, 0,
|
||||
0,
|
||||
};
|
||||
const VALUE *ptr = register_info;
|
||||
ID mid;
|
||||
VALUE bop;
|
||||
|
||||
vm_opt_method_table = st_init_numtable();
|
||||
|
||||
while (*ptr) {
|
||||
ID mid = *ptr++;
|
||||
VALUE bop = *ptr++;
|
||||
while(*ptr) {
|
||||
VALUE klass = *ptr++;
|
||||
add_opt_method(klass, mid, bop);
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
#define OP(mid_, bop_) (mid = id##mid_, bop = BOP_##bop_)
|
||||
#define C(k) add_opt_method(rb_c##k, mid, bop)
|
||||
OP(PLUS, PLUS), (C(Fixnum), C(Float), C(String), C(Array));
|
||||
OP(MINUS, MINUS), (C(Fixnum));
|
||||
OP(MULT, MULT), (C(Fixnum), C(Float));
|
||||
OP(DIV, DIV), (C(Fixnum), C(Float));
|
||||
OP(MOD, MOD), (C(Fixnum), C(Float));
|
||||
OP(Eq, EQ), (C(Fixnum), C(Float), C(String));
|
||||
OP(LT, LT), (C(Fixnum));
|
||||
OP(LE, LE), (C(Fixnum));
|
||||
OP(LTLT, LTLT), (C(String), C(Array));
|
||||
OP(AREF, AREF), (C(Array), C(Hash));
|
||||
OP(ASET, ASET), (C(Array), C(Hash));
|
||||
OP(Length, LENGTH), (C(Array), C(String), C(Hash));
|
||||
OP(Succ, SUCC), (C(Fixnum), C(String), C(Time));
|
||||
OP(GT, GT), (C(Fixnum));
|
||||
OP(GE, GE), (C(Fixnum));
|
||||
#undef C
|
||||
#undef OP
|
||||
}
|
||||
|
||||
/* evaluator body */
|
||||
|
|
Загрузка…
Ссылка в новой задаче