changeset 13216:51e97f88c771

Profile deoptimizations of OSR methods separately.
author Roland Schatz <roland.schatz@oracle.com>
date Tue, 03 Dec 2013 11:25:40 +0100
parents dca16b3416ab
children 210f58e992a1
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProfilingInfo.java src/share/vm/oops/methodData.hpp src/share/vm/runtime/deoptimization.cpp src/share/vm/runtime/deoptimization.hpp
diffstat 6 files changed, 35 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Tue Dec 03 11:10:16 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Tue Dec 03 11:25:40 2013 +0100
@@ -1145,6 +1145,7 @@
     @HotSpotVMConstant(name = "Deoptimization::Reason_constraint") @Stable public int deoptReasonConstraint;
     @HotSpotVMConstant(name = "Deoptimization::Reason_loop_limit_check") @Stable public int deoptReasonLoopLimitCheck;
     @HotSpotVMConstant(name = "Deoptimization::Reason_aliasing") @Stable public int deoptReasonAliasing;
+    @HotSpotVMConstant(name = "Deoptimization::Reason_LIMIT") @Stable public int deoptReasonOSROffset;
 
     @HotSpotVMConstant(name = "Deoptimization::Action_none") @Stable public int deoptActionNone;
     @HotSpotVMConstant(name = "Deoptimization::Action_maybe_recompile") @Stable public int deoptActionMaybeRecompile;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java	Tue Dec 03 11:10:16 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java	Tue Dec 03 11:25:40 2013 +0100
@@ -95,6 +95,11 @@
         return unsafe.getByte(metaspaceMethodData + config.methodDataOopTrapHistoryOffset + reasonIndex) & 0xFF;
     }
 
+    public int getOSRDeoptimizationCount(DeoptimizationReason reason) {
+        int reasonIndex = runtime().getHostProviders().getMetaAccess().convertDeoptReason(reason);
+        return unsafe.getByte(metaspaceMethodData + config.methodDataOopTrapHistoryOffset + config.deoptReasonOSROffset + reasonIndex) & 0xFF;
+    }
+
     public HotSpotMethodDataAccessor getNormalData(int position) {
         if (position >= normalDataSize) {
             return null;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProfilingInfo.java	Tue Dec 03 11:10:16 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProfilingInfo.java	Tue Dec 03 11:25:40 2013 +0100
@@ -95,7 +95,7 @@
 
     @Override
     public int getDeoptimizationCount(DeoptimizationReason reason) {
-        return methodData.getDeoptimizationCount(reason);
+        return methodData.getDeoptimizationCount(reason) + methodData.getOSRDeoptimizationCount(reason);
     }
 
     private void findBCI(int targetBCI, boolean searchExtraData) {
--- a/src/share/vm/oops/methodData.hpp	Tue Dec 03 11:10:16 2013 +0100
+++ b/src/share/vm/oops/methodData.hpp	Tue Dec 03 11:25:40 2013 +0100
@@ -1900,7 +1900,11 @@
 
   // Whole-method sticky bits and flags
   enum {
+#ifdef GRAAL
+    _trap_hist_limit    = 18,   // decoupled from Deoptimization::Reason_LIMIT
+#else
     _trap_hist_limit    = 17,   // decoupled from Deoptimization::Reason_LIMIT
+#endif
     _trap_hist_mask     = max_jubyte,
     _extra_data_count   = 4     // extra DataLayout headers, for trap history
   }; // Public flag values
@@ -1910,7 +1914,11 @@
   uint _nof_overflow_traps;         // trap count, excluding _trap_hist
   union {
     intptr_t _align;
+#ifdef GRAAL
+    u1 _array[2*_trap_hist_limit];
+#else
     u1 _array[_trap_hist_limit];
+#endif
   } _trap_hist;
 
   // Support for interprocedural escape analysis, from Thomas Kotzmann.
--- a/src/share/vm/runtime/deoptimization.cpp	Tue Dec 03 11:10:16 2013 +0100
+++ b/src/share/vm/runtime/deoptimization.cpp	Tue Dec 03 11:25:40 2013 +0100
@@ -1618,6 +1618,9 @@
       bool maybe_prior_trap = false;
       bool maybe_prior_recompile = false;
       pdata = query_update_method_data(trap_mdo, trap_bci, reason, true,
+#ifdef GRAAL
+                                   nm->is_compiled_by_graal() && nm->is_osr_method(),
+#endif
                                    //outputs:
                                    this_trap_count,
                                    maybe_prior_trap,
@@ -1752,6 +1755,9 @@
                                          int trap_bci,
                                          Deoptimization::DeoptReason reason,
                                          bool update_total_trap_count,
+#ifdef GRAAL
+                                         bool is_osr,
+#endif
                                          //outputs:
                                          uint& ret_this_trap_count,
                                          bool& ret_maybe_prior_trap,
@@ -1760,8 +1766,14 @@
   bool maybe_prior_recompile = false;
   uint this_trap_count = 0;
   if (update_total_trap_count) {
-    uint prior_trap_count = trap_mdo->trap_count(reason);
-    this_trap_count  = trap_mdo->inc_trap_count(reason);
+    uint idx = reason;
+#ifdef GRAAL
+    if (is_osr) {
+      idx += Reason_LIMIT;
+    }
+#endif
+    uint prior_trap_count = trap_mdo->trap_count(idx);
+    this_trap_count  = trap_mdo->inc_trap_count(idx);
 
     // If the runtime cannot find a place to store trap history,
     // it is estimated based on the general condition of the method.
@@ -1826,6 +1838,9 @@
   query_update_method_data(trap_mdo, trap_bci,
                            (DeoptReason)reason,
                            update_total_counts,
+#ifdef GRAAL
+                           false,
+#endif
                            ignore_this_trap_count,
                            ignore_maybe_prior_trap,
                            ignore_maybe_prior_recompile);
--- a/src/share/vm/runtime/deoptimization.hpp	Tue Dec 03 11:10:16 2013 +0100
+++ b/src/share/vm/runtime/deoptimization.hpp	Tue Dec 03 11:25:40 2013 +0100
@@ -378,6 +378,9 @@
                                                int trap_bci,
                                                DeoptReason reason,
                                                bool update_total_trap_count,
+#ifdef GRAAL
+                                               bool is_osr,
+#endif
                                                //outputs:
                                                uint& ret_this_trap_count,
                                                bool& ret_maybe_prior_trap,