changeset 54672:3997614d4834

8218031: Zero broken after JDK-8217922 (Compiler dead code removal) Reviewed-by: thartmann, sgehwolf, shade Contributed-by: Ao Qi <aoqi@loongson.cn>
author shade
date Wed, 30 Jan 2019 18:34:31 +0100
parents ab7fcc43dab4
children f5480f924571
files src/hotspot/share/interpreter/invocationCounter.cpp src/hotspot/share/interpreter/invocationCounter.hpp
diffstat 2 files changed, 23 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/interpreter/invocationCounter.cpp	Wed Jan 30 18:27:40 2019 +0100
+++ b/src/hotspot/share/interpreter/invocationCounter.cpp	Wed Jan 30 18:34:31 2019 +0100
@@ -79,6 +79,10 @@
 int                       InvocationCounter::_init  [InvocationCounter::number_of_states];
 InvocationCounter::Action InvocationCounter::_action[InvocationCounter::number_of_states];
 
+#ifdef CC_INTERP
+int                       InvocationCounter::InterpreterInvocationLimit;
+int                       InvocationCounter::InterpreterBackwardBranchLimit;
+#endif
 
 const char* InvocationCounter::state_as_string(State state) {
   switch (state) {
@@ -132,6 +136,22 @@
   guarantee((int)number_of_states <= (int)state_limit, "adjust number_of_state_bits");
   def(wait_for_nothing, 0, do_nothing);
   def(wait_for_compile, 0, do_decay);
+
+#ifdef CC_INTERP
+  InterpreterInvocationLimit = CompileThreshold << number_of_noncount_bits;
+
+  // When methodData is collected, the backward branch limit is compared against a
+  // methodData counter, rather than an InvocationCounter.  In the former case, we
+  // don't need the shift by number_of_noncount_bits, but we do need to adjust
+  // the factor by which we scale the threshold.
+  if (ProfileInterpreter) {
+    InterpreterBackwardBranchLimit = (int)((int64_t)CompileThreshold * (OnStackReplacePercentage - InterpreterProfilePercentage) / 100);
+  } else {
+    InterpreterBackwardBranchLimit = (int)(((int64_t)CompileThreshold * OnStackReplacePercentage / 100) << number_of_noncount_bits);
+  }
+
+  assert(0 <= InterpreterBackwardBranchLimit, "OSR threshold should be non-negative");
+#endif
 }
 
 void invocationCounter_init() {
--- a/src/hotspot/share/interpreter/invocationCounter.hpp	Wed Jan 30 18:27:40 2019 +0100
+++ b/src/hotspot/share/interpreter/invocationCounter.hpp	Wed Jan 30 18:34:31 2019 +0100
@@ -92,6 +92,9 @@
   int    count() const                           { return _counter >> number_of_noncount_bits; }
 
 #ifdef CC_INTERP
+  static int InterpreterInvocationLimit;        // CompileThreshold scaled for interpreter use
+  static int InterpreterBackwardBranchLimit;    // A separate threshold for on stack replacement
+
   // Test counter using scaled limits like the asm interpreter would do rather than doing
   // the shifts to normalize the counter.
   // Checks sum of invocation_counter and backedge_counter as the template interpreter does.
@@ -103,11 +106,6 @@
     return (_counter & count_mask) + (back_edge_count->_counter & count_mask) >=
            (unsigned int) InterpreterBackwardBranchLimit;
   }
-  // Do this just like asm interpreter does for max speed.
-  bool reached_ProfileLimit(InvocationCounter *back_edge_count) const {
-    return (_counter & count_mask) + (back_edge_count->_counter & count_mask) >=
-           (unsigned int) InterpreterProfileLimit;
-  }
 #endif // CC_INTERP
 
   void increment()                               { _counter += count_increment; }