Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

gc: tiny fixes in BITMAP size and HEAP_OBJ_LIMIT #92

Closed
wants to merge 2 commits into from

3 participants

Sokolov Yura NARUSE, Yui Nobuyoshi Nakada
NARUSE, Yui
Collaborator

Could you make a ticket on Redmine and assign to Narihiro Nakamura?

Sokolov Yura

There is issue http://bugs.ruby-lang.org/issues/6006 . I forgot to assign it and set category.

Nobuyoshi Nakada nobu closed this
Sandor Szücs szuecs referenced this pull request from a commit in szuecs/ruby
Narihiro Nakamura authorNari * gc.c (HEAP_OBJ_LIMIT, HEAP_BITMAP_LIMIT): HEAP_OBJ_LIMIT used
  `sizeof(struct heaps_slot)` while heap is currently allocated
  with `struct heaps_header`.
  HEAP_BITMAP_LIMIT were calculated from
  `HEAP_OBJ_LIMIT/sizeof(uintptr_t)` - one Byte for each object,
  not one Bit. [Bug #6006]
  patched by Sokolov Yura. ruby#92

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
261400e
Sandor Szücs szuecs referenced this pull request from a commit in szuecs/ruby
Narihiro Nakamura authorNari * gc.c (assign_heap_slot): SEGV happens cause on 64-bit platform
  sometime there should be `objs-=2` instead of `objs--`.
  patched by Sokolov Yura. ruby#92

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
64e7aed
Aaron Patterson tenderlove referenced this pull request from a commit in tenderlove/ruby
Narihiro Nakamura authorNari * gc.c (HEAP_OBJ_LIMIT, HEAP_BITMAP_LIMIT): HEAP_OBJ_LIMIT used
  `sizeof(struct heaps_slot)` while heap is currently allocated
  with `struct heaps_header`.
  HEAP_BITMAP_LIMIT were calculated from
  `HEAP_OBJ_LIMIT/sizeof(uintptr_t)` - one Byte for each object,
  not one Bit. [Bug #6006]
  patched by Sokolov Yura. ruby#92

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
a862692
Aaron Patterson tenderlove referenced this pull request from a commit in tenderlove/ruby
Narihiro Nakamura authorNari * gc.c (assign_heap_slot): SEGV happens cause on 64-bit platform
  sometime there should be `objs-=2` instead of `objs--`.
  patched by Sokolov Yura. ruby#92

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
c6a541b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 14, 2012
  1. Sokolov Yura

    gc: fix 64-bit issue

    funny-falcon authored
  2. Sokolov Yura
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 9 deletions.
  1. +5 9 gc.c
14 gc.c
View
@@ -544,10 +544,11 @@ rb_objspace_free(rb_objspace_t *objspace)
#define HEAP_ALIGN_MASK (~(~0UL << HEAP_ALIGN_LOG))
#define REQUIRED_SIZE_BY_MALLOC (sizeof(size_t) * 5)
#define HEAP_SIZE (HEAP_ALIGN - REQUIRED_SIZE_BY_MALLOC)
-#define CEILMOD(i, mod) (((i) + (mod) - 1)/(mod))
+#define CEILDIV(i, mod) (((i) + (mod) - 1)/(mod))
+#define ROUNDUP(i, mod) (CEILDIV((i), (mod)) * (mod))
#define HEAP_OBJ_LIMIT (unsigned int)((HEAP_SIZE - sizeof(struct heaps_header))/sizeof(struct RVALUE))
-#define HEAP_BITMAP_LIMIT CEILMOD(HEAP_OBJ_LIMIT, sizeof(uintptr_t)*8)
+#define HEAP_BITMAP_LIMIT CEILDIV(HEAP_OBJ_LIMIT, sizeof(uintptr_t)*8)
#define GET_HEAP_HEADER(x) (HEAP_HEADER(((uintptr_t)x) & ~(HEAP_ALIGN_MASK)))
#define GET_HEAP_SLOT(x) (GET_HEAP_HEADER(x)->base)
@@ -1162,13 +1163,8 @@ assign_heap_slot(rb_objspace_t *objspace)
heaps = slot;
membase = p;
- p = (RVALUE*)((VALUE)p + sizeof(struct heaps_header));
- if ((VALUE)p % sizeof(RVALUE) != 0) {
- p = (RVALUE*)((VALUE)p + sizeof(RVALUE) - ((VALUE)p % sizeof(RVALUE)));
- if ((HEAP_SIZE - HEAP_OBJ_LIMIT * sizeof(RVALUE)) < (size_t)((char*)p - (char*)membase)) {
- objs--;
- }
- }
+ p = (RVALUE*)ROUNDUP((VALUE)p, sizeof(RVALUE));
+ objs = (HEAP_SIZE - (size_t)((char*)p - (char*)membase))/sizeof(RVALUE);
lo = 0;
hi = heaps_used;
Something went wrong with that request. Please try again.