diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | dln.c | 8 | ||||
-rw-r--r-- | eval.c | 27 | ||||
-rw-r--r-- | gc.c | 8 | ||||
-rw-r--r-- | node.h | 3 |
5 files changed, 40 insertions, 13 deletions
@@ -1,7 +1,12 @@ +Thu Jan 22 16:21:08 1998 Yukihiro Matsumoto <matz@netlab.co.jp> + + * eval.c (ALLOCTMP): replace ALLOCA_N, where thread context switch + may happen. + Wed Jan 21 01:43:42 1998 Yukihiro Matsumoto <matz@netlab.co.jp> * eval.c (PUSH_FRAME): do not use ALLOCA_N(). crash on some - platforms (such as HP-UX or mswin32). + platforms that use missing/alloca.c. * regex.c (re_compile_pattern): too many pops for non register subexpr. @@ -10,16 +10,16 @@ ************************************************/ -#ifdef _AIX -#pragma alloca -#endif - #include "config.h" #include "defines.h" #include "dln.h" char *dln_argv0; +#ifdef _AIX +#pragma alloca +#endif + #if defined(HAVE_ALLOCA_H) && !defined(__GNUC__) #include <alloca.h> #endif @@ -1103,6 +1103,17 @@ mod_alias_method(mod, new, old) return mod; } +#if defined(C_ALLOCA) && defined(THREAD) +# define TMP_PROTECT NODE *__protect_tmp=0 +# define ALLOCTMP(type,n) \ + (__protect_tmp = node_newnode(NODE_ALLOCA, \ + str_new(0,sizeof(type)*(n)),0,__protect_tmp), \ + (void*)RSTRING(__protect_tmp->nd_head)->ptr) +#else +# define TMP_PROTECT typedef int foobazzz +# define ALLOCTMP(type,n) ALLOCA_N(type,n) +#endif + #define SETUP_ARGS(anode) {\ NODE *n = anode;\ if (!n) {\ @@ -1116,7 +1127,7 @@ mod_alias_method(mod, new, old) int line = sourceline;\ int i;\ n = anode;\ - argv = ALLOCA_N(VALUE,argc);\ + argv = ALLOCTMP(VALUE,argc);\ for (i=0;i<argc;i++) {\ argv[i] = rb_eval(self,n->nd_head);\ n=n->nd_next;\ @@ -1757,6 +1768,7 @@ rb_eval(self, node) { VALUE recv; int argc; VALUE *argv; /* used in SETUP_ARGS */ + TMP_PROTECT; PUSH_ITER(ITER_NOT); recv = rb_eval(self, node->nd_recv); @@ -1769,6 +1781,7 @@ rb_eval(self, node) case NODE_FCALL: { int argc; VALUE *argv; /* used in SETUP_ARGS */ + TMP_PROTECT; PUSH_ITER(ITER_NOT); SETUP_ARGS(node->nd_args); @@ -1785,6 +1798,7 @@ rb_eval(self, node) case NODE_ZSUPER: { int argc; VALUE *argv; /* used in SETUP_ARGS */ + TMP_PROTECT; if (nd_type(node) == NODE_ZSUPER) { argc = the_frame->argc; @@ -1836,6 +1850,7 @@ rb_eval(self, node) int argc; VALUE *argv; /* used in SETUP_ARGS */ VALUE recv, val; NODE *rval; + TMP_PROTECT; recv = rb_eval(self, node->nd_recv); rval = node->nd_args->nd_head; @@ -2325,6 +2340,7 @@ module_setup(module, node) VALUE result; /* OK */ char *file = sourcefile; int line = sourceline; + TMP_PROTECT; /* fill c-ref */ node->nd_clss = module; @@ -2336,7 +2352,7 @@ module_setup(module, node) if (node->nd_rval) the_frame->cbase = node->nd_rval; if (node->nd_tbl) { - VALUE *vars = ALLOCA_N(VALUE, node->nd_tbl[0]+1); + VALUE *vars = ALLOCTMP(VALUE, node->nd_tbl[0]+1); *vars++ = (VALUE)node; the_scope->local_vars = vars; memclear(the_scope->local_vars, node->nd_tbl[0]); @@ -2827,6 +2843,7 @@ handle_rescue(self, node) NODE *node; { int argc; VALUE *argv; /* used in SETUP_ARGS */ + TMP_PROTECT; if (!node->nd_args) { return obj_is_kind_of(errinfo, eException); @@ -3036,6 +3053,7 @@ rb_call(class, recv, mid, argc, argv, scope) int itr; enum node_type type; static int tick; + TMP_PROTECT; again: /* is it in the method cache? */ @@ -3224,7 +3242,7 @@ rb_call(class, recv, mid, argc, argv, scope) if (body->nd_rval) the_frame->cbase = body->nd_rval; if (body->nd_tbl) { - local_vars = ALLOCA_N(VALUE, body->nd_tbl[0]+1); + local_vars = ALLOCTMP(VALUE, body->nd_tbl[0]+1); *local_vars++ = (VALUE)body; memclear(local_vars, body->nd_tbl[0]); the_scope->local_tbl = body->nd_tbl; @@ -3721,6 +3739,7 @@ f_load(obj, fname) int state; char *file; volatile ID last_func; + TMP_PROTECT; Check_SafeStr(fname); if (RSTRING(fname)->ptr[0] == '~') { @@ -3736,7 +3755,7 @@ f_load(obj, fname) if (top_scope->local_tbl) { int len = top_scope->local_tbl[0]+1; ID *tbl = ALLOC_N(ID, len); - VALUE *vars = ALLOCA_N(VALUE, len); + VALUE *vars = ALLOCTMP(VALUE, len); *vars++ = 0; MEMCPY(tbl, top_scope->local_tbl, ID, len); MEMCPY(vars, top_scope->local_vars, ID, len-1); @@ -26,10 +26,6 @@ #endif #endif -#ifdef _AIX -#pragma alloca -#endif - #ifdef C_ALLOCA void *alloca(); #endif @@ -400,6 +396,10 @@ gc_mark(ptr) case NODE_DREGX_ONCE: case NODE_FBODY: case NODE_CALL: + case NODE_CREF: +#ifdef C_ALLOCA + case NODE_ALLOCA: +#endif gc_mark(obj->as.node.u1.node); /* fall through */ case NODE_SUPER: /* 3 */ @@ -101,6 +101,9 @@ enum node_type { NODE_TAG, NODE_NEWLINE, NODE_POSTEXE, +#ifdef C_ALLOCA + NODE_ALLOCA, +#endif }; typedef struct RNode { |