+ 2000-04-22 Anthony Green <green@cygnus.com> + + * include/jvm.h (__builtin_expect): Define as unused for now.

+ 2000-04-22  Anthony Green  <green@cygnus.com>
+
+ 	* include/jvm.h (__builtin_expect): Define as unused for now.
+ 	* java/lang/natObject.cc (_Jv_MonitorEnter): Add __builtin_expect.
+ 	(notify): Ditto.
+ 	(notifyAll): Ditto.
+ 	(wait): Ditto.
+ 	(_Jv_MonitorExit): Ditto.
+ 	* boehm.cc (_Jv_MarkObj): Ditto.
+ 	(_Jv_MarkObj): Ditto.
+ 	(_Jv_MarkArray): Ditto.
+ 	(_Jv_AllocBytes): 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.
+
+ 	* include/Makefile.in: Rebuilt.
+ 	* include/Makefile.am (include_HEADERS): Add jvmpi.h.
+

From-SVN: r33339
This commit is contained in:
Anthony Green 2000-04-22 17:09:39 +00:00 committed by Anthony Green
parent 3fb304e7e4
commit 1143c0a03f
7 changed files with 65 additions and 34 deletions

View file

@ -1,3 +1,29 @@
2000-04-22 Anthony Green <green@cygnus.com>
* include/jvm.h (__builtin_expect): Define as unused for now.
* java/lang/natObject.cc (_Jv_MonitorEnter): Add __builtin_expect.
(notify): Ditto.
(notifyAll): Ditto.
(wait): Ditto.
(_Jv_MonitorExit): Ditto.
* boehm.cc (_Jv_MarkObj): Ditto.
(_Jv_MarkObj): Ditto.
(_Jv_MarkArray): Ditto.
(_Jv_AllocBytes): 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.
* include/Makefile.in: Rebuilt.
* include/Makefile.am (include_HEADERS): Add jvmpi.h.
2000-04-21 Tom Tromey <tromey@cygnus.com>
* java/io/PipedInputStream.java, java/io/PipedOutputStream.java:

View file

@ -87,7 +87,7 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /*env*/)
_Jv_VTable *dt = *(_Jv_VTable **) addr;
// We check this in case a GC occurs before the vtbl is set. FIXME:
// should use allocation lock while initializing object.
if (! dt)
if (__builtin_expect (! dt, 0))
return mark_stack_ptr;
jclass klass = dt->clas;
@ -98,7 +98,7 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /*env*/)
p = (ptr_t) klass;
MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, obj, o2label);
if (klass == &ClassClass)
if (__builtin_expect (klass == &ClassClass, 0))
{
jclass c = (jclass) addr;
@ -281,7 +281,7 @@ _Jv_MarkArray (void *addr, void *msp, void *msl, void * /*env*/)
_Jv_VTable *dt = *(_Jv_VTable **) addr;
// We check this in case a GC occurs before the vtbl is set. FIXME:
// should use allocation lock while initializing object.
if (! dt)
if (__builtin_expect (! dt, 0))
return mark_stack_ptr;
jclass klass = dt->clas;
@ -329,7 +329,7 @@ _Jv_AllocBytes (jsize size)
// guarantee that PTRFREE allocations are zeroed. Note that we
// don't have to do this for other allocation types because we set
// the `ok_init' flag in the type descriptor.
if (r != NULL)
if (__builtin_expect (r != NULL, !NULL))
memset (r, 0, size);
return r;
}

View file

@ -2,4 +2,4 @@
AUTOMAKE_OPTIONS = foreign no-installinfo
include_HEADERS = jni.h
include_HEADERS = jni.h jvmpi.h

View file

@ -116,7 +116,7 @@ libgcj_basedir = @libgcj_basedir@
AUTOMAKE_OPTIONS = foreign no-installinfo
include_HEADERS = jni.h
include_HEADERS = jni.h jvmpi.h
mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES =
@ -127,7 +127,7 @@ DIST_COMMON = ./stamp-h.in Makefile.am Makefile.in config.h.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
TAR = gtar
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
@ -224,7 +224,7 @@ distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$/$$file $(distdir)/$$file; \
cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \

