diff options
author | Bryce McKinlay <mckinlay@redhat.com> | 2006-02-09 23:59:30 +0000 |
---|---|---|
committer | Bryce McKinlay <bryce@gcc.gnu.org> | 2006-02-09 23:59:30 +0000 |
commit | a286e145de1b08b1a73d4efe03d36375fa698273 (patch) | |
tree | bd4f0f64a0edeb902ab500f977edf15f2ea0b8f7 /libjava/java | |
parent | c4bbc105641ea61b0d4e5a826d639f1051a00667 (diff) | |
download | gcc-a286e145de1b08b1a73d4efe03d36375fa698273.zip gcc-a286e145de1b08b1a73d4efe03d36375fa698273.tar.gz gcc-a286e145de1b08b1a73d4efe03d36375fa698273.tar.bz2 |
Class.h (_Jv_IDispatchTable): Make it a struct.
2006-02-09 Bryce McKinlay <mckinlay@redhat.com>
* java/lang/Class.h (_Jv_IDispatchTable): Make it a struct. Put
'itable' inline, instead of as a pointer.
(java::lang::Class): Put 'idt' in anonymous union with 'ioffsets'.
* link.cc (null_idt): Update definition.
(_Jv_Linker::prepare_constant_time_tables): Allocate klass->idt
as a single struct. Use _Jv_AllocBytes, not _Jv_AllocRawObj.
(_Jv_Linker::generate_itable): Update to use 'ioffsets'.
(_Jv_Linker::find_iindex): Likewise. Update comment.
* java/lang/natClass.cc (_Jv_LookupInterfaceMethodIdx): Update for
_Jv_IDispatchTable change.
(_Jv_IsAssignableFrom): Likewise.
From-SVN: r110818
Diffstat (limited to 'libjava/java')
-rw-r--r-- | libjava/java/lang/Class.h | 32 | ||||
-rw-r--r-- | libjava/java/lang/natClass.cc | 17 |
2 files changed, 22 insertions, 27 deletions
diff --git a/libjava/java/lang/Class.h b/libjava/java/lang/Class.h index 62e280c..787e263 100644 --- a/libjava/java/lang/Class.h +++ b/libjava/java/lang/Class.h @@ -120,23 +120,14 @@ struct _Jv_Method { return this + 1; } }; -// Interface Dispatch Tables -union _Jv_IDispatchTable +// The table used to resolve interface calls. +struct _Jv_IDispatchTable { - struct - { - // Index into interface's ioffsets. - jshort iindex; - jshort itable_length; - // Class Interface dispatch table. - void **itable; - } cls; - - struct - { - // Offsets into implementation class itables. - jshort *ioffsets; - } iface; + // Index into interface's ioffsets. + jshort iindex; + jshort itable_length; + // Class Interface dispatch table. + void *itable[0]; }; // Used by _Jv_Linker::get_interfaces () @@ -600,8 +591,13 @@ private: jshort depth; // Vector of this class's superclasses, ordered by decreasing depth. jclass *ancestors; - // Interface Dispatch Table. - _Jv_IDispatchTable *idt; + // In a regular class, this field points to the Class Interface Dispatch + // Table. In an interface, it points to the ioffsets table. + union + { + _Jv_IDispatchTable *idt; + jshort *ioffsets; + }; // Pointer to the class that represents an array of this class. jclass arrayclass; // Security Domain to which this class belongs (or null). diff --git a/libjava/java/lang/natClass.cc b/libjava/java/lang/natClass.cc index 04a5bc4..8972cb2 100644 --- a/libjava/java/lang/natClass.cc +++ b/libjava/java/lang/natClass.cc @@ -985,8 +985,8 @@ void * _Jv_LookupInterfaceMethodIdx (jclass klass, jclass iface, int method_idx) { _Jv_IDispatchTable *cldt = klass->idt; - int idx = iface->idt->iface.ioffsets[cldt->cls.iindex] + method_idx; - return cldt->cls.itable[idx]; + int idx = iface->ioffsets[cldt->iindex] + method_idx; + return cldt->itable[idx]; } jboolean @@ -1013,16 +1013,15 @@ _Jv_IsAssignableFrom (jclass source, jclass target) return _Jv_InterfaceAssignableFrom (source, target); _Jv_IDispatchTable *cl_idt = source->idt; - _Jv_IDispatchTable *if_idt = target->idt; - if (__builtin_expect ((if_idt == NULL), false)) + if (__builtin_expect ((target->ioffsets == NULL), false)) return false; // No class implementing TARGET has been loaded. - jshort cl_iindex = cl_idt->cls.iindex; - if (cl_iindex < if_idt->iface.ioffsets[0]) + jshort cl_iindex = cl_idt->iindex; + if (cl_iindex < target->ioffsets[0]) { - jshort offset = if_idt->iface.ioffsets[cl_iindex]; - if (offset != -1 && offset < cl_idt->cls.itable_length - && cl_idt->cls.itable[offset] == target) + jshort offset = target->ioffsets[cl_iindex]; + if (offset != -1 && offset < cl_idt->itable_length + && cl_idt->itable[offset] == target) return true; } return false; |