From fd59c87eaeb61da5fe78d11aadbfa2fe813f8eb5 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 30 Jan 2006 07:03:34 +0000 Subject: [PATCH] AMD64 FFI fixes; httpd load fix; minor opengl optimization --- CHANGES.html | 3 +++ contrib/httpd/test/html.factor | 2 +- library/alien/compiler.factor | 16 ++++++++----- library/compiler/amd64/alien.factor | 3 ++- library/freetype/freetype-gl.factor | 36 ++++++++++++++--------------- library/math/pow.factor | 2 -- library/opengl/opengl-utils.factor | 16 ++++++------- library/test/compiler/alien.factor | 6 +++++ library/test/math/integer.factor | 2 +- library/test/test.factor | 1 + native/ffi_test.c | 12 ++++++++++ 11 files changed, 62 insertions(+), 37 deletions(-) diff --git a/CHANGES.html b/CHANGES.html index 350fca1e13..8c6cecdb36 100644 --- a/CHANGES.html +++ b/CHANGES.html @@ -48,6 +48,9 @@ this is lexicographic order, and for words, this compares word names. contrib/math/.
  • The mod word is now supported for ratios and floating point numbers.
  • The truncate, floor and ceiling words are now supported for floating point numbers.
  • +
  • The NaN, positive infinity and negative infinity floating point numbers now parse and unparse as 0.0/0.0, 1.0/0.0, and -1.0/0.0 respectively.
  • +
  • The NaN value is now equal to itself under =.
  • +
  • Negative and postive zero are no longer equal under =. However, the new zero? word tests if the top of the stack is a zero, and it tests for both positive and negative zero.
  • diff --git a/contrib/httpd/test/html.factor b/contrib/httpd/test/html.factor index a7595482f9..a1fc1aec63 100644 --- a/contrib/httpd/test/html.factor +++ b/contrib/httpd/test/html.factor @@ -2,7 +2,7 @@ IN: temporary USING: html http io kernel namespaces styles test xml ; [ - "/responder/foo/?z=%20" + "/responder/foo?z=%20" ] [ "/responder/foo" H{ { "z" " " } } build-url ] unit-test diff --git a/library/alien/compiler.factor b/library/alien/compiler.factor index 31c216705f..d6af9ee432 100644 --- a/library/alien/compiler.factor +++ b/library/alien/compiler.factor @@ -1,5 +1,5 @@ -! Copyright (C) 2004, 2005 Slava Pestov. -! See http://factor.sf.net/license.txt for BSD license. +! Copyright (C) 2004, 2006 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. IN: alien USING: assembler compiler compiler-backend compiler-frontend errors generic hashtables inference inspector io kernel @@ -116,12 +116,16 @@ C: alien-node make-node ; c-type [ "boxer" get "reg-class" get ] bind %box , ] if ; +: linearize-cleanup ( node -- ) + node-param cdr library-abi "stdcall" = + [ dup parameters stack-space %cleanup , ] unless ; + M: alien-node linearize* ( node -- ) dup parameters linearize-parameters - dup node-param dup uncons %alien-invoke , - cdr library-abi "stdcall" = - [ dup parameters stack-space %cleanup , ] unless - dup linearize-return linearize-next ; + dup node-param uncons %alien-invoke , + dup linearize-cleanup + dup linearize-return + linearize-next ; : parse-arglist ( lst -- types stack effect ) unpair [ diff --git a/library/compiler/amd64/alien.factor b/library/compiler/amd64/alien.factor index ebee97ede1..60c19fdc1c 100644 --- a/library/compiler/amd64/alien.factor +++ b/library/compiler/amd64/alien.factor @@ -24,7 +24,8 @@ M: float-regs store-insn M: float-regs load-insn [ fastcall-regs nth swap stack@ ] keep MOVSS/LPD ; -M: stack-params load-insn 3drop ; +M: stack-params load-insn + drop >r R11 swap stack@ MOV r> stack@ R11 MOV ; M: %unbox generate-node ( vop -- ) drop diff --git a/library/freetype/freetype-gl.factor b/library/freetype/freetype-gl.factor index 76979c3c90..eefa8e5c0f 100644 --- a/library/freetype/freetype-gl.factor +++ b/library/freetype/freetype-gl.factor @@ -1,7 +1,7 @@ -! Copyright (C) 2005 Slava Pestov. -! See http://factor.sf.net/license.txt for BSD license. +! Copyright (C) 2005, 2006 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. USING: alien arrays errors hashtables io kernel -kernel-internals lists math namespaces opengl prettyprint +kernel-internals math namespaces opengl prettyprint sequences styles ; IN: freetype @@ -54,19 +54,19 @@ M: font = eq? ; init-freetype [ close-freetype ] cleanup ; inline : ttf-name ( font style -- name ) - cons H{ - { [[ "monospace" plain ]] "VeraMono" } - { [[ "monospace" bold ]] "VeraMoBd" } - { [[ "monospace" bold-italic ]] "VeraMoBI" } - { [[ "monospace" italic ]] "VeraMoIt" } - { [[ "sans-serif" plain ]] "Vera" } - { [[ "sans-serif" bold ]] "VeraBd" } - { [[ "sans-serif" bold-italic ]] "VeraBI" } - { [[ "sans-serif" italic ]] "VeraIt" } - { [[ "serif" plain ]] "VeraSe" } - { [[ "serif" bold ]] "VeraSeBd" } - { [[ "serif" bold-italic ]] "VeraBI" } - { [[ "serif" italic ]] "VeraIt" } + 2array H{ + { { "monospace" plain } "VeraMono" } + { { "monospace" bold } "VeraMoBd" } + { { "monospace" bold-italic } "VeraMoBI" } + { { "monospace" italic } "VeraMoIt" } + { { "sans-serif" plain } "Vera" } + { { "sans-serif" bold } "VeraBd" } + { { "sans-serif" bold-italic } "VeraBI" } + { { "sans-serif" italic } "VeraIt" } + { { "serif" plain } "VeraSe" } + { { "serif" bold } "VeraSeBd" } + { { "serif" bold-italic } "VeraBI" } + { { "serif" italic } "VeraIt" } } hash ; : ttf-path ( name -- string ) @@ -159,8 +159,8 @@ C: font ( handle -- font ) font-ascent swap glyph-hori-bearing-y - ft-floor 0 3array ; : glyph-texture-size ( glyph -- dim ) - dup glyph-bitmap-width next-power-of-2 - swap glyph-bitmap-rows next-power-of-2 0 3array ; + dup glyph-bitmap-width + swap glyph-bitmap-rows 0 3array ; : ( font char -- sprite ) #! Create a new display list of a rendered glyph. This diff --git a/library/math/pow.factor b/library/math/pow.factor index 5941246934..f5d56440c7 100644 --- a/library/math/pow.factor +++ b/library/math/pow.factor @@ -19,8 +19,6 @@ GENERIC: ^ ( z w -- z^w ) foldable : ^theta ( w abs arg -- theta ) >r >r >rect r> flog * swap r> * + ; inline -: 0^0 "0^0 is not defined" throw ; - : 0^ ( z w -- ) dup zero? [ 2drop 0.0/0.0 diff --git a/library/opengl/opengl-utils.factor b/library/opengl/opengl-utils.factor index c7848b7612..1321e303f6 100644 --- a/library/opengl/opengl-utils.factor +++ b/library/opengl/opengl-utils.factor @@ -1,5 +1,5 @@ -! Copyright (C) 2005 Slava Pestov. -! See http://factor.sf.net/license.txt for BSD license. +! Copyright (C) 2005, 2006 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. IN: opengl USING: alien errors kernel math namespaces opengl sdl sequences ; @@ -51,14 +51,14 @@ USING: alien errors kernel math namespaces opengl sdl sequences ; swap [ glMatrixMode glPushMatrix call ] keep glMatrixMode glPopMatrix ; inline +: top-left drop 0 0 glTexCoord2d 0 0 0 glVertex3d ; inline + +: top-right 1 0 glTexCoord2d first 0 0 glVertex3d ; inline + +: bottom-left 0 1 glTexCoord2d second 0 swap 0 glVertex3d ; inline + : gl-vertex first3 glVertex3d ; inline -: top-left drop 0 0 glTexCoord2d { 0 0 0 } gl-vertex ; inline - -: top-right 1 0 glTexCoord2d { 1 0 0 } v* gl-vertex ; inline - -: bottom-left 0 1 glTexCoord2d { 0 1 0 } v* gl-vertex ; inline - : bottom-right 1 1 glTexCoord2d gl-vertex ; inline : four-sides ( dim -- ) diff --git a/library/test/compiler/alien.factor b/library/test/compiler/alien.factor index ba650dd078..f19cfcbdfa 100644 --- a/library/test/compiler/alien.factor +++ b/library/test/compiler/alien.factor @@ -27,3 +27,9 @@ FUNCTION: double ffi_test_7 double x double y ; compiled FUNCTION: double ffi_test_8 double x float y double z float t int w ; compiled [ 19.0 ] [ 3.0 2.0 1.0 6.0 7 ffi_test_8 ] unit-test +FUNCTION: int ffi_test_9 int a int b int c int d int e int f int g ; compiled +[ 28 ] [ 1 2 3 4 5 6 7 ffi_test_9 ] unit-test + +FUNCTION: int ffi_test_10 int a int b double c int d float e int f int g int h ; compiled +[ -34 ] [ 1 2 3 4 5 6 7 8 ffi_test_10 ] unit-test + diff --git a/library/test/math/integer.factor b/library/test/math/integer.factor index 0bb99474a9..b8aa39ae99 100644 --- a/library/test/math/integer.factor +++ b/library/test/math/integer.factor @@ -67,7 +67,7 @@ USING: kernel math namespaces prettyprint test ; [ 134217728 dup + dup + dup + dup + dup + dup + unparse ] unit-test -[ 0 0 ^ ] unit-test-fails +[ 0.0/0.0 ] [ 0 0 ^ ] unit-test [ 1 ] [ 10 0 ^ ] unit-test [ 1/8 ] [ 1/2 3 ^ ] unit-test [ 1/8 ] [ 2 -3 ^ ] unit-test diff --git a/library/test/test.factor b/library/test/test.factor index 4665e80dd1..12f651ed97 100644 --- a/library/test/test.factor +++ b/library/test/test.factor @@ -109,4 +109,5 @@ SYMBOL: failures "compiler/generic" "compiler/bail-out" "compiler/linearizer" "compiler/intrinsics" "compiler/identities" "compiler/optimizer" + "compiler/alien" } run-tests ; diff --git a/native/ffi_test.c b/native/ffi_test.c index 3ff87c634c..79510a4b16 100644 --- a/native/ffi_test.c +++ b/native/ffi_test.c @@ -54,3 +54,15 @@ double ffi_test_8(double x, float y, double z, float t, int w) printf("ffi_test_8(%f,%f,%f,%f,%d)\n",x,y,z,t,w); return x * y + z * t + w; } + +int ffi_test_9(int a, int b, int c, int d, int e, int f, int g) +{ + printf("ffi_test_9(%d,%d,%d,%d,%d,%d,%d)\n",a,b,c,d,e,f,g); + return a + b + c + d + e + f + g; +} + +int ffi_test_10(int a, int b, double c, int d, float e, int f, int g, int h) +{ + printf("ffi_test_10(%d,%d,%f,%d,%f,%d,%d,%d)\n",a,b,c,d,e,f,g,h); + return a - b - c - d - e - f - g - h; +}