git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2000-09-25 17:51:29 +00:00
Родитель ba2b829a0f
Коммит 9448424dba
5 изменённых файлов: 54 добавлений и 16 удалений

Просмотреть файл

@ -1,5 +1,14 @@
Tue Sep 26 02:44:54 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
* gc.c (GC_MALLOC_LIMIT): size extended.
* regex.c (DOUBLE_STACK): use machine's stack region for regex
stack if its size is small enough.
Mon Sep 25 18:13:07 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
* regex.c: include <defines.h>.
* eval.c (rb_add_method): cache mismatch by method
definition. need to clear_cache_by_id every time.

17
eval.c
Просмотреть файл

@ -238,7 +238,6 @@ rb_add_method(klass, mid, node, noex)
if (OBJ_FROZEN(klass)) rb_error_frozen("class/module");
body = NEW_METHOD(node, noex);
st_insert(RCLASS(klass)->m_tbl, mid, body);
rb_clear_cache_by_id(mid);
}
static NODE*
@ -360,6 +359,7 @@ rb_disable_super(klass, name)
}
else {
rb_add_method(klass, mid, 0, NOEX_UNDEF);
rb_clear_cache_by_id(mid);
}
}
@ -409,6 +409,7 @@ rb_export_method(klass, name, noex)
}
else {
rb_add_method(klass, name, NEW_ZSUPER(), noex);
rb_clear_cache_by_id(name);
}
}
}
@ -477,12 +478,14 @@ rb_attr(klass, id, read, write, ex)
if (read) {
rb_add_method(klass, id, NEW_IVAR(attriv), noex);
rb_funcall(klass, added, 1, ID2SYM(id));
rb_clear_cache_by_id(id);
}
sprintf(buf, "%s=", name);
id = rb_intern(buf);
if (write) {
rb_add_method(klass, id, NEW_ATTRSET(attriv), noex);
rb_funcall(klass, added, 1, ID2SYM(id));
rb_clear_cache_by_id(id);
}
}
@ -1494,6 +1497,7 @@ rb_undef(klass, id)
rb_id2name(id),s0,rb_class2name(c));
}
rb_add_method(klass, id, 0, NOEX_PUBLIC);
rb_clear_cache_by_id(id);
}
static VALUE
@ -2851,6 +2855,7 @@ rb_eval(self, n)
node->nd_mid, node->nd_defn, NOEX_PUBLIC);
rb_funcall(ruby_class, singleton_added, 1, ID2SYM(node->nd_mid));
}
rb_clear_cache_by_id(node->nd_mid);
if (FL_TEST(ruby_class, FL_SINGLETON)) {
rb_funcall(rb_iv_get(ruby_class, "__attached__"),
singleton_added, 1, ID2SYM(node->nd_mid));
@ -2891,6 +2896,7 @@ rb_eval(self, n)
rb_add_method(klass, node->nd_mid, node->nd_defn,
NOEX_PUBLIC|(body?body->nd_noex&NOEX_UNDEF:0));
rb_funcall(recv, singleton_added, 1, ID2SYM(node->nd_mid));
rb_clear_cache_by_id(node->nd_mid);
result = Qnil;
}
break;
@ -5035,12 +5041,12 @@ rb_feature_p(feature, wait)
if (strcmp(f, feature) == 0) {
goto load_wait;
}
if (strncmp(f, feature, strlen(feature)) == 0) {
char *ext = strrchr(f, '.');
if (strcmp(ext, ".so") == 0) {
len = strlen(feature);
if (strncmp(f, feature, len) == 0) {
if (strcmp(f+len, ".so") == 0) {
return Qtrue;
}
if (strcmp(ext, ".rb") == 0) {
if (strcmp(f+len, ".rb") == 0) {
if (wait) goto load_wait;
return Qtrue;
}
@ -5345,6 +5351,7 @@ rb_mod_modfunc(argc, argv, module)
}
rb_add_method(rb_singleton_class(module), id, body->nd_body, NOEX_PUBLIC);
rb_funcall(module, singleton_added, 1, ID2SYM(id));
rb_clear_cache_by_id(id);
}
return module;
}

7
gc.c
Просмотреть файл

@ -41,9 +41,9 @@ static void run_final();
#ifndef GC_MALLOC_LIMIT
#if defined(MSDOS) || defined(__human68k__)
#define GC_MALLOC_LIMIT 100000
#define GC_MALLOC_LIMIT 200000
#else
#define GC_MALLOC_LIMIT 4000000
#define GC_MALLOC_LIMIT 8000000
#endif
#endif
@ -70,6 +70,7 @@ ruby_xmalloc(size)
}
if (size == 0) size = 1;
malloc_memories += size;
if (malloc_memories > GC_MALLOC_LIMIT) {
rb_gc();
}
@ -118,7 +119,7 @@ ruby_xrealloc(ptr, size)
rb_gc();
mem = realloc(ptr, size);
if (!mem)
if (size >= 10 * 1024 * 1024) {
if (size >= 50 * 1024 * 1024) {
rb_raise(rb_eNoMemError, "tryed to re-allocate too big memory");
}
mem_error("failed to allocate memory(realloc)");

Просмотреть файл

@ -5,7 +5,9 @@ class String
printf STDERR, "feel free for some warnings:\n" if $VERBOSE
def _regex_quote(str)
a = str.gsub(/\W/){|s| if s == "-" then s else "\\\\#{s}" end}
str.gsub(/\W/){|s|
if s == "-" then s elsif s == "\\" then "\\\\" else "\\\\#{s}" end
}
end
private :_regex_quote

33
regex.c
Просмотреть файл

@ -62,6 +62,8 @@
#endif
#ifdef RUBY_PLATFORM
#include "defines.h"
# define RUBY
extern int rb_prohibit_interrupt;
extern int rb_trap_pending;
@ -128,11 +130,25 @@ char *alloca();
#define FREE_VARIABLES()
#define FREE_AND_RETURN_VOID(stackb) do { xfree(stackb); return; } while(0)
#define FREE_AND_RETURN(stackb,val) do { xfree(stackb); return(val); } while(0)
#define FREE_AND_RETURN_VOID(stackb) do { \
if (stackb != stacka) xfree(stackb); \
return; \
} while(0)
#define FREE_AND_RETURN(stackb,val) do { \
if (stackb != stacka) xfree(stackb); \
return(val); \
} while(0)
#define DOUBLE_STACK(stackx,stackb,len,type) do { \
stackx = (type*)xrealloc(stackb, 2 * len * sizeof(type)); \
if (stackb == stacka) { \
stackx = (type*)xmalloc(2*len*sizeof(type)); \
} \
else { \
stackx = (type*)xrealloc(stackb, 2 * len * sizeof(type)); \
} \
} while (0)
#endif /* NO_ALLOCA */
#define RE_TALLOC(n,t) ((t*)RE_ALLOCATE((n)*sizeof(t)))
@ -1245,7 +1261,8 @@ re_compile_pattern(pattern, size, bufp)
Fourth, the value of regnum.
Fifth, the type of the paren. */
int *stackb = RE_TALLOC(40, int);
int stacka[40];
int *stackb = stacka;
int *stackp = stackb;
int *stacke = stackb + 40;
int *stackt;
@ -2752,7 +2769,9 @@ re_compile_fastmap(bufp)
register int j, k;
unsigned is_a_succeed_n;
unsigned char **stackb = RE_TALLOC(NFAILURES, unsigned char*);
unsigned char *stacka[NFAILURES];
unsigned char **stackb = stacka;
unsigned char **stackp = stackb;
unsigned char **stacke = stackb + NFAILURES;
int options = bufp->options;
@ -3545,11 +3564,11 @@ re_match(bufp, string_arg, size, pos, regs)
``dummy''; if a failure happens and the failure point is a dummy, it
gets discarded and the next next one is tried. */
unsigned char *stacka[MAX_NUM_FAILURE_ITEMS * NFAILURES];
unsigned char **stackb;
unsigned char **stackp;
unsigned char **stacke;
/* Information on the contents of registers. These are pointers into
the input strings; they record just what was matched (on this
attempt) by a subexpression part of the pattern, that is, the
@ -3594,7 +3613,7 @@ re_match(bufp, string_arg, size, pos, regs)
}
/* Initialize the stack. */
stackb = RE_TALLOC(MAX_NUM_FAILURE_ITEMS * NFAILURES, unsigned char*);
stackb = stacka;
stackp = stackb;
stacke = &stackb[MAX_NUM_FAILURE_ITEMS * NFAILURES];