ruby-changes:17565
From: yugui <ko1@a...>
Date: Sat, 23 Oct 2010 21:55:16 +0900 (JST)
Subject: [ruby-changes:17565] Ruby:r29570 (ruby_1_9_2): merges r28986 from trunk into ruby_1_9_2. fixes
yugui 2010-10-23 21:50:53 +0900 (Sat, 23 Oct 2010) New Revision: 29570 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29570 Log: merges r28986 from trunk into ruby_1_9_2. fixes [ruby-core:32667] -- * test/objspace/test_objspace.rb: added test for objspace. * ext/objspace/objspace.c: considers T_ZOMBIE by lazy sweep GC. * gc.c: considers that dsize was 0. [ruby-dev:42022] Added directories: branches/ruby_1_9_2/test/objspace/ Added files: branches/ruby_1_9_2/test/objspace/test_objspace.rb Modified files: branches/ruby_1_9_2/ChangeLog branches/ruby_1_9_2/ext/objspace/objspace.c branches/ruby_1_9_2/gc.c branches/ruby_1_9_2/version.h Index: ruby_1_9_2/ChangeLog =================================================================== --- ruby_1_9_2/ChangeLog (revision 29569) +++ ruby_1_9_2/ChangeLog (revision 29570) @@ -1,3 +1,11 @@ +Sat Aug 14 17:48:41 2010 Narihiro Nakamura <authorNari@g...> + + * test/objspace/test_objspace.rb: added test for objspace. + + * ext/objspace/objspace.c: considers T_ZOMBIE by lazy sweep GC. + + * gc.c: considers that dsize was 0. [ruby-dev:42022] + Tue Aug 31 03:42:14 2010 NARUSE, Yui <naruse@r...> * string.c (tr_setup_table): fix bug in r29146. Index: ruby_1_9_2/gc.c =================================================================== --- ruby_1_9_2/gc.c (revision 29569) +++ ruby_1_9_2/gc.c (revision 29570) @@ -1145,7 +1145,7 @@ size_t rb_objspace_data_type_memsize(VALUE obj) { - if (RTYPEDDATA_P(obj)) { + if (RTYPEDDATA_P(obj) && RTYPEDDATA_TYPE(obj)->dsize) { return RTYPEDDATA_TYPE(obj)->dsize(RTYPEDDATA_DATA(obj)); } else { Index: ruby_1_9_2/ext/objspace/objspace.c =================================================================== --- ruby_1_9_2/ext/objspace/objspace.c (revision 29569) +++ ruby_1_9_2/ext/objspace/objspace.c (revision 29570) @@ -141,6 +141,9 @@ } break; + case T_ZOMBIE: + break; + default: rb_bug("objspace/memsize_of(): unknown data type 0x%x(%p)", BUILTIN_TYPE(obj), (void*)obj); Index: ruby_1_9_2/version.h =================================================================== --- ruby_1_9_2/version.h (revision 29569) +++ ruby_1_9_2/version.h (revision 29570) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.2" -#define RUBY_PATCHLEVEL 23 +#define RUBY_PATCHLEVEL 24 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 Index: ruby_1_9_2/test/objspace/test_objspace.rb =================================================================== --- ruby_1_9_2/test/objspace/test_objspace.rb (revision 0) +++ ruby_1_9_2/test/objspace/test_objspace.rb (revision 29570) @@ -0,0 +1,44 @@ +require "test/unit" +require "objspace" + +class TestObjSpace < Test::Unit::TestCase + def test_memsize_of + assert_equal(0, ObjectSpace.memsize_of(true)) + assert_kind_of(Integer, ObjectSpace.memsize_of(Object.new)) + assert_kind_of(Integer, ObjectSpace.memsize_of(Class)) + assert_kind_of(Integer, ObjectSpace.memsize_of("")) + assert_kind_of(Integer, ObjectSpace.memsize_of([])) + assert_kind_of(Integer, ObjectSpace.memsize_of({})) + assert_kind_of(Integer, ObjectSpace.memsize_of(//)) + f = File.new(__FILE__) + assert_kind_of(Integer, ObjectSpace.memsize_of(f)) + f.close + assert_kind_of(Integer, ObjectSpace.memsize_of(/a/.match("a"))) + assert_kind_of(Integer, ObjectSpace.memsize_of(Struct.new(:a))) + end + + def test_count_objects_size + res = ObjectSpace.count_objects_size + assert_equal(false, res.empty?) + assert_equal(true, res[:TOTAL] > 0) + arg = {} + ObjectSpace.count_objects_size(arg) + assert_equal(false, arg.empty?) + end + + def test_count_nodes + res = ObjectSpace.count_nodes + assert_equal(false, res.empty?) + arg = {} + ObjectSpace.count_nodes(arg) + assert_equal(false, arg.empty?) + end + + def test_count_tdata_objects + res = ObjectSpace.count_tdata_objects + assert_equal(false, res.empty?) + arg = {} + ObjectSpace.count_tdata_objects(arg) + assert_equal(false, arg.empty?) + end +end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/