Project

General

Profile

Actions

Feature #11299

open

[PATCH] use Array instead of custom struct for generic ivars

Added by normalperson (Eric Wong) over 9 years ago. Updated 8 months ago.

Status:
Assigned
Target version:
-
[ruby-core:69714]

Description

I'll commit this in a few days unless there's an objection.

This reduces both code and object size while reducing the cognitive
overhead necessary to understand the code.  Memory usage should be
slightly higher due to Array overheads, but still better than what we
had in Ruby 2.2 and earlier.

   text    data     bss     dec     hex filename
2837117   22688   71576 2931381  2cbab5 ruby.before
2836221   22688   71576 2930485  2cb735 ruby.after

 array.c    |  28 +++++-----
 internal.h |   1 +
 variable.c | 170 +++++++++++++++++++------------------------------------------
 3 files changed, 69 insertions(+), 130 deletions(-)

* array.c (rb_mem_clear): use memfill
  (rb_ary_store_fill): new function
  (rb_ary_store): use rb_ary_store_fill
* internal.h (rb_ary_store_fill): new declaration
* variable.c (struct gen_ivtbl): remove
  (struct ivar_update): adjust type
  (struct gen_ivar_compat_tbl): ditto
  (struct gen_ivar_tag): ditto
  (struct givar_copy): ditto
  (gen_ivar_compat_tbl_i): adjust for type change
  (gen_ivtbl_get): ditto
  (generic_ivar_delete): ditto
  (generic_ivar_get): ditto
  (generic_ivar_update): ditto
  (generic_ivar_defined): ditto
  (rb_mark_generic_ivar): ditto
  (rb_free_generic_ivar): ditto
  (rb_generic_ivar_memsize): ditto
  (generic_ivar_set): ditto
  (gen_ivtbl_count): ditto
  (gen_ivar_each_i): ditto
  (gen_ivar_copy): ditto
  (rb_copy_generic_ivar): ditto
  (rb_ivar_count): ditto
  (gen_ivtbl_bytes): remove
  (gen_ivtbl_resize): remove
  (gen_ivtbl_dup): remove
  (gen_ivtbl_mark): remove

Files

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0