x86 assembler fixes for new code heap layout

slava 2006-08-09 22:25:11 +00:00
parent 40e3a2a063
commit 9dc1a9854a
5 changed files with 24 additions and 9 deletions

View File

@ -57,6 +57,9 @@ DEFER: %jump-t ( label vreg -- )
! Jump table of addresses (one cell each) is right after this
DEFER: %dispatch ( vreg -- )
! Jump table entry
DEFER: %target ( label -- )
! Return to caller
DEFER: %return ( -- )

View File

@ -166,7 +166,7 @@ M: #call-label generate-node ( node -- next )
{ +input { { f "n" } } }
{ +scratch { { f "scratch" } } }
} with-template
node-children [ <label> dup target-label 2array ] map ;
node-children [ <label> dup %target 2array ] map ;
: dispatch-body ( label/node -- )
<label> swap [

View File

@ -84,6 +84,8 @@ M: object load-literal ( literal vreg -- )
"n" operand MTLR
BLR ;
: %target ( label -- ) 0 , rel-absolute-cell rel-label ;
: %return ( -- ) %epilogue BLR ;
: compile-dlsym ( symbol dll register -- )

View File

@ -4,6 +4,8 @@ USING: alien arrays assembler generic kernel kernel-internals
math memory namespaces sequences words ;
IN: compiler
: code-format 1 ; inline
! x86 register assignments
! EAX, ECX, EDX integer vregs
! XMM0 - XMM7 float vregs
@ -106,6 +108,9 @@ M: object load-literal ( literal vreg -- )
: %jump-t ( label -- ) "flag" operand f v>operand CMP JNE ;
: compile-aligned ( -- )
compiled-offset [ 8 align ] keep - 0 <array> % ;
: %dispatch ( -- )
#! Compile a piece of code that jumps to an offset in a
#! jump table indexed by the fixnum at the top of the stack.
@ -126,6 +131,8 @@ M: object load-literal ( literal vreg -- )
! Fix up jump table pointer
"end" get resolve-label ;
: %target ( label -- ) 0 cell, rel-absolute-cell rel-label ;
: %return ( -- ) %epilogue RET ;
: %move-int>int ( dst src -- )

View File

@ -266,6 +266,7 @@ GENERIC: PUSH ( op -- )
M: register PUSH f HEX: 50 short-operand ;
M: integer PUSH HEX: 68 , 4, ;
M: callable PUSH 0 PUSH rel-absolute rel-word ;
M: label PUSH 0 PUSH rel-absolute rel-label ;
M: operand PUSH BIN: 110 f HEX: ff 1-operand ;
GENERIC: POP ( op -- )
@ -280,24 +281,26 @@ M: operand (MOV-I) BIN: 000 t HEX: c7 1-operand 4, ;
GENERIC: MOV ( dst src -- )
M: integer MOV swap (MOV-I) ;
M: callable MOV 0 rot (MOV-I) rel-absolute-cell rel-word ;
M: label MOV 0 rot (MOV-I) rel-absolute-cell rel-label ;
M: operand MOV HEX: 89 2-operand ;
( Control flow )
GENERIC: JMP ( op -- )
! M: integer JMP HEX: e9 , from 4, ;
M: callable JMP 0 JMP rel-relative rel-word ;
: (JMP) HEX: e9 , 0 4, rel-relative ;
M: callable JMP (JMP) rel-word ;
M: label JMP (JMP) rel-label ;
M: operand JMP BIN: 100 t HEX: ff 1-operand ;
GENERIC: CALL ( op -- )
! M: integer CALL HEX: e8 , from 4, ;
M: callable CALL 0 CALL rel-relative rel-word ;
: (CALL) HEX: e8 , 0 4, rel-relative ;
M: callable CALL (CALL) rel-word ;
M: label CALL (CALL) rel-label ;
M: operand CALL BIN: 010 t HEX: ff 1-operand ;
G: JUMPcc ( addr opcode -- ) 1 standard-combination ;
! M: integer JUMPcc ( addr opcode -- )
! swap HEX: 0f , swap , from assemble-4 ;
M: callable JUMPcc ( addr opcode -- )
swap >r 0 swap JUMPcc r> rel-relative rel-word ;
: (JUMPcc) HEX: 0f , , 0 4, rel-relative ;
M: callable JUMPcc ( addr opcode -- ) (JUMPcc) rel-word ;
M: label JUMPcc ( addr opcode -- ) (JUMPcc) rel-label ;
: JO HEX: 80 JUMPcc ;
: JNO HEX: 81 JUMPcc ;