diff options
author | Bryce McKinlay <bryce@albatross.co.nz> | 2000-05-05 02:56:14 +0000 |
---|---|---|
committer | Bryce McKinlay <bryce@gcc.gnu.org> | 2000-05-05 03:56:14 +0100 |
commit | 9d4c21486cc7709172723c8fe12dd7f8d213b605 (patch) | |
tree | cf14a17edadc80507b8cb59cbdf177d63a7452e0 /libjava | |
parent | 59b30ca6ddd5930d454517cd8e6c54701b21b97b (diff) | |
download | gcc-9d4c21486cc7709172723c8fe12dd7f8d213b605.zip gcc-9d4c21486cc7709172723c8fe12dd7f8d213b605.tar.gz gcc-9d4c21486cc7709172723c8fe12dd7f8d213b605.tar.bz2 |
natClass.cc (isInstance): Use __builtin_expect.
2000-05-05 Bryce McKinlay <bryce@albatross.co.nz>
* java/lang/natClass.cc (isInstance): Use __builtin_expect.
(_Jv_IsAssignableFrom): Ditto.
(_Jv_IsInstanceOf): Ditto.
(_Jv_CheckCast): Ditto.
(_Jv_CheckArrayStore): Ditto.
* java/lang/Class.h (_Jv_InitClass): Ditto.
* java/lang/natObject.cc (_Jv_MonitorEnter): __builtin_expect `false',
not `0'.
(notify): Ditto.
(notifyAll): Ditto.
(wait): Ditto.
(_Jv_MonitorExit): Ditto.
* boehm.cc (_Jv_MarkObj): Ditto.
(_Jv_MarkObj): Ditto.
(_Jv_MarkArray): Ditto.
* prims.cc (_Jv_AllocObject): Ditto.
(_Jv_NewObjectArray): Ditto.
(_Jv_NewPrimArray): Ditto.
(_Jv_Malloc): Ditto.
(_Jv_Realloc): Ditto.
(_Jv_MallocUnchecked): Ditto.
(_Jv_divI): Ditto.
(_Jv_remI): Ditto.
(_Jv_divJ): Ditto.
(_Jv_remJ): Ditto.
From-SVN: r33698
Diffstat (limited to 'libjava')
-rw-r--r-- | libjava/ChangeLog | 28 | ||||
-rw-r--r-- | libjava/java/lang/Class.h | 2 | ||||
-rw-r--r-- | libjava/java/lang/natClass.cc | 14 | ||||
-rw-r--r-- | libjava/java/lang/natObject.cc | 18 | ||||
-rw-r--r-- | libjava/prims.cc | 34 |
5 files changed, 64 insertions, 32 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 60bbf86..c3c16e3 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,31 @@ +2000-05-05 Bryce McKinlay <bryce@albatross.co.nz> + + * java/lang/natClass.cc (isInstance): Use __builtin_expect. + (_Jv_IsAssignableFrom): Ditto. + (_Jv_IsInstanceOf): Ditto. + (_Jv_CheckCast): Ditto. + (_Jv_CheckArrayStore): Ditto. + * java/lang/Class.h (_Jv_InitClass): Ditto. + * java/lang/natObject.cc (_Jv_MonitorEnter): __builtin_expect `false', + not `0'. + (notify): Ditto. + (notifyAll): Ditto. + (wait): Ditto. + (_Jv_MonitorExit): Ditto. + * boehm.cc (_Jv_MarkObj): Ditto. + (_Jv_MarkObj): Ditto. + (_Jv_MarkArray): Ditto. + * prims.cc (_Jv_AllocObject): Ditto. + (_Jv_NewObjectArray): Ditto. + (_Jv_NewPrimArray): Ditto. + (_Jv_Malloc): Ditto. + (_Jv_Realloc): Ditto. + (_Jv_MallocUnchecked): Ditto. + (_Jv_divI): Ditto. + (_Jv_remI): Ditto. + (_Jv_divJ): Ditto. + (_Jv_remJ): Ditto. + 2000-05-04 Tom Tromey <tromey@cygnus.com> * java/util/Locale.java (Locale): Don't explicitly check for diff --git a/libjava/java/lang/Class.h b/libjava/java/lang/Class.h index c25398c..d685a1b 100644 --- a/libjava/java/lang/Class.h +++ b/libjava/java/lang/Class.h @@ -203,7 +203,7 @@ private: inline friend void _Jv_InitClass (jclass klass) { - if (klass->state != JV_STATE_DONE) + if (__builtin_expect (klass->state != JV_STATE_DONE, false)) klass->initializeClass (); } diff --git a/libjava/java/lang/natClass.cc b/libjava/java/lang/natClass.cc index 3284992..93e8210 100644 --- a/libjava/java/lang/natClass.cc +++ b/libjava/java/lang/natClass.cc @@ -622,7 +622,7 @@ java::lang::Class::isAssignableFrom (jclass klass) inline jboolean java::lang::Class::isInstance (jobject obj) { - if (! obj || isPrimitive ()) + if (__builtin_expect (! obj || isPrimitive (), false)) return false; _Jv_InitClass (this); return _Jv_IsAssignableFrom (this, JV_CLASS (obj)); @@ -923,7 +923,7 @@ _Jv_IsAssignableFrom (jclass target, jclass source) { _Jv_IDispatchTable *cl_idt = source->idt; _Jv_IDispatchTable *if_idt = target->idt; - if (if_idt == NULL) + if (__builtin_expect ((if_idt == 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]) @@ -941,13 +941,16 @@ _Jv_IsAssignableFrom (jclass target, jclass source) jboolean _Jv_IsInstanceOf(jobject obj, jclass cl) { - return (obj ? _Jv_IsAssignableFrom (cl, JV_CLASS (obj)) : false); + if (__builtin_expect (!obj, false)) + return false; + return (_Jv_IsAssignableFrom (cl, JV_CLASS (obj))); } void * _Jv_CheckCast (jclass c, jobject obj) { - if (obj != NULL && ! _Jv_IsAssignableFrom(c, JV_CLASS (obj))) + if (__builtin_expect + (obj != NULL && ! _Jv_IsAssignableFrom(c, JV_CLASS (obj)), false)) JvThrow (new java::lang::ClassCastException); return obj; } @@ -960,7 +963,8 @@ _Jv_CheckArrayStore (jobject arr, jobject obj) JvAssert (arr != NULL); jclass elt_class = (JV_CLASS (arr))->getComponentType(); jclass obj_class = JV_CLASS (obj); - if (! _Jv_IsAssignableFrom (elt_class, obj_class)) + if (__builtin_expect + (! _Jv_IsAssignableFrom (elt_class, obj_class), false)) JvThrow (new java::lang::ArrayStoreException); } } diff --git a/libjava/java/lang/natObject.cc b/libjava/java/lang/natObject.cc index 6aed898..26b3f96 100644 --- a/libjava/java/lang/natObject.cc +++ b/libjava/java/lang/natObject.cc @@ -172,10 +172,10 @@ java::lang::Object::sync_init (void) void java::lang::Object::notify (void) { - if (__builtin_expect (INIT_NEEDED (this), 0)) + if (__builtin_expect (INIT_NEEDED (this), false)) sync_init (); _Jv_SyncInfo *si = (_Jv_SyncInfo *) sync_info; - if (__builtin_expect (_Jv_CondNotify (&si->condition, &si->mutex), 0)) + if (__builtin_expect (_Jv_CondNotify (&si->condition, &si->mutex), false)) JvThrow (new IllegalMonitorStateException(JvNewStringLatin1 ("current thread not owner"))); } @@ -183,10 +183,10 @@ java::lang::Object::notify (void) void java::lang::Object::notifyAll (void) { - if (__builtin_expect (INIT_NEEDED (this), 0)) + if (__builtin_expect (INIT_NEEDED (this), false)) sync_init (); _Jv_SyncInfo *si = (_Jv_SyncInfo *) sync_info; - if (__builtin_expect (_Jv_CondNotifyAll (&si->condition, &si->mutex), 0)) + if (__builtin_expect (_Jv_CondNotifyAll (&si->condition, &si->mutex), false)) JvThrow (new IllegalMonitorStateException(JvNewStringLatin1 ("current thread not owner"))); } @@ -194,9 +194,9 @@ java::lang::Object::notifyAll (void) void java::lang::Object::wait (jlong timeout, jint nanos) { - if (__builtin_expect (INIT_NEEDED (this), 0)) + if (__builtin_expect (INIT_NEEDED (this), false)) sync_init (); - if (__builtin_expect (timeout < 0 || nanos < 0 || nanos > 999999, 0)) + if (__builtin_expect (timeout < 0 || nanos < 0 || nanos > 999999, false)) JvThrow (new IllegalArgumentException); _Jv_SyncInfo *si = (_Jv_SyncInfo *) sync_info; switch (_Jv_CondWait (&si->condition, &si->mutex, timeout, nanos)) @@ -226,10 +226,10 @@ jint _Jv_MonitorEnter (jobject obj) { #ifndef HANDLE_SEGV - if (__builtin_expect (! obj, 0)) + if (__builtin_expect (! obj, false)) JvThrow (new java::lang::NullPointerException); #endif - if (__builtin_expect (INIT_NEEDED (obj), 0)) + if (__builtin_expect (INIT_NEEDED (obj), false)) obj->sync_init (); _Jv_SyncInfo *si = (_Jv_SyncInfo *) obj->sync_info; return _Jv_MutexLock (&si->mutex); @@ -241,7 +241,7 @@ _Jv_MonitorExit (jobject obj) JvAssert (obj); JvAssert (! INIT_NEEDED (obj)); _Jv_SyncInfo *si = (_Jv_SyncInfo *) obj->sync_info; - if (__builtin_expect (_Jv_MutexUnlock (&si->mutex), 0)) + if (__builtin_expect (_Jv_MutexUnlock (&si->mutex), false)) JvThrow (new java::lang::IllegalMonitorStateException); return 0; } diff --git a/libjava/prims.cc b/libjava/prims.cc index 606aeab..c9cb92e 100644 --- a/libjava/prims.cc +++ b/libjava/prims.cc @@ -328,7 +328,7 @@ _Jv_AllocObject (jclass c, jint size) _Jv_InitClass (c); jobject obj = (jobject) _Jv_AllocObj (size); - if (__builtin_expect (! obj, 0)) + if (__builtin_expect (! obj, false)) JvThrow (no_memory); *((_Jv_VTable **) obj) = c->vtable; @@ -345,7 +345,7 @@ _Jv_AllocObject (jclass c, jint size) #ifdef ENABLE_JVMPI // Service JVMPI request. - if (__builtin_expect (_Jv_JVMPI_Notify_OBJECT_ALLOC != 0, 0)) + if (__builtin_expect (_Jv_JVMPI_Notify_OBJECT_ALLOC != 0, false)) { JVMPI_Event event; @@ -372,7 +372,7 @@ _Jv_AllocObject (jclass c, jint size) jobjectArray _Jv_NewObjectArray (jsize count, jclass elementClass, jobject init) { - if (__builtin_expect (count < 0, 0)) + if (__builtin_expect (count < 0, false)) JvThrow (new java::lang::NegativeArraySizeException); JvAssert (! elementClass->isPrimitive ()); @@ -383,7 +383,7 @@ _Jv_NewObjectArray (jsize count, jclass elementClass, jobject init) // Check for overflow. if (__builtin_expect ((size_t) count > - (SIZE_T_MAX - size) / sizeof (jobject), 0)) + (SIZE_T_MAX - size) / sizeof (jobject), false)) JvThrow (no_memory); size += count * sizeof (jobject); @@ -392,7 +392,7 @@ _Jv_NewObjectArray (jsize count, jclass elementClass, jobject init) jclass clas = _Jv_FindArrayClass (elementClass, 0); obj = (jobjectArray) _Jv_AllocArray (size); - if (__builtin_expect (! obj, 0)) + if (__builtin_expect (! obj, false)) JvThrow (no_memory); obj->length = count; jobject* ptr = elements(obj); @@ -416,7 +416,7 @@ jobject _Jv_NewPrimArray (jclass eltype, jint count) { int elsize = eltype->size(); - if (__builtin_expect (count < 0, 0)) + if (__builtin_expect (count < 0, false)) JvThrow (new java::lang::NegativeArraySizeException ()); JvAssert (eltype->isPrimitive ()); @@ -425,11 +425,11 @@ _Jv_NewPrimArray (jclass eltype, jint count) // Check for overflow. if (__builtin_expect ((size_t) count > - (SIZE_T_MAX - size) / elsize, 0)) + (SIZE_T_MAX - size) / elsize, false)) JvThrow (no_memory); __JArray *arr = (__JArray*) _Jv_AllocObj (size + elsize * count); - if (__builtin_expect (! arr, 0)) + if (__builtin_expect (! arr, false)) JvThrow (no_memory); arr->length = count; // Note that we assume we are given zeroed memory by the allocator. @@ -932,10 +932,10 @@ _Jv_SetMaximumHeapSize (const char *arg) void * _Jv_Malloc (jsize size) { - if (__builtin_expect (size == 0, 0)) + if (__builtin_expect (size == 0, false)) size = 1; void *ptr = malloc ((size_t) size); - if (__builtin_expect (ptr == NULL, 0)) + if (__builtin_expect (ptr == NULL, false)) JvThrow (no_memory); return ptr; } @@ -943,10 +943,10 @@ _Jv_Malloc (jsize size) void * _Jv_Realloc (void *ptr, jsize size) { - if (__builtin_expect (size == 0, 0)) + if (__builtin_expect (size == 0, false)) size = 1; ptr = realloc (ptr, (size_t) size); - if (__builtin_expect (ptr == NULL, 0)) + if (__builtin_expect (ptr == NULL, false)) JvThrow (no_memory); return ptr; } @@ -954,7 +954,7 @@ _Jv_Realloc (void *ptr, jsize size) void * _Jv_MallocUnchecked (jsize size) { - if (__builtin_expect (size == 0, 0)) + if (__builtin_expect (size == 0, false)) size = 1; return malloc ((size_t) size); } @@ -975,7 +975,7 @@ _Jv_Free (void* ptr) jint _Jv_divI (jint dividend, jint divisor) { - if (__builtin_expect (divisor == 0, 0)) + if (__builtin_expect (divisor == 0, false)) _Jv_Throw (arithexception); if (dividend == (jint) 0x80000000L && divisor == -1) @@ -987,7 +987,7 @@ _Jv_divI (jint dividend, jint divisor) jint _Jv_remI (jint dividend, jint divisor) { - if (__builtin_expect (divisor == 0, 0)) + if (__builtin_expect (divisor == 0, false)) _Jv_Throw (arithexception); if (dividend == (jint) 0x80000000L && divisor == -1) @@ -999,7 +999,7 @@ _Jv_remI (jint dividend, jint divisor) jlong _Jv_divJ (jlong dividend, jlong divisor) { - if (__builtin_expect (divisor == 0, 0)) + if (__builtin_expect (divisor == 0, false)) _Jv_Throw (arithexception); if (dividend == (jlong) 0x8000000000000000LL && divisor == -1) @@ -1011,7 +1011,7 @@ _Jv_divJ (jlong dividend, jlong divisor) jlong _Jv_remJ (jlong dividend, jlong divisor) { - if (__builtin_expect (divisor == 0, 0)) + if (__builtin_expect (divisor == 0, false)) _Jv_Throw (arithexception); if (dividend == (jlong) 0x8000000000000000LL && divisor == -1) |