Skip to content

Commit 1454c98

Browse files
committed
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@mb.i-chubu.ne.jp> in [ruby-dev:33776]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@17140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 465eec7 commit 1454c98

File tree

4 files changed

+32
-24
lines changed

4 files changed

+32
-24
lines changed

ChangeLog

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
Fri Jun 13 13:14:31 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
2+
3+
* ext/dl/ptr.c (dlmem_each_i): typo fixed. a patch from IKOMA
4+
Yoshiki <ikoma@mb.i-chubu.ne.jp> in [ruby-dev:33776].
5+
6+
Fri Jun 13 13:13:23 2008 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
7+
8+
* gc.c (rb_newobj): prohibit call of rb_newobj() during gc.
9+
Submitted by Sylvain Joyeux [ruby-core:12099].
10+
11+
* ext/dl/ptr.c: do not use LONG2NUM() inside dlptr_free().
12+
Slightly modified fix bassed on a patch by Sylvain Joyeux
13+
[ruby-core:12099] [ ruby-bugs-11859 ] [ ruby-bugs-11882 ]
14+
[ ruby-patches-13151 ].
15+
116
Fri Jun 13 12:10:13 2008 NARUSE, Yui <naruse@ruby-lang.org>
217

318
* lib/benchmark.rb (Job::Benchmark#item): fix typo.

ext/dl/ptr.c

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,22 @@
44

55
#include <ruby.h>
66
#include <ctype.h>
7-
#include <version.h> /* for ruby version code */
7+
#include "st.h"
88
#include "dl.h"
99

1010
VALUE rb_cDLPtrData;
1111
VALUE rb_mDLMemorySpace;
12-
static VALUE DLMemoryTable;
12+
static st_table* st_memory_table;
1313

1414
#ifndef T_SYMBOL
1515
# define T_SYMBOL T_FIXNUM
1616
#endif
1717

18-
#if RUBY_VERSION_CODE < 171
19-
static VALUE
20-
rb_hash_delete(VALUE hash, VALUE key)
21-
{
22-
return rb_funcall(hash, rb_intern("delete"), 1, key);
23-
}
24-
#endif
25-
2618
static void
2719
rb_dlmem_delete(void *ptr)
2820
{
2921
rb_secure(4);
30-
rb_hash_delete(DLMemoryTable, DLLONG2NUM(ptr));
22+
st_delete(st_memory_table, (st_data_t*)&ptr, NULL);
3123
}
3224

3325
static void
@@ -37,7 +29,7 @@ rb_dlmem_aset(void *ptr, VALUE obj)
3729
rb_dlmem_delete(ptr);
3830
}
3931
else{
40-
rb_hash_aset(DLMemoryTable, DLLONG2NUM(ptr), DLLONG2NUM(obj));
32+
st_insert(st_memory_table, (st_data_t)ptr, (st_data_t)obj);
4133
}
4234
}
4335

@@ -46,8 +38,8 @@ rb_dlmem_aref(void *ptr)
4638
{
4739
VALUE val;
4840

49-
val = rb_hash_aref(DLMemoryTable, DLLONG2NUM(ptr));
50-
return val == Qnil ? Qnil : (VALUE)DLNUM2LONG(val);
41+
if(!st_lookup(st_memory_table, (st_data_t)ptr, &val)) return Qnil;
42+
return val == Qundef ? Qnil : val;
5143
}
5244

5345
void
@@ -1010,20 +1002,18 @@ rb_dlptr_size(int argc, VALUE argv[], VALUE self)
10101002
}
10111003
}
10121004

1013-
static VALUE
1014-
dlmem_each_i(VALUE assoc, void *data)
1005+
static int
1006+
dlmem_each_i(void* key, VALUE value, void* arg)
10151007
{
1016-
VALUE key, val;
1017-
key = rb_ary_entry(assoc, 0);
1018-
val = rb_ary_entry(assoc, 1);
1019-
rb_yield(rb_assoc_new(key,(VALUE)DLNUM2LONG(val)));
1008+
VALUE vkey = DLLONG2NUM(key);
1009+
rb_yield(rb_assoc_new(vkey, value));
10201010
return Qnil;
10211011
}
10221012

10231013
VALUE
10241014
rb_dlmem_each(VALUE self)
10251015
{
1026-
rb_iterate(rb_each, DLMemoryTable, dlmem_each_i, 0);
1016+
st_foreach(st_memory_table, dlmem_each_i, 0);
10271017
return Qnil;
10281018
}
10291019

@@ -1062,7 +1052,7 @@ Init_dlptr()
10621052
rb_define_method(rb_cDLPtrData, "size=", rb_dlptr_size, -1);
10631053

10641054
rb_mDLMemorySpace = rb_define_module_under(rb_mDL, "MemorySpace");
1065-
DLMemoryTable = rb_hash_new();
1066-
rb_define_const(rb_mDLMemorySpace, "MemoryTable", DLMemoryTable);
1055+
st_memory_table = st_init_numtable();
1056+
rb_define_const(rb_mDLMemorySpace, "MemoryTable", Qnil); /* historical */
10671057
rb_define_module_function(rb_mDLMemorySpace, "each", rb_dlmem_each, 0);
10681058
}

gc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,9 @@ rb_newobj()
378378
{
379379
VALUE obj;
380380

381+
if (during_gc)
382+
rb_bug("object allocation during garbage collection phase");
383+
381384
if (!freelist) garbage_collect();
382385

383386
obj = (VALUE)freelist;

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define RUBY_RELEASE_DATE "2008-06-13"
33
#define RUBY_VERSION_CODE 186
44
#define RUBY_RELEASE_CODE 20080613
5-
#define RUBY_PATCHLEVEL 174
5+
#define RUBY_PATCHLEVEL 175
66

77
#define RUBY_VERSION_MAJOR 1
88
#define RUBY_VERSION_MINOR 8

0 commit comments

Comments
 (0)