changeset 2054:3c0a889a176b

Added GC stats. Enabling intrinsics.
author Thomas Wuerthinger <wuerthinger@ssw.jku.at>
date Wed, 12 Jan 2011 19:14:32 +0100
parents 0db8c8cc5b4a
children 99ad52189524
files c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/Compiler.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/CompilerObject.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotConstantPool.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotExceptionHandler.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotField.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethod.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodResolved.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotSignature.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTargetMethod.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotType.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypePrimitive.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotVMConfig.java src/cpu/x86/vm/c1_Runtime1_x86.cpp src/share/vm/c1x/c1x_CodeInstaller.cpp
diffstat 14 files changed, 65 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/Compiler.java	Tue Jan 11 17:02:38 2011 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/Compiler.java	Wed Jan 12 19:14:32 2011 +0100
@@ -20,6 +20,7 @@
  */
 package com.sun.hotspot.c1x;
 
+import java.lang.management.*;
 import java.lang.reflect.Proxy;
 import java.net.*;
 
@@ -40,6 +41,7 @@
 public final class Compiler {
 
     private static Compiler theInstance;
+    private static boolean PrintGCStats = false;
 
     public static Compiler getInstance() {
         if (theInstance == null) {
@@ -62,9 +64,33 @@
             if (C1XOptions.PrintTimers) {
                 C1XTimers.print();
             }
+
+            if (PrintGCStats) {
+                printGCStats();
+            }
         }
     }
 
+    public static void printGCStats() {
+        long totalGarbageCollections = 0;
+        long garbageCollectionTime = 0;
+
+        for (GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) {
+            long count = gc.getCollectionCount();
+            if (count >= 0) {
+                totalGarbageCollections += count;
+            }
+
+            long time = gc.getCollectionTime();
+            if (time >= 0) {
+                garbageCollectionTime += time;
+            }
+        }
+
+        System.out.println("Total Garbage Collections: " + totalGarbageCollections);
+        System.out.println("Total Garbage Collection Time (ms): " + garbageCollectionTime);
+    }
+
     public static VMExits initializeServer(VMEntries entries) {
         if (Logger.ENABLED) {
             vmEntries = LoggingProxy.getProxy(VMEntries.class, entries);
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/CompilerObject.java	Tue Jan 11 17:02:38 2011 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/CompilerObject.java	Wed Jan 12 19:14:32 2011 +0100
@@ -28,5 +28,26 @@
  *
  * @author Lukas Stadler
  */
-public interface CompilerObject extends Serializable {
+public abstract class CompilerObject implements Serializable {
+
+
+    private static final boolean PrintStats = false;
+    private static int AllocatedCount;
+    private static int FinalizeCount;
+
+    public CompilerObject() {
+        AllocatedCount++;
+        if (PrintStats && AllocatedCount % 1000 == 0) {
+            System.out.println("Allocated " + AllocatedCount);
+        }
+    }
+
+    @Override
+    protected void finalize() throws Throwable {
+        FinalizeCount++;
+        if (PrintStats && FinalizeCount % 1000 == 0) {
+            System.out.println("Finalized " + FinalizeCount);
+        }
+        super.finalize();
+    }
 }
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotConstantPool.java	Tue Jan 11 17:02:38 2011 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotConstantPool.java	Wed Jan 12 19:14:32 2011 +0100
@@ -27,7 +27,7 @@
  *
  * @author Thomas Wuerthinger, Lukas Stadler
  */
-public class HotSpotConstantPool implements RiConstantPool, CompilerObject {
+public class HotSpotConstantPool extends CompilerObject implements RiConstantPool {
 
     private final long vmId;
 
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotExceptionHandler.java	Tue Jan 11 17:02:38 2011 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotExceptionHandler.java	Wed Jan 12 19:14:32 2011 +0100
@@ -23,7 +23,7 @@
 import com.sun.cri.ri.*;
 
 
-public class HotSpotExceptionHandler implements RiExceptionHandler, CompilerObject {
+public class HotSpotExceptionHandler extends CompilerObject implements RiExceptionHandler {
     private int startBci;
     private int endBci;
     private int handlerBci;
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotField.java	Tue Jan 11 17:02:38 2011 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotField.java	Wed Jan 12 19:14:32 2011 +0100
@@ -31,7 +31,7 @@
  *
  * @author Thomas Wuerthinger, Lukas Stadler
  */
-public class HotSpotField implements RiField, CompilerObject {
+public class HotSpotField extends CompilerObject implements RiField {
 
     private final RiType holder;
     private final String name;
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethod.java	Tue Jan 11 17:02:38 2011 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethod.java	Wed Jan 12 19:14:32 2011 +0100
@@ -23,6 +23,6 @@
 import com.sun.cri.ri.*;
 
 
-public interface HotSpotMethod extends RiMethod, CompilerObject {
+public interface HotSpotMethod extends RiMethod {
 
 }
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodResolved.java	Tue Jan 11 17:02:38 2011 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodResolved.java	Wed Jan 12 19:14:32 2011 +0100
@@ -30,7 +30,7 @@
  *
  * @author Thomas Wuerthinger, Lukas Stadler
  */
-public class HotSpotMethodResolved implements HotSpotMethod {
+public class HotSpotMethodResolved extends CompilerObject implements HotSpotMethod {
 
     private final long vmId;
     private final String name;
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotSignature.java	Tue Jan 11 17:02:38 2011 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotSignature.java	Wed Jan 12 19:14:32 2011 +0100
@@ -30,7 +30,7 @@
  *
  * @author Thomas Wuerthinger, Lukas Stadler
  */
-public class HotSpotSignature implements RiSignature, CompilerObject {
+public class HotSpotSignature extends CompilerObject implements RiSignature {
 
     private final List<String> arguments = new ArrayList<String>();
     private final String returnType;
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTargetMethod.java	Tue Jan 11 17:02:38 2011 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTargetMethod.java	Wed Jan 12 19:14:32 2011 +0100
@@ -31,7 +31,7 @@
  *
  * @author Lukas Stadler
  */
-public final class HotSpotTargetMethod implements CompilerObject {
+public final class HotSpotTargetMethod extends CompilerObject {
 
     public final CiTargetMethod targetMethod;
     public final HotSpotMethodResolved method; // used only for methods
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotType.java	Tue Jan 11 17:02:38 2011 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotType.java	Wed Jan 12 19:14:32 2011 +0100
@@ -27,7 +27,7 @@
  *
  * @author Lukas Stadler
  */
-public interface HotSpotType extends RiType, CompilerObject {
+public interface HotSpotType extends RiType {
 
     String simpleName();
 
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypePrimitive.java	Tue Jan 11 17:02:38 2011 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypePrimitive.java	Wed Jan 12 19:14:32 2011 +0100
@@ -28,7 +28,7 @@
  *
  * @author Thomas Wuerthinger, Lukas Stadler
  */
-public final class HotSpotTypePrimitive implements HotSpotType {
+public final class HotSpotTypePrimitive extends CompilerObject implements HotSpotType {
 
     private CiKind kind;
 
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotVMConfig.java	Tue Jan 11 17:02:38 2011 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotVMConfig.java	Wed Jan 12 19:14:32 2011 +0100
@@ -27,7 +27,7 @@
  *
  * @author Lukas Stadler
  */
-public class HotSpotVMConfig implements CompilerObject {
+public class HotSpotVMConfig extends CompilerObject {
 
     // os information, register layout, code generation, ...
     public boolean windowsOs;
--- a/src/cpu/x86/vm/c1_Runtime1_x86.cpp	Tue Jan 11 17:02:38 2011 +0100
+++ b/src/cpu/x86/vm/c1_Runtime1_x86.cpp	Wed Jan 12 19:14:32 2011 +0100
@@ -1343,8 +1343,8 @@
         // will be place in C abi locations
 
 #ifdef _LP64
-        __ verify_oop(c_rarg0);
-        __ mov(rax, c_rarg0);
+        __ verify_oop((UseC1X) ? j_rarg0 : c_rarg0);
+        __ mov(rax, (UseC1X) ? j_rarg0 : c_rarg0);
 #else
         // The object is passed on the stack and we haven't pushed a
         // frame yet so it's one work away from top of stack.
--- a/src/share/vm/c1x/c1x_CodeInstaller.cpp	Tue Jan 11 17:02:38 2011 +0100
+++ b/src/share/vm/c1x/c1x_CodeInstaller.cpp	Wed Jan 12 19:14:32 2011 +0100
@@ -520,9 +520,12 @@
       call->set_destination(Runtime1::entry_for(Runtime1::c1x_arithmetic_drem_id));
       _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec(), Assembler::call32_operand);
       TRACE_C1X_3("CiRuntimeCall::ArithmeticDrem()");
+    } else if (runtime_call == CiRuntimeCall::RegisterFinalizer()) {
+      call->set_destination(Runtime1::entry_for(Runtime1::register_finalizer_id));
+      _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec(), Assembler::call32_operand);
     } else {
-      TRACE_C1X_1("runtime_call not implemented: ");
-      IF_TRACE_C1X_1 runtime_call->print();
+      runtime_call->print();
+      fatal("runtime_call not implemented");
     }
   } else if (global_stub != NULL) {
     NativeInstruction* inst = nativeInstruction_at(_instructions->start() + pc_offset);