The expression that was popped from mimic-stack was used as an argument
of STMT_CHECKCAST and it was pushed back onto mimic-stack. This led
to double-evaluation of the expression. Solution for that is to
save the expression's result to a temporary and use this temporary
in both places.

Signed-off-by: Tomek Grabiec <tgrab...@gmail.com>
---
 jit/object-bc.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/jit/object-bc.c b/jit/object-bc.c
index a194a7b..3866a64 100644
--- a/jit/object-bc.c
+++ b/jit/object-bc.c
@@ -485,12 +485,12 @@ int convert_instanceof(struct parse_context *ctx)
 
 int convert_checkcast(struct parse_context *ctx)
 {
-       struct expression *object_ref;
+       struct expression *object_ref_tmp;
        struct vm_class *class;
        struct statement *checkcast_stmt;
        unsigned long type_idx;
 
-       object_ref = stack_pop(ctx->bb->mimic_stack);
+       object_ref_tmp = copy_expr_value(ctx, stack_pop(ctx->bb->mimic_stack));
 
        type_idx = bytecode_read_u16(ctx->buffer);
        class = vm_class_resolve_class(ctx->cu->method->class, type_idx);
@@ -502,11 +502,10 @@ int convert_checkcast(struct parse_context *ctx)
                return -ENOMEM;
 
        checkcast_stmt->checkcast_class = class;
-       checkcast_stmt->checkcast_ref = &object_ref->node;
+       checkcast_stmt->checkcast_ref = &object_ref_tmp->node;
 
-       expr_get(object_ref);
        convert_statement(ctx, checkcast_stmt);
-       convert_expression(ctx, object_ref);
+       convert_expression(ctx, expr_get(object_ref_tmp));
 
        return 0;
 }
-- 
1.6.0.6


------------------------------------------------------------------------------
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to