Skip to content

Commit

Permalink
matz
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Sep 25, 2000
1 parent ba2b829 commit 9448424
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 16 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
Tue Sep 26 02:44:54 2000 Yukihiro Matsumoto <[email protected]>

* 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 <[email protected]>

* regex.c: include <defines.h>.

* eval.c (rb_add_method): cache mismatch by method
definition. need to clear_cache_by_id every time.

Expand Down
17 changes: 12 additions & 5 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down Expand Up @@ -360,6 +359,7 @@ rb_disable_super(klass, name)
}
else {
rb_add_method(klass, mid, 0, NOEX_UNDEF);
rb_clear_cache_by_id(mid);
}
}

Expand Down Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 4 additions & 3 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -70,6 +70,7 @@ ruby_xmalloc(size)
}
if (size == 0) size = 1;
malloc_memories += size;

if (malloc_memories > GC_MALLOC_LIMIT) {
rb_gc();
}
Expand Down Expand Up @@ -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)");
Expand Down
4 changes: 3 additions & 1 deletion lib/jcode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
33 changes: 26 additions & 7 deletions regex.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
#endif

#ifdef RUBY_PLATFORM
#include "defines.h"

# define RUBY
extern int rb_prohibit_interrupt;
extern int rb_trap_pending;
Expand Down Expand Up @@ -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)))
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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];

Expand Down

0 comments on commit 9448424

Please sign in to comment.