Skip to content

Commit 50e2018

Browse files
authored
Merge pull request #74 from ruby/pz-sync-files
Sync files from ruby/ruby
2 parents 44f47db + 2ad917c commit 50e2018

3 files changed

Lines changed: 16 additions & 12 deletions

File tree

darray.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,12 @@ rb_darray_free(void *ary)
161161
xfree(ary);
162162
}
163163

164-
void ruby_sized_xfree(void *x, size_t size);
165-
166164
static inline void
167165
rb_darray_free_sized0(void *ary, size_t element_size)
168166
{
169167
const rb_darray_meta_t *meta = ary;
170168
if (meta) {
171-
ruby_sized_xfree(ary, sizeof(*meta) + (element_size * meta->capa));
169+
ruby_xfree_sized(ary, sizeof(*meta) + (element_size * meta->capa));
172170
}
173171
}
174172
#define rb_darray_free_sized(ary, T) rb_darray_free_sized0((ary), sizeof(T))
@@ -203,7 +201,7 @@ rb_darray_calloc_mul_add_without_gc(size_t x, size_t y, size_t z)
203201
return ptr;
204202
}
205203

206-
void *ruby_sized_xrealloc(void *ptr, size_t new_size, size_t old_size);
204+
void *ruby_xrealloc_sized(void *ptr, size_t new_size, size_t old_size);
207205

208206
/* Internal function. Like rb_xrealloc_mul_add. */
209207
static inline void *
@@ -212,7 +210,7 @@ rb_darray_realloc_mul_add(void *orig_ptr, size_t capa, size_t element_size, size
212210
size_t size = rbimpl_size_add_or_raise(rbimpl_size_mul_or_raise(capa, element_size), header_size);
213211
size_t old_size = (rb_darray_capa(orig_ptr) * element_size) + header_size; // We know it won't overflow
214212

215-
void *ptr = ruby_sized_xrealloc(orig_ptr, size, old_size);
213+
void *ptr = ruby_xrealloc_sized(orig_ptr, size, old_size);
216214
RUBY_ASSERT(ptr != NULL);
217215

218216
return ptr;

gc/mmtk/mmtk.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -635,22 +635,29 @@ void rb_gc_impl_set_params(void *objspace_ptr) { }
635635

636636
static VALUE gc_verify_internal_consistency(VALUE self) { return Qnil; }
637637

638-
#define MMTK_HEAP_COUNT 6
639-
#define MMTK_MAX_OBJ_SIZE 640
640-
638+
#if SIZEOF_VALUE >= 8
639+
#define MMTK_HEAP_COUNT 12
640+
#define MMTK_MAX_OBJ_SIZE 1024
641641
static size_t heap_sizes[MMTK_HEAP_COUNT + 1] = {
642-
32, 40, 80, 160, 320, MMTK_MAX_OBJ_SIZE, 0
642+
32, 40, 64, 80, 96, 128, 160, 256, 512, 640, 768, MMTK_MAX_OBJ_SIZE, 0
643643
};
644+
#else
645+
#define MMTK_HEAP_COUNT 5
646+
#define MMTK_MAX_OBJ_SIZE 512
647+
static size_t heap_sizes[MMTK_HEAP_COUNT + 1] = {
648+
32, 64, 128, 256, MMTK_MAX_OBJ_SIZE, 0
649+
};
650+
#endif
644651

645652
void
646653
rb_gc_impl_init(void)
647654
{
648655
VALUE gc_constants = rb_hash_new();
656+
rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_SIZE")), SIZET2NUM(SIZEOF_VALUE >= 8 ? 64 : 32));
649657
rb_hash_aset(gc_constants, ID2SYM(rb_intern("RBASIC_SIZE")), SIZET2NUM(sizeof(struct RBasic)));
650658
rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_OVERHEAD")), INT2NUM(0));
651659
rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVARGC_MAX_ALLOCATE_SIZE")), LONG2FIX(MMTK_MAX_OBJ_SIZE));
652-
// Pretend we have 5 size pools
653-
rb_hash_aset(gc_constants, ID2SYM(rb_intern("SIZE_POOL_COUNT")), LONG2FIX(MMTK_HEAP_COUNT));
660+
rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_COUNT")), LONG2FIX(MMTK_HEAP_COUNT));
654661
// TODO: correctly set RVALUE_OLD_AGE when we have generational GC support
655662
rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_OLD_AGE")), INT2FIX(0));
656663
OBJ_FREEZE(gc_constants);
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
exclude(:test_dump_all_full, "testing behaviour specific to default GC")
22
exclude(:test_dump_flag_age, "testing behaviour specific to default GC")
33
exclude(:test_dump_flags, "testing behaviour specific to default GC")
4-
exclude(:test_dump_includes_slot_size, "can be removed when pool 0 slot size is 32 bytes")
54
exclude(:test_dump_objects_dumps_page_slot_sizes, "testing behaviour specific to default GC")

0 commit comments

Comments
 (0)