mirror of git://gcc.gnu.org/git/gcc.git
prims.cc (_Jv_AllocObject): Remove `size' argument.
libjava: 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. 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. gcc/java: 2004-04-15 Bryce McKinlay <mckinlay@redhat.com> * expr.c (expand_java_NEW): Don't use size argument for _Jv_AllocObject calls. * parse.y (patch_invoke): Likewise. From-SVN: r80754
This commit is contained in:
parent
2f228199b9
commit
245c3c04af
|
@ -1,3 +1,8 @@
|
||||||
|
2004-04-15 Bryce McKinlay <mckinlay@redhat.com>
|
||||||
|
|
||||||
|
* init.c (build_new_1): Don't use type size argument for Java
|
||||||
|
_Jv_AllocObject call.
|
||||||
|
|
||||||
2004-04-09 Danny Smith <dannysmith@users.sourceforge.net>
|
2004-04-09 Danny Smith <dannysmith@users.sourceforge.net>
|
||||||
|
|
||||||
* method.c (make_alias_for_thunk): Remove preprocessor guard on
|
* method.c (make_alias_for_thunk): Remove preprocessor guard on
|
||||||
|
|
|
@ -2019,7 +2019,6 @@ build_new_1 (tree exp)
|
||||||
{
|
{
|
||||||
tree class_addr, alloc_decl;
|
tree class_addr, alloc_decl;
|
||||||
tree class_decl = build_java_class_ref (true_type);
|
tree class_decl = build_java_class_ref (true_type);
|
||||||
tree class_size = size_in_bytes (true_type);
|
|
||||||
static const char alloc_name[] = "_Jv_AllocObject";
|
static const char alloc_name[] = "_Jv_AllocObject";
|
||||||
use_java_new = 1;
|
use_java_new = 1;
|
||||||
if (!get_global_value_if_present (get_identifier (alloc_name),
|
if (!get_global_value_if_present (get_identifier (alloc_name),
|
||||||
|
@ -2037,8 +2036,7 @@ build_new_1 (tree exp)
|
||||||
class_addr = build1 (ADDR_EXPR, jclass_node, class_decl);
|
class_addr = build1 (ADDR_EXPR, jclass_node, class_decl);
|
||||||
alloc_call = (build_function_call
|
alloc_call = (build_function_call
|
||||||
(alloc_decl,
|
(alloc_decl,
|
||||||
tree_cons (NULL_TREE, class_addr,
|
build_tree_list (NULL_TREE, class_addr)));
|
||||||
build_tree_list (NULL_TREE, class_size))));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
2004-04-15 Bryce McKinlay <mckinlay@redhat.com>
|
||||||
|
|
||||||
|
* expr.c (expand_java_NEW): Don't use size argument for
|
||||||
|
_Jv_AllocObject calls.
|
||||||
|
* parse.y (patch_invoke): Likewise.
|
||||||
|
|
||||||
2004-04-12 Bryce McKinlay <mckinlay@redhat.com>
|
2004-04-12 Bryce McKinlay <mckinlay@redhat.com>
|
||||||
|
|
||||||
* expr.c (build_invokeinterface): Remove unused variables to
|
* expr.c (build_invokeinterface): Remove unused variables to
|
||||||
|
|
|
@ -1150,9 +1150,7 @@ expand_java_NEW (tree type)
|
||||||
safe_layout_class (type);
|
safe_layout_class (type);
|
||||||
push_value (build (CALL_EXPR, promote_type (type),
|
push_value (build (CALL_EXPR, promote_type (type),
|
||||||
build_address_of (alloc_node),
|
build_address_of (alloc_node),
|
||||||
tree_cons (NULL_TREE, build_class_ref (type),
|
build_tree_list (NULL_TREE, build_class_ref (type)),
|
||||||
build_tree_list (NULL_TREE,
|
|
||||||
size_in_bytes (type))),
|
|
||||||
NULL_TREE));
|
NULL_TREE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10863,11 +10863,9 @@ patch_invoke (tree patch, tree method, tree args)
|
||||||
(class_has_finalize_method (class) ? alloc_object_node
|
(class_has_finalize_method (class) ? alloc_object_node
|
||||||
: alloc_no_finalizer_node);
|
: alloc_no_finalizer_node);
|
||||||
new = build (CALL_EXPR, promote_type (class),
|
new = build (CALL_EXPR, promote_type (class),
|
||||||
build_address_of (alloc_node),
|
build_address_of (alloc_node),
|
||||||
tree_cons (NULL_TREE, build_class_ref (class),
|
build_tree_list (NULL_TREE, build_class_ref (class)),
|
||||||
build_tree_list (NULL_TREE,
|
NULL_TREE);
|
||||||
size_in_bytes (class))),
|
|
||||||
NULL_TREE);
|
|
||||||
saved_new = save_expr (new);
|
saved_new = save_expr (new);
|
||||||
c1 = build_tree_list (NULL_TREE, saved_new);
|
c1 = build_tree_list (NULL_TREE, saved_new);
|
||||||
TREE_CHAIN (c1) = TREE_OPERAND (original_call, 1);
|
TREE_CHAIN (c1) = TREE_OPERAND (original_call, 1);
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
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.
|
||||||
|
|
||||||
2004-04-14 Andrew Haley <aph@redhat.com>
|
2004-04-14 Andrew Haley <aph@redhat.com>
|
||||||
Bryce McKinlay <mckinlay@redhat.com>
|
Bryce McKinlay <mckinlay@redhat.com>
|
||||||
|
|
||||||
|
|
|
@ -23,13 +23,13 @@ details. */
|
||||||
extern inline jobject
|
extern inline jobject
|
||||||
JvAllocObject (jclass cls)
|
JvAllocObject (jclass cls)
|
||||||
{
|
{
|
||||||
return _Jv_AllocObject (cls, cls->size());
|
return _Jv_AllocObject (cls);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern inline jobject
|
extern inline jobject
|
||||||
JvAllocObject (jclass cls, jsize sz)
|
JvAllocObject (jclass cls, jsize sz)
|
||||||
{
|
{
|
||||||
return _Jv_AllocObject (cls, sz);
|
return _Jv_AllocObject (cls);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" jstring _Jv_NewStringUTF (const char *bytes);
|
extern "C" jstring _Jv_NewStringUTF (const char *bytes);
|
||||||
|
|
|
@ -450,17 +450,17 @@ struct _Jv_JNIEnv;
|
||||||
typedef struct _Jv_Field *jfieldID;
|
typedef struct _Jv_Field *jfieldID;
|
||||||
typedef struct _Jv_Method *jmethodID;
|
typedef struct _Jv_Method *jmethodID;
|
||||||
|
|
||||||
extern "C" jobject _Jv_AllocObject (jclass, jint) __attribute__((__malloc__));
|
extern "C" jobject _Jv_AllocObject (jclass) __attribute__((__malloc__));
|
||||||
extern "C" jobject _Jv_AllocObjectNoFinalizer (jclass, jint) __attribute__((__malloc__));
|
extern "C" jobject _Jv_AllocObjectNoFinalizer (jclass) __attribute__((__malloc__));
|
||||||
extern "C" jobject _Jv_AllocObjectNoInitNoFinalizer (jclass, jint) __attribute__((__malloc__));
|
extern "C" jobject _Jv_AllocObjectNoInitNoFinalizer (jclass) __attribute__((__malloc__));
|
||||||
#ifdef JV_HASH_SYNCHRONIZATION
|
#ifdef JV_HASH_SYNCHRONIZATION
|
||||||
extern "C" jobject _Jv_AllocPtrFreeObject (jclass, jint)
|
extern "C" jobject _Jv_AllocPtrFreeObject (jclass)
|
||||||
__attribute__((__malloc__));
|
__attribute__((__malloc__));
|
||||||
#else
|
#else
|
||||||
// Collector still needs to scan sync_info
|
// 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
|
#endif
|
||||||
extern "C" jboolean _Jv_IsInstanceOf(jobject, jclass);
|
extern "C" jboolean _Jv_IsInstanceOf(jobject, jclass);
|
||||||
|
|
|
@ -96,8 +96,7 @@ _Jv_create_core (_Jv_core_chain *node, jstring name)
|
||||||
gnu::gcj::Core *core = NULL;
|
gnu::gcj::Core *core = NULL;
|
||||||
if (node)
|
if (node)
|
||||||
{
|
{
|
||||||
core = (gnu::gcj::Core *) _Jv_AllocObject(&gnu::gcj::Core::class$,
|
core = new gnu::gcj::Core ();
|
||||||
sizeof (gnu::gcj::Core));
|
|
||||||
core->ptr = (gnu::gcj::RawData *) node->data;
|
core->ptr = (gnu::gcj::RawData *) node->data;
|
||||||
core->length = node->data_length;
|
core->length = node->data_length;
|
||||||
}
|
}
|
||||||
|
|
|
@ -286,7 +286,7 @@ private:
|
||||||
friend jfieldID JvGetFirstStaticField (jclass);
|
friend jfieldID JvGetFirstStaticField (jclass);
|
||||||
friend jint JvNumStaticFields (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_AllocObj (jint, jclass);
|
||||||
friend void *_Jv_AllocPtrFreeObj (jint, jclass);
|
friend void *_Jv_AllocPtrFreeObj (jint, jclass);
|
||||||
friend void *_Jv_AllocArray (jint, jclass);
|
friend void *_Jv_AllocArray (jint, jclass);
|
||||||
|
|
|
@ -401,30 +401,6 @@ java::lang::String::valueOf (jint num)
|
||||||
return _Jv_NewString (buffer+11-i, i);
|
return _Jv_NewString (buffer+11-i, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
jstring
|
||||||
_Jv_NewString(const jchar *chars, jsize len)
|
_Jv_NewString(const jchar *chars, jsize len)
|
||||||
{
|
{
|
||||||
|
|
|
@ -389,16 +389,15 @@ jvmpi_notify_alloc(jclass klass, jint size, jobject obj)
|
||||||
# define jvmpi_notify_alloc(klass,size,obj) /* do nothing */
|
# define jvmpi_notify_alloc(klass,size,obj) /* do nothing */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Allocate a new object of class KLASS. SIZE is the size of the object
|
// Allocate a new object of class KLASS.
|
||||||
// to allocate. You might think this is redundant, but it isn't; some
|
|
||||||
// classes, such as String, aren't of fixed size.
|
|
||||||
// First a version that assumes that we have no finalizer, and that
|
// First a version that assumes that we have no finalizer, and that
|
||||||
// the class is already initialized.
|
// the class is already initialized.
|
||||||
// If we know that JVMPI is disabled, this can be replaced by a direct call
|
// If we know that JVMPI is disabled, this can be replaced by a direct call
|
||||||
// to the allocator for the appropriate GC.
|
// to the allocator for the appropriate GC.
|
||||||
jobject
|
jobject
|
||||||
_Jv_AllocObjectNoInitNoFinalizer (jclass klass, jint size)
|
_Jv_AllocObjectNoInitNoFinalizer (jclass klass)
|
||||||
{
|
{
|
||||||
|
jint size = klass->size ();
|
||||||
jobject obj = (jobject) _Jv_AllocObj (size, klass);
|
jobject obj = (jobject) _Jv_AllocObj (size, klass);
|
||||||
jvmpi_notify_alloc (klass, size, obj);
|
jvmpi_notify_alloc (klass, size, obj);
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -406,9 +405,10 @@ _Jv_AllocObjectNoInitNoFinalizer (jclass klass, jint size)
|
||||||
|
|
||||||
// And now a version that initializes if necessary.
|
// And now a version that initializes if necessary.
|
||||||
jobject
|
jobject
|
||||||
_Jv_AllocObjectNoFinalizer (jclass klass, jint size)
|
_Jv_AllocObjectNoFinalizer (jclass klass)
|
||||||
{
|
{
|
||||||
_Jv_InitClass (klass);
|
_Jv_InitClass (klass);
|
||||||
|
jint size = klass->size ();
|
||||||
jobject obj = (jobject) _Jv_AllocObj (size, klass);
|
jobject obj = (jobject) _Jv_AllocObj (size, klass);
|
||||||
jvmpi_notify_alloc (klass, size, obj);
|
jvmpi_notify_alloc (klass, size, obj);
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -416,9 +416,9 @@ _Jv_AllocObjectNoFinalizer (jclass klass, jint size)
|
||||||
|
|
||||||
// And now the general version that registers a finalizer if necessary.
|
// And now the general version that registers a finalizer if necessary.
|
||||||
jobject
|
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
|
// We assume that the compiler only generates calls to this routine
|
||||||
// if there really is an interesting finalizer.
|
// if there really is an interesting finalizer.
|
||||||
|
@ -432,14 +432,62 @@ _Jv_AllocObject (jclass klass, jint size)
|
||||||
return obj;
|
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,
|
// A version of the above that assumes the object contains no pointers,
|
||||||
// and requires no finalization. This can't happen if we need pointers
|
// and requires no finalization. This can't happen if we need pointers
|
||||||
// to locks.
|
// to locks.
|
||||||
#ifdef JV_HASH_SYNCHRONIZATION
|
#ifdef JV_HASH_SYNCHRONIZATION
|
||||||
jobject
|
jobject
|
||||||
_Jv_AllocPtrFreeObject (jclass klass, jint size)
|
_Jv_AllocPtrFreeObject (jclass klass)
|
||||||
{
|
{
|
||||||
_Jv_InitClass (klass);
|
_Jv_InitClass (klass);
|
||||||
|
jint size = klass->size ();
|
||||||
|
|
||||||
jobject obj = (jobject) _Jv_AllocPtrFreeObj (size, klass);
|
jobject obj = (jobject) _Jv_AllocPtrFreeObj (size, klass);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue