summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-10 06:32:44 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-10 06:32:44 +0000
commitb3a4367ce40912344310eded05e3d6fa5657330f (patch)
tree16284601d291b707c65eae0838b990c09e97844e /vm_insnhelper.c
parentea4c97904e37df0937af1742b41f3bb999b785b8 (diff)
rb_call_info_t: shrink to 96 bytes from 104 bytes on 64-bit
This keeps ci->flag and ci->aux.index consistent across 32-bit and 64-bit platforms. ci->flag: VM_CALL_* flags only use 9 bits, currently ci->aux.index: 2 billion ivars per class should be enough for anybody This saves around 50K allocations on "valgrind ruby -e exit" on x86-64 before: total heap usage: 48,122 allocs, 19,253 frees, 8,099,197 bytes allocated after: total heap usage: 48,069 allocs, 19,214 frees, 8,047,266 bytes allocated * vm_core.h (rb_call_info_t): ci->flag becomes 32-bit unsigned int ci->index becomes a 32-bit signed int (from signed long). Reorder for better packing on 64-bit, giving an 8 byte reduction from 104 to 96 bytes for each ci. * compile.c (new_callinfo, setup_args, iseq_compile_each, iseq_build_from_ary_body): adjust for type changes * vm_insnhelper.c (vm_getivar): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 2c43e06f63..c9ec803630 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -498,7 +498,7 @@ vm_getivar(VALUE obj, ID id, IC ic, rb_call_info_t *ci, int is_attr)
if (LIKELY((!is_attr && ic->ic_serial == RCLASS_SERIAL(klass)) ||
(is_attr && ci->aux.index > 0))) {
- long index = !is_attr ? (long)ic->ic_value.index : ci->aux.index - 1;
+ int index = !is_attr ? (int)ic->ic_value.index : ci->aux.index - 1;
long len = ROBJECT_NUMIV(obj);
VALUE *ptr = ROBJECT_IVPTR(obj);
@@ -522,7 +522,7 @@ vm_getivar(VALUE obj, ID id, IC ic, rb_call_info_t *ci, int is_attr)
ic->ic_serial = RCLASS_SERIAL(klass);
}
else { /* call_info */
- ci->aux.index = index + 1;
+ ci->aux.index = (int)index + 1;
}
}
}