When method returns char, byte, boolean or short then int value should
be pushed on mimic stack. Primitive types listed above do not occur
in java stack. They are always converted to int implicitly.

This caused failed assertion for the following method:

jato: jit/typeconv-bc.c:56: convert_truncation: Assertion failed 
`from_expression->vm_type == J_INT'.

[main] TRACE: org/jpc/emulator/pci/AbstractPCIDevice.configReadWord(I)S
[main] Length: 30
[main] Code:
[main] [ 0000 ] 2a 1b 04 60 b6 00 0b 93  3d 1c 10 08 78 93 3d 1c
[main] [ 0016 ] 11 00 ff 2a 1b b6 00 0b  7e 80 93 3d 1c ac
[main]
[main]
[main] Code:
[main]    [ 0   ]  0x2a  aload_0
[main]    [ 1   ]  0x1b  iload_1
[main]    [ 2   ]  0x04  iconst_1
[main]    [ 3   ]  0x60  iadd
[main]    [ 4   ]  0xb6  invokevirtual  0x00 0x0b // 
org/jpc/emulator/pci/AbstractPCIDevice.configReadByte(I)B
[main]    [ 7   ]  0x93  i2s

Signed-off-by: Tomek Grabiec <tgrab...@gmail.com>
---
 jit/expression.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/jit/expression.c b/jit/expression.c
index 12fe984..78f3256 100644
--- a/jit/expression.c
+++ b/jit/expression.c
@@ -426,7 +426,13 @@ struct expression *instance_field_expr(enum vm_type 
vm_type,
 static struct expression *
 __invoke_expr(enum expression_type expr_type, enum vm_type vm_type, struct 
vm_method *target_method)
 {
-       struct expression *expr = alloc_expression(expr_type, vm_type);
+       struct expression *expr;
+
+       if (vm_type == J_CHAR || vm_type == J_BYTE ||
+           vm_type == J_SHORT || vm_type == J_BOOLEAN)
+               vm_type = J_INT;
+
+       expr = alloc_expression(expr_type, vm_type);
 
        if (expr)
                expr->target_method = target_method;
-- 
1.6.0.6


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to