View file

@ -11,6 +11,9 @@ details. */
#ifndef __JAVA_JVM_H__
#define __JAVA_JVM_H__
// FIXME: __builtin_expect doesn't work yet.
#define __builtin_expect(A,B) (A)
#include <gcj/javaprims.h>
#include <java-assert.h>

View file

@ -172,10 +172,10 @@ java::lang::Object::sync_init (void)
void
java::lang::Object::notify (void)
{
if (INIT_NEEDED (this))
if (__builtin_expect (INIT_NEEDED (this), 0))
sync_init ();
_Jv_SyncInfo *si = (_Jv_SyncInfo *) sync_info;
if (_Jv_CondNotify (&si->condition, &si->mutex))
if (__builtin_expect (_Jv_CondNotify (&si->condition, &si->mutex), 0))
JvThrow (new IllegalMonitorStateException(JvNewStringLatin1
("current thread not owner")));
}
@ -183,10 +183,10 @@ java::lang::Object::notify (void)
void
java::lang::Object::notifyAll (void)
{
if (INIT_NEEDED (this))
if (__builtin_expect (INIT_NEEDED (this), 0))
sync_init ();
_Jv_SyncInfo *si = (_Jv_SyncInfo *) sync_info;
if (_Jv_CondNotifyAll (&si->condition, &si->mutex))
if (__builtin_expect (_Jv_CondNotifyAll (&si->condition, &si->mutex), 0))
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 (INIT_NEEDED (this))
if (__builtin_expect (INIT_NEEDED (this), 0))
sync_init ();
if (timeout < 0 || nanos < 0 || nanos > 999999)
if (__builtin_expect (timeout < 0 || nanos < 0 || nanos > 999999, 0))
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 (! obj)
if (__builtin_expect (! obj, 0))
JvThrow (new java::lang::NullPointerException);
#endif
if (INIT_NEEDED (obj))
if (__builtin_expect (INIT_NEEDED (obj), 0))
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 (_Jv_MutexUnlock (&si->mutex))
if (__builtin_expect (_Jv_MutexUnlock (&si->mutex), 0))
JvThrow (new java::lang::IllegalMonitorStateException);
return 0;
}

View file

