OSDN Git Service

libjava:
authorbryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 16 Apr 2004 16:27:19 +0000 (16:27 +0000)
committerbryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 16 Apr 2004 16:27:19 +0000 (16:27 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@80754 138bc75d-0d04-0410-961f-82ee72b054a4

12 files changed:
gcc/cp/ChangeLog
gcc/cp/init.c
gcc/java/ChangeLog
gcc/java/expr.c
gcc/java/parse.y
libjava/ChangeLog
libjava/gcj/cni.h
libjava/gcj/javaprims.h
libjava/gnu/gcj/natCore.cc
libjava/java/lang/Class.h
libjava/java/lang/natString.cc
libjava/prims.cc

index c0b5725..a3a2c6a 100644 (file)
@@ -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>
 
        * method.c (make_alias_for_thunk): Remove preprocessor guard on
index e9142b7..5a64ed5 100644 (file)
@@ -2019,7 +2019,6 @@ build_new_1 (tree exp)
     {
       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 @@ build_new_1 (tree exp)
       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 6336c2e..ac5a568 100644 (file)
@@ -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>
 
        * expr.c (build_invokeinterface): Remove unused variables to
index 2c0312e..839480b 100644 (file)
@@ -1150,9 +1150,7 @@ expand_java_NEW (tree type)
   safe_layout_class (type);
   push_value (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_in_bytes (type))),
+                    build_tree_list (NULL_TREE, build_class_ref (type)),
                     NULL_TREE));
 }
 
index a21fc2a..7d4c2de 100644 (file)
@@ -10863,11 +10863,9 @@ patch_invoke (tree patch, tree method, tree args)
        (class_has_finalize_method (class) ? alloc_object_node
                                           : alloc_no_finalizer_node);
       new = build (CALL_EXPR, promote_type (class),
-                  build_address_of (alloc_node),
-                  tree_cons (NULL_TREE, build_class_ref (class),
-                             build_tree_list (NULL_TREE,
-                                              size_in_bytes (class))),
-                  NULL_TREE);
+                    build_address_of (alloc_node),
+                    build_tree_list (NULL_TREE, build_class_ref (class)),
+                    NULL_TREE);
       saved_new = save_expr (new);
       c1 = build_tree_list (NULL_TREE, saved_new);
       TREE_CHAIN (c1) = TREE_OPERAND (original_call, 1);
index 297bd70..bae0343 100644 (file)
@@ -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>
             Bryce McKinlay  <mckinlay@redhat.com>
 
index 3790dc4..4040f19 100644 (file)
@@ -23,13 +23,13 @@ details.  */
 extern inline jobject
 JvAllocObject (jclass cls)
 {
-  return _Jv_AllocObject (cls, cls->size());
+  return _Jv_AllocObject (cls);
 }
 
 extern inline jobject
 JvAllocObject (jclass cls, jsize sz)
 {
-  return _Jv_AllocObject (cls, sz);
+  return _Jv_AllocObject (cls);
 }
 
 extern "C" jstring _Jv_NewStringUTF (const char *bytes);
index 60f99cf..0cdd550 100644 (file)
@@ -450,17 +450,17 @@ struct _Jv_JNIEnv;
 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 91b0247..bb3fd57 100644 (file)
@@ -96,8 +96,7 @@ _Jv_create_core (_Jv_core_chain *node, jstring name)
   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 1577628..b8a8d90 100644 (file)
@@ -286,7 +286,7 @@ private:
   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);
index 8217f70..e01f467 100644 (file)
@@ -402,30 +402,6 @@ java::lang::String::valueOf (jint num)
 }
 
 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 06791d3..29f2b20 100644 (file)
@@ -389,16 +389,15 @@ jvmpi_notify_alloc(jclass klass, jint size, jobject obj)
 # 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)
 {
+  jint size = klass->size ();
   jobject obj = (jobject) _Jv_AllocObj (size, klass);
   jvmpi_notify_alloc (klass, size, obj);
   return obj;
@@ -406,9 +405,10 @@ _Jv_AllocObjectNoInitNoFinalizer (jclass klass, jint size)
 
 // And now a version that initializes if necessary.
 jobject
-_Jv_AllocObjectNoFinalizer (jclass klass, jint size)
+_Jv_AllocObjectNoFinalizer (jclass klass)
 {
   _Jv_InitClass (klass);
+  jint size = klass->size ();
   jobject obj = (jobject) _Jv_AllocObj (size, klass);
   jvmpi_notify_alloc (klass, size, obj);
   return obj;
@@ -416,10 +416,10 @@ _Jv_AllocObjectNoFinalizer (jclass klass, jint size)
 
 // 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
@@ -432,14 +432,62 @@ _Jv_AllocObject (jclass klass, jint size)
   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);