From ebd3d34ff0e05cce8d5a815a88ccceac490b5679 Mon Sep 17 00:00:00 2001 From: akr Date: Tue, 27 Dec 2005 16:35:57 +0000 Subject: * eval.c (struct thread): add bstr_max. (rb_thread_save_context): use realloc instead of REALLOC_N to avoid GC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ eval.c | 17 +++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4653aa715a..1540421789 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Dec 28 01:32:39 2005 Tanaka Akira + + * eval.c (struct thread): add bstr_max. + (rb_thread_save_context): use realloc instead of REALLOC_N + to avoid GC. + Tue Dec 27 23:59:53 2005 Nobuyoshi Nakada * lib/optparse.rb (CompletingHash#match): fix for 1.9. diff --git a/eval.c b/eval.c index 24f5663dec..ce3ace616c 100644 --- a/eval.c +++ b/eval.c @@ -9697,9 +9697,10 @@ struct thread { VALUE *stk_ptr; VALUE *stk_pos; #ifdef IA64 - VALUE *bstr_pos; - VALUE *bstr_ptr; long bstr_len; + long bstr_max; + VALUE *bstr_ptr; + VALUE *bstr_pos; #endif struct FRAME *frame; @@ -10074,8 +10075,15 @@ rb_thread_save_context(rb_thread_t th) MEMCPY(th->stk_ptr, th->stk_pos, VALUE, th->stk_len); #ifdef IA64 th->bstr_pos = rb_gc_register_stack_start; - th->bstr_len = (VALUE*)rb_ia64_bsp() - th->bstr_pos; - REALLOC_N(th->bstr_ptr, VALUE, th->bstr_len); + len = (VALUE*)rb_ia64_bsp() - th->bstr_pos; + th->bstr_len = 0; + if (len > th->bstr_max) { + VALUE *ptr = realloc(th->bstr_ptr, sizeof(VALUE) * len); + if (!ptr) rb_memerror(); + th->bstr_ptr = ptr; + th->bstr_max = len; + } + th->bstr_len = len; MEMCPY(th->bstr_ptr, th->bstr_pos, VALUE, th->bstr_len); #endif #ifdef SAVE_WIN32_EXCEPTION_LIST @@ -11476,6 +11484,7 @@ rb_thread_group(VALUE thread) th->wait_for = 0;\ IA64_INIT(th->bstr_ptr = 0);\ IA64_INIT(th->bstr_len = 0);\ + IA64_INIT(th->bstr_max = 0);\ rb_fd_init(&th->readfds);\ rb_fd_init(&th->writefds);\ rb_fd_init(&th->exceptfds);\ -- cgit v1.2.3