* src/vm/jit/jit.h (stackptr): Removed.
[cacao.git] / src / vm / jit / argument.c
index 9c27cb3b517e587fd490e5da5fd1e85ad04ffe7c..8705e6be13cedcb8e1a9c0302df135e706b62d19 100644 (file)
@@ -36,7 +36,7 @@
 
 #include "native/llni.h"
 
-#include "vm/exceptions.h"
+#include "vm/array.h"
 #include "vm/global.h"
 #include "vm/primitive.h"
 #include "vm/resolve.h"
@@ -374,7 +374,8 @@ static void argument_vmarray_store_adr(uint64_t *array, paramdesc *pd, java_hand
 
 /* argument_vmarray_from_valist ************************************************
 
-   XXX
+   Creates an argument array which can be passed to asm_vm_call_method.
+   The array is created from the passed valist.
 
    ATTENTION: This function has to be used outside the native world.
 
@@ -454,7 +455,8 @@ uint64_t *argument_vmarray_from_valist(methodinfo *m, java_handle_t *o, va_list
 
 /* argument_vmarray_from_jvalue ************************************************
 
-   XXX
+   Creates an argument array which can be passed to asm_vm_call_method.
+   The array is created from the passed jvalue array.
 
    ATTENTION: This function has to be used outside the native world.
 
@@ -516,7 +518,7 @@ uint64_t *argument_vmarray_from_jvalue(methodinfo *m, java_handle_t *o,
                        break;
 
                case TYPE_ADR: 
-                       argument_vmarray_store_adr(array, pd, args[j].l);
+                       argument_vmarray_store_adr(array, pd, (java_handle_t *) args[j].l);
                        break;
                }
        }
@@ -527,10 +529,16 @@ uint64_t *argument_vmarray_from_jvalue(methodinfo *m, java_handle_t *o,
 
 /* argument_vmarray_from_objectarray *******************************************
 
-   XXX
+   Creates an argument array which can be passed to asm_vm_call_method.
+   The array is created from the passed objectarray of boxed values.
 
    ATTENTION: This function has to be used outside the native world.
 
+   RETURN VALUE:
+      NULL.........indicates an error while creating the array
+      (-1).........no error, but an empty array
+      otherwise....array containing the argument values
+
 *******************************************************************************/
 
 uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o,
@@ -557,6 +565,14 @@ uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o,
 
        array = DMNEW(uint64_t, INT_ARG_CNT + FLT_ARG_CNT + md->memuse);
 
+       /* The array can be NULL if we don't have any arguments to pass
+          and the architecture does not have any argument registers
+          (e.g. i386).  In that case we return (-1) to indicate
+          that no exception should be thrown */
+
+       if (array == NULL)
+               array = (uint64_t *)(-1);
+
        /* if method is non-static fill first block and skip `this' pointer */
 
        i = 0;
@@ -571,14 +587,14 @@ uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o,
        }
 
        for (j = 0; i < md->paramcount; i++, j++, pd++, td++) {
-               LLNI_objectarray_element_get(params, j, param);
+               /* XXX This function can throw an exception, which should not happend
+                  here, since we are outside the nativeworld. */
+               param = array_objectarray_element_get(params, j);
 
                switch (td->type) {
                case TYPE_INT:
-                       if (param == NULL) {
-                               exceptions_throw_illegalargumentexception();
+                       if (param == NULL)
                                return NULL;
-                       }
 
                        /* convert the value according to its declared type */
 
@@ -592,7 +608,6 @@ uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o,
                                        /* This type is OK. */
                                        break;
                                default:
-                                       exceptions_throw_illegalargumentexception();
                                        return NULL;
                                }
                                break;
@@ -603,7 +618,6 @@ uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o,
                                        /* This type is OK. */
                                        break;
                                default:
-                                       exceptions_throw_illegalargumentexception();
                                        return NULL;
                                }
                                break;
@@ -614,7 +628,6 @@ uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o,
                                        /* This type is OK. */
                                        break;
                                default:
-                                       exceptions_throw_illegalargumentexception();
                                        return NULL;
                                }
                                break;
@@ -626,7 +639,6 @@ uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o,
                                        /* These types are OK. */
                                        break;
                                default:
-                                       exceptions_throw_illegalargumentexception();
                                        return NULL;
                                }
                                break;
@@ -639,7 +651,6 @@ uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o,
                                        /* These types are OK. */
                                        break;
                                default:
-                                       exceptions_throw_illegalargumentexception();
                                        return NULL;
                                }
                                break;
@@ -654,10 +665,8 @@ uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o,
                        break;
 
                case TYPE_LNG:
-                       if (param == NULL) {
-                               exceptions_throw_illegalargumentexception();
+                       if (param == NULL)
                                return NULL;
-                       }
 
                        LLNI_class_get(param, c);
                        type = primitive_type_get_by_wrapperclass(c);
@@ -672,7 +681,6 @@ uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o,
                                /* These types are OK. */
                                break;
                        default:
-                               exceptions_throw_illegalargumentexception();
                                return NULL;
                        }
 
@@ -681,10 +689,8 @@ uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o,
                        break;
 
                case TYPE_FLT:
-                       if (param == NULL) {
-                               exceptions_throw_illegalargumentexception();
+                       if (param == NULL)
                                return NULL;
-                       }
 
                        LLNI_class_get(param, c);
                        type = primitive_type_get_by_wrapperclass(c);
@@ -696,7 +702,6 @@ uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o,
                                /* This type is OK. */
                                break;
                        default:
-                               exceptions_throw_illegalargumentexception();
                                return NULL;
                        }
 
@@ -705,10 +710,8 @@ uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o,
                        break;
 
                case TYPE_DBL:
-                       if (param == NULL) {
-                               exceptions_throw_illegalargumentexception();
+                       if (param == NULL)
                                return NULL;
-                       }
 
                        LLNI_class_get(param, c);
                        type = primitive_type_get_by_wrapperclass(c);
@@ -721,7 +724,6 @@ uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o,
                                /* These types are OK. */
                                break;
                        default:
-                               exceptions_throw_illegalargumentexception();
                                return NULL;
                        }
 
@@ -735,16 +737,12 @@ uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o,
 
                        if (param != NULL) {
                                if (td->arraydim > 0) {
-                                       if (!builtin_arrayinstanceof(param, c)) {
-                                               exceptions_throw_illegalargumentexception();
+                                       if (!builtin_arrayinstanceof(param, c))
                                                return NULL;
-                                       }
                                }
                                else {
-                                       if (!builtin_instanceof(param, c)) {
-                                               exceptions_throw_illegalargumentexception();
+                                       if (!builtin_instanceof(param, c))
                                                return NULL;
-                                       }
                                }
                        }