%dispatch: sometimes the generated sequence is one byte longer, so instead of hard-coding it, compute the right length

db4
Slava Pestov 2009-06-30 18:11:15 -05:00
parent 54876d0cba
commit 4db44cd23f
2 changed files with 6 additions and 2 deletions

View File

@ -30,12 +30,14 @@ M: x86.32 temp-reg-2 EDX ;
M:: x86.32 %dispatch ( src temp -- )
! Load jump table base.
temp src HEX: ffffffff [+] LEA
building get length cell - :> start
0 rc-absolute-cell rel-here
! Go
temp HEX: 7f [+] JMP
building get length :> end
! Fix up the displacement above
cell code-alignment
[ 7 + building get dup pop* push ]
[ end start - + building get dup pop* push ]
[ align-code ]
bi ;

View File

@ -23,15 +23,17 @@ M: x86.64 rs-reg R15 ;
M: x86.64 stack-reg RSP ;
M:: x86.64 %dispatch ( src temp -- )
building get length :> start
! Load jump table base.
temp HEX: ffffffff MOV
0 rc-absolute-cell rel-here
! Add jump table base
temp src ADD
temp HEX: 7f [+] JMP
building get length :> end
! Fix up the displacement above
cell code-alignment
[ 15 + building get dup pop* push ]
[ end start - 2 - + building get dup pop* push ]
[ align-code ]
bi ;