8025566: EXCEPTION_ACCESS_VIOLATION in compiled by C1 String.valueOf method
authortwisti
Mon, 07 Oct 2013 10:41:56 -0700
changeset 20695 4f5a5e95090b
parent 20694 2b8425bb18c2
child 20696 946797ddfade
8025566: EXCEPTION_ACCESS_VIOLATION in compiled by C1 String.valueOf method Reviewed-by: kvn
hotspot/src/share/vm/c1/c1_LIRGenerator.cpp
hotspot/src/share/vm/ci/ciMethod.cpp
hotspot/src/share/vm/ci/ciMethod.hpp
hotspot/src/share/vm/ci/ciMethodData.cpp
hotspot/src/share/vm/ci/ciMethodData.hpp
hotspot/src/share/vm/ci/ciReplay.cpp
hotspot/src/share/vm/oops/method.hpp
hotspot/src/share/vm/opto/parseHelper.cpp
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Mon Oct 07 14:13:28 2013 +0400
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Mon Oct 07 10:41:56 2013 -0700
@@ -3053,7 +3053,11 @@
   int offset = -1;
   LIR_Opr counter_holder;
   if (level == CompLevel_limited_profile) {
-    address counters_adr = method->ensure_method_counters();
+    MethodCounters* counters_adr = method->ensure_method_counters();
+    if (counters_adr == NULL) {
+      bailout("method counters allocation failed");
+      return;
+    }
     counter_holder = new_pointer_register();
     __ move(LIR_OprFact::intptrConst(counters_adr), counter_holder);
     offset = in_bytes(backedge ? MethodCounters::backedge_counter_offset() :
--- a/hotspot/src/share/vm/ci/ciMethod.cpp	Mon Oct 07 14:13:28 2013 +0400
+++ b/hotspot/src/share/vm/ci/ciMethod.cpp	Mon Oct 07 10:41:56 2013 -0700
@@ -846,7 +846,9 @@
 // Return true if allocation was successful or no MDO is required.
 bool ciMethod::ensure_method_data(methodHandle h_m) {
   EXCEPTION_CONTEXT;
-  if (is_native() || is_abstract() || h_m()->is_accessor()) return true;
+  if (is_native() || is_abstract() || h_m()->is_accessor()) {
+    return true;
+  }
   if (h_m()->method_data() == NULL) {
     Method::build_interpreter_method_data(h_m, THREAD);
     if (HAS_PENDING_EXCEPTION) {
@@ -903,22 +905,21 @@
 // NULL otherwise.
 ciMethodData* ciMethod::method_data_or_null() {
   ciMethodData *md = method_data();
-  if (md->is_empty()) return NULL;
+  if (md->is_empty()) {
+    return NULL;
+  }
   return md;
 }
 
 // ------------------------------------------------------------------
 // ciMethod::ensure_method_counters
 //
-address ciMethod::ensure_method_counters() {
+MethodCounters* ciMethod::ensure_method_counters() {
   check_is_loaded();
   VM_ENTRY_MARK;
   methodHandle mh(THREAD, get_Method());
-  MethodCounters *counter = mh->method_counters();
-  if (counter == NULL) {
-    counter = Method::build_method_counters(mh(), CHECK_AND_CLEAR_NULL);
-  }
-  return (address)counter;
+  MethodCounters* method_counters = mh->get_method_counters(CHECK_NULL);
+  return method_counters;
 }
 
 // ------------------------------------------------------------------
--- a/hotspot/src/share/vm/ci/ciMethod.hpp	Mon Oct 07 14:13:28 2013 +0400
+++ b/hotspot/src/share/vm/ci/ciMethod.hpp	Mon Oct 07 10:41:56 2013 -0700
@@ -265,7 +265,7 @@
   bool is_klass_loaded(int refinfo_index, bool must_be_resolved) const;
   bool check_call(int refinfo_index, bool is_static) const;
   bool ensure_method_data();  // make sure it exists in the VM also
-  address ensure_method_counters();
+  MethodCounters* ensure_method_counters();
   int instructions_size();
   int scale_count(int count, float prof_factor = 1.);  // make MDO count commensurate with IIC
 
--- a/hotspot/src/share/vm/ci/ciMethodData.cpp	Mon Oct 07 14:13:28 2013 +0400
+++ b/hotspot/src/share/vm/ci/ciMethodData.cpp	Mon Oct 07 10:41:56 2013 -0700
@@ -78,7 +78,9 @@
 
 void ciMethodData::load_data() {
   MethodData* mdo = get_MethodData();
-  if (mdo == NULL) return;
+  if (mdo == NULL) {
+    return;
+  }
 
   // To do: don't copy the data if it is not "ripe" -- require a minimum #
   // of invocations.
--- a/hotspot/src/share/vm/ci/ciMethodData.hpp	Mon Oct 07 14:13:28 2013 +0400
+++ b/hotspot/src/share/vm/ci/ciMethodData.hpp	Mon Oct 07 10:41:56 2013 -0700
@@ -232,8 +232,6 @@
 public:
   bool is_method_data() const { return true; }
 
-  void set_mature() { _state = mature_state; }
-
   bool is_empty()  { return _state == empty_state; }
   bool is_mature() { return _state == mature_state; }
 
--- a/hotspot/src/share/vm/ci/ciReplay.cpp	Mon Oct 07 14:13:28 2013 +0400
+++ b/hotspot/src/share/vm/ci/ciReplay.cpp	Mon Oct 07 10:41:56 2013 -0700
@@ -965,14 +965,12 @@
     tty->cr();
   } else {
     EXCEPTION_CONTEXT;
-    MethodCounters* mcs = method->method_counters();
     // m->_instructions_size = rec->instructions_size;
     m->_instructions_size = -1;
     m->_interpreter_invocation_count = rec->interpreter_invocation_count;
     m->_interpreter_throwout_count = rec->interpreter_throwout_count;
-    if (mcs == NULL) {
-      mcs = Method::build_method_counters(method, CHECK_AND_CLEAR);
-    }
+    MethodCounters* mcs = method->get_method_counters(CHECK_AND_CLEAR);
+    guarantee(mcs != NULL, "method counters allocation failed");
     mcs->invocation_counter()->_counter = rec->invocation_counter;
     mcs->backedge_counter()->_counter = rec->backedge_counter;
   }
--- a/hotspot/src/share/vm/oops/method.hpp	Mon Oct 07 14:13:28 2013 +0400
+++ b/hotspot/src/share/vm/oops/method.hpp	Mon Oct 07 10:41:56 2013 -0700
@@ -804,6 +804,7 @@
  private:
   void print_made_not_compilable(int comp_level, bool is_osr, bool report, const char* reason);
 
+ public:
   MethodCounters* get_method_counters(TRAPS) {
     if (_method_counters == NULL) {
       build_method_counters(this, CHECK_AND_CLEAR_NULL);
@@ -811,7 +812,6 @@
     return _method_counters;
   }
 
- public:
   bool   is_not_c1_compilable() const         { return access_flags().is_not_c1_compilable();  }
   void  set_not_c1_compilable()               {       _access_flags.set_not_c1_compilable();   }
   void clear_not_c1_compilable()              {       _access_flags.clear_not_c1_compilable(); }
--- a/hotspot/src/share/vm/opto/parseHelper.cpp	Mon Oct 07 14:13:28 2013 +0400
+++ b/hotspot/src/share/vm/opto/parseHelper.cpp	Mon Oct 07 10:41:56 2013 -0700
@@ -343,10 +343,14 @@
 
   // Get the Method* node.
   ciMethod* m = method();
-  address counters_adr = m->ensure_method_counters();
+  MethodCounters* counters_adr = m->ensure_method_counters();
+  if (counters_adr == NULL) {
+    C->record_failure("method counters allocation failed");
+    return;
+  }
 
   Node* ctrl = control();
-  const TypePtr* adr_type = TypeRawPtr::make(counters_adr);
+  const TypePtr* adr_type = TypeRawPtr::make((address) counters_adr);
   Node *counters_node = makecon(adr_type);
   Node* adr_iic_node = basic_plus_adr(counters_node, counters_node,
     MethodCounters::interpreter_invocation_counter_offset_in_bytes());