]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler.*, stack-checker.*: fixes to make the tests work on 32bit too
authorBjörn Lindqvist <bjourne@gmail.com>
Fri, 5 Aug 2016 14:44:19 +0000 (16:44 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Fri, 5 Aug 2016 14:44:19 +0000 (16:44 +0200)
basis/compiler/cfg/builder/alien/boxing/boxing-tests.factor
basis/stack-checker/alien/alien-tests.factor

index 648caf2fe75788bbd6998f9d242c5f6478af6aec..4d8cdb1464f99c159567ced136eefffaf8c494d7 100644 (file)
@@ -1,6 +1,6 @@
 USING: alien.c-types classes.struct compiler.cfg.builder.alien.boxing
-compiler.cfg.instructions compiler.test cpu.architecture kernel make
-system tools.test ;
+compiler.cfg.instructions compiler.cfg.registers compiler.test
+cpu.architecture kernel make system tools.test ;
 IN: compiler.cfg.builder.alien.boxing.tests
 
 STRUCT: some-struct
@@ -16,53 +16,109 @@ STRUCT: some-struct
     int base-type flatten-c-type
 ] unit-test
 
-cpu x86.64? [
+cpu x86.32?
+{
+    {
+        { int-rep t f }
+        { int-rep t f }
+        { int-rep t f }
+        { int-rep t f }
+    }
+} {
     {
-        { { int-rep f f } { int-rep f f } }
-    } [
-        some-struct base-type base-type flatten-c-type
-    ] unit-test
-] when
+        { int-rep f f }
+        { int-rep f f }
+    }
+} ? [
+    some-struct base-type base-type flatten-c-type
+] unit-test
 
 ! unbox
+cpu x86.32?
 {
+    { 1 }
+    { { int-rep f f } }
+    {
+        T{ ##unbox
+           { dst 1 }
+           { src 20 }
+           { unboxer "to_fixnum" }
+           { rep int-rep }
+         }
+    }
+} {
     { 20 }
     { { int-rep f f } }
-} [
-    20 int base-type unbox
+    { }
+} ? [
+    reset-vreg-counter [ 20 int base-type unbox ] { } make
 ] unit-test
 
-cpu x86.64? [
+cpu x86.32?
+{
+    { 2 3 4 5 }
     {
-        { 2 3 }
-        { { int-rep f f } { int-rep f f } }
-        V{
-            T{ ##unbox-any-c-ptr { dst 1 } { src 20 } }
-            T{ ##load-memory-imm
-               { dst 2 }
-               { base 1 }
-               { offset 0 }
-               { rep int-rep }
-             }
-            T{ ##load-memory-imm
-               { dst 3 }
-               { base 1 }
-               { offset 8 }
-               { rep int-rep }
-             }
-        }
-    } [
-        [ 20 some-struct base-type unbox ] V{ } make
-    ] cfg-unit-test
-] when
+        { int-rep t f }
+        { int-rep t f }
+        { int-rep t f }
+        { int-rep t f }
+    }
+    {
+        T{ ##unbox-any-c-ptr { dst 1 } { src 20 } }
+        T{ ##load-memory-imm
+           { dst 2 }
+           { base 1 }
+           { offset 0 }
+           { rep int-rep }
+         }
+        T{ ##load-memory-imm
+           { dst 3 }
+           { base 1 }
+           { offset 4 }
+           { rep int-rep }
+         }
+        T{ ##load-memory-imm
+           { dst 4 }
+           { base 1 }
+           { offset 8 }
+           { rep int-rep }
+         }
+        T{ ##load-memory-imm
+           { dst 5 }
+           { base 1 }
+           { offset 12 }
+           { rep int-rep }
+         }
+    }
+} {
+    { 2 3 }
+    { { int-rep f f } { int-rep f f } }
+    {
+        T{ ##unbox-any-c-ptr { dst 1 } { src 20 } }
+        T{ ##load-memory-imm
+           { dst 2 }
+           { base 1 }
+           { offset 0 }
+           { rep int-rep }
+         }
+        T{ ##load-memory-imm
+           { dst 3 }
+           { base 1 }
+           { offset 8 }
+           { rep int-rep }
+         }
+    }
+} ? [
+    [ 20 some-struct base-type unbox ] { } make
+] cfg-unit-test
 
 ! unbox-parameter
 {
     { 1 }
     { { int-rep f f } }
-    V{ T{ ##unbox-any-c-ptr { dst 1 } { src 77 } } }
+    { T{ ##unbox-any-c-ptr { dst 1 } { src 77 } } }
 } [
-    [ 77 c-string base-type unbox-parameter ] V{ } make
+    [ 77 c-string base-type unbox-parameter ] { } make
 ] cfg-unit-test
 
 ! unboxing is only needed on 32bit archs
@@ -70,7 +126,7 @@ cpu x86.32?
 {
     { 1 }
     { { int-rep f f } }
-    V{
+    {
         T{ ##unbox
            { dst 1 }
            { src 77 }
@@ -78,7 +134,8 @@ cpu x86.32?
            { rep int-rep }
         }
     }
-}
-{ { 77 } { { int-rep f f } } V{ } } ? [
-    [ 77 int base-type unbox-parameter ] V{ } make
+} {
+    { 77 } { { int-rep f f } } { }
+} ? [
+    [ 77 int base-type unbox-parameter ] { } make
 ] cfg-unit-test
index 6768bdb94c4dcc3c4a92c14cf2dbb3efac8a6376..8f360145104af545f52d823c290f7631f62766f4 100644 (file)
@@ -1,6 +1,7 @@
-USING: accessors alien.c-types alien.private kernel kernel.private
-math namespaces stack-checker.alien stack-checker.state
-stack-checker.values threads.private tools.test ;
+USING: accessors alien alien.c-types alien.private kernel
+kernel.private literals math namespaces stack-checker.alien
+stack-checker.state stack-checker.values system threads.private
+tools.test ;
 IN: stack-checker.alien.tests
 
 ! alien-inputs/outputs
@@ -31,7 +32,17 @@ IN: stack-checker.alien.tests
 ] unit-test
 
 ! wrap-callback-quot
-{
+${
+    cpu x86.32?
+    [
+        [
+            { integer integer } declare [ [ ] dip ] dip
+            "hello" >integer
+        ] [
+            dup current-callback eq?
+            [ drop ] [ wait-for-callback ] if
+        ] do-callback
+    ]
     [
         [
             { fixnum fixnum } declare [ [ ] dip ] dip
@@ -40,9 +51,8 @@ IN: stack-checker.alien.tests
             dup current-callback eq?
             [ drop ] [ wait-for-callback ] if
         ] do-callback
-    ]
+    ] ?
 } [
-    alien-node-params new
-    int >>return { int int } >>parameters
+    int { int int } cdecl alien-node-params boa
     [ "hello" ] wrap-callback-quot
 ] unit-test