vm: new megamorphic hashcode algorithm improves bootstrap speed

db4
Slava Pestov 2009-11-02 01:37:58 -06:00
parent 94e9230ba3
commit 7e17c3077c
3 changed files with 17 additions and 5 deletions

View File

@ -224,8 +224,13 @@ CONSTANT: rs-reg 14
[
! cache = ...
0 3 LOAD32 rc-absolute-ppc-2/2 rt-immediate jit-rel
! key = class
5 4 MR
! key = hashcode(class)
5 4 3 SRAWI
6 4 8 SRAWI
5 5 6 ADD
6 4 13 SRAWI
5 5 6 ADD
5 5 3 SLWI
! key &= cache.length - 1
5 5 mega-cache-size get 1 - bootstrap-cell * ANDI
! cache += array-start-offset

View File

@ -222,9 +222,16 @@ big-endian off
[
! cache = ...
temp0 0 MOV rc-absolute-cell rt-immediate jit-rel
! key = class
! key = hashcode(class)
temp2 temp1 MOV
bootstrap-cell 8 = [ temp2 1 SHL ] when
temp2 3 SHR
temp3 temp1 MOV
temp3 8 SHR
temp2 temp3 ADD
temp3 temp1 MOV
temp3 13 SHR
temp2 temp3 ADD
temp2 bootstrap-cell 4 = 3 4 ? SHL
! key &= cache.length - 1
temp2 mega-cache-size get 1 - bootstrap-cell * AND
! cache += array-start-offset

View File

@ -126,7 +126,7 @@ cell factor_vm::object_class(cell obj)
cell factor_vm::method_cache_hashcode(cell klass, array *array)
{
cell capacity = (array_capacity(array) >> 1) - 1;
return ((klass >> TAG_BITS) & capacity) << 1;
return (((klass >> 3) + (klass >> 8) + (klass >> 13)) & capacity) << 1;
}
void factor_vm::update_method_cache(cell cache, cell klass, cell method)