Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added gcdata patch for 1.9.3-p0

  • Loading branch information...
commit aece113ff1462b792ea58c6559d3c8fc9c95b468 1 parent dc2d7ec
@goncalossilva goncalossilva authored
Showing with 143 additions and 0 deletions.
  1. +143 −0 patches/1.9.3/p0/gcdata.patch
View
143 patches/1.9.3/p0/gcdata.patch
@@ -0,0 +1,143 @@
+--- a/gc.c (revision 33566)
++++ b/gc.c (working copy)
+@@ -309,16 +309,12 @@
+ struct gc_list *next;
+ };
+
+-#define CALC_EXACT_MALLOC_SIZE 0
+-
+ typedef struct rb_objspace {
+ struct {
+ size_t limit;
+ size_t increase;
+-#if CALC_EXACT_MALLOC_SIZE
+ size_t allocated_size;
+ size_t allocations;
+-#endif
+ } malloc_params;
+ struct {
+ size_t increment;
+@@ -715,10 +711,6 @@
+ }
+ if (size == 0) size = 1;
+
+-#if CALC_EXACT_MALLOC_SIZE
+- size += sizeof(size_t);
+-#endif
+-
+ if ((ruby_gc_stress && !ruby_disable_gc_stress) ||
+ (malloc_increase+size) > malloc_limit) {
+ garbage_collect_with_gvl(objspace);
+@@ -732,12 +724,8 @@
+ {
+ malloc_increase += size;
+
+-#if CALC_EXACT_MALLOC_SIZE
+ objspace->malloc_params.allocated_size += size;
+ objspace->malloc_params.allocations++;
+- ((size_t *)mem)[0] = size;
+- mem = (size_t *)mem + 1;
+-#endif
+
+ return mem;
+ }
+@@ -776,11 +764,7 @@
+ if (ruby_gc_stress && !ruby_disable_gc_stress)
+ garbage_collect_with_gvl(objspace);
+
+-#if CALC_EXACT_MALLOC_SIZE
+- size += sizeof(size_t);
+ objspace->malloc_params.allocated_size -= size;
+- ptr = (size_t *)ptr - 1;
+-#endif
+
+ mem = realloc(ptr, size);
+ if (!mem) {
+@@ -793,11 +777,7 @@
+ }
+ malloc_increase += size;
+
+-#if CALC_EXACT_MALLOC_SIZE
+ objspace->malloc_params.allocated_size += size;
+- ((size_t *)mem)[0] = size;
+- mem = (size_t *)mem + 1;
+-#endif
+
+ return mem;
+ }
+@@ -805,14 +785,6 @@
+ static void
+ vm_xfree(rb_objspace_t *objspace, void *ptr)
+ {
+-#if CALC_EXACT_MALLOC_SIZE
+- size_t size;
+- ptr = ((size_t *)ptr) - 1;
+- size = ((size_t*)ptr)[0];
+- objspace->malloc_params.allocated_size -= size;
+- objspace->malloc_params.allocations--;
+-#endif
+-
+ free(ptr);
+ }
+
+@@ -3384,7 +3356,6 @@
+ }
+
+
+-#if CALC_EXACT_MALLOC_SIZE
+ /*
+ * call-seq:
+ * GC.malloc_allocated_size -> Integer
+@@ -3394,8 +3365,8 @@
+ * It returns the allocated size by malloc().
+ */
+
+-static VALUE
+-gc_malloc_allocated_size(VALUE self)
++VALUE
++rb_gc_malloc_allocated_size(VALUE self)
+ {
+ return UINT2NUM((&rb_objspace)->malloc_params.allocated_size);
+ }
+@@ -3409,12 +3380,11 @@
+ * It returns the number of allocated memory object by malloc().
+ */
+
+-static VALUE
+-gc_malloc_allocations(VALUE self)
++VALUE
++rb_gc_malloc_allocations(VALUE self)
+ {
+ return UINT2NUM((&rb_objspace)->malloc_params.allocations);
+ }
+-#endif
+
+ static VALUE
+ gc_profile_record_get(void)
+@@ -3599,6 +3569,8 @@
+ rb_define_singleton_method(rb_mGC, "start", rb_gc_start, 0);
+ rb_define_singleton_method(rb_mGC, "enable", rb_gc_enable, 0);
+ rb_define_singleton_method(rb_mGC, "disable", rb_gc_disable, 0);
++ rb_define_singleton_method(rb_mGC, "malloc_allocated_size", rb_gc_malloc_allocated_size, 0);
++ rb_define_singleton_method(rb_mGC, "malloc_allocations", rb_gc_malloc_allocations, 0);
+ rb_define_singleton_method(rb_mGC, "stress", gc_stress_get, 0);
+ rb_define_singleton_method(rb_mGC, "stress=", gc_stress_set, 1);
+ rb_define_singleton_method(rb_mGC, "count", gc_count, 0);
+@@ -3613,6 +3585,7 @@
+ rb_define_singleton_method(rb_mProfiler, "result", gc_profile_result, 0);
+ rb_define_singleton_method(rb_mProfiler, "report", gc_profile_report, -1);
+ rb_define_singleton_method(rb_mProfiler, "total_time", gc_profile_total_time, 0);
++ rb_define_singleton_method(rb_mProfiler, "data", gc_profile_record_get, 0);
+
+ rb_mObSpace = rb_define_module("ObjectSpace");
+ rb_define_module_function(rb_mObSpace, "each_object", os_each_obj, -1);
+@@ -3632,9 +3605,4 @@
+ rb_define_method(rb_mKernel, "object_id", rb_obj_id, 0);
+
+ rb_define_module_function(rb_mObSpace, "count_objects", count_objects, -1);
+-
+-#if CALC_EXACT_MALLOC_SIZE
+- rb_define_singleton_method(rb_mGC, "malloc_allocated_size", gc_malloc_allocated_size, 0);
+- rb_define_singleton_method(rb_mGC, "malloc_allocations", gc_malloc_allocations, 0);
+-#endif
+ }
Please sign in to comment.
Something went wrong with that request. Please try again.