[前][次][番号順一覧][スレッド一覧]

ruby-changes:5632

From: shyouhei <ko1@a...>
Date: Fri, 13 Jun 2008 13:12:53 +0900 (JST)
Subject: [ruby-changes:5632] Ruby:r17138 (ruby_1_8_5): merge revision(s) 15429, 15471:

shyouhei	2008-06-13 13:12:35 +0900 (Fri, 13 Jun 2008)

  New Revision: 17138

  Modified files:
    branches/ruby_1_8_5/ChangeLog
    branches/ruby_1_8_5/ext/dl/ptr.c
    branches/ruby_1_8_5/gc.c
    branches/ruby_1_8_5/version.h

  Log:
    merge revision(s) 15429, 15471:
    * gc.c (rb_newobj): prohibit call of rb_newobj() during gc.
      Submitted by Sylvain Joyeux [ruby-core:12099].
    * ext/dl/ptr.c: do not use LONG2NUM() inside dlptr_free().
      Slightly modified fix bassed on a patch by Sylvain Joyeux
      [ruby-core:12099] [ ruby-bugs-11859 ] [ ruby-bugs-11882 ]
      [ ruby-patches-13151 ].
    * ext/dl/ptr.c (dlmem_each_i): typo fixed.  a patch from IKOMA
      Yoshiki <ikoma@m...> in [ruby-dev:33776].


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_5/ext/dl/ptr.c?r1=17138&r2=17137&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_5/version.h?r1=17138&r2=17137&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_5/ChangeLog?r1=17138&r2=17137&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_5/gc.c?r1=17138&r2=17137&diff_format=u

Index: ruby_1_8_5/ext/dl/ptr.c
===================================================================
--- ruby_1_8_5/ext/dl/ptr.c	(revision 17137)
+++ ruby_1_8_5/ext/dl/ptr.c	(revision 17138)
@@ -4,30 +4,22 @@
 
 #include <ruby.h>
 #include <ctype.h>
-#include <version.h> /* for ruby version code */
+#include "st.h"
 #include "dl.h"
 
 VALUE rb_cDLPtrData;
 VALUE rb_mDLMemorySpace;
-static VALUE DLMemoryTable;
+static st_table* st_memory_table;
 
 #ifndef T_SYMBOL
 # define T_SYMBOL T_FIXNUM
 #endif
 
-#if RUBY_VERSION_CODE < 171
-static VALUE
-rb_hash_delete(VALUE hash, VALUE key)
-{
-  return rb_funcall(hash, rb_intern("delete"), 1, key);
-}
-#endif
-
 static void
 rb_dlmem_delete(void *ptr)
 {
   rb_secure(4);
-  rb_hash_delete(DLMemoryTable, DLLONG2NUM(ptr));
+  st_delete(st_memory_table, (st_data_t*)&ptr, NULL);
 }
 
 static void
@@ -37,7 +29,7 @@
     rb_dlmem_delete(ptr);
   }
   else{
-    rb_hash_aset(DLMemoryTable, DLLONG2NUM(ptr), DLLONG2NUM(obj));
+    st_insert(st_memory_table, (st_data_t)ptr, (st_data_t)obj);
   }
 }
 
@@ -46,8 +38,8 @@
 {
   VALUE val;
 
-  val = rb_hash_aref(DLMemoryTable, DLLONG2NUM(ptr));
-  return val == Qnil ? Qnil : (VALUE)DLNUM2LONG(val);
+  if(!st_lookup(st_memory_table, (st_data_t)ptr, &val)) return Qnil;
+  return val == Qundef ? Qnil : val;
 }
 
 void
@@ -1010,20 +1002,18 @@
   }
 }
 
-static VALUE
-dlmem_each_i(VALUE assoc, void *data)
+static int
+dlmem_each_i(void* key, VALUE value, void* arg)
 {
-  VALUE key, val;
-  key = rb_ary_entry(assoc, 0);
-  val = rb_ary_entry(assoc, 1);
-  rb_yield(rb_assoc_new(key,(VALUE)DLNUM2LONG(val)));
+  VALUE vkey = DLLONG2NUM(key);
+  rb_yield(rb_assoc_new(vkey, value));
   return Qnil;
 }
 
 VALUE
 rb_dlmem_each(VALUE self)
 {
-  rb_iterate(rb_each, DLMemoryTable, dlmem_each_i, 0);
+  st_foreach(st_memory_table, dlmem_each_i, 0);
   return Qnil;
 }
 
@@ -1062,7 +1052,7 @@
   rb_define_method(rb_cDLPtrData, "size=", rb_dlptr_size, -1);
 
   rb_mDLMemorySpace = rb_define_module_under(rb_mDL, "MemorySpace");
-  DLMemoryTable = rb_hash_new();
-  rb_define_const(rb_mDLMemorySpace, "MemoryTable", DLMemoryTable);
+  st_memory_table = st_init_numtable();
+  rb_define_const(rb_mDLMemorySpace, "MemoryTable", Qnil); /* historical */
   rb_define_module_function(rb_mDLMemorySpace, "each", rb_dlmem_each, 0);
 }
Index: ruby_1_8_5/ChangeLog
===================================================================
--- ruby_1_8_5/ChangeLog	(revision 17137)
+++ ruby_1_8_5/ChangeLog	(revision 17138)
@@ -1,3 +1,18 @@
+Fri Jun 13 13:10:12 2008  Yukihiro Matsumoto  <matz@r...>
+
+	* ext/dl/ptr.c (dlmem_each_i): typo fixed.  a patch from IKOMA
+	  Yoshiki <ikoma@m...> in [ruby-dev:33776].
+
+Fri Jun 13 12:10:58 2008  URABE Shyouhei  <shyouhei@i...>
+
+	* gc.c (rb_newobj): prohibit call of rb_newobj() during gc.
+	  Submitted by Sylvain Joyeux [ruby-core:12099].
+
+	* ext/dl/ptr.c: do not use LONG2NUM() inside dlptr_free().
+	  Slightly modified fix bassed on a patch by Sylvain Joyeux
+	  [ruby-core:12099] [ ruby-bugs-11859 ] [ ruby-bugs-11882 ]
+	  [ ruby-patches-13151 ].
+
 Fri Jun 13 12:09:02 2008  NARUSE, Yui  <naruse@r...>
 
 	* lib/benchmark.rb (Job::Benchmark#item): fix typo.
Index: ruby_1_8_5/version.h
===================================================================
--- ruby_1_8_5/version.h	(revision 17137)
+++ ruby_1_8_5/version.h	(revision 17138)
@@ -2,7 +2,7 @@
 #define RUBY_RELEASE_DATE "2008-06-13"
 #define RUBY_VERSION_CODE 185
 #define RUBY_RELEASE_CODE 20080613
-#define RUBY_PATCHLEVEL 173
+#define RUBY_PATCHLEVEL 174
 
 #define RUBY_VERSION_MAJOR 1
 #define RUBY_VERSION_MINOR 8
Index: ruby_1_8_5/gc.c
===================================================================
--- ruby_1_8_5/gc.c	(revision 17137)
+++ ruby_1_8_5/gc.c	(revision 17138)
@@ -392,6 +392,9 @@
 {
     VALUE obj;
 
+    if (during_gc)
+	rb_bug("object allocation during garbage collection phase");
+
     if (!freelist) garbage_collect();
 
     obj = (VALUE)freelist;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]