diff options
Diffstat (limited to 'libjava/include')
-rw-r--r-- | libjava/include/java-cpool.h | 128 | ||||
-rw-r--r-- | libjava/include/java-interp.h | 21 | ||||
-rw-r--r-- | libjava/include/javaprims.h | 21 |
3 files changed, 65 insertions, 105 deletions
diff --git a/libjava/include/java-cpool.h b/libjava/include/java-cpool.h index f4d7ef99..b5e3ab3 100644 --- a/libjava/include/java-cpool.h +++ b/libjava/include/java-cpool.h @@ -31,142 +31,86 @@ details. */ #define JV_CONSTANT_ResolvedString (16L | 8L) #define JV_CONSTANT_ResolvedClass (16L | 7L) -/* We use the following two operations uniformly for all put/get operations - * in the runtime system (constant pool & stack), to assure that we keep - * everything in the same format. The idea is, that these should be inlined - * away, into just a simple store (for small data types, and a pair of stores - * if double or long has alignment greater than void *. On an 64-bit - * architecture, all operations should be simple stores; on a 32-bit - * architecture it depends on the alignment requirement for the specific - * type. */ - -template <class T> -static inline void _Jv_put (void *dst, T value) -{ -#if 0 - if (sizeof (T) == 8 && __alignof__ (T) > __alignof__ (void*)) - { - jint *v_dst = (jint*)(dst); - jint *v_src = (jint*)&value; - - v_dst[0] = v_src[0]; - v_dst[1] = v_src[1]; - } - else -#endif - { - *((T*) (dst)) = value; - } -} - -template <class T> -static inline T _Jv_get (void *src) -{ -#if 0 - if (sizeof (T) == 8 && __alignof__ (T) > __alignof__ (void*)) - { - T value; - jint *v_dst = (jint*)&value; - jint *v_src = (jint*)src; - - v_dst[0] = v_src[0]; - v_dst[1] = v_src[1]; - - return value; - } - else -#endif - { - return *((T*) (src)); - } -} - -/** needed to keep the CONSTANT_XXXRef & CONSTANT_NameAndType entries */ extern inline void -_Jv_storeIndexes (void **data, +_Jv_storeIndexes (_Jv_word *data, _Jv_ushort index0, _Jv_ushort index1) { - // accomodate 64bit machines... - if (sizeof (void*) == (2 * sizeof (jint))) - { - ((jint*)data)[0] = index0; - ((jint*)data)[1] = index0; - } - else - { - _Jv_put<jint>(data, ((jint)index0 << 16) | (jint)index1); - } + data->i = (((jint)index0) << 16) | (jint) index1; } extern inline void -_Jv_loadIndexes (const void **data, +_Jv_loadIndexes (const _Jv_word *data, _Jv_ushort& index0, _Jv_ushort& index1) { - if (sizeof (void*) == (2*sizeof (jint))) - { - index0 = ((jint*)data)[0]; - index0 = ((jint*)data)[1]; - } - else - { - jint udata = _Jv_get<jint>(data); + jint udata = data->i; - _Jv_uint uindex0 = ((udata >> 16) & 0xffff); - _Jv_uint uindex1 = udata & 0xffff; + _Jv_uint uindex0 = ((udata >> 16) & 0xffff); + _Jv_uint uindex1 = udata & 0xffff; - index0 = uindex0; - index1 = uindex1; - } + index0 = uindex0; + index1 = uindex1; } extern inline void -_Jv_storeFloat (void **data, jfloat f) +_Jv_storeFloat (_Jv_word *data, jfloat f) { - _Jv_put<jfloat>(data, f); + data->f = f; } extern inline jfloat -_Jv_loadFloat (void **data) +_Jv_loadFloat (_Jv_word *data) { - return _Jv_get<jfloat>(data); + return data->f; } extern inline void -_Jv_storeInt (void **data, jint i) +_Jv_storeInt (_Jv_word *data, jint i) { - _Jv_put<jint>(data, i); + data->i = i; } extern inline jint -_Jv_loadInt (void **data) +_Jv_loadInt (_Jv_word *data) { - return _Jv_get<jint>(data); + return data->i; } extern inline void -_Jv_storeLong (void **data, jlong l) +_Jv_storeLong (_Jv_word *data, jlong l) { - return _Jv_put<jlong>(data, l); + _Jv_word2 tmp; + tmp.l = l; + data[0].ia[0] = tmp.ia[0]; + data[1].ia[0] = tmp.ia[1]; } extern inline jlong -_Jv_loadLong (void **data) +_Jv_loadLong (_Jv_word *data) { - return _Jv_get<jlong>(data); + _Jv_word2 tmp; + tmp.ia[0] = data[0].ia[0]; + tmp.ia[1] = data[1].ia[0]; + return tmp.l; } extern inline void -_Jv_storeDouble (void **data, jdouble d) +_Jv_storeDouble (_Jv_word *data, jdouble d) { - _Jv_put<jdouble>(data, d); + _Jv_word2 tmp; + tmp.d = d; + data[0].ia[0] = tmp.ia[0]; + data[1].ia[0] = tmp.ia[1]; } extern inline jdouble -_Jv_loadDouble (void **data) +_Jv_loadDouble (_Jv_word *data) { - return _Jv_get<jdouble> (data); + _Jv_word2 tmp; + tmp.ia[0] = data[0].ia[0]; + tmp.ia[1] = data[1].ia[0]; + return tmp.d; } diff --git a/libjava/include/java-interp.h b/libjava/include/java-interp.h index 70feec1..ffd53a8 100644 --- a/libjava/include/java-interp.h +++ b/libjava/include/java-interp.h @@ -105,11 +105,11 @@ class _Jv_InterpMethod { void *ncode (); void continue1 (_Jv_InterpMethodInvocation *inv); - static void run_normal (ffi_cif*, void*, void**, void*); - static void run_synch_object (ffi_cif*, void*, void**, void*); - static void run_synch_class (ffi_cif*, void*, void**, void*); + static void run_normal (ffi_cif*, void*, ffi_raw*, void*); + static void run_synch_object (ffi_cif*, void*, ffi_raw*, void*); + static void run_synch_class (ffi_cif*, void*, ffi_raw*, void*); - inline jobject run (ffi_cif*, void*, void**, + inline jobject run (ffi_cif*, void*, ffi_raw*, _Jv_InterpMethodInvocation*); bool find_exception (jobject ex, @@ -123,21 +123,16 @@ class _Jv_InterpMethod { friend class gnu::gcj::runtime::MethodInvocation; friend void _Jv_PrepareClass(jclass); - - friend void _Jv_callInterpretedMethod (ffi_cif*, - void*, - void **, - void*); }; class _Jv_InterpMethodInvocation { _Jv_InterpMethod *running; - void **sp; + _Jv_word *sp; unsigned char *pc; - void* state[0]; + _Jv_word state[0]; - void** stack_base () { return &state[0]; } - void** local_base () { return &state[running->max_stack]; } + _Jv_word* stack_base () { return &state[0]; } + _Jv_word* local_base () { return &state[running->max_stack]; } friend class _Jv_InterpMethod; }; diff --git a/libjava/include/javaprims.h b/libjava/include/javaprims.h index 9d8c0a6..ef87519 100644 --- a/libjava/include/javaprims.h +++ b/libjava/include/javaprims.h @@ -261,6 +261,27 @@ extern "C" void _Jv_Free (void*); typedef unsigned short _Jv_ushort __attribute__((__mode__(__HI__))); typedef unsigned int _Jv_uint __attribute__((__mode__(__SI__))); +typedef union { + jobject o; + jint i; // Also stores smaller integral types. + jfloat f; + jint ia[1]; // Half of _Jv_word2. + void* p; + + // these are things we will store in the constant + jclass clazz; + jstring string; + struct _Jv_Field *field; + struct _Jv_Utf8Const *utf8; + struct _Jv_ResolvedMethod *rmethod; +} _Jv_word; + +typedef union { + jint ia[2]; + jlong l; + jdouble d; +} _Jv_word2; + struct _Jv_Utf8Const { _Jv_ushort hash; |