@ -322,7 +322,7 @@ _Jv_AllocObject (jclass c, jint size)
_Jv_InitClass (c);
jobject obj = (jobject) _Jv_AllocObj (size);
if (! obj)
if (__builtin_expect (! obj, 0))
JvThrow (no_memory);
*((_Jv_VTable **) obj) = c->vtable;
@ -339,7 +339,7 @@ _Jv_AllocObject (jclass c, jint size)
#ifdef ENABLE_JVMPI
// Service JVMPI request.
if (_Jv_JVMPI_Notify_OBJECT_ALLOC)
if (__builtin_expect (_Jv_JVMPI_Notify_OBJECT_ALLOC != 0, 0))
{
JVMPI_Event event;
@ -366,7 +366,7 @@ _Jv_AllocObject (jclass c, jint size)
jobjectArray
_Jv_NewObjectArray (jsize count, jclass elementClass, jobject init)
{
if (count < 0)
if (__builtin_expect (count < 0, 0))
JvThrow (new java::lang::NegativeArraySizeException);
JvAssert (! elementClass->isPrimitive ());
@ -376,7 +376,8 @@ _Jv_NewObjectArray (jsize count, jclass elementClass, jobject init)
elementClass);
// Check for overflow.
if ((size_t) count > (SIZE_T_MAX - size) / sizeof (jobject))
if (__builtin_expect ((size_t) count >
(SIZE_T_MAX - size) / sizeof (jobject), 0));
JvThrow (no_memory);
size += count * sizeof (jobject);
@ -385,7 +386,7 @@ _Jv_NewObjectArray (jsize count, jclass elementClass, jobject init)
jclass clas = _Jv_FindArrayClass (elementClass, 0);
obj = (jobjectArray) _Jv_AllocArray (size);
if (! obj)
if (__builtin_expect (! obj, 0))
JvThrow (no_memory);
obj->length = count;
jobject* ptr = elements(obj);
@ -409,7 +410,7 @@ jobject
_Jv_NewPrimArray (jclass eltype, jint count)
{
int elsize = eltype->size();
if (count < 0)
if (__builtin_expect (count < 0, 0))
JvThrow (new java::lang::NegativeArraySizeException ());
JvAssert (eltype->isPrimitive ());
@ -417,11 +418,12 @@ _Jv_NewPrimArray (jclass eltype, jint count)
size_t size = (size_t) _Jv_GetArrayElementFromElementType (dummy, eltype);
// Check for overflow.
if ((size_t) count > (SIZE_T_MAX - size) / elsize)
if (__builtin_expect ((size_t) count >
(SIZE_T_MAX - size) / elsize, 0))
JvThrow (no_memory);
__JArray *arr = (__JArray*) _Jv_AllocObj (size + elsize * count);
if (! arr)
if (__builtin_expect (! arr, 0))
JvThrow (no_memory);
arr->length = count;
// Note that we assume we are given zeroed memory by the allocator.
@ -924,10 +926,10 @@ _Jv_SetMaximumHeapSize (const char *arg)
void *
_Jv_Malloc (jsize size)
{
if (size == 0)
if (__builtin_expect (size == 0, 0))
size = 1;
void *ptr = malloc ((size_t) size);
if (ptr == NULL)
if (__builtin_expect (ptr == NULL, 0))
JvThrow (no_memory);
return ptr;
}
@ -935,10 +937,10 @@ _Jv_Malloc (jsize size)
void *
_Jv_Realloc (void *ptr, jsize size)
{
if (size == 0)
if (__builtin_expect (size == 0, 0))
size = 1;
ptr = realloc (ptr, (size_t) size);
if (ptr == NULL)
if (__builtin_expect (ptr == NULL, 0))
JvThrow (no_memory);
return ptr;
}
@ -946,7 +948,7 @@ _Jv_Realloc (void *ptr, jsize size)
void *
_Jv_MallocUnchecked (jsize size)
{
if (size == 0)
if (__builtin_expect (size == 0, 0))
size = 1;
return malloc ((size_t) size);
}
@ -967,7 +969,7 @@ _Jv_Free (void* ptr)
jint
_Jv_divI (jint dividend, jint divisor)
{
if (divisor == 0)
if (__builtin_expect (divisor == 0, 0))
_Jv_Throw (arithexception);
if (dividend == (jint) 0x80000000L && divisor == -1)
@ -979,7 +981,7 @@ _Jv_divI (jint dividend, jint divisor)
jint
_Jv_remI (jint dividend, jint divisor)
{
if (divisor == 0)
if (__builtin_expect (divisor == 0, 0))
_Jv_Throw (arithexception);
if (dividend == (jint) 0x80000000L && divisor == -1)
@ -991,7 +993,7 @@ _Jv_remI (jint dividend, jint divisor)
jlong
_Jv_divJ (jlong dividend, jlong divisor)
{
if (divisor == 0)
if (__builtin_expect (divisor == 0, 0))
_Jv_Throw (arithexception);
if (dividend == (jlong) 0x8000000000000000LL && divisor == -1)
@ -1003,7 +1005,7 @@ _Jv_divJ (jlong dividend, jlong divisor)
jlong
_Jv_remJ (jlong dividend, jlong divisor)
{
if (divisor == 0)
if (__builtin_expect (divisor == 0, 0))
_Jv_Throw (arithexception);
if (dividend == (jlong) 0x8000000000000000LL && divisor == -1)