[#27919] 1.8.4 Preview2 検証 — "URABE Shyouhei aka. mput" <root@...>
卜部です。
まつもと ゆきひろです
[#27944] Ruby 1.8.3 on FreeBSD — Masayoshi Takahashi <maki@...>
高橋征義です。
[#27991] GC.always — Tanaka Akira <akr@...17n.org>
というように、GC を常に動かすというのは GC 関連の問題を発見
まつもと ゆきひろです
In article <1134314081.457781.8573.nullmailer@x31.priv.netlab.jp>,
[#27997] 1.8.4 documents? — "URABE Shyouhei aka. mput" <root@...>
卜部です。
新井です。
新井です。
[#28010] IA64 BSPSTORE — Tanaka Akira <akr@...17n.org>
そういえば、IA64 で gc.c や eval.c に BSPSTORE レジスタの値
まつもと ゆきひろです
In article <1134478762.181062.2779.nullmailer@x31.priv.netlab.jp>,
[#28045] 1.8.4 what remains? — "URABE Shyouhei aka. mput" <root@...>
卜部です。
[#28082] ruby_1_8 Segmentation fault on Cygwin — yanagi@...
柳田です。
山本です。
こんにちは、なかむら(う)です。
山本です。
こんにちは、なかむら(う)です。
柳田です。
山本です。
[#28087] test(?-, file1, file2) — Tanaka Akira <akr@...17n.org>
マニュアルの test(?-, file1, file2) の説明に、
[#28109] Kernel#fail — "URABE Shyouhei aka. mput" <root@...>
さすがにもう誰も使ってないのではないかと思います。Kernel#failは廃止にし
[#28121] post_connection_check with javacc.dev.java.net — Tanaka Akira <akr@...17n.org>
ふと、https://javacc.dev.java.net/ を open-uri でアクセスすると、
[#28127] Intel C++ Compiler and HP aC++/ANSI C on IA64 — Tanaka Akira <akr@...17n.org>
TestDrive で IA64 上の Intel C++ Compiler and HP aC++/ANSI C
渡辺哲也です。
[#28140] ia64-hpux11.23/socket.sl: this executable file can't load extension libraries (LoadError) — Tanaka Akira <akr@...17n.org>
HP-UX で HP aC++/ANSI C を使って作った ruby で、openssl や drb のテストをすると、
渡辺哲也です。
In article <200512280307.jBS37nnj005909@pbsg500.nifty.com>,
In message "[ruby-dev:28142] Re: ia64-hpux11.23/socket.sl: this executable file can't load extension libraries (LoadError)"
山本です。
In article <20051228210640.13C71A10.ocean@m2.ccsnet.ne.jp>,
渡辺哲也です。
山本です。
山本です。
In article <20051229114438.44D19F00.ocean@m2.ccsnet.ne.jp>,
なかだです。
In article <ypvtr77wv7q9.wl%nobuyoshi.nakada@ge.com>,
なかだです。
In article <ypvtoe30v1zk.wl%nobuyoshi.nakada@ge.com>,
なかだです。
In article <ypvtmzikv11x.wl%nobuyoshi.nakada@ge.com>,
なかだです。
In article <ypvtwthol15x.wl%nobuyoshi.nakada@ge.com>,
[#28177] Generator dumps core — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>
山本です。
[#28178] accessing ruby_cbase (nil) dumps core — SASADA Koichi <ko1@...>
ささだです。
[#28181] zsuper (with define_method) dumps core — SASADA Koichi <ko1@...>
ささだです。
[#28182] generator.rb deadlocks — Tanaka Akira <akr@...17n.org>
RUBY_ALWAYS_GC= つきで test_generator.rb を動かすと deadlock が起きます。
[#28184] test_each(TC_SyncEnumerator) fails. — Tanaka Akira <akr@...17n.org>
deadlock は解決しましたが次のようにテストが失敗します。
[ruby-dev:27991] GC.always
というように、GC を常に動かすというのは GC 関連の問題を発見
するのに有効なわけですが、パッチを当ててコンパイルし直すのは
面倒臭いので、GC.always というメソッドを加えたいのですが、ど
うでしょう?
GC 関連の問題は対象プラットフォームやコンパイラのバージョン・
最適化などで問題の起こりかたが変わるため、たとえ今 i386 で
-O2 なケースについて発見できたものを修正したとしても、全部修
正できるとはかぎりません。というわけで、問題が発見された時に
簡単に絞りこめるように、GC を常に動かすという挙動を簡単に選
べるといいと思うんですが。
あと名前については、disable, enable が他動詞なのに対して、
always がそうでないのが気になるのですが、なんか他にいい名前
を思いつく人はいませんか?
Index: gc.c
===================================================================
RCS file: /src/ruby/gc.c,v
retrieving revision 1.217
diff -u -p -r1.217 gc.c
--- gc.c 6 Dec 2005 07:52:17 -0000 1.217
+++ gc.c 11 Dec 2005 14:42:20 -0000
@@ -93,6 +93,12 @@ static void run_final(VALUE obj);
static VALUE nomem_error;
static int garbage_collect(void);
+static enum {
+ gc_disable = 0,
+ gc_enable = 1,
+ gc_always = 2
+} do_gc = gc_enable;
+
void
rb_memerror(void)
{
@@ -117,7 +123,7 @@ ruby_xmalloc(size_t size)
if (size == 0) size = 1;
malloc_increase += size;
- if (malloc_increase > malloc_limit) {
+ if (do_gc == gc_always || malloc_increase > malloc_limit) {
garbage_collect();
}
RUBY_CRITICAL(mem = malloc(size));
@@ -165,6 +171,7 @@ ruby_xrealloc(void *ptr, size_t size)
if (!ptr) return ruby_xmalloc(size);
if (size == 0) size = 1;
malloc_increase += size;
+ if (do_gc == gc_always) garbage_collect();
RUBY_CRITICAL(mem = realloc(ptr, size));
if (!mem) {
if (garbage_collect()) {
@@ -195,18 +202,30 @@ ruby_xfree(void *x)
RUBY_CRITICAL(free(x));
}
-static int dont_gc;
static int during_gc;
static int need_call_final = 0;
static st_table *finalizer_table = 0;
+static VALUE
+gc_status(void)
+{
+ switch (do_gc) {
+ case gc_disable: return Qtrue;
+ case gc_enable: return Qfalse;
+ case gc_always: return ID2SYM(rb_intern("always"));
+ }
+}
/*
* call-seq:
- * GC.enable => true or false
+ * GC.enable => true, false or :always
*
- * Enables garbage collection, returning <code>true</code> if garbage
- * collection was previously disabled.
+ * Enables garbage collection.
+ * It returns previous GC status:
+ *
+ * disable:: true
+ * enable:: false
+ * always:: :always
*
* GC.disable #=> false
* GC.enable #=> true
@@ -217,18 +236,22 @@ static st_table *finalizer_table = 0;
VALUE
rb_gc_enable(void)
{
- int old = dont_gc;
+ VALUE old = gc_status();
- dont_gc = Qfalse;
+ do_gc = gc_enable;
return old;
}
/*
* call-seq:
- * GC.disable => true or false
+ * GC.disable => true, false or :always
+ *
+ * Disables garbage collection.
+ * It returns previous GC status:
*
- * Disables garbage collection, returning <code>true</code> if garbage
- * collection was already disabled.
+ * disable:: true
+ * enable:: false
+ * always:: :always
*
* GC.disable #=> false
* GC.disable #=> true
@@ -238,9 +261,36 @@ rb_gc_enable(void)
VALUE
rb_gc_disable(void)
{
- int old = dont_gc;
+ VALUE old = gc_status();
+
+ do_gc = gc_disable;
+ return old;
+}
+
+/*
+ * call-seq:
+ * GC.always => true, false or :always
+ *
+ * Enables garbage collection.
+ * GC will be always activated whenever possible.
+ * It returns previous GC status:
+ *
+ * disable:: true
+ * enable:: false
+ * always:: :always
+ *
+ * GC.disable #=> false
+ * GC.always #=> true
+ * GC.always #=> :always
+ *
+ */
+
+VALUE
+rb_gc_always(void)
+{
+ VALUE old = gc_status();
- dont_gc = Qtrue;
+ do_gc = gc_always;
return old;
}
@@ -394,7 +444,7 @@ rb_newobj(void)
{
VALUE obj;
- if (!freelist && !garbage_collect())
+ if ((do_gc == gc_always || !freelist) && !garbage_collect())
rb_memerror();
obj = (VALUE)freelist;
@@ -1277,7 +1327,7 @@ garbage_collect(void)
rb_bug("cross-thread violation on rb_gc()");
}
#endif
- if (dont_gc || during_gc) {
+ if (do_gc == gc_disable || during_gc) {
if (!freelist) {
add_heap();
}
@@ -1879,6 +1929,7 @@ Init_GC(void)
rb_define_singleton_method(rb_mGC, "start", rb_gc_start, 0);
rb_define_singleton_method(rb_mGC, "enable", rb_gc_enable, 0);
rb_define_singleton_method(rb_mGC, "disable", rb_gc_disable, 0);
+ rb_define_singleton_method(rb_mGC, "always", rb_gc_always, 0);
rb_define_method(rb_mGC, "garbage_collect", rb_gc_start, 0);
rb_mObSpace = rb_define_module("ObjectSpace");
--
[田中 哲][たなか あきら][Tanaka Akira]