diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-01-24 19:05:34 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-01-24 19:05:34 +0000 |
commit | 5b3dbbc367f0c2417f34db8cd9cdaa4b35b31d2c (patch) | |
tree | 0ee3307d0e89506b5d2eddd057065bf2334d4ace | |
parent | d24b67c00a8695771a83d787498227ac539c321d (diff) | |
download | gcc-5b3dbbc367f0c2417f34db8cd9cdaa4b35b31d2c.tar.gz |
* java/lang/Class.h (next): Updated documentation. Renamed to
'next_or_version'.
* java/lang/natClassLoader.cc (_Jv_RegisterClasses): Use
_Jv_CheckABIVersion.
(_Jv_RegisterClasses_Counted): Likewise.
(_Jv_RegisterClassHookDefault): Fix starting condition of
duplicate-checking loop.
* include/jvm.h (GCJ_VERSION): New define.
(GCJ_BINARYCOMPAT_ADDITION): Likewise.
(_Jv_CheckABIVersion): New function.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@94173 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | libjava/ChangeLog | 13 | ||||
-rw-r--r-- | libjava/include/jvm.h | 15 | ||||
-rw-r--r-- | libjava/java/lang/Class.h | 6 | ||||
-rw-r--r-- | libjava/java/lang/natClassLoader.cc | 24 |
4 files changed, 43 insertions, 15 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 1638e58232e..8bc63074903 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,16 @@ +2005-01-24 Tom Tromey <tromey@redhat.com> + + * java/lang/Class.h (next): Updated documentation. Renamed to + 'next_or_version'. + * java/lang/natClassLoader.cc (_Jv_RegisterClasses): Use + _Jv_CheckABIVersion. + (_Jv_RegisterClasses_Counted): Likewise. + (_Jv_RegisterClassHookDefault): Fix starting condition of + duplicate-checking loop. + * include/jvm.h (GCJ_VERSION): New define. + (GCJ_BINARYCOMPAT_ADDITION): Likewise. + (_Jv_CheckABIVersion): New function. + 2005-01-24 Jakub Jelinek <jakub@redhat.com> * Makefile.am (libgij_la_LIBADD): Add -L$(here)/.libs. diff --git a/libjava/include/jvm.h b/libjava/include/jvm.h index 67a4b18176e..cf4d7d640d0 100644 --- a/libjava/include/jvm.h +++ b/libjava/include/jvm.h @@ -566,4 +566,19 @@ extern void (*_Jv_JVMPI_Notify_THREAD_END) (JVMPI_Event *event); extern void _Jv_RegisterBootstrapPackages (); + +// This is used to find ABI versions we recognize. +#define GCJ_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 10) +#define GCJ_BINARYCOMPAT_ADDITION 5 + +inline bool +_Jv_CheckABIVersion (unsigned long value) +{ + // For this release, recognize just our defined C++ ABI and our + // defined BC ABI. (In the future we may recognize past BC ABIs as + // well.) + return (value == GCJ_VERSION + || value == (GCJ_VERSION + GCJ_BINARYCOMPAT_ADDITION)); +} + #endif /* __JAVA_JVM_H__ */ diff --git a/libjava/java/lang/Class.h b/libjava/java/lang/Class.h index cea1c13a8e2..4e061cee574 100644 --- a/libjava/java/lang/Class.h +++ b/libjava/java/lang/Class.h @@ -488,8 +488,10 @@ private: friend void ::_Jv_sharedlib_register_hook (jclass klass); - // Chain for class pool. - jclass next; + // Chain for class pool. This also doubles as the ABI version + // number. It is only used for this purpose at class registration + // time, and only for precompiled classes. + jclass next_or_version; // Name of class. _Jv_Utf8Const *name; // Access flags for class. diff --git a/libjava/java/lang/natClassLoader.cc b/libjava/java/lang/natClassLoader.cc index b05c1dd0a5b..15fb9eb415c 100644 --- a/libjava/java/lang/natClassLoader.cc +++ b/libjava/java/lang/natClassLoader.cc @@ -75,7 +75,7 @@ _Jv_FindClassInCache (_Jv_Utf8Const *name) jint hash = HASH_UTF (name); jclass klass; - for (klass = loaded_classes[hash]; klass; klass = klass->next) + for (klass = loaded_classes[hash]; klass; klass = klass->next_or_version) { if (_Jv_equalUtf8Consts (name, klass->name)) break; @@ -91,11 +91,11 @@ _Jv_UnregisterClass (jclass the_class) jint hash = HASH_UTF(the_class->name); jclass *klass = &(loaded_classes[hash]); - for ( ; *klass; klass = &((*klass)->next)) + for ( ; *klass; klass = &((*klass)->next_or_version)) { if (*klass == the_class) { - *klass = (*klass)->next; + *klass = (*klass)->next_or_version; break; } } @@ -122,7 +122,8 @@ _Jv_RegisterClasses (const jclass *classes) { jclass klass = *classes; - (*_Jv_RegisterClassHook) (klass); + if (_Jv_CheckABIVersion ((unsigned long) klass->next_or_version)) + (*_Jv_RegisterClassHook) (klass); } } @@ -135,7 +136,8 @@ _Jv_RegisterClasses_Counted (const jclass * classes, size_t count) { jclass klass = classes[i]; - (*_Jv_RegisterClassHook) (klass); + if (_Jv_CheckABIVersion ((unsigned long) klass->next_or_version)) + (*_Jv_RegisterClassHook) (klass); } } @@ -144,12 +146,10 @@ _Jv_RegisterClassHookDefault (jclass klass) { jint hash = HASH_UTF (klass->name); - // The BC ABI makes this check unnecessary: we always resolve all - // data references via the appropriate class loader, so the kludge - // that required this check has gone. // If the class is already registered, don't re-register it. - jclass check_class = klass->next; - while (check_class != NULL) + for (jclass check_class = loaded_classes[hash]; + check_class != NULL; + check_class = check_class->next_or_version) { if (check_class == klass) { @@ -170,14 +170,12 @@ _Jv_RegisterClassHookDefault (jclass klass) throw new java::lang::VirtualMachineError (str); } } - - check_class = check_class->next; } // FIXME: this is really bogus! if (! klass->engine) klass->engine = &_Jv_soleCompiledEngine; - klass->next = loaded_classes[hash]; + klass->next_or_version = loaded_classes[hash]; loaded_classes[hash] = klass; } |