Bum 3 instructions out of megamorphic fast path by switching to fixed-size caches

db4
Slava Pestov 2009-04-30 04:14:14 -05:00
parent 1ce65acff1
commit 59d6131c7c
4 changed files with 7 additions and 8 deletions

View File

@ -243,12 +243,8 @@ big-endian off
temp0 0 MOV rc-absolute-cell rt-immediate jit-rel temp0 0 MOV rc-absolute-cell rt-immediate jit-rel
! key = class ! key = class
temp2 temp1 MOV temp2 temp1 MOV
! compute cache.length - 1
temp3 temp0 1 bootstrap-cells array tag-number - [+] MOV
temp3 1 SHR
temp3 4 SUB
! key &= cache.length - 1 ! key &= cache.length - 1
temp2 temp3 AND temp2 mega-cache-size get 1- bootstrap-cell * AND
! cache += array-start-offset ! cache += array-start-offset
temp0 array-start-offset ADD temp0 array-start-offset ADD
! cache += key ! cache += key

View File

@ -11,6 +11,8 @@ BIN: 111 tag-mask set
15 num-types set 15 num-types set
32 mega-cache-size set
H{ H{
{ fixnum BIN: 000 } { fixnum BIN: 000 }
{ bignum BIN: 001 } { bignum BIN: 001 }

View File

@ -3,7 +3,7 @@
USING: accessors definitions generic generic.single kernel USING: accessors definitions generic generic.single kernel
namespaces words math math.order combinators sequences namespaces words math math.order combinators sequences
generic.single.private quotations kernel.private generic.single.private quotations kernel.private
assocs arrays ; assocs arrays layouts ;
IN: generic.standard IN: generic.standard
TUPLE: standard-combination < single-combination # ; TUPLE: standard-combination < single-combination # ;
@ -47,8 +47,7 @@ M: standard-combination inline-cache-quot ( word methods -- )
combination get #>> [ f inline-cache-miss ] 3curry [ ] like ; combination get #>> [ f inline-cache-miss ] 3curry [ ] like ;
: make-empty-cache ( -- array ) : make-empty-cache ( -- array )
generic-word get "methods" word-prop mega-cache-size get f <array> ;
assoc-size 2 * next-power-of-2 f <array> ;
M: standard-combination mega-cache-quot M: standard-combination mega-cache-quot
combination get #>> make-empty-cache [ mega-cache-lookup ] 3curry [ ] like ; combination get #>> make-empty-cache [ mega-cache-lookup ] 3curry [ ] like ;

View File

@ -16,6 +16,8 @@ SYMBOL: tag-numbers
SYMBOL: type-numbers SYMBOL: type-numbers
SYMBOL: mega-cache-size
: type-number ( class -- n ) : type-number ( class -- n )
type-numbers get at ; type-numbers get at ;