diff options
author | Bryce McKinlay <bryce@albatross.co.nz> | 2000-03-07 09:52:56 +0000 |
---|---|---|
committer | Bryce McKinlay <bryce@gcc.gnu.org> | 2000-03-07 09:52:56 +0000 |
commit | ddf0fc6c9f1eb8747c9cf6b69e48f11f779632d2 (patch) | |
tree | 3d1200ab45d37376fcbddeff18a6199837857dca /libjava/prims.cc | |
parent | 173f556ccc41ea93cf66896d0c7778241467407f (diff) | |
download | gcc-ddf0fc6c9f1eb8747c9cf6b69e48f11f779632d2.zip gcc-ddf0fc6c9f1eb8747c9cf6b69e48f11f779632d2.tar.gz gcc-ddf0fc6c9f1eb8747c9cf6b69e48f11f779632d2.tar.bz2 |
resolve.cc (_Jv_SearchMethodInClass): New function.
2000-03-07 Bryce McKinlay <bryce@albatross.co.nz>
* resolve.cc (_Jv_SearchMethodInClass): New function.
(_Jv_ResolvePoolEntry): Search superinterfaces for interface
methods.
* java/lang/Class.h (_Jv_SearchMethodInClass): New prototype.
2000-03-07 Bryce McKinlay <bryce@albatross.co.nz>
* java/lang/Class.h (union _Jv_IDispatchTable): New declaration.
(struct _Jv_ifaces): New declaration.
JV_CLASS: New macro definition.
(getComponentType): Relocate below isArray() for inlining.
(getModifiers): Declare `inline'.
(getSuperclass): Ditto.
(isArray): Ditto.
(isPrimitive): Ditto.
(_Jv_IsAssignableFrom): New prototype.
(_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C"
linkage.
(_Jv_InitClass): Move from natClass.cc. Declare `inline'.
Check for JV_STATE_DONE before invoking initializeClass().
(_Jv_PrepareConstantTimeTables): New prototype.
(_Jv_GetInterfaces): Ditto.
(_Jv_GenerateITable): Ditto.
(_Jv_GetMethodString): Ditto.
(_Jv_AppendPartialITable): Ditto.
(_Jv_FindIIndex): Ditto.
depth, ancestors, idt: New class fields.
* java/lang/natClass.cc (isAssignableFrom): Move functionality to
inline function `_Jv_IsAssignableFrom'. Use that function.
(isInstance): Declare `inline'.
(initializeClass): Get lock on class before checking `state'. Unlock
before calling resolveClass0. Call _Jv_PrepareConstantTimeTables
with the lock held.
(_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString.
(_Jv_IsAssignableFrom): New inline function. Test assignability
using class->depth and ancestor table.
(_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom.
(_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and
_Jv_IsAssignableFrom.
(_Jv_CheckArrayStore): Ditto.
(_Jv_LookupInterfaceMethodIdx): New function.
INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines.
(_Jv_PrepareConstantTimeTables): New function.
(_Jv_IndexOf): Ditto.
(_Jv_GetInterfaces): Ditto.
(_Jv_GenerateITable): Ditto.
(_Jv_GetMethodString): Ditto.
(_Jv_AppendPartialITable): Ditto.
iindex_mutex, iindex_mutex_initialized: New static fields.
(_Jv_FindIIndex): New function.
* java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields.
* prims.cc (_Jv_CheckCast): Moved to natClass.cc.
(_Jv_CheckArrayStore): Ditto.
(JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray,
JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray):
Moved to gcj/array.h.
(_Jv_Realloc): New function.
* gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h.
* gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h.
(JvNewCharArray, JvNewBooleanArray, JvNewByteArray,
JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray,
JvNewDoubleArray): Implementations moved from prims.cc and
declared `inline'.
* gcj/javaprims.h (_Jv_Realloc): Prototype.
* include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype.
From-SVN: r32382
Diffstat (limited to 'libjava/prims.cc')
-rw-r--r-- | libjava/prims.cc | 94 |
1 files changed, 15 insertions, 79 deletions
diff --git a/libjava/prims.cc b/libjava/prims.cc index 2c5c464..beec6a6 100644 --- a/libjava/prims.cc +++ b/libjava/prims.cc @@ -42,11 +42,9 @@ details. */ #include <java/lang/ArrayIndexOutOfBoundsException.h> #include <java/lang/ArithmeticException.h> #include <java/lang/ClassFormatError.h> -#include <java/lang/ClassCastException.h> #include <java/lang/NegativeArraySizeException.h> #include <java/lang/NullPointerException.h> #include <java/lang/OutOfMemoryError.h> -#include <java/lang/ArrayStoreException.h> #include <java/lang/System.h> #include <java/lang/reflect/Modifier.h> #include <java/io/PrintStream.h> @@ -286,31 +284,6 @@ _Jv_ThrowBadArrayIndex(jint bad_index) (java::lang::String::valueOf(bad_index))); } -void* -_Jv_CheckCast (jclass c, jobject obj) -{ - if (obj != NULL && ! c->isAssignableFrom(obj->getClass())) - JvThrow (new java::lang::ClassCastException); - return obj; -} - -void -_Jv_CheckArrayStore (jobject arr, jobject obj) -{ - if (obj) - { - JvAssert (arr != NULL); - jclass arr_class = arr->getClass(); - JvAssert (arr_class->isArray()); - jclass elt_class = arr_class->getComponentType(); - jclass obj_class = obj->getClass(); - if (! elt_class->isAssignableFrom(obj_class)) - JvThrow (new java::lang::ArrayStoreException); - } -} - - - // Allocate some unscanned memory and throw an exception if no memory. void * _Jv_AllocBytesChecked (jsize size) @@ -421,54 +394,6 @@ _Jv_NewPrimArray (jclass eltype, jint count) return arr; } -jcharArray -JvNewCharArray (jint length) -{ - return (jcharArray) _Jv_NewPrimArray (JvPrimClass (char), length); -} - -jbooleanArray -JvNewBooleanArray (jint length) -{ - return (jbooleanArray) _Jv_NewPrimArray (JvPrimClass (boolean), length); -} - -jbyteArray -JvNewByteArray (jint length) -{ - return (jbyteArray) _Jv_NewPrimArray (JvPrimClass (byte), length); -} - -jshortArray -JvNewShortArray (jint length) -{ - return (jshortArray) _Jv_NewPrimArray (JvPrimClass (short), length); -} - -jintArray -JvNewIntArray (jint length) -{ - return (jintArray) _Jv_NewPrimArray (JvPrimClass (int), length); -} - -jlongArray -JvNewLongArray (jint length) -{ - return (jlongArray) _Jv_NewPrimArray (JvPrimClass (long), length); -} - -jfloatArray -JvNewFloatArray (jint length) -{ - return (jfloatArray) _Jv_NewPrimArray (JvPrimClass (float), length); -} - -jdoubleArray -JvNewDoubleArray (jint length) -{ - return (jdoubleArray) _Jv_NewPrimArray (JvPrimClass (double), length); -} - jobject _Jv_NewArray (jint type, jint size) { @@ -919,24 +844,35 @@ _Jv_SetMaximumHeapSize (const char *arg) void * -_Jv_MallocUnchecked (jsize size) +_Jv_Malloc (jsize size) { if (size == 0) size = 1; - return malloc ((size_t) size); + void *ptr = malloc ((size_t) size); + if (ptr == NULL) + JvThrow (no_memory); + return ptr; } void * -_Jv_Malloc (jsize size) +_Jv_Realloc (void *ptr, jsize size) { if (size == 0) size = 1; - void *ptr = malloc ((size_t) size); + ptr = realloc (ptr, (size_t) size); if (ptr == NULL) JvThrow (no_memory); return ptr; } +void * +_Jv_MallocUnchecked (jsize size) +{ + if (size == 0) + size = 1; + return malloc ((size_t) size); +} + void _Jv_Free (void* ptr) { |