Skip to content

Commit

Permalink
gc.c: define objspace functions always
Browse files Browse the repository at this point in the history
* gc.c (rb_objspace_alloc, rb_objspace_free): define always
  regardless ENABLE_VM_OBJSPACE, and free heap pages.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Sep 15, 2015
1 parent 70b2af3 commit abbd388
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
@@ -1,3 +1,8 @@
Tue Sep 15 19:38:55 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>

* gc.c (rb_objspace_alloc, rb_objspace_free): define always
regardless ENABLE_VM_OBJSPACE, and free heap pages.

Tue Sep 15 15:15:41 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>

* win32/win32.c (rb_w32_sysinit, rb_w32_readdir): compare by
Expand Down
11 changes: 7 additions & 4 deletions gc.c
Expand Up @@ -1256,11 +1256,14 @@ RVALUE_WHITE_P(VALUE obj)
--------------------------- ObjectSpace -----------------------------
*/

#if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
rb_objspace_t *
rb_objspace_alloc(void)
{
#if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
rb_objspace_t *objspace = calloc(1, sizeof(rb_objspace_t));
#else
rb_objspace_t *objspace = &rb_objspace;
#endif
malloc_limit = gc_params.malloc_limit_min;

return objspace;
Expand Down Expand Up @@ -1303,9 +1306,11 @@ rb_objspace_free(rb_objspace_t *objspace)
objspace->eden_heap.pages = NULL;
}
free_stack_chunks(&objspace->mark_stack);
#if !(defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE)
if (objspace == &rb_objspace) return;
#endif
free(objspace);
}
#endif

static void
heap_pages_expand_sorted(rb_objspace_t *objspace)
Expand Down Expand Up @@ -3662,7 +3667,6 @@ pop_mark_stack_chunk(mark_stack_t *stack)
stack->index = stack->limit;
}

#if (defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE) || (RGENGC_CHECK_MODE >= 4)
static void
free_stack_chunks(mark_stack_t *stack)
{
Expand All @@ -3675,7 +3679,6 @@ free_stack_chunks(mark_stack_t *stack)
chunk = next;
}
}
#endif

static void
push_mark_stack(mark_stack_t *stack, VALUE data)
Expand Down
6 changes: 0 additions & 6 deletions vm.c
Expand Up @@ -1861,9 +1861,7 @@ ruby_vm_destruct(rb_vm_t *vm)

if (vm) {
rb_thread_t *th = vm->main_thread;
#if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
struct rb_objspace *objspace = vm->objspace;
#endif
vm->main_thread = 0;
if (th) {
rb_fiber_reset_root_local_storage(th->self);
Expand All @@ -1872,11 +1870,9 @@ ruby_vm_destruct(rb_vm_t *vm)
rb_vm_living_threads_init(vm);
ruby_vm_run_at_exit_hooks(vm);
rb_vm_gvl_destroy(vm);
#if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
if (objspace) {
rb_objspace_free(objspace);
}
#endif
/* after freeing objspace, you *can't* use ruby_xfree() */
ruby_mimfree(vm);
ruby_current_vm = 0;
Expand Down Expand Up @@ -2800,9 +2796,7 @@ Init_BareVM(void)
rb_thread_set_current_raw(th);

vm_init2(vm);
#if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
vm->objspace = rb_objspace_alloc();
#endif
ruby_current_vm = vm;

Init_native_thread();
Expand Down

0 comments on commit abbd388

Please sign in to comment.