You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by dl...@apache.org on 2007/08/12 23:23:57 UTC

svn commit: r565156 - /harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/heap_simple.c

Author: dlydick
Date: Sun Aug 12 14:23:56 2007
New Revision: 565156

URL: http://svn.apache.org/viewvc?view=rev&rev=565156
Log:
Added heap_init_flag parameter to heap_init_simple() and
heap_shutdown_simple().

Modified:
    harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/heap_simple.c

Modified: harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/heap_simple.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/heap_simple.c?view=diff&rev=565156&r1=565155&r2=565156
==============================================================================
--- harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/heap_simple.c (original)
+++ harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/heap_simple.c Sun Aug 12 14:23:56 2007
@@ -57,7 +57,6 @@
 "$URL$",
 "$Id$");
 
-#if defined(CONFIG_HEAP_TYPE_SIMPLE) || defined(CONFIG_COMPILE_ALL_OPTIONS)
 
 #include <errno.h>
 
@@ -76,20 +75,22 @@
  * to do, but in other methods there might be.
  *
  *
- * @b Parameters: @link #rvoid rvoid@endlink
+ * @param[out]   heap_init_flag   Pointer to rboolean, changed to
+ *                                @link #rtrue rtrue@endlink
+ *                                to indicate heap now available.
  *
  *
  * @returns @link #rvoid rvoid@endlink
  *
  */
-rvoid heap_init_simple()
+rvoid heap_init_simple(rboolean *heap_init_flag)
 {
     ARCH_FUNCTION_NAME(heap_init_simple);
 
     ; /* Nothing to do in this methodology */
 
     /* Declare this module initialized */
-    jvm_heap_initialized = rtrue;
+    *heap_init_flag = rtrue;
 
     return;
 
@@ -106,24 +107,115 @@
 /*!
  * @brief Number of calls to @c @b malloc(3).
  *
- * One of two global variables providing rudimentary statistics
+ * One of three global variables providing rudimentary statistics
  * for heap allocation history.
  *
  * @see heap_free_count
+ * @see heap_inuse_count
  */
 static rlong heap_malloc_count = 0;
 
 /*!
  * @brief Number of calls to @c @b free(3).
  *
- * One of two global variables providing rudimentary statistics
+ * One of three global variables providing rudimentary statistics
  * for heap allocation history.
  *
  * @see heap_malloc_count
+ * @see heap_inuse_count
  */
 static rlong heap_free_count   = 0;
 
 /*!
+ * @brief Number of @c @b malloc(3) blocks in use.
+ *
+ * One of three global variables providing rudimentary statistics
+ * for heap allocation history.
+ *
+ * @see heap_malloc_count
+ * @see heap_free_count
+ */
+static rlong heap_inuse_count   = 0;
+
+
+/*!
+ * @brief Report on status of heap initialization.
+ *
+ * Report on the heap configuration.
+ *
+ *
+ * @param   heap_init_flag   Pointer to status of heap initialization.
+ *
+ *
+ * @returns @link #rvoid rvoid@endlink
+ *
+ */
+rvoid heap_init_report_simple(rboolean *heap_init_flag)
+{
+    ARCH_FUNCTION_NAME(heap_init_report_simple);
+
+#define SETUP_MSG_DML DML5 /**< Initialization report debug msg level */
+
+    if (rtrue == *heap_init_flag)
+    {
+        sysDbgMsg(SETUP_MSG_DML,
+                  arch_function_name,
+                  "heap available");
+    }
+    else
+    {
+        sysDbgMsg(SETUP_MSG_DML,
+                  arch_function_name,
+                  "heap NOT available");
+    }
+
+    return;
+
+} /* END of heap_init_report_simple() */
+
+
+/*!
+ * @brief Report on status of heap management.
+ *
+ * Report on the status of the number of allocations made, freed, and
+ * currently in use.
+ *
+ *
+ * @param   heap_init_flag   Pointer to status of heap initialization.
+ *
+ *
+ * @returns @link #rvoid rvoid@endlink
+ *
+ */
+
+rvoid heap_report_simple(rboolean *heap_init_flag)
+{
+    ARCH_FUNCTION_NAME(heap_report_simple);
+
+#define CURRENT_MSG_DML DML5/**< Usage report debug msg level */
+
+    if (rtrue == *heap_init_flag)
+    {
+        sysDbgMsg(CURRENT_MSG_DML,
+                  arch_function_name,
+                  "malloc = %8x  free = %8x  inuse = %8x\n",
+                  heap_malloc_count,
+                  heap_free_count,
+                  heap_inuse_count);
+    }
+    else
+    {
+        sysDbgMsg(CURRENT_MSG_DML,
+                  arch_function_name,
+                  "heap NOT available");
+    }
+
+    return;
+
+} /* END of heap_report_simple() */
+
+
+/*!
  * @brief Simple heap allocation method that uses only @c @b malloc(3)
  * and @c @b free(3).
  *
@@ -232,6 +324,7 @@
     }
 
     heap_malloc_count++;
+    heap_inuse_count++;
 
     return(rc);
 
@@ -404,6 +497,7 @@
     {
         /* Free larger requests */
         heap_free_count++;
+        heap_inuse_count--;
 
         portable_free(pheap_block_local);
     }
@@ -535,26 +629,29 @@
  * @brief Shut down up heap management after JVM execution is finished.
  *
  *
- * @b Parameters: @link #rvoid rvoid@endlink
+ * @param[out]   heap_init_flag   Pointer to rboolean, changed to
+ *                                @link #rtrue rtrue@endlink
+ *                                to indicate heap no longer available.
  *
  *
  * @returns @link #rvoid rvoid@endlink
  *
  */
-rvoid heap_shutdown_simple()
+rvoid heap_shutdown_simple(rboolean *heap_init_flag)
 {
     ARCH_FUNCTION_NAME(heap_shutdown_simple);
 
     heap_last_errno = ERROR0;
 
+    heap_report_simple(heap_init_flag);
+
     /* Declare this module uninitialized */
-    jvm_heap_initialized = rfalse;
+    *heap_init_flag = rfalse;
 
     return;
 
 } /* END of heap_shutdown_simple() */
 
-#endif /* CONFIG_HEAP_TYPE_SIMPLE || CONFIG_OPTIONS_COMPILE_ALL */
 
 
 /* EOF */