vm: new megamorphic hashcode algorithm improves bootstrap speed
parent
94e9230ba3
commit
7e17c3077c
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue