summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-11-04 12:06:08 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-11-04 12:06:08 +0000
commit71603f3f011bd47993e3ae0db441916ec2533991 (patch)
tree93822268dc167297f48dbccbec49b31fcd615a20
parentbe4eee217c5630c62e16fb31ae729cf6754ad013 (diff)
* gc.c (rb_newobj): force garbage_collect() if GC.stress == true.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--gc.c34
2 files changed, 21 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index 4776e47af2..274db4c3b2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Thu Nov 4 20:04:44 2010 Koichi Sasada <ko1@atdot.net>
+
+ * gc.c (rb_newobj): force garbage_collect() if GC.stress == true.
+
Thu Nov 4 19:48:22 2010 Koichi Sasada <ko1@atdot.net>
* ChangeLog: missed to write a last ChangeLog.
diff --git a/gc.c b/gc.c
index 284c86fd01..a8e721707c 100644
--- a/gc.c
+++ b/gc.c
@@ -1042,12 +1042,26 @@ rb_during_gc(void)
#define RANY(o) ((RVALUE*)(o))
-static VALUE
-rb_newobj_from_heap(rb_objspace_t *objspace)
+VALUE
+rb_newobj(void)
{
+ rb_objspace_t *objspace = &rb_objspace;
VALUE obj;
- if ((ruby_gc_stress && !ruby_disable_gc_stress) || !freelist) {
+ if (UNLIKELY(during_gc)) {
+ dont_gc = 1;
+ during_gc = 0;
+ rb_bug("object allocation during garbage collection phase");
+ }
+
+ if (UNLIKELY(ruby_gc_stress) && UNLIKELY(!ruby_disable_gc_stress)) {
+ if (!garbage_collect(objspace)) {
+ during_gc = 0;
+ rb_memerror();
+ }
+ }
+
+ if (UNLIKELY(!freelist)) {
if (!gc_lazy_sweep(objspace)) {
during_gc = 0;
rb_memerror();
@@ -1067,20 +1081,6 @@ rb_newobj_from_heap(rb_objspace_t *objspace)
return obj;
}
-VALUE
-rb_newobj(void)
-{
- rb_objspace_t *objspace = &rb_objspace;
-
- if (during_gc) {
- dont_gc = 1;
- during_gc = 0;
- rb_bug("object allocation during garbage collection phase");
- }
-
- return rb_newobj_from_heap(objspace);
-}
-
NODE*
rb_node_newnode(enum node_type type, VALUE a0, VALUE a1, VALUE a2)
{