It was using convert_args() to encapsulate array dimensions but now convert_args() got so tightly related to java method invocations that it can no longer be used. convert_native_args() is introduced to encapsulate dimensions which are later passed to native VM functions.
Signed-off-by: Tomek Grabiec <tgrab...@gmail.com> --- include/jit/args.h | 2 ++ jit/args.c | 38 ++++++++++++++++++++++++++++++++++++++ jit/object-bc.c | 4 +--- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/include/jit/args.h b/include/jit/args.h index 0047925..b2fdd5a 100644 --- a/include/jit/args.h +++ b/include/jit/args.h @@ -15,6 +15,8 @@ struct expression *insert_arg(struct expression *root, struct expression *convert_args(struct stack *mimic_stack, unsigned long nr_args, struct vm_method *method); +struct expression *convert_native_args(struct stack *mimic_stack, + unsigned long nr_args); const char *parse_method_args(const char *type_str, enum vm_type *vmtype); #ifndef CONFIG_ARGS_MAP diff --git a/jit/args.c b/jit/args.c index 5d5a018..3da92a8 100644 --- a/jit/args.c +++ b/jit/args.c @@ -159,6 +159,44 @@ struct expression *convert_args(struct stack *mimic_stack, return args_list; } +static struct expression * +insert_native_arg(struct expression *root, struct expression *expr) +{ + struct expression *_expr; + + _expr = arg_expr(expr); + _expr->bytecode_offset = expr->bytecode_offset; + + if (!root) + return _expr; + + return args_list_expr(root, _expr); +} + +/** + * This function prepares argument list that will be used + * with the native VM call. All arguments are passed on stack. + */ +struct expression * +convert_native_args(struct stack *mimic_stack, unsigned long nr_args) +{ + struct expression *args_list = NULL; + unsigned long i; + + if (nr_args == 0) { + args_list = no_args_expr(); + goto out; + } + + for (i = 0; i < nr_args; i++) { + struct expression *expr = stack_pop(mimic_stack); + args_list = insert_native_arg(args_list, expr); + } + + out: + return args_list; +} + const char *parse_method_args(const char *type_str, enum vm_type *vmtype) { char type_name[] = { "X" }; diff --git a/jit/object-bc.c b/jit/object-bc.c index f74868e..2a48fb1 100644 --- a/jit/object-bc.c +++ b/jit/object-bc.c @@ -444,12 +444,10 @@ int convert_multianewarray(struct parse_context *ctx) unsigned long type_idx; unsigned char dimension; struct vm_class *class; - struct vm_method *method; type_idx = bytecode_read_u16(ctx->buffer); dimension = bytecode_read_u8(ctx->buffer); class = vm_class_resolve_class(ctx->cu->method->class, type_idx); - method = ctx->cu->method; if (!class) return warn("out of memory"), -ENOMEM; @@ -457,7 +455,7 @@ int convert_multianewarray(struct parse_context *ctx) if (!arrayref) return warn("out of memory"), -ENOMEM; - args_list = convert_args(ctx->bb->mimic_stack, dimension, method); + args_list = convert_native_args(ctx->bb->mimic_stack, dimension); size_check = multiarray_size_check_expr(args_list); if (!size_check) -- 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