Merge pull request #2235 from kusumotonorio/system-v-amd64-abi
Improved System V AMD64 ABI compliancemaster
commit
4e17fb13cb
|
@ -15,6 +15,8 @@ IN: compiler.cfg.builder.alien
|
|||
0 stack-params set
|
||||
V{ } clone reg-values set
|
||||
V{ } clone stack-values set
|
||||
0 int-reg-reps set
|
||||
0 float-reg-reps set
|
||||
@
|
||||
reg-values get
|
||||
stack-values get
|
||||
|
|
|
@ -10,19 +10,30 @@ IN: compiler.cfg.builder.alien.boxing
|
|||
|
||||
SYMBOL: struct-return-area
|
||||
|
||||
SYMBOLS: int-reg-reps float-reg-reps ;
|
||||
|
||||
: reg-reps ( reps -- int-reps float-reps )
|
||||
[ second ] reject [ [ first int-rep? ] count ] [ length over - ] bi ;
|
||||
|
||||
: record-reg-reps ( reps -- reps )
|
||||
dup reg-reps [ int-reg-reps +@ ] [ float-reg-reps +@ ] bi* ;
|
||||
|
||||
: unrecord-reg-reps ( reps -- reps )
|
||||
dup reg-reps [ neg int-reg-reps +@ ] [ neg float-reg-reps +@ ] bi* ;
|
||||
|
||||
GENERIC: flatten-c-type ( c-type -- pairs )
|
||||
|
||||
M: c-type flatten-c-type
|
||||
rep>> f f 3array 1array ;
|
||||
rep>> f f 3array 1array record-reg-reps ;
|
||||
|
||||
M: long-long-type flatten-c-type
|
||||
drop 2 [ int-rep long-long-on-stack? f 3array ] replicate ;
|
||||
drop 2 [ int-rep long-long-on-stack? f 3array ] replicate record-reg-reps ;
|
||||
|
||||
HOOK: flatten-struct-type cpu ( type -- pairs )
|
||||
HOOK: flatten-struct-type-return cpu ( type -- pairs )
|
||||
|
||||
M: object flatten-struct-type
|
||||
heap-size cell align cell /i { int-rep f f } <array> ;
|
||||
heap-size cell align cell /i { int-rep f f } <array> record-reg-reps ;
|
||||
|
||||
M: struct-c-type flatten-c-type
|
||||
flatten-struct-type ;
|
||||
|
@ -70,12 +81,12 @@ M: c-type unbox
|
|||
[ swap ^^unbox ]
|
||||
} case 1array
|
||||
]
|
||||
[ drop f f 3array 1array ] 2bi ;
|
||||
[ drop f f 3array 1array ] 2bi record-reg-reps ;
|
||||
|
||||
M: long-long-type unbox
|
||||
[ next-vreg next-vreg 2dup ] 2dip unboxer>> ##unbox-long-long, 2array
|
||||
int-rep long-long-on-stack? long-long-odd-register? 3array
|
||||
int-rep long-long-on-stack? f 3array 2array ;
|
||||
int-rep long-long-on-stack? f 3array 2array record-reg-reps ;
|
||||
|
||||
M: struct-c-type unbox ( src c-type -- vregs reps )
|
||||
[ ^^unbox-any-c-ptr ] dip explode-struct ;
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors alien.c-types arrays assocs
|
||||
compiler.cfg.builder.alien.boxing cpu.architecture cpu.x86
|
||||
cpu.x86.assembler cpu.x86.assembler.operands kernel layouts make math
|
||||
math.order sequences splitting system ;
|
||||
cpu.x86.assembler cpu.x86.assembler.operands kernel layouts locals
|
||||
make math math.order namespaces sequences splitting system ;
|
||||
IN: cpu.x86.64.unix
|
||||
|
||||
M: x86.64 param-regs
|
||||
|
@ -24,16 +24,26 @@ M: x86.64 reserved-stack-space 0 ;
|
|||
[ 8 mod zero? [ t , ] when , ] assoc-each
|
||||
] { } make { t } split harvest ;
|
||||
|
||||
: flatten-small-struct ( c-type -- seq )
|
||||
struct-types&offset split-struct [
|
||||
:: flatten-small-struct ( c-type -- seq )
|
||||
c-type struct-types&offset split-struct [
|
||||
[ lookup-c-type c-type-rep reg-class-of ] map
|
||||
int-regs swap member? int-rep double-rep ?
|
||||
f f 3array
|
||||
] map ;
|
||||
] map :> reps
|
||||
int-reg-reps get float-reg-reps get and [
|
||||
reps reg-reps :> ( int-mems float-mems )
|
||||
int-reg-reps get int-mems + 6 >
|
||||
float-reg-reps get float-mems + 8 > or [
|
||||
reps [ first t f 3array ] map
|
||||
] [ reps ] if
|
||||
] [ reps ] if ;
|
||||
|
||||
M: x86.64 flatten-struct-type ( c-type -- seq )
|
||||
dup heap-size 16 <=
|
||||
[ flatten-small-struct ] [ call-next-method [ first t f 3array ] map ] if ;
|
||||
[ flatten-small-struct record-reg-reps ] [
|
||||
call-next-method unrecord-reg-reps
|
||||
[ first t f 3array ] map
|
||||
] if ;
|
||||
|
||||
M: x86.64 return-struct-in-registers? ( c-type -- ? )
|
||||
heap-size 2 cells <= ;
|
||||
|
|
|
@ -238,16 +238,15 @@ IMPORT: NSAttributedString
|
|||
] [ underlines ] if ;
|
||||
|
||||
:: update-marked-text ( gadget str selectedRange replacementRange -- )
|
||||
replacementRange location>> NSNotFound = not ! [
|
||||
replacementRange length>> NSNotFound = not and [ ! erase this line
|
||||
replacementRange location>> NSNotFound = not [
|
||||
gadget editor-caret first
|
||||
dup gadget editor-line
|
||||
[
|
||||
replacementRange length>> ! location>>
|
||||
replacementRange location>>
|
||||
>codepoint-index
|
||||
2array gadget set-caret
|
||||
] [
|
||||
replacementRange length>> 1 + ! [ location>> ] [ length>> ] bi +
|
||||
replacementRange [ location>> ] [ length>> ] bi +
|
||||
>codepoint-index
|
||||
2array gadget set-mark
|
||||
] 2bi
|
||||
|
|
Loading…
Reference in New Issue