iseq_inline_storage_entry: 24=>16 bytes on 64-bit

We may tag the running_thread pointer to avoid making the "once" struct
bigger than "struct iseq_inline_cache_entry".

This only saves a small amount with "valgrind ruby -e exit"
before:
  total heap usage: 48,122 allocs, 19,248 frees, 8,110,149 bytes allocated
after:
  total heap usage: 48,122 allocs, 19,253 frees, 8,099,197 bytes allocated

* insns.def (once): define and use fake RUNNING_THREAD_ONCE_DONE
  pointer to indicate is->once.running_thread is done.

* vm_core.h (iseq_inline_storage_entry): remove done field,
  allowing the union to be reduced from 24=>16 bytes on 64-bit

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
normal 2014-09-11 19:25:32 +00:00
parent 1d0de2a513
commit f0c968a778
3 changed files with 27 additions and 20 deletions

View File

@ -1,3 +1,12 @@
Fri Sep 12 04:24:03 2014 Eric Wong <e@80x24.org>
* insns.def (once): define and use fake RUNNING_THREAD_ONCE_DONE
pointer to indicate is->once.running_thread is done.
* vm_core.h (iseq_inline_storage_entry): remove done field,
allowing the union to be reduced from 24=>16 bytes on 64-bit
[Feature #10187]
Thu Sep 11 20:10:00 2014 Koichi Sasada <ko1@atdot.net> Thu Sep 11 20:10:00 2014 Koichi Sasada <ko1@atdot.net>
* vm.c (rb_thread_mark): use rb_gc_mark_values() to mark VM stack. * vm.c (rb_thread_mark): use rb_gc_mark_values() to mark VM stack.

View File

@ -1239,13 +1239,16 @@ once
{ {
union iseq_inline_storage_entry *is = (union iseq_inline_storage_entry *)ic; union iseq_inline_storage_entry *is = (union iseq_inline_storage_entry *)ic;
#define RUNNING_THREAD_ONCE_DONE ((rb_thread_t *)(0x1))
retry: retry:
if (is->once.done == Qfalse) { if (is->once.running_thread == RUNNING_THREAD_ONCE_DONE) {
if (is->once.running_thread == NULL) { val = is->once.value;
}
else if (is->once.running_thread == NULL) {
is->once.running_thread = th; is->once.running_thread = th;
val = is->once.value = rb_ensure(vm_once_exec, (VALUE)iseq, vm_once_clear, (VALUE)is); val = is->once.value = rb_ensure(vm_once_exec, (VALUE)iseq, vm_once_clear, (VALUE)is);
/* is->once.running_thread is cleared by vm_once_clear() */ /* is->once.running_thread is cleared by vm_once_clear() */
is->once.done = Qtrue; is->once.running_thread = RUNNING_THREAD_ONCE_DONE; /* success */
rb_iseq_add_mark_object(GET_ISEQ(), val); rb_iseq_add_mark_object(GET_ISEQ(), val);
} }
else if (is->once.running_thread == th) { else if (is->once.running_thread == th) {
@ -1258,10 +1261,6 @@ once
rb_thread_schedule(); rb_thread_schedule();
goto retry; goto retry;
} }
}
else {
val = is->once.value;
}
} }
/** /**

View File

@ -127,7 +127,6 @@ union iseq_inline_storage_entry {
struct { struct {
struct rb_thread_struct *running_thread; struct rb_thread_struct *running_thread;
VALUE value; VALUE value;
VALUE done;
} once; } once;
struct iseq_inline_cache_entry cache; struct iseq_inline_cache_entry cache;
}; };