From 489bea18d543f61e716454c2badd47fe01c55aaa Mon Sep 17 00:00:00 2001 From: slava Date: Tue, 11 Jul 2006 04:48:35 +0000 Subject: [PATCH] AMD64 fix, Cocoa UI memory leak fix --- TODO.FACTOR.txt | 1 - library/compiler/x86/architecture.factor | 2 +- library/compiler/x86/assembler.factor | 12 +++++++++-- library/compiler/x86/intrinsics.factor | 27 +++++++++++++----------- library/ui/cocoa/view-utils.factor | 2 +- 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index e69b335978..167ebf8657 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -1,4 +1,3 @@ -- amd64 crash - make-frame should compile - httpd search tools diff --git a/library/compiler/x86/architecture.factor b/library/compiler/x86/architecture.factor index 046dba8d9e..1e1b441ca6 100644 --- a/library/compiler/x86/architecture.factor +++ b/library/compiler/x86/architecture.factor @@ -114,7 +114,7 @@ M: object load-literal ( literal vreg -- ) ! Untag and multiply to get a jump table offset "n" operand fixnum>slot@ ! Add to jump table base. We use a temporary register since - ! on AMD4 we have to load a 64-bit immediate. On x86, this + ! on AMD64 we have to load a 64-bit immediate. On x86, this ! is redundant. "scratch" operand HEX: ffffffff MOV "end" get absolute-cell "n" operand "scratch" operand ADD diff --git a/library/compiler/x86/assembler.factor b/library/compiler/x86/assembler.factor index 06ed8d88e6..cf7486cd43 100644 --- a/library/compiler/x86/assembler.factor +++ b/library/compiler/x86/assembler.factor @@ -190,8 +190,16 @@ M: register displacement drop f ; ( Utilities ) UNION: operand register indirect ; -: rex.w? ( reg mod-r/m rex.w -- ? ) - [ register-64? ] 2apply or and ; +: operand-64? ( operand -- ? ) + dup indirect? [ + dup indirect-base register-64? + swap indirect-index register-64? or + ] [ + register-64? + ] if ; + +: rex.w? ( rex.w reg mod-r/m -- ? ) + [ operand-64? ] [ operand-64? ] ?if and ; : lhs-prefix extended? [ BIN: 00000100 bitor ] when ; diff --git a/library/compiler/x86/intrinsics.factor b/library/compiler/x86/intrinsics.factor index c6b23a12af..c08a03205f 100644 --- a/library/compiler/x86/intrinsics.factor +++ b/library/compiler/x86/intrinsics.factor @@ -88,15 +88,18 @@ IN: compiler { +clobber { "obj" "slot" } } } define-intrinsic +: char-reg cell 8 = RBX EBX ? ; inline +: char-reg-16 BX ; inline + \ char-slot [ - EBX PUSH + char-reg PUSH "n" operand 2 SHR - EBX dup XOR + char-reg dup XOR "obj" operand "n" operand ADD - BX "obj" operand string-offset [+] MOV - EBX tag-bits SHL - "obj" operand EBX MOV - EBX POP + char-reg-16 "obj" operand string-offset [+] MOV + char-reg tag-bits SHL + "obj" operand char-reg MOV + char-reg POP ] H{ { +input { { f "n" } { f "obj" } } } { +output { "obj" } } @@ -104,13 +107,13 @@ IN: compiler } define-intrinsic \ set-char-slot [ - EBX PUSH + char-reg PUSH "val" operand tag-bits SHR "slot" operand 2 SHR "obj" operand "slot" operand ADD - EBX "val" operand MOV - "obj" operand string-offset [+] BX MOV - EBX POP + char-reg "val" operand MOV + "obj" operand string-offset [+] char-reg-16 MOV + char-reg POP ] H{ { +input { { f "val" } { f "slot" } { f "obj" } } } { +clobber { "val" "slot" "obj" } } @@ -223,13 +226,13 @@ IN: compiler ! save EDX since its volatile. remainder-reg PUSH ! Align the stack -- only needed on Mac OS X - ESP 12 SUB + stack-reg 16 cell - SUB "s48_long_to_bignum" f "y" operand 1array compile-c-call* ! An untagged pointer to the bignum is now in EAX; tag it T{ int-regs } return-reg bignum-tag OR ! Align the stack -- only needed on Mac OS X - ESP 12 ADD + stack-reg 16 cell - ADD ! the remainder is now in EDX remainder-reg POP "end" get save-xt ; diff --git a/library/ui/cocoa/view-utils.factor b/library/ui/cocoa/view-utils.factor index ed04f217e3..ec0df69ccb 100644 --- a/library/ui/cocoa/view-utils.factor +++ b/library/ui/cocoa/view-utils.factor @@ -63,7 +63,7 @@ opengl sequences ; : send-key-event ( view event quot -- ) >r event>gesture r> call swap window world-focus - handle-gesture ; inline + handle-gesture drop ; inline : send-user-input ( view event -- ) -> characters CF>string swap window world-focus user-input ;