--- old/src/share/vm/c1/c1_LIRGenerator.cpp 2013-10-04 14:50:16.000000000 -0700 +++ new/src/share/vm/c1/c1_LIRGenerator.cpp 2013-10-04 14:50:16.000000000 -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() : --- old/src/share/vm/ci/ciMethod.cpp 2013-10-04 14:50:17.000000000 -0700 +++ new/src/share/vm/ci/ciMethod.cpp 2013-10-04 14:50:17.000000000 -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; } // ------------------------------------------------------------------ --- old/src/share/vm/ci/ciMethod.hpp 2013-10-04 14:50:18.000000000 -0700 +++ new/src/share/vm/ci/ciMethod.hpp 2013-10-04 14:50:18.000000000 -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 --- old/src/share/vm/ci/ciMethodData.cpp 2013-10-04 14:50:19.000000000 -0700 +++ new/src/share/vm/ci/ciMethodData.cpp 2013-10-04 14:50:19.000000000 -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. --- old/src/share/vm/ci/ciMethodData.hpp 2013-10-04 14:50:19.000000000 -0700 +++ new/src/share/vm/ci/ciMethodData.hpp 2013-10-04 14:50:19.000000000 -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; } --- old/src/share/vm/oops/method.hpp 2013-10-04 14:50:20.000000000 -0700 +++ new/src/share/vm/oops/method.hpp 2013-10-04 14:50:20.000000000 -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(); } --- old/src/share/vm/opto/parseHelper.cpp 2013-10-04 14:50:21.000000000 -0700 +++ new/src/share/vm/opto/parseHelper.cpp 2013-10-04 14:50:21.000000000 -0700 @@ -343,10 +343,16 @@ // 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"); + // Record a failure but continue the compile. The null value is only + // a problem when we execute the method. Somewhere a failing() call + // will abort this compile anyway. + } 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());