MethodPool: removed demo call stuff - added printGCStats instead;
authorHarald Steinlechner <haraldsteinlechner@gmail.com>
Fri, 24 Aug 2012 12:41:38 +0000 (14:41 +0200)
committerHarald Steinlechner <haraldsteinlechner@gmail.com>
Fri, 24 Aug 2012 12:41:38 +0000 (14:41 +0200)
added Makefile to build simple GC tests in scratch (tests which cannot be run with openjdk currently because  native interface stuff);

Makefile
Mate/GarbageAlloc.hs
Mate/MethodPool.hs
jmate/lang/MateRuntime.java
scratch/GCTest.java [new file with mode: 0644]

index 04685026df52dccae37e8038c26ef96ad9c5c21a..f05bf977c067f0c1dd97cd141509876cd4433335 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -88,7 +88,8 @@ clean:
        rm -rf $(BUILD) mate mate.static mate.dbg ffi/native.o \
                tests/*.class Mate/*_stub.* \
                jmate/lang/*.class jmate/io/*.class java/io/*.class \
-               java/lang/{Integer,Character,String,System}.class
+               java/lang/{Integer,Character,String,System}.class \
+               scratch/*.class
 
 ghci: mate.static
        ghci -I. $(PACKAGES) -outputdir $(B_STATIC) Mate.hs $(GHC_CPP)
@@ -107,3 +108,8 @@ hlint:
        @# ignore error code from hlint
        -hlint Mate.hs Mate/
        @mv debug_tmp.h debug.h
+
+scratch: mate $(wildcard jmate/lang/*.java) scratch/GCTest.java
+       javac $(wildcard jmate/lang/*.java)
+       javac scratch/GCTest.java
+       ./mate scratch.GCTest  
index 5dccda0f806332ec2e6cd7ba401d46865ea9b32d..dc806b7418a99a90ab10fe3f5f1a77baacf4ca3f 100644 (file)
@@ -8,14 +8,15 @@ module Mate.GarbageAlloc(
     getHeapMemory,
     printMemoryUsage,
     mallocStringVM,
-    mallocObjectVM)  where
+    mallocObjectVM,
+    printGCStats)  where
 
 import Foreign
 import Foreign.C
 
 import Mate.GC.Boehm
 
-import Text.Printf
+--import Text.Printf
 import Mate.Debug
 
 -- unified place for allocating Memory
@@ -49,17 +50,13 @@ mallocObjectVM size = do
   printfStr "mallocObject VM: %d\n" size
   return $ fromIntegral $ ptrToIntPtr ptr
 
--- TODO: delete me
-foreign export ccall demoInterfaceCall :: CUInt -> IO ()
-demoInterfaceCall :: CUInt -> IO ()
-demoInterfaceCall val = do
-  printf "demoInterfaceCall: 0x%08x\n" (fromIntegral val :: Word32)
-  return ()
-
 getHeapMemory :: IO Int
 getHeapMemory = getHeapSizeGC
 
-
 foreign export ccall printMemoryUsage :: IO ()
 printMemoryUsage :: IO ()
 printMemoryUsage = getHeapMemory >>= print
+
+foreign export ccall printGCStats :: IO ()
+printGCStats :: IO ()
+printGCStats = putStrLn "Should print GC Stats"
index 4be3cf2577a7764660e59c19b1a55d01c33c6c1a..79b63e3ca2d9ec768221830cd14d0b926eaf6b48 100644 (file)
@@ -37,15 +37,15 @@ import Mate.Rts()
 foreign import ccall "dynamic"
    code_void :: FunPtr (IO ()) -> IO ()
 
-foreign import ccall "&demoInterfaceCall"
-  demoInterfaceCallAddr :: FunPtr (CUInt -> IO ())
-
 foreign import ccall "&printMemoryUsage"
   printMemoryUsageAddr :: FunPtr (IO ())
  
 foreign import ccall "&loadLibrary"
   loadLibraryAddr :: FunPtr (IO ())
 
+foreign import ccall "&printGCStats"
+  printGCStatsAddr :: FunPtr (IO ())
+
 getMethodEntry :: CPtrdiff -> CPtrdiff -> IO CPtrdiff
 getMethodEntry signal_from methodtable = do
   mmap <- getMethodMap
@@ -79,8 +79,8 @@ getMethodEntry signal_from methodtable = do
                   case smethod of
                     "loadLibrary" ->
                        return . funPtrToAddr $ loadLibraryAddr
-                    "demoInterfaceCall" ->
-                       return . funPtrToAddr $ demoInterfaceCallAddr
+                    "printGCStats" ->
+                       return . funPtrToAddr $ printGCStatsAddr
                     "printMemoryUsage" ->
                        return . funPtrToAddr $ printMemoryUsageAddr
                     _ ->
index 678182bf7b713605cd086f5eef42a5957be905ad..d9d1d5f1ff7c1d5427cce0b0cbbbd0b33f6e8ccd 100644 (file)
@@ -4,4 +4,5 @@ public class MateRuntime {
 
        public static native void loadLibrary(String lib);
         public static native int getCurrentHeapSize();
+       public static native void printGCStats();
 }
diff --git a/scratch/GCTest.java b/scratch/GCTest.java
new file mode 100644 (file)
index 0000000..d6896d4
--- /dev/null
@@ -0,0 +1,29 @@
+package scratch;
+
+import jmate.lang.MateRuntime;
+
+public class GCTest
+{
+       public static void main(String[] args)
+       {
+               List myList = new List(3,
+                       new List(5,
+                               new List(6,
+                                       new List(10,null))));
+
+               MateRuntime.printGCStats();
+               System.out.println("done.");
+       }
+} 
+
+class List
+{
+       public int elem;
+       public List xs;
+
+       public List(int elem, List xs)
+       {
+               this.elem = elem;
+               this.xs = xs;
+       }
+}