Skip to content

Commit

Permalink
2004-04-19 Bryce McKinlay <mckinlay@redhat.com>
Browse files Browse the repository at this point in the history
	* class.c (make_class_data): Add new field aux_info.
	* decl.c (java_init_decl_processing): Push type and decl for
	`aux_info'.

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.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@80875 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
bryce committed Apr 20, 2004
1 parent 4c9902f commit 0233d85
Show file tree
Hide file tree
Showing 17 changed files with 113 additions and 82 deletions.
6 changes: 6 additions & 0 deletions gcc/java/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
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'.

2004-04-15 Bryce McKinlay <mckinlay@redhat.com>

* expr.c (expand_java_NEW): Don't use size argument for
Expand Down
1 change: 1 addition & 0 deletions gcc/java/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -1723,6 +1723,7 @@ make_class_data (tree type)
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);

Expand Down
1 change: 1 addition & 0 deletions gcc/java/decl.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ java_init_decl_processing (void)
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);
Expand Down
23 changes: 23 additions & 0 deletions libjava/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
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-17 Mark Wielaard <mark@klomp.org>

* javax/swing/JToggleButton.java (ToggleButtonModel):
Expand Down
4 changes: 3 additions & 1 deletion libjava/boehm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,13 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /* env */)
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);
Expand Down
32 changes: 18 additions & 14 deletions libjava/defineclass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ struct _Jv_ClassReader {
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)
Expand Down Expand Up @@ -221,7 +224,8 @@ struct _Jv_ClassReader {
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 */
Expand Down Expand Up @@ -1047,10 +1051,10 @@ void _Jv_ClassReader::handleFieldsBegin (int count)
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,
Expand Down Expand Up @@ -1133,7 +1137,7 @@ void _Jv_ClassReader::handleConstantValueAttribute (int field_index,
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 */

Expand All @@ -1153,7 +1157,7 @@ void _Jv_ClassReader::handleFieldsEnd ()
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)
Expand Down Expand Up @@ -1195,13 +1199,13 @@ _Jv_ClassReader::handleMethodsBegin (int count)
{
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;
}

Expand Down Expand Up @@ -1284,7 +1288,7 @@ void _Jv_ClassReader::handleCodeAttribute
(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))
{
Expand All @@ -1301,7 +1305,7 @@ void _Jv_ClassReader::handleExceptionTableEntry
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;
Expand All @@ -1319,7 +1323,7 @@ void _Jv_ClassReader::handleMethodsEnd ()
_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
{
Expand All @@ -1328,7 +1332,7 @@ void _Jv_ClassReader::handleMethodsEnd ()
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))
Expand All @@ -1344,12 +1348,12 @@ void _Jv_ClassReader::handleMethodsEnd ()
}
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");
}
}
Expand Down
12 changes: 0 additions & 12 deletions libjava/gcj/cni.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,6 @@ details. */

#include <string.h>

extern inline jobject
JvAllocObject (jclass cls)
{
return _Jv_AllocObject (cls);
}

extern inline jobject
JvAllocObject (jclass cls, jsize sz)
{
return _Jv_AllocObject (cls);
}

extern "C" jstring _Jv_NewStringUTF (const char *bytes);
extern "C" void _Jv_InitClass (jclass);

Expand Down
12 changes: 7 additions & 5 deletions libjava/include/java-interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ details. */
#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>
Expand Down Expand Up @@ -80,7 +79,7 @@ class _Jv_MethodBase
{
protected:
// The class which defined this method.
_Jv_InterpClass *defining_class;
jclass defining_class;

// The method description.
_Jv_Method *self;
Expand Down Expand Up @@ -150,6 +149,7 @@ class _Jv_InterpMethod : public _Jv_MethodBase
friend class _Jv_BytecodeVerifier;
friend class gnu::gcj::runtime::NameFinder;
friend class gnu::gcj::runtime::StackTrace;


friend void _Jv_PrepareClass(jclass);

Expand All @@ -158,7 +158,7 @@ class _Jv_InterpMethod : public _Jv_MethodBase
#endif
};

class _Jv_InterpClass : public java::lang::Class
class _Jv_InterpClass
{
_Jv_MethodBase **interpreted_methods;
_Jv_ushort *field_initializers;
Expand All @@ -185,13 +185,15 @@ extern inline void
_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;
Expand Down
2 changes: 1 addition & 1 deletion libjava/java/io/natObjectInputStream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ java::io::ObjectInputStream::allocateObject (jclass klass)
obj = NULL;
else
{
obj = JvAllocObject (klass);
obj = _Jv_AllocObject (klass);
}
}
catch (jthrowable t)
Expand Down
4 changes: 4 additions & 0 deletions libjava/java/lang/Class.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ class java::lang::Class : public java::lang::Object
#endif

friend class _Jv_BytecodeVerifier;
friend class _Jv_StackTrace;
friend class gnu::gcj::runtime::StackTrace;
friend class java::io::VMObjectStreamClass;

Expand Down Expand Up @@ -449,6 +450,9 @@ class java::lang::Class : public java::lang::Object
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__ */
4 changes: 2 additions & 2 deletions libjava/java/lang/natClass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ java::lang::Class::newInstance (void)
if (! meth)
throw new java::lang::InstantiationException (getName());

jobject r = JvAllocObject (this);
jobject r = _Jv_AllocObject (this);
((void (*) (jobject)) meth->ncode) (r);
return r;
}
Expand Down Expand Up @@ -1901,7 +1901,7 @@ _Jv_MakeVTable (jclass klass)
|| (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);

Expand Down
2 changes: 1 addition & 1 deletion libjava/java/lang/natClassLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ jclass
_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;
Expand Down
2 changes: 1 addition & 1 deletion libjava/java/lang/natObject.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ java::lang::Object::clone (void)
throw new CloneNotSupportedException;

size = klass->size();
r = JvAllocObject (klass, size);
r = _Jv_AllocObject (klass);
}

memcpy ((void *) r, (void *) this, size);
Expand Down
4 changes: 2 additions & 2 deletions libjava/java/lang/natVMClassLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ java::lang::VMClassLoader::defineClass (java::lang::ClassLoader *loader,
{
#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.
Expand Down
2 changes: 1 addition & 1 deletion libjava/java/lang/reflect/natMethod.cc
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ _Jv_CallAnyMethodA (jobject obj,
// 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;
Expand Down
2 changes: 1 addition & 1 deletion libjava/jni.cc
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ static jobject
if (clazz->isInterface() || Modifier::isAbstract(clazz->getModifiers()))
env->ex = new java::lang::InstantiationException ();
else
obj = JvAllocObject (clazz);
obj = _Jv_AllocObject (clazz);
}
catch (jthrowable t)
{
Expand Down
Loading

0 comments on commit 0233d85

Please sign in to comment.