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
: caller-parameters ( params -- reg-inputs stack-inputs )
[ abi>> ] [ parameters>> ] [ return>> ] tri
'[
- _ unbox-parameters
+ _ unbox-parameters
_ prepare-struct-caller struct-return-area set
(caller-parameters)
] with-param-regs ;
SYMBOL: struct-return-area
+SYMBOLS: int-reg-reps float-reg-reps ;
+
+: inc-not-f ( variable -- ) dup get [ inc ] [ drop ] if ; inline
+
+: dec-not-f ( variable -- ) dup get [ dec ] [ drop ] if ; inline
+
+: record-reg-reps ( seq -- seq )
+ dup [
+ dup second not [ ! on-stack?: f
+ first int-rep? int-reg-reps float-reg-reps ? inc-not-f
+ ] [ drop ] if
+ ] each ;
+
+: unrecord-reg-reps ( seq -- seq )
+ dup [
+ dup second not [ ! on-stack?: f
+ first int-rep? int-reg-reps float-reg-reps ? dec-not-f
+ ] [ drop ] if
+ ] each ;
+
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 ;
[ 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 ;
! 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
[ 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 ;
+ int-regs swap member? int-rep double-rep ? f f 3array
+ ] map :> reps
+ int-reg-reps get float-reg-reps get and [
+ 0 :> int-mems!
+ 0 :> float-mems!
+ reps [
+ first int-rep? [
+ int-mems 1 + int-mems!
+ ] [
+ float-mems 1 + float-mems!
+ ] if
+ ] each
+ 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 [ first t f 3array ] map
+ unrecord-reg-reps
+ ] if ;
M: x86.64 return-struct-in-registers? ( c-type -- ? )
heap-size 2 cells <= ;
] [ 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