dumping ground for random patches and texts
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH] vm.c: reduce branches for always-set VM fields
Date: Sat,  4 Jul 2015 00:34:36 +0000	[thread overview]
Message-ID: <1435970076-23353-1-git-send-email-e@80x24.org> (raw)

thgroup_default, mark_object_ary, load_path, load_path_snapshot,
expanded_load_path, loaded_features, loaded_features_snapshot,
top_self, defined_module_hash are always defined at process startup.

This makes it wasteful to have extra branches in an an effort to
skip the function call to `rb_gc_mark'.

This reduces binary size a small amount:

   text	   data	    bss	    dec	    hex	filename
2830738	  22672	  71584	2924994	 2ca1c2	ruby.orig
2830234	  22672	  71584	2924490	 2c9fca	ruby.after
---
 vm.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/vm.c b/vm.c
index 06719ad..36d5c8b 100644
--- a/vm.c
+++ b/vm.c
@@ -1816,17 +1816,17 @@ rb_vm_mark(void *ptr)
 	list_for_each(&vm->living_threads, th, vmlt_node) {
 	    rb_gc_mark(th->self);
 	}
-	RUBY_MARK_UNLESS_NULL(vm->thgroup_default);
-	RUBY_MARK_UNLESS_NULL(vm->mark_object_ary);
-	RUBY_MARK_UNLESS_NULL(vm->load_path);
-	RUBY_MARK_UNLESS_NULL(vm->load_path_snapshot);
+	rb_gc_mark(vm->thgroup_default);
+	rb_gc_mark(vm->mark_object_ary);
+	rb_gc_mark(vm->load_path);
+	rb_gc_mark(vm->load_path_snapshot);
 	RUBY_MARK_UNLESS_NULL(vm->load_path_check_cache);
-	RUBY_MARK_UNLESS_NULL(vm->expanded_load_path);
-	RUBY_MARK_UNLESS_NULL(vm->loaded_features);
-	RUBY_MARK_UNLESS_NULL(vm->loaded_features_snapshot);
-	RUBY_MARK_UNLESS_NULL(vm->top_self);
+	rb_gc_mark(vm->expanded_load_path);
+	rb_gc_mark(vm->loaded_features);
+	rb_gc_mark(vm->loaded_features_snapshot);
+	rb_gc_mark(vm->top_self);
 	RUBY_MARK_UNLESS_NULL(vm->coverages);
-	RUBY_MARK_UNLESS_NULL(vm->defined_module_hash);
+	rb_gc_mark(vm->defined_module_hash);
 
 	if (vm->loading_table) {
 	    rb_mark_tbl(vm->loading_table);
@@ -1858,9 +1858,9 @@ int
 rb_vm_add_root_module(ID id, VALUE module)
 {
     rb_vm_t *vm = GET_VM();
-    if (vm->defined_module_hash) {
-	rb_hash_aset(vm->defined_module_hash, ID2SYM(id), module);
-    }
+
+    rb_hash_aset(vm->defined_module_hash, ID2SYM(id), module);
+
     return TRUE;
 }
 
-- 
EW


                 reply	other threads:[~2015-07-04  0:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1435970076-23353-1-git-send-email-e@80x24.org \
    --to=e@80x24.org \
    --cc=spew@80x24.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).