This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[ABI] Merge _Jv_AllocObject changes with branch
- From: Bryce McKinlay <mckinlay at redhat dot com>
- To: java-patches at gcc dot gnu dot org
- Date: Tue, 20 Apr 2004 18:00:47 -0400
- Subject: [ABI] Merge _Jv_AllocObject changes with branch
This merge updates the ABI branch to match HEAD w.r.t. changes to remove
the size argument from _Jv_AllocObject().
I'm checking this in.
Bryce.
gcc/java:
2004-04-20 Bryce McKinlay <mckinlay@redhat.com>
* expr.c (java_create_object): Don't use size argument for
_Jv_AllocObject call.
2004-04-19 Bryce McKinlay <mckinlay@redhat.com>
* class.c (make_class_data): Add new field aux_info.
* decl.c (java_init_decl_processing): Push type and decl for
`aux_info'.
gcc/cp:
2004-04-15 Bryce McKinlay <mckinlay@redhat.com>
* init.c (build_new_1): Don't use type size argument for Java
_Jv_AllocObject call.
libjava:
2004-04-19 Bryce McKinlay <mckinlay@redhat.com>
* gcj/cni.h (JvAllocObject): Remove these obsolete,
undocumented CNI calls.
* include/java-interp.h (_Jv_InterpClass): No longer
extends java.lang.Class.
* java/lang/Class.h (Class): Add new field `aux_info'.
* boehm.cc (_Jv_MarkObj): Update java.lang.Class marking.
* defineclass.cc: Remove Class<->_Jv_InterpClass casts.
Use Class->aux_info instead.
* jni.cc (_Jv_JNI_AllocObject): Use _Jv_AllocObject.
* resolve.cc: Remove Class<->_Jv_InterpClass casts.
Use Class->aux_info instead.
* java/io/natObjectInputStream.cc (allocateObject): Use
_Jv_AllocObject.
* java/lang/natClass.cc (newInstance): Likewise.
* java/lang/natClassLoader.cc (_Jv_NewClass): Likewise.
* java/lang/natObject.cc (clone): Likewise.
* java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): Likewise.
* java/lang/natVMClassLoader.cc (defineClass): Don't use
JvAllocObject. Allocate klass->aux_info here for interpreted
class.
2004-04-16 Bryce McKinlay <mckinlay@redhat.com>
* interpret.cc (_Jv_InterpMethod::run): Update _Jv_AllocObject
arguments to match new signature. Remove FIXME comments.
2004-04-15 Bryce McKinlay <mckinlay@redhat.com>
* prims.cc (_Jv_AllocObject): Remove `size' argument.
(_Jv_AllocObjectNoFinalizer): Likewise.
(_Jv_AllocObjectNoInitNoFinalizer): Likewise.
(_Jv_AllocPtrFreeObject): Likewise.
(_Jv_AllocString): Moved from natString.cc. Call collector interface
directly even in the JVMPI case.
* gcj/cni.h (JvAllocObject): Remove `size' argument from
_Jv_AllocObject calls.
* gcj/javaprims.h: Update prototypes.
* gnu/gcj/natCore.cc (_Jv_create_core): Use `new', not _Jv_AllocObject.
* java/lang/Class.h: Update _Jv_AllocObject friend prototype.
* java/lang/natString.cc (_Jv_AllocString): Move to prims.cc.
Index: gcc/cp/init.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/init.c,v
retrieving revision 1.366
diff -u -r1.366 init.c
--- gcc/cp/init.c 5 Apr 2004 12:25:15 -0000 1.366
+++ gcc/cp/init.c 20 Apr 2004 21:50:09 -0000
@@ -2019,7 +2019,6 @@
{
tree class_addr, alloc_decl;
tree class_decl = build_java_class_ref (true_type);
- tree class_size = size_in_bytes (true_type);
static const char alloc_name[] = "_Jv_AllocObject";
use_java_new = 1;
if (!get_global_value_if_present (get_identifier (alloc_name),
@@ -2037,8 +2036,7 @@
class_addr = build1 (ADDR_EXPR, jclass_node, class_decl);
alloc_call = (build_function_call
(alloc_decl,
- tree_cons (NULL_TREE, class_addr,
- build_tree_list (NULL_TREE, class_size))));
+ build_tree_list (NULL_TREE, class_addr)));
}
else
{
Index: gcc/java/class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/class.c,v
retrieving revision 1.180.2.1
diff -u -r1.180.2.1 class.c
--- gcc/java/class.c 16 Apr 2004 12:47:15 -0000 1.180.2.1
+++ gcc/java/class.c 20 Apr 2004 21:50:15 -0000
@@ -1738,6 +1738,7 @@
PUSH_FIELD_VALUE (cons, "protectionDomain", null_pointer_node);
PUSH_FIELD_VALUE (cons, "hack_signers", null_pointer_node);
PUSH_FIELD_VALUE (cons, "chain", null_pointer_node);
+ PUSH_FIELD_VALUE (cons, "aux_info", null_pointer_node);
FINISH_RECORD_CONSTRUCTOR (cons);
Index: gcc/java/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/decl.c,v
retrieving revision 1.178
diff -u -r1.178 decl.c
--- gcc/java/decl.c 5 Feb 2004 22:07:32 -0000 1.178
+++ gcc/java/decl.c 20 Apr 2004 21:50:15 -0000
@@ -690,6 +690,7 @@
PUSH_FIELD (class_type_node, field, "protectionDomain", ptr_type_node);
PUSH_FIELD (class_type_node, field, "hack_signers", ptr_type_node);
PUSH_FIELD (class_type_node, field, "chain", ptr_type_node);
+ PUSH_FIELD (class_type_node, field, "aux_info", ptr_type_node);
for (t = TYPE_FIELDS (class_type_node); t != NULL_TREE; t = TREE_CHAIN (t))
FIELD_PRIVATE (t) = 1;
push_super_field (class_type_node, object_type_node);
Index: gcc/java/expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/expr.c,v
retrieving revision 1.185.2.1
diff -u -r1.185.2.1 expr.c
--- gcc/java/expr.c 16 Apr 2004 12:47:15 -0000 1.185.2.1
+++ gcc/java/expr.c 20 Apr 2004 21:50:16 -0000
@@ -1184,12 +1184,10 @@
tree alloc_node = (class_has_finalize_method (type)
? alloc_object_node
: alloc_no_finalizer_node);
- tree size = flag_indirect_dispatch ? integer_zero_node : size_in_bytes (type);
return build (CALL_EXPR, promote_type (type),
build_address_of (alloc_node),
- tree_cons (NULL_TREE, build_class_ref (type),
- build_tree_list (NULL_TREE, size)),
+ build_tree_list (NULL_TREE, build_class_ref (type)),
NULL_TREE);
}
Index: libjava/boehm.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/boehm.cc,v
retrieving revision 1.42
diff -u -r1.42 boehm.cc
--- libjava/boehm.cc 4 Dec 2003 13:07:07 -0000 1.42
+++ libjava/boehm.cc 20 Apr 2004 21:50:27 -0000
@@ -208,11 +208,13 @@
MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, cPlabel);
p = (ptr_t) c->hack_signers;
MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, cSlabel);
+ p = (ptr_t) c->aux_info;
+ MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, cTlabel);
#ifdef INTERPRETER
if (_Jv_IsInterpretedClass (c))
{
- _Jv_InterpClass* ic = (_Jv_InterpClass*) c;
+ _Jv_InterpClass* ic = (_Jv_InterpClass*) c->aux_info;
p = (ptr_t) ic->interpreted_methods;
MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, ic, cElabel);
Index: libjava/defineclass.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/defineclass.cc,v
retrieving revision 1.35.16.1
diff -u -r1.35.16.1 defineclass.cc
--- libjava/defineclass.cc 16 Apr 2004 12:49:51 -0000 1.35.16.1
+++ libjava/defineclass.cc 20 Apr 2004 21:50:28 -0000
@@ -96,7 +96,10 @@
unsigned int *offsets;
// the class to define (see java-interp.h)
- _Jv_InterpClass *def;
+ jclass def;
+
+ // the classes associated interpreter data.
+ _Jv_InterpClass *def_interp;
/* check that the given number of input bytes are available */
inline void check (int num)
@@ -221,7 +224,8 @@
bytes = (unsigned char*) (elements (data)+offset);
len = length;
pos = 0;
- def = (_Jv_InterpClass*) klass;
+ def = klass;
+ def_interp = (_Jv_InterpClass *) def->aux_info;
}
/** and here goes the parser members defined out-of-line */
@@ -1047,10 +1051,10 @@
def->fields = (_Jv_Field*)
_Jv_AllocBytes (count * sizeof (_Jv_Field));
def->field_count = count;
- def->field_initializers = (_Jv_ushort*)
+ def_interp->field_initializers = (_Jv_ushort*)
_Jv_AllocBytes (count * sizeof (_Jv_ushort));
for (int i = 0; i < count; i++)
- def->field_initializers[i] = (_Jv_ushort) 0;
+ def_interp->field_initializers[i] = (_Jv_ushort) 0;
}
void _Jv_ClassReader::handleField (int field_no,
@@ -1133,7 +1137,7 @@
throw_class_format_error ("field has multiple ConstantValue attributes");
field->flags |= _Jv_FIELD_CONSTANT_VALUE;
- def->field_initializers[field_index] = value;
+ def_interp->field_initializers[field_index] = value;
/* type check the initializer */
@@ -1153,7 +1157,7 @@
int low = 0;
int high = def->field_count-1;
_Jv_Field *fields = def->fields;
- _Jv_ushort *inits = def->field_initializers;
+ _Jv_ushort *inits = def_interp->field_initializers;
// this is kind of a raw version of quicksort.
while (low < high)
@@ -1195,13 +1199,13 @@
{
def->methods = (_Jv_Method *) _Jv_AllocBytes (sizeof (_Jv_Method) * count);
- def->interpreted_methods
+ def_interp->interpreted_methods
= (_Jv_MethodBase **) _Jv_AllocBytes (sizeof (_Jv_MethodBase *)
* count);
for (int i = 0; i < count; i++)
{
- def->interpreted_methods[i] = 0;
+ def_interp->interpreted_methods[i] = 0;
def->methods[i].index = (_Jv_ushort) -1;
}
@@ -1284,7 +1288,7 @@
(void*) (bytes+code_start),
code_length);
- def->interpreted_methods[method_index] = method;
+ def_interp->interpreted_methods[method_index] = method;
if ((method->self->accflags & java::lang::reflect::Modifier::STATIC))
{
@@ -1301,7 +1305,7 @@
int start_pc, int end_pc, int handler_pc, int catch_type)
{
_Jv_InterpMethod *method = reinterpret_cast<_Jv_InterpMethod *>
- (def->interpreted_methods[method_index]);
+ (def_interp->interpreted_methods[method_index]);
_Jv_InterpException *exc = method->exceptions ();
exc[exc_index].start_pc.i = start_pc;
@@ -1319,7 +1323,7 @@
_Jv_Method *method = &def->methods[i];
if ((method->accflags & Modifier::NATIVE) != 0)
{
- if (def->interpreted_methods[i] != 0)
+ if (def_interp->interpreted_methods[i] != 0)
throw_class_format_error ("code provided for native method");
else
{
@@ -1328,7 +1332,7 @@
m->defining_class = def;
m->self = method;
m->function = NULL;
- def->interpreted_methods[i] = m;
+ def_interp->interpreted_methods[i] = m;
m->deferred = NULL;
if ((method->accflags & Modifier::STATIC))
@@ -1344,12 +1348,12 @@
}
else if ((method->accflags & Modifier::ABSTRACT) != 0)
{
- if (def->interpreted_methods[i] != 0)
+ if (def_interp->interpreted_methods[i] != 0)
throw_class_format_error ("code provided for abstract method");
}
else
{
- if (def->interpreted_methods[i] == 0)
+ if (def_interp->interpreted_methods[i] == 0)
throw_class_format_error ("method with no code");
}
}
Index: libjava/interpret.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/interpret.cc,v
retrieving revision 1.40
diff -u -r1.40 interpret.cc
--- libjava/interpret.cc 14 Oct 2003 17:53:41 -0000 1.40
+++ libjava/interpret.cc 20 Apr 2004 21:50:28 -0000
@@ -2917,11 +2917,7 @@
{
int index = GET2U ();
jclass klass = (_Jv_ResolvePoolEntry (defining_class, index)).clazz;
- // We initialize here because otherwise `size_in_bytes' may
- // not be set correctly, leading us to pass `0' as the size.
- // FIXME: fix in the allocator? There is a PR for this.
- _Jv_InitClass (klass);
- jobject res = _Jv_AllocObject (klass, klass->size_in_bytes);
+ jobject res = _Jv_AllocObject (klass);
PUSHA (res);
#ifdef DIRECT_THREADED
@@ -2935,7 +2931,7 @@
new_resolved:
{
jclass klass = (jclass) AVAL ();
- jobject res = _Jv_AllocObject (klass, klass->size_in_bytes);
+ jobject res = _Jv_AllocObject (klass);
PUSHA (res);
}
NEXT_INSN;
Index: libjava/jni.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni.cc,v
retrieving revision 1.81
diff -u -r1.81 jni.cc
--- libjava/jni.cc 1 Feb 2004 20:05:02 -0000 1.81
+++ libjava/jni.cc 20 Apr 2004 21:50:29 -0000
@@ -633,7 +633,7 @@
if (clazz->isInterface() || Modifier::isAbstract(clazz->getModifiers()))
env->ex = new java::lang::InstantiationException ();
else
- obj = JvAllocObject (clazz);
+ obj = _Jv_AllocObject (clazz);
}
catch (jthrowable t)
{
Index: libjava/prims.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/prims.cc,v
retrieving revision 1.87.10.1
diff -u -r1.87.10.1 prims.cc
--- libjava/prims.cc 16 Apr 2004 12:49:51 -0000 1.87.10.1
+++ libjava/prims.cc 20 Apr 2004 21:50:29 -0000
@@ -389,18 +389,15 @@
# define jvmpi_notify_alloc(klass,size,obj) /* do nothing */
#endif
-// Allocate a new object of class KLASS. SIZE is the size of the object
-// to allocate. You might think this is redundant, but it isn't; some
-// classes, such as String, aren't of fixed size.
+// Allocate a new object of class KLASS.
// First a version that assumes that we have no finalizer, and that
// the class is already initialized.
// If we know that JVMPI is disabled, this can be replaced by a direct call
// to the allocator for the appropriate GC.
jobject
-_Jv_AllocObjectNoInitNoFinalizer (jclass klass, jint size)
+_Jv_AllocObjectNoInitNoFinalizer (jclass klass)
{
- if (size == 0)
- size = klass->size ();
+ jint size = klass->size ();
jobject obj = (jobject) _Jv_AllocObj (size, klass);
jvmpi_notify_alloc (klass, size, obj);
return obj;
@@ -408,11 +405,10 @@
// And now a version that initializes if necessary.
jobject
-_Jv_AllocObjectNoFinalizer (jclass klass, jint size)
+_Jv_AllocObjectNoFinalizer (jclass klass)
{
_Jv_InitClass (klass);
- if (size == 0)
- size = klass->size ();
+ jint size = klass->size ();
jobject obj = (jobject) _Jv_AllocObj (size, klass);
jvmpi_notify_alloc (klass, size, obj);
return obj;
@@ -420,10 +416,10 @@
// And now the general version that registers a finalizer if necessary.
jobject
-_Jv_AllocObject (jclass klass, jint size)
+_Jv_AllocObject (jclass klass)
{
- jobject obj = _Jv_AllocObjectNoFinalizer (klass, size);
-
+ jobject obj = _Jv_AllocObjectNoFinalizer (klass);
+
// We assume that the compiler only generates calls to this routine
// if there really is an interesting finalizer.
// Unfortunately, we still have to the dynamic test, since there may
@@ -436,14 +432,62 @@
return obj;
}
+// Allocate a String, including variable length storage.
+jstring
+_Jv_AllocString(jsize len)
+{
+ using namespace java::lang;
+
+ jsize sz = sizeof(java::lang::String) + len * sizeof(jchar);
+
+ // We assert that for strings allocated this way, the data field
+ // will always point to the object itself. Thus there is no reason
+ // for the garbage collector to scan any of it.
+ // Furthermore, we're about to overwrite the string data, so
+ // initialization of the object is not an issue.
+
+ // String needs no initialization, and there is no finalizer, so
+ // we can go directly to the collector's allocator interface.
+ jstring obj = (jstring) _Jv_AllocPtrFreeObj(sz, &String::class$);
+
+ obj->data = obj;
+ obj->boffset = sizeof(java::lang::String);
+ obj->count = len;
+ obj->cachedHashCode = 0;
+
+#ifdef ENABLE_JVMPI
+ // Service JVMPI request.
+
+ if (__builtin_expect (_Jv_JVMPI_Notify_OBJECT_ALLOC != 0, false))
+ {
+ JVMPI_Event event;
+
+ event.event_type = JVMPI_EVENT_OBJECT_ALLOC;
+ event.env_id = NULL;
+ event.u.obj_alloc.arena_id = 0;
+ event.u.obj_alloc.class_id = (jobjectID) &String::class$;
+ event.u.obj_alloc.is_array = 0;
+ event.u.obj_alloc.size = sz;
+ event.u.obj_alloc.obj_id = (jobjectID) obj;
+
+ _Jv_DisableGC ();
+ (*_Jv_JVMPI_Notify_OBJECT_ALLOC) (&event);
+ _Jv_EnableGC ();
+ }
+#endif
+
+ return obj;
+}
+
// A version of the above that assumes the object contains no pointers,
// and requires no finalization. This can't happen if we need pointers
// to locks.
#ifdef JV_HASH_SYNCHRONIZATION
jobject
-_Jv_AllocPtrFreeObject (jclass klass, jint size)
+_Jv_AllocPtrFreeObject (jclass klass)
{
_Jv_InitClass (klass);
+ jint size = klass->size ();
jobject obj = (jobject) _Jv_AllocPtrFreeObj (size, klass);
Index: libjava/resolve.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/resolve.cc,v
retrieving revision 1.44.2.1
diff -u -r1.44.2.1 resolve.cc
--- libjava/resolve.cc 16 Apr 2004 12:49:51 -0000 1.44.2.1
+++ libjava/resolve.cc 20 Apr 2004 21:50:29 -0000
@@ -365,9 +365,9 @@
// A helper for _Jv_PrepareClass. This adds missing `Miranda methods'
// to a class.
void
-_Jv_PrepareMissingMethods (jclass base2, jclass iface_class)
+_Jv_PrepareMissingMethods (jclass base, jclass iface_class)
{
- _Jv_InterpClass *base = reinterpret_cast<_Jv_InterpClass *> (base2);
+ _Jv_InterpClass *interp_base = (_Jv_InterpClass *) base->aux_info;
for (int i = 0; i < iface_class->interface_count; ++i)
{
jclass interface = iface_class->interfaces[i];
@@ -423,11 +423,11 @@
_Jv_MethodBase **new_im
= (_Jv_MethodBase **) _Jv_AllocBytes (sizeof (_Jv_MethodBase *)
* new_count);
- memcpy (new_im, base->interpreted_methods,
+ memcpy (new_im, interp_base->interpreted_methods,
sizeof (_Jv_MethodBase *) * base->method_count);
base->methods = new_m;
- base->interpreted_methods = new_im;
+ interp_base->interpreted_methods = new_im;
base->method_count = new_count;
}
}
@@ -478,7 +478,7 @@
int static_size = 0;
_Jv_LayoutClass(klass, &static_size);
- _Jv_InterpClass *clz = (_Jv_InterpClass*)klass;
+ _Jv_InterpClass *iclass = (_Jv_InterpClass*)klass->aux_info;
// allocate static memory
if (static_size != 0)
@@ -487,18 +487,18 @@
memset (static_data, 0, static_size);
- for (int i = 0; i < clz->field_count; i++)
+ for (int i = 0; i < klass->field_count; i++)
{
- _Jv_Field *field = &clz->fields[i];
+ _Jv_Field *field = &klass->fields[i];
if ((field->flags & Modifier::STATIC) != 0)
{
field->u.addr = static_data + field->u.boffset;
-
- if (clz->field_initializers[i] != 0)
+
+ if (iclass->field_initializers[i] != 0)
{
- _Jv_ResolveField (field, clz->loader);
- _Jv_InitField (0, clz, i);
+ _Jv_ResolveField (field, klass->loader);
+ _Jv_InitField (0, klass, i);
}
}
}
@@ -506,31 +506,31 @@
// now we don't need the field_initializers anymore, so let the
// collector get rid of it!
- clz->field_initializers = 0;
+ iclass->field_initializers = 0;
}
/************ PART TWO: VTABLE LAYOUT ***************/
/* preparation: build the vtable stubs (even interfaces can)
have code -- for static constructors. */
- for (int i = 0; i < clz->method_count; i++)
+ for (int i = 0; i < klass->method_count; i++)
{
- _Jv_MethodBase *imeth = clz->interpreted_methods[i];
+ _Jv_MethodBase *imeth = iclass->interpreted_methods[i];
- if ((clz->methods[i].accflags & Modifier::NATIVE) != 0)
+ if ((klass->methods[i].accflags & Modifier::NATIVE) != 0)
{
// You might think we could use a virtual `ncode' method in
// the _Jv_MethodBase and unify the native and non-native
// cases. Well, we can't, because we don't allocate these
// objects using `new', and thus they don't get a vtable.
_Jv_JNIMethod *jnim = reinterpret_cast<_Jv_JNIMethod *> (imeth);
- clz->methods[i].ncode = jnim->ncode ();
+ klass->methods[i].ncode = jnim->ncode ();
}
else if (imeth != 0) // it could be abstract
{
_Jv_InterpMethod *im = reinterpret_cast<_Jv_InterpMethod *> (imeth);
_Jv_VerifyMethod (im);
- clz->methods[i].ncode = im->ncode ();
+ klass->methods[i].ncode = im->ncode ();
// Resolve ctable entries pointing to this method. See
// _Jv_Defer_Resolution.
@@ -538,16 +538,16 @@
while (code)
{
void **target = (void **)*code;
- *code = clz->methods[i].ncode;
+ *code = klass->methods[i].ncode;
code = target;
}
}
}
- if ((clz->accflags & Modifier::INTERFACE))
+ if ((klass->accflags & Modifier::INTERFACE))
{
- clz->state = JV_STATE_PREPARED;
- clz->notifyAll ();
+ klass->state = JV_STATE_PREPARED;
+ klass->notifyAll ();
return;
}
@@ -559,15 +559,15 @@
// this here by searching for such methods and constructing new
// internal declarations for them. We only need to do this for
// abstract classes.
- if ((clz->accflags & Modifier::ABSTRACT))
- _Jv_PrepareMissingMethods (clz, clz);
+ if ((klass->accflags & Modifier::ABSTRACT))
+ _Jv_PrepareMissingMethods (klass, klass);
- clz->vtable_method_count = -1;
- _Jv_MakeVTable (clz);
+ klass->vtable_method_count = -1;
+ _Jv_MakeVTable (klass);
/* wooha! we're done. */
- clz->state = JV_STATE_PREPARED;
- clz->notifyAll ();
+ klass->state = JV_STATE_PREPARED;
+ klass->notifyAll ();
}
/** Do static initialization for fields with a constant initializer */
@@ -582,18 +582,18 @@
if (!_Jv_IsInterpretedClass (klass))
return;
- _Jv_InterpClass *clz = (_Jv_InterpClass*)klass;
+ _Jv_InterpClass *iclass = (_Jv_InterpClass*)klass->aux_info;
- _Jv_Field * field = (&clz->fields[0]) + index;
+ _Jv_Field * field = (&klass->fields[0]) + index;
- if (index > clz->field_count)
+ if (index > klass->field_count)
throw_internal_error ("field out of range");
- int init = clz->field_initializers[index];
+ int init = iclass->field_initializers[index];
if (init == 0)
return;
- _Jv_Constants *pool = &clz->constants;
+ _Jv_Constants *pool = &klass->constants;
int tag = pool->tags[init];
if (! field->isResolved ())
@@ -613,12 +613,12 @@
{
case JV_CONSTANT_String:
{
- _Jv_MonitorEnter (clz);
+ _Jv_MonitorEnter (klass);
jstring str;
str = _Jv_NewStringUtf8Const (pool->data[init].utf8);
pool->data[init].string = str;
pool->tags[init] = JV_CONSTANT_ResolvedString;
- _Jv_MonitorExit (clz);
+ _Jv_MonitorExit (klass);
}
/* fall through */
Index: libjava/gcj/cni.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gcj/cni.h,v
retrieving revision 1.10
diff -u -r1.10 cni.h
--- libjava/gcj/cni.h 8 Jul 2003 21:27:37 -0000 1.10
+++ libjava/gcj/cni.h 20 Apr 2004 21:50:29 -0000
@@ -20,18 +20,6 @@
#include <string.h>
-extern inline jobject
-JvAllocObject (jclass cls)
-{
- return _Jv_AllocObject (cls, cls->size());
-}
-
-extern inline jobject
-JvAllocObject (jclass cls, jsize sz)
-{
- return _Jv_AllocObject (cls, sz);
-}
-
extern "C" jstring _Jv_NewStringUTF (const char *bytes);
extern "C" void _Jv_InitClass (jclass);
Index: libjava/gcj/javaprims.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gcj/javaprims.h,v
retrieving revision 1.48
diff -u -r1.48 javaprims.h
--- libjava/gcj/javaprims.h 25 Nov 2003 18:26:08 -0000 1.48
+++ libjava/gcj/javaprims.h 20 Apr 2004 21:50:29 -0000
@@ -450,17 +450,17 @@
typedef struct _Jv_Field *jfieldID;
typedef struct _Jv_Method *jmethodID;
-extern "C" jobject _Jv_AllocObject (jclass, jint) __attribute__((__malloc__));
-extern "C" jobject _Jv_AllocObjectNoFinalizer (jclass, jint) __attribute__((__malloc__));
-extern "C" jobject _Jv_AllocObjectNoInitNoFinalizer (jclass, jint) __attribute__((__malloc__));
+extern "C" jobject _Jv_AllocObject (jclass) __attribute__((__malloc__));
+extern "C" jobject _Jv_AllocObjectNoFinalizer (jclass) __attribute__((__malloc__));
+extern "C" jobject _Jv_AllocObjectNoInitNoFinalizer (jclass) __attribute__((__malloc__));
#ifdef JV_HASH_SYNCHRONIZATION
- extern "C" jobject _Jv_AllocPtrFreeObject (jclass, jint)
+ extern "C" jobject _Jv_AllocPtrFreeObject (jclass)
__attribute__((__malloc__));
#else
// Collector still needs to scan sync_info
- static inline jobject _Jv_AllocPtrFreeObject (jclass klass, jint sz)
+ static inline jobject _Jv_AllocPtrFreeObject (jclass klass)
{
- return _Jv_AllocObject(klass, sz);
+ return _Jv_AllocObject(klass);
}
#endif
extern "C" jboolean _Jv_IsInstanceOf(jobject, jclass);
Index: libjava/gnu/gcj/natCore.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/gcj/natCore.cc,v
retrieving revision 1.3
diff -u -r1.3 natCore.cc
--- libjava/gnu/gcj/natCore.cc 28 Aug 2003 22:17:35 -0000 1.3
+++ libjava/gnu/gcj/natCore.cc 20 Apr 2004 21:50:29 -0000
@@ -96,8 +96,7 @@
gnu::gcj::Core *core = NULL;
if (node)
{
- core = (gnu::gcj::Core *) _Jv_AllocObject(&gnu::gcj::Core::class$,
- sizeof (gnu::gcj::Core));
+ core = new gnu::gcj::Core ();
core->ptr = (gnu::gcj::RawData *) node->data;
core->length = node->data_length;
}
Index: libjava/include/java-interp.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/include/java-interp.h,v
retrieving revision 1.23
diff -u -r1.23 java-interp.h
--- libjava/include/java-interp.h 24 Oct 2003 09:29:42 -0000 1.23
+++ libjava/include/java-interp.h 20 Apr 2004 21:50:30 -0000
@@ -22,7 +22,6 @@
#include <java/lang/Class.h>
#include <java/lang/ClassLoader.h>
#include <java/lang/reflect/Modifier.h>
-#include <gnu/gcj/runtime/StackTrace.h>
extern "C" {
#include <ffi.h>
@@ -80,7 +79,7 @@
{
protected:
// The class which defined this method.
- _Jv_InterpClass *defining_class;
+ jclass defining_class;
// The method description.
_Jv_Method *self;
@@ -150,6 +149,7 @@
friend class _Jv_BytecodeVerifier;
friend class gnu::gcj::runtime::NameFinder;
friend class gnu::gcj::runtime::StackTrace;
+
friend void _Jv_PrepareClass(jclass);
@@ -158,7 +158,7 @@
#endif
};
-class _Jv_InterpClass : public java::lang::Class
+class _Jv_InterpClass
{
_Jv_MethodBase **interpreted_methods;
_Jv_ushort *field_initializers;
@@ -185,13 +185,15 @@
_Jv_Defer_Resolution (void *cl, _Jv_Method *meth, void **address)
{
int i;
- _Jv_InterpClass *self = (_Jv_InterpClass *)cl;
+ jclass self = (jclass) cl;
+ _Jv_InterpClass *interp_cl = (_Jv_InterpClass*) self->aux_info;
+
for (i = 0; i < self->method_count; i++)
{
_Jv_Method *m = &self->methods[i];
if (m == meth)
{
- _Jv_MethodBase *imeth = self->interpreted_methods[i];
+ _Jv_MethodBase *imeth = interp_cl->interpreted_methods[i];
*address = imeth->deferred;
imeth->deferred = address;
return;
Index: libjava/java/io/natObjectInputStream.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/natObjectInputStream.cc,v
retrieving revision 1.6.28.1
diff -u -r1.6.28.1 natObjectInputStream.cc
--- libjava/java/io/natObjectInputStream.cc 16 Apr 2004 12:49:55 -0000 1.6.28.1
+++ libjava/java/io/natObjectInputStream.cc 20 Apr 2004 21:50:30 -0000
@@ -40,7 +40,7 @@
obj = NULL;
else
{
- obj = JvAllocObject (klass);
+ obj = _Jv_AllocObject (klass);
}
}
catch (jthrowable t)
Index: libjava/java/lang/Class.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/Class.h,v
retrieving revision 1.63.12.2
diff -u -r1.63.12.2 Class.h
--- libjava/java/lang/Class.h 20 Apr 2004 21:11:55 -0000 1.63.12.2
+++ libjava/java/lang/Class.h 20 Apr 2004 21:50:30 -0000
@@ -315,7 +315,7 @@
friend jfieldID JvGetFirstStaticField (jclass);
friend jint JvNumStaticFields (jclass);
- friend jobject _Jv_AllocObject (jclass, jint);
+ friend jobject _Jv_AllocObject (jclass);
friend void *_Jv_AllocObj (jint, jclass);
friend void *_Jv_AllocPtrFreeObj (jint, jclass);
friend void *_Jv_AllocArray (jint, jclass);
@@ -413,6 +413,7 @@
#endif
friend class _Jv_BytecodeVerifier;
+ friend class _Jv_StackTrace;
friend class gnu::gcj::runtime::StackTrace;
friend class java::io::VMObjectStreamClass;
@@ -478,6 +479,9 @@
JArray<jobject> *hack_signers;
// Used by Jv_PopClass and _Jv_PushClass to communicate with StackTrace.
jclass chain;
+ // Additional data, specific to the generator (JIT, native, interpreter) of this
+ // class.
+ void *aux_info;
};
#endif /* __JAVA_LANG_CLASS_H__ */
Index: libjava/java/lang/natClass.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natClass.cc,v
retrieving revision 1.75.2.2
diff -u -r1.75.2.2 natClass.cc
--- libjava/java/lang/natClass.cc 20 Apr 2004 21:11:55 -0000 1.75.2.2
+++ libjava/java/lang/natClass.cc 20 Apr 2004 21:50:30 -0000
@@ -763,7 +763,7 @@
if (! meth)
throw new java::lang::InstantiationException (getName());
- jobject r = JvAllocObject (this);
+ jobject r = _Jv_AllocObject (this);
((void (*) (jobject)) meth->ncode) (r);
return r;
}
@@ -2017,7 +2017,7 @@
|| (klass->accflags & Modifier::ABSTRACT))
return;
- // out before we can create a vtable.
+ // Class must be laid out before we can create a vtable.
if (klass->vtable_method_count == -1)
_Jv_LayoutVTableMethods (klass);
Index: libjava/java/lang/natClassLoader.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natClassLoader.cc,v
retrieving revision 1.64.8.1
diff -u -r1.64.8.1 natClassLoader.cc
--- libjava/java/lang/natClassLoader.cc 16 Apr 2004 12:49:53 -0000 1.64.8.1
+++ libjava/java/lang/natClassLoader.cc 20 Apr 2004 21:50:31 -0000
@@ -438,7 +438,7 @@
_Jv_NewClass (_Jv_Utf8Const *name, jclass superclass,
java::lang::ClassLoader *loader)
{
- jclass ret = (jclass) JvAllocObject (&java::lang::Class::class$);
+ jclass ret = (jclass) _Jv_AllocObject (&java::lang::Class::class$);
ret->name = name;
ret->superclass = superclass;
ret->loader = loader;
Index: libjava/java/lang/natObject.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natObject.cc,v
retrieving revision 1.29
diff -u -r1.29 natObject.cc
--- libjava/java/lang/natObject.cc 23 Oct 2003 21:48:36 -0000 1.29
+++ libjava/java/lang/natObject.cc 20 Apr 2004 21:50:31 -0000
@@ -98,7 +98,7 @@
throw new CloneNotSupportedException;
size = klass->size();
- r = JvAllocObject (klass, size);
+ r = _Jv_AllocObject (klass);
}
memcpy ((void *) r, (void *) this, size);
Index: libjava/java/lang/natString.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natString.cc,v
retrieving revision 1.33
diff -u -r1.33 natString.cc
--- libjava/java/lang/natString.cc 16 Oct 2003 21:28:23 -0000 1.33
+++ libjava/java/lang/natString.cc 20 Apr 2004 21:50:31 -0000
@@ -402,30 +402,6 @@
}
jstring
-_Jv_AllocString(jsize len)
-{
- jsize sz = sizeof(java::lang::String) + len * sizeof(jchar);
-
- // We assert that for strings allocated this way, the data field
- // will always point to the object itself. Thus there is no reason
- // for the garbage collector to scan any of it.
- // Furthermore, we're about to overwrite the string data, so
- // initialization of the object is not an issue.
-#ifdef ENABLE_JVMPI
- jstring obj = (jstring) _Jv_AllocPtrFreeObject(&StringClass, sz);
-#else
- // Class needs no initialization, and there is no finalizer, so
- // we can go directly to the collector's allocator interface.
- jstring obj = (jstring) _Jv_AllocPtrFreeObj(sz, &StringClass);
-#endif
- obj->data = obj;
- obj->boffset = sizeof(java::lang::String);
- obj->count = len;
- obj->cachedHashCode = 0;
- return obj;
-}
-
-jstring
_Jv_NewString(const jchar *chars, jsize len)
{
jstring str = _Jv_AllocString(len);
Index: libjava/java/lang/natVMClassLoader.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natVMClassLoader.cc,v
retrieving revision 1.1
diff -u -r1.1 natVMClassLoader.cc
--- libjava/java/lang/natVMClassLoader.cc 16 Jan 2004 23:54:22 -0000 1.1
+++ libjava/java/lang/natVMClassLoader.cc 20 Apr 2004 21:50:31 -0000
@@ -39,8 +39,8 @@
{
#ifdef INTERPRETER
jclass klass;
- klass = (jclass) JvAllocObject (&java::lang::Class::class$,
- sizeof (_Jv_InterpClass));
+ klass = new java::lang::Class ();
+ klass->aux_info = (void *) _Jv_AllocBytes (sizeof (_Jv_InterpClass));
// Synchronize on the class, so that it is not attempted initialized
// until we're done loading.
Index: libjava/java/lang/reflect/natMethod.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/reflect/natMethod.cc,v
retrieving revision 1.37.4.1
diff -u -r1.37.4.1 natMethod.cc
--- libjava/java/lang/reflect/natMethod.cc 16 Apr 2004 12:49:57 -0000 1.37.4.1
+++ libjava/java/lang/reflect/natMethod.cc 20 Apr 2004 21:50:31 -0000
@@ -379,7 +379,7 @@
// the JDK 1.2 docs specify that the new object must be allocated
// before argument conversions are done.
if (is_constructor)
- obj = JvAllocObject (return_type);
+ obj = _Jv_AllocObject (return_type);
const int size_per_arg = sizeof(jvalue);
ffi_cif cif;