Quoting JVM spec for ireturn: "Any other values on the operand stack of the current method are discarded."
Signed-off-by: Tomek Grabiec <tgrab...@gmail.com> --- include/jit/basic-block.h | 1 + include/vm/stack.h | 5 +++++ jit/basic-block.c | 10 ++++++++++ jit/exception-bc.c | 6 +----- jit/invoke-bc.c | 2 ++ 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/include/jit/basic-block.h b/include/jit/basic-block.h index 6aedff5..e50f6c6 100644 --- a/include/jit/basic-block.h +++ b/include/jit/basic-block.h @@ -89,6 +89,7 @@ unsigned char *bb_native_ptr(struct basic_block *bb); void resolution_block_init(struct resolution_block *block); bool branch_needs_resolution_block(struct basic_block *from, int idx); int bb_lookup_successor_index(struct basic_block *from, struct basic_block *to); +void clear_mimic_stack(struct basic_block *bb); #define for_each_basic_block(bb, bb_list) list_for_each_entry(bb, bb_list, bb_list_node) #define for_each_basic_block_reverse(bb, bb_list) list_for_each_entry_reverse(bb, bb_list, bb_list_node) diff --git a/include/vm/stack.h b/include/vm/stack.h index 12120ee..4132863 100644 --- a/include/vm/stack.h +++ b/include/vm/stack.h @@ -33,4 +33,9 @@ static inline bool stack_is_empty(struct stack * stack) return !stack->nr_elements; } +static inline void stack_clear(struct stack *stack) +{ + stack->nr_elements = 0; +} + #endif diff --git a/jit/basic-block.c b/jit/basic-block.c index 6a3075e..6de5c3f 100644 --- a/jit/basic-block.c +++ b/jit/basic-block.c @@ -254,3 +254,13 @@ bool branch_needs_resolution_block(struct basic_block *from, int idx) { return !list_is_empty(&from->resolution_blocks[idx].insns); } + +void clear_mimic_stack(struct basic_block *bb) +{ + struct expression *expr; + + while (!stack_is_empty(bb->mimic_stack)) { + expr = stack_pop(bb->mimic_stack); + expr_put(expr); + } +} diff --git a/jit/exception-bc.c b/jit/exception-bc.c index c0106cf..e1cd428 100644 --- a/jit/exception-bc.c +++ b/jit/exception-bc.c @@ -61,11 +61,7 @@ int convert_athrow(struct parse_context *ctx) * reference is not transferred to exception handlers in * BC2IR layer. */ - while (!stack_is_empty(mimic_stack)) { - struct expression *expr = stack_pop(mimic_stack); - - expr_put(expr); - } + clear_mimic_stack(ctx->bb); convert_statement(ctx, stmt); diff --git a/jit/invoke-bc.c b/jit/invoke-bc.c index 947f522..baed9cd 100644 --- a/jit/invoke-bc.c +++ b/jit/invoke-bc.c @@ -35,6 +35,7 @@ int convert_xreturn(struct parse_context *ctx) expr = stack_pop(ctx->bb->mimic_stack); return_stmt->return_value = &expr->node; convert_statement(ctx, return_stmt); + clear_mimic_stack(ctx->bb); return 0; } @@ -47,6 +48,7 @@ int convert_return(struct parse_context *ctx) return_stmt->return_value = NULL; convert_statement(ctx, return_stmt); + clear_mimic_stack(ctx->bb); return 0; } -- 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