From: Bernhard Urban Date: Wed, 25 Apr 2012 15:13:49 +0000 (+0200) Subject: callconv: once again, fail... X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=mate.git;a=commitdiff_plain;h=35124f75aedd2970b59a5b57bff250efbb04a965 callconv: once again, fail... the arguments were in the wrong order, which wasn't covered by the test cases, because I use addition everywhere... *d'oh* --- diff --git a/Makefile b/Makefile index 3c004ec..4a5863d 100644 --- a/Makefile +++ b/Makefile @@ -48,6 +48,8 @@ test: mate $(CLASS_FILES) @printf "should be: 0x%08x\n" 0x1337 ./$< tests/CallConv2 | grep mainresult @printf "should be: 0x%08x\n" 0x1337 + ./$< tests/CallConv3 | grep mainresult + @printf "should be: 0x%08x 0x%08x 0x%08x 0x%08x\n" 0x1000 0x300 0x30 0x7 ./$< tests/Instance1 | grep mainresult @printf "should be: 0x%08x 0x%08x\n" 0x55 0x11 ./$< tests/Instance2 | grep mainresult diff --git a/Mate/X86CodeGen.hs b/Mate/X86CodeGen.hs index 57ffdff..70ee013 100644 --- a/Mate/X86CodeGen.hs +++ b/Mate/X86CodeGen.hs @@ -294,7 +294,7 @@ emitFromBB method cls hmap = do cArgs x = if (x' >= thisMethodArgCnt) -- TODO(bernhard): maybe s/(-4)/(-8)/ then fromIntegral $ (-4) * (x' - thisMethodArgCnt + 1) - else 8 + (4 * x') + else 4 + (thisMethodArgCnt * 4) - (4 * x') where x' = fromIntegral x cArgs_ :: IMM -> Word32 diff --git a/tests/CallConv3.java b/tests/CallConv3.java new file mode 100644 index 0000000..d5fa6da --- /dev/null +++ b/tests/CallConv3.java @@ -0,0 +1,23 @@ +package tests; + +public class CallConv3 { + public static void main(String []args) { + manyVars_A(0x1000, 0x300, 0x30, 0x7); + manyVars_B(0x1000, 0x300, 0x30, 0x7); + manyVars_C(0x1000, 0x300, 0x30, 0x7); + manyVars_D(0x1000, 0x300, 0x30, 0x7); + } + + public static int manyVars_A(int a, int b, int c, int d) { + return a; + } + public static int manyVars_B(int a, int b, int c, int d) { + return b; + } + public static int manyVars_C(int a, int b, int c, int d) { + return c; + } + public static int manyVars_D(int a, int b, int c, int d) { + return d; + } +}