[前][次][番号順一覧][スレッド一覧]

ruby-changes:39055

From: normal <ko1@a...>
Date: Sat, 4 Jul 2015 09:47:24 +0900 (JST)
Subject: [ruby-changes:39055] normal:r51136 (trunk): vm.c: reduce branches for always-set VM fields

normal	2015-07-04 09:47:05 +0900 (Sat, 04 Jul 2015)

  New Revision: 51136

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51136

  Log:
    vm.c: reduce branches for always-set VM fields
    
    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 on x86-64:
    
       text	   data	    bss	    dec	    hex	filename
    2830738	  22672	  71584	2924994	 2ca1c2	ruby.orig
    2830234	  22672	  71584	2924490	 2c9fca	ruby.after
    
    More similar changes coming when I'm bored enough to notice...
    
    * vm.c (rb_vm_mark): reduce branches for always-set VM fields
      (rb_vm_add_root_module): ditto

  Modified files:
    trunk/ChangeLog
    trunk/vm.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51135)
+++ ChangeLog	(revision 51136)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Jul  4 09:38:52 2015  Eric Wong  <e@8...>
+
+	* vm.c (rb_vm_mark): reduce branches for always-set VM fields
+	  (rb_vm_add_root_module): ditto
+
 Fri Jul 03 20:05:10 2015  Koichi Sasada  <ko1@a...>
 
 	* method.h: introduce rb_callable_method_entry_t to remove
Index: vm.c
===================================================================
--- vm.c	(revision 51135)
+++ vm.c	(revision 51136)
@@ -1816,17 +1816,17 @@ rb_vm_mark(void *ptr) https://github.com/ruby/ruby/blob/trunk/vm.c#L1816
 	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 https://github.com/ruby/ruby/blob/trunk/vm.c#L1858
 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;
 }
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]