-/* vm_array_store_int **********************************************************
-
- Helper function to store an integer into the argument array, taking
- care of architecture specific issues.
-
-*******************************************************************************/
-
-static void vm_array_store_int(uint64_t *array, paramdesc *pd, int32_t value)
-{
- int32_t index;
-
- if (!pd->inmemory) {
- index = pd->index;
- array[index] = (int64_t) value;
- }
- else {
- index = ARG_CNT + pd->index;
-#if SIZEOF_VOID_P == 8
- array[index] = (int64_t) value;
-#else
-# if WORDS_BIGENDIAN == 1
- array[index] = ((int64_t) value) << 32;
-# else
- array[index] = (int64_t) value;
-# endif
-#endif
- }
-}
-
-
-/* vm_array_store_lng **********************************************************
-
- Helper function to store a long into the argument array, taking
- care of architecture specific issues.
-
-*******************************************************************************/
-
-static void vm_array_store_lng(uint64_t *array, paramdesc *pd, int64_t value)
-{
- int32_t index;
-
-#if SIZEOF_VOID_P == 8
- if (!pd->inmemory)
- index = pd->index;
- else
- index = ARG_CNT + pd->index;
-
- array[index] = value;
-#else
- if (!pd->inmemory) {
- /* move low and high 32-bits into it's own argument slot */
-
- index = GET_LOW_REG(pd->index);
- array[index] = value & 0x00000000ffffffff;
-
- index = GET_HIGH_REG(pd->index);
- array[index] = value >> 32;
- }
- else {
- index = ARG_CNT + pd->index;
- array[index] = value;
- }
-#endif
-}
-
-
-/* vm_array_store_flt **********************************************************
-
- Helper function to store a float into the argument array, taking
- care of architecture specific issues.
-
-*******************************************************************************/
-
-static void vm_array_store_flt(uint64_t *array, paramdesc *pd, uint64_t value)
-{
- int32_t index;
-
- if (!pd->inmemory) {
-#if defined(SUPPORT_PASS_FLOATARGS_IN_INTREGS)
- index = pd->index;
-#else
- index = INT_ARG_CNT + pd->index;
-#endif
-#if WORDS_BIGENDIAN == 1 && !defined(__POWERPC__) && !defined(__POWERPC64__) && !defined(__S390__)
- array[index] = value >> 32;
-#else
- array[index] = value;
-#endif
- }
- else {
- index = ARG_CNT + pd->index;
-#if defined(__SPARC_64__)
- array[index] = value >> 32;
-#else
- array[index] = value;
-#endif
- }
-}
-
-
-/* vm_array_store_dbl **********************************************************
-
- Helper function to store a double into the argument array, taking
- care of architecture specific issues.
-
-*******************************************************************************/
-
-static void vm_array_store_dbl(uint64_t *array, paramdesc *pd, uint64_t value)
-{
- int32_t index;
-
- if (!pd->inmemory) {
-#if SIZEOF_VOID_P != 8 && defined(SUPPORT_PASS_FLOATARGS_IN_INTREGS)
- index = GET_LOW_REG(pd->index);
- array[index] = value & 0x00000000ffffffff;
-
- index = GET_HIGH_REG(pd->index);
- array[index] = value >> 32;
-#else
- index = INT_ARG_CNT + pd->index;
- array[index] = value;
-#endif
- }
- else {
- index = ARG_CNT + pd->index;
- array[index] = value;
- }
-}
-
-
-/* vm_array_store_adr **********************************************************
-
- Helper function to store an address into the argument array, taking
- care of architecture specific issues.
-
-*******************************************************************************/
-
-static void vm_array_store_adr(uint64_t *array, paramdesc *pd, void *value)
-{
- int32_t index;
-
- if (!pd->inmemory) {
-#if defined(HAS_ADDRESS_REGISTER_FILE)
- /* When the architecture has address registers, place them
- after integer and float registers. */
-
- index = INT_ARG_CNT + FLT_ARG_CNT + pd->index;
-#else
- index = pd->index;
-#endif
- array[index] = (uint64_t) (intptr_t) value;
- }
- else {
- index = ARG_CNT + pd->index;
-#if SIZEOF_VOID_P == 8
- array[index] = (uint64_t) (intptr_t) value;
-#else
-# if WORDS_BIGENDIAN == 1
- array[index] = ((uint64_t) (intptr_t) value) << 32;
-# else
- array[index] = (uint64_t) (intptr_t) value;
-# endif
-#endif
- }
-}
-
-
-/* vm_array_from_valist ********************************************************
-
- XXX
-
-*******************************************************************************/
-
-uint64_t *vm_array_from_valist(methodinfo *m, java_handle_t *o, va_list ap)
-{
- methoddesc *md;
- paramdesc *pd;
- typedesc *td;
- uint64_t *array;
- int32_t i;
- imm_union value;
-
- /* get the descriptors */
-
- md = m->parseddesc;
- pd = md->params;
- td = md->paramtypes;
-
- /* allocate argument array */
-
- array = DMNEW(uint64_t, INT_ARG_CNT + FLT_ARG_CNT + md->memuse);
-
- /* if method is non-static fill first block and skip `this' pointer */
-
- i = 0;
-
- if (o != NULL) {
- /* the `this' pointer */
- vm_array_store_adr(array, pd, o);
-
- pd++;
- td++;
- i++;
- }
-
- for (; i < md->paramcount; i++, pd++, td++) {
- switch (td->type) {
- case TYPE_INT:
- value.i = va_arg(ap, int32_t);
- vm_array_store_int(array, pd, value.i);
- break;
-
- case TYPE_LNG:
- value.l = va_arg(ap, int64_t);
- vm_array_store_lng(array, pd, value.l);
- break;
-
- case TYPE_FLT:
-#if defined(__ALPHA__) || defined(__POWERPC__) || defined(__POWERPC64__)
- /* This is required to load the correct float value in
- assembler code. */
-
- value.d = (double) va_arg(ap, double);
-#else
- value.f = (float) va_arg(ap, double);
-#endif
- vm_array_store_flt(array, pd, value.l);
- break;
-
- case TYPE_DBL:
- value.d = va_arg(ap, double);
- vm_array_store_dbl(array, pd, value.l);
- break;
-
- case TYPE_ADR:
- value.a = va_arg(ap, void*);
- vm_array_store_adr(array, pd, value.a);
- break;
- }
- }
-
- return array;
-}
-