This fixes a bug in type_to_scale() where for element types less than
word size it returned 0 or 1 scale exponent. This caused that during
store to an array element the following elements were overwriten. This
caused that this code didn't work:
{
byte x[] = new byte[2];
x[1] = 1;
x[0] = 2;
assertEquals(1, x[1]);
}
Signed-off-by: Tomek Grabiec <[email protected]>
---
arch/x86/insn-selector_32.brg | 28 +++++++++++-----------------
1 files changed, 11 insertions(+), 17 deletions(-)
diff --git a/arch/x86/insn-selector_32.brg b/arch/x86/insn-selector_32.brg
index 2d50ea6..6346454 100644
--- a/arch/x86/insn-selector_32.brg
+++ b/arch/x86/insn-selector_32.brg
@@ -51,25 +51,19 @@ static void select_exception_test(struct basic_block *bb,
static unsigned char type_to_scale(enum vm_type vm_type)
{
- unsigned char scale;
-
- switch (vm_type) {
- case J_BYTE:
- case J_CHAR:
- scale = 0;
- break;
- case J_SHORT:
- scale = 1;
- break;
- case J_INT:
- case J_REFERENCE:
- scale = 2;
- break;
+ /* Currently we can store not less than machine word at once */
+ switch (get_vmtype_size(vm_type)) {
+ case 1:
+ return 0;
+ case 2:
+ return 1;
+ case 4:
+ return 2;
+ case 8:
+ return 3;
default:
- assert(!"Not supported yet");
+ error("Invalid type size");
}
-
- return scale;
}
static void method_args_cleanup(struct basic_block *bb, struct tree_node *tree,
--
1.6.0.6
------------------------------------------------------------------------------
_______________________________________________
Jatovm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jatovm-devel