compiler.*, stack-checker.*: fixes to make the tests work on 32bit too

char-rename
Björn Lindqvist 2016-08-05 16:44:19 +02:00
parent 76139dca56
commit a79309680c
2 changed files with 117 additions and 50 deletions

View File

@ -1,6 +1,6 @@
USING: alien.c-types classes.struct compiler.cfg.builder.alien.boxing USING: alien.c-types classes.struct compiler.cfg.builder.alien.boxing
compiler.cfg.instructions compiler.test cpu.architecture kernel make compiler.cfg.instructions compiler.cfg.registers compiler.test
system tools.test ; cpu.architecture kernel make system tools.test ;
IN: compiler.cfg.builder.alien.boxing.tests IN: compiler.cfg.builder.alien.boxing.tests
STRUCT: some-struct STRUCT: some-struct
@ -16,27 +16,84 @@ STRUCT: some-struct
int base-type flatten-c-type int base-type flatten-c-type
] unit-test ] unit-test
cpu x86.64? [ cpu x86.32?
{
{ { int-rep f f } { int-rep f f } }
} [
some-struct base-type base-type flatten-c-type
] unit-test
] when
! unbox
{ {
{ 20 } {
{ { int-rep f f } } { int-rep t f }
} [ { int-rep t f }
20 int base-type unbox { 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 ] unit-test
cpu x86.64? [ ! 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 } }
{ }
} ? [
reset-vreg-counter [ 20 int base-type unbox ] { } make
] unit-test
cpu x86.32?
{
{ 2 3 4 5 }
{
{ 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 } { 2 3 }
{ { int-rep f f } { int-rep f f } } { { int-rep f f } { int-rep f f } }
V{ {
T{ ##unbox-any-c-ptr { dst 1 } { src 20 } } T{ ##unbox-any-c-ptr { dst 1 } { src 20 } }
T{ ##load-memory-imm T{ ##load-memory-imm
{ dst 2 } { dst 2 }
@ -51,18 +108,17 @@ cpu x86.64? [
{ rep int-rep } { rep int-rep }
} }
} }
} [ } ? [
[ 20 some-struct base-type unbox ] V{ } make [ 20 some-struct base-type unbox ] { } make
] cfg-unit-test ] cfg-unit-test
] when
! unbox-parameter ! unbox-parameter
{ {
{ 1 } { 1 }
{ { int-rep f f } } { { 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 ] cfg-unit-test
! unboxing is only needed on 32bit archs ! unboxing is only needed on 32bit archs
@ -70,7 +126,7 @@ cpu x86.32?
{ {
{ 1 } { 1 }
{ { int-rep f f } } { { int-rep f f } }
V{ {
T{ ##unbox T{ ##unbox
{ dst 1 } { dst 1 }
{ src 77 } { src 77 }
@ -78,7 +134,8 @@ cpu x86.32?
{ rep int-rep } { rep int-rep }
} }
} }
} } {
{ { 77 } { { int-rep f f } } V{ } } ? [ { 77 } { { int-rep f f } } { }
[ 77 int base-type unbox-parameter ] V{ } make } ? [
[ 77 int base-type unbox-parameter ] { } make
] cfg-unit-test ] cfg-unit-test

View File

@ -1,6 +1,7 @@
USING: accessors alien.c-types alien.private kernel kernel.private USING: accessors alien alien.c-types alien.private kernel
math namespaces stack-checker.alien stack-checker.state kernel.private literals math namespaces stack-checker.alien
stack-checker.values threads.private tools.test ; stack-checker.state stack-checker.values system threads.private
tools.test ;
IN: stack-checker.alien.tests IN: stack-checker.alien.tests
! alien-inputs/outputs ! alien-inputs/outputs
@ -31,7 +32,17 @@ IN: stack-checker.alien.tests
] unit-test ] unit-test
! wrap-callback-quot ! 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 { fixnum fixnum } declare [ [ ] dip ] dip
@ -40,9 +51,8 @@ IN: stack-checker.alien.tests
dup current-callback eq? dup current-callback eq?
[ drop ] [ wait-for-callback ] if [ drop ] [ wait-for-callback ] if
] do-callback ] do-callback
] ] ?
} [ } [
alien-node-params new int { int int } cdecl alien-node-params boa
int >>return { int int } >>parameters
[ "hello" ] wrap-callback-quot [ "hello" ] wrap-callback-quot
] unit-test ] unit-test