Those instructions are supposed to push J_INT value on mimic-stack.
Signed-off-by: Tomek Grabiec <[email protected]>
---
jit/object-bc.c | 10 +++++++++-
regression/jvm/ArrayTest.java | 14 ++++++++++++++
2 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/jit/object-bc.c b/jit/object-bc.c
index 0604e7c..b88423c 100644
--- a/jit/object-bc.c
+++ b/jit/object-bc.c
@@ -176,6 +176,8 @@ static int convert_array_load(struct parse_context *ctx,
enum vm_type type)
struct expression *arrayref_pure;
struct expression *index_pure;
+ assert(type != J_BOOLEAN);
+
index = stack_pop(ctx->bb->mimic_stack);
arrayref = null_check_expr(stack_pop(ctx->bb->mimic_stack));
if (!arrayref)
@@ -195,7 +197,13 @@ static int convert_array_load(struct parse_context *ctx,
enum vm_type type)
index_pure = get_pure_expr(ctx, index);
src_expr = array_deref_expr(type, arrayref_pure, index_pure);
- dest_expr = temporary_expr(type, ctx->cu);
+ /*
+ * baload, caload and saload should push int value on stack.
+ */
+ if (type == J_BYTE || type == J_CHAR || type == J_SHORT)
+ dest_expr = temporary_expr(J_INT, ctx->cu);
+ else
+ dest_expr = temporary_expr(type, ctx->cu);
store_stmt->store_src = &src_expr->node;
store_stmt->store_dest = &dest_expr->node;
diff --git a/regression/jvm/ArrayTest.java b/regression/jvm/ArrayTest.java
index 6c85ebc..f60a642 100644
--- a/regression/jvm/ArrayTest.java
+++ b/regression/jvm/ArrayTest.java
@@ -163,6 +163,19 @@ public class ArrayTest extends TestCase {
assertTrue(arr2.getClass().equals(big_arr[0][0].getClass()));
}
+ public static void testByteCharShortLoadPushesInt() {
+ char c[] = { 0 };
+ byte b[] = { 0 };
+ short s[] = { 0 };
+
+ // caload, baload, saload should push INT on stack. If
+ // they don't the following will trigger assertion
+ // failure in convert_truncation().
+ takeInt( (byte) c[0] );
+ takeInt( (char) b[0] );
+ takeInt( (byte) s[0] );
+ }
+
public static void main(String args[]) {
testEmptyStaticArrayLength();
testEmptyArrayLength();
@@ -181,5 +194,6 @@ public class ArrayTest extends TestCase {
testDoubleElementLoadStore();
testArrayClass();
+ testByteCharShortLoadPushesInt();
}
}
--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/jatovm-devel