diff options
| author | Yukihiro Matsumoto <[email protected]> | 2012-05-30 16:01:48 +0900 |
|---|---|---|
| committer | Yukihiro Matsumoto <[email protected]> | 2012-05-30 16:01:48 +0900 |
| commit | e5d1dd2a8eebf4500bcbf319e264a08b99c788d7 (patch) | |
| tree | 3a60e89504a5a34865995b6c23e8d10d40f489a1 | |
| parent | b662a12ee5cda85209c1c9d64cd78fee425ef413 (diff) | |
| download | mruby-e5d1dd2a8eebf4500bcbf319e264a08b99c788d7.tar.gz mruby-e5d1dd2a8eebf4500bcbf319e264a08b99c788d7.zip | |
MRB_GC_STRESS for GC test
| -rw-r--r-- | src/gc.c | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -247,6 +247,9 @@ mrb_obj_alloc(mrb_state *mrb, enum mrb_vtype ttype, struct RClass *cls) { struct RBasic *p; +#ifdef MRB_GC_STRESS + mrb_garbage_collect(mrb); +#endif if (mrb->gc_threshold < mrb->live) { mrb_incremental_gc(mrb); } @@ -277,6 +280,11 @@ mrb_obj_alloc(mrb_state *mrb, enum mrb_vtype ttype, struct RClass *cls) static inline void add_gray_list(mrb_state *mrb, struct RBasic *obj) { +#ifdef MRB_GC_STRESS + if (obj->tt > MRB_TT_MAXDEFINE) { + abort(); + } +#endif paint_gray(obj); obj->gcnext = mrb->gray_list; mrb->gray_list = obj; @@ -501,13 +509,16 @@ root_scan_phase(mrb_state *mrb) if (!ci) continue; mrb_gc_mark(mrb, (struct RBasic*)ci->env); mrb_gc_mark(mrb, (struct RBasic*)ci->proc); + mrb_gc_mark(mrb, (struct RBasic*)ci->target_class); } /* mark irep pool */ for (i=0; i<mrb->irep_len; i++) { - mrb_irep *irep = mrb->irep[i]; - if (!irep) continue; - for (j=0; j<irep->plen; j++) { - mrb_gc_mark_value(mrb, irep->pool[j]); + if (mrb->irep) { + mrb_irep *irep = mrb->irep[i]; + if (!irep) continue; + for (j=0; j<irep->plen; j++) { + mrb_gc_mark_value(mrb, irep->pool[j]); + } } } } |
