17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "c1/c1_Compilation.hpp"
27 #include "c1/c1_Defs.hpp"
28 #include "c1/c1_FrameMap.hpp"
29 #include "c1/c1_Instruction.hpp"
30 #include "c1/c1_LIRAssembler.hpp"
31 #include "c1/c1_LIRGenerator.hpp"
32 #include "c1/c1_ValueStack.hpp"
33 #include "ci/ciArrayKlass.hpp"
34 #include "ci/ciInstance.hpp"
35 #include "ci/ciObjArray.hpp"
36 #include "ci/ciUtilities.hpp"
37 #include "compiler/compilerDefinitions.inline.hpp"
38 #include "compiler/compilerOracle.hpp"
39 #include "gc/shared/barrierSet.hpp"
40 #include "gc/shared/c1/barrierSetC1.hpp"
41 #include "oops/klass.inline.hpp"
42 #include "oops/methodCounters.hpp"
43 #include "runtime/sharedRuntime.hpp"
44 #include "runtime/stubRoutines.hpp"
45 #include "runtime/vm_version.hpp"
46 #include "utilities/bitMap.inline.hpp"
47 #include "utilities/macros.hpp"
48 #include "utilities/powerOfTwo.hpp"
49
50 #ifdef ASSERT
51 #define __ gen()->lir(__FILE__, __LINE__)->
52 #else
53 #define __ gen()->lir()->
54 #endif
55
56 #ifndef PATCHED_ADDR
3262 freq_log = CompilerConfig::scaled_freq_log(freq_log, scale);
3263 }
3264 increment_event_counter_impl(info, info->scope()->method(), step, right_n_bits(freq_log), bci, backedge, true);
3265 }
3266
3267 void LIRGenerator::increment_event_counter_impl(CodeEmitInfo* info,
3268 ciMethod *method, LIR_Opr step, int frequency,
3269 int bci, bool backedge, bool notify) {
3270 assert(frequency == 0 || is_power_of_2(frequency + 1), "Frequency must be x^2 - 1 or 0");
3271 int level = _compilation->env()->comp_level();
3272 assert(level > CompLevel_simple, "Shouldn't be here");
3273
3274 int offset = -1;
3275 LIR_Opr counter_holder;
3276 if (level == CompLevel_limited_profile) {
3277 MethodCounters* counters_adr = method->ensure_method_counters();
3278 if (counters_adr == nullptr) {
3279 bailout("method counters allocation failed");
3280 return;
3281 }
3282 counter_holder = new_pointer_register();
3283 __ move(LIR_OprFact::intptrConst(counters_adr), counter_holder);
3284 offset = in_bytes(backedge ? MethodCounters::backedge_counter_offset() :
3285 MethodCounters::invocation_counter_offset());
3286 } else if (level == CompLevel_full_profile) {
3287 counter_holder = new_register(T_METADATA);
3288 offset = in_bytes(backedge ? MethodData::backedge_counter_offset() :
3289 MethodData::invocation_counter_offset());
3290 ciMethodData* md = method->method_data_or_null();
3291 assert(md != nullptr, "Sanity");
3292 __ metadata2reg(md->constant_encoding(), counter_holder);
3293 } else {
3294 ShouldNotReachHere();
3295 }
3296 LIR_Address* counter = new LIR_Address(counter_holder, offset, T_INT);
3297 LIR_Opr result = new_register(T_INT);
3298 __ load(counter, result);
3299 __ add(result, step, result);
3300 __ store(result, counter);
3301 if (notify && (!backedge || UseOnStackReplacement)) {
3302 LIR_Opr meth = LIR_OprFact::metadataConst(method->constant_encoding());
3303 // The bci for info can point to cmp for if's we want the if bci
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "c1/c1_Compilation.hpp"
27 #include "c1/c1_Defs.hpp"
28 #include "c1/c1_FrameMap.hpp"
29 #include "c1/c1_Instruction.hpp"
30 #include "c1/c1_LIRAssembler.hpp"
31 #include "c1/c1_LIRGenerator.hpp"
32 #include "c1/c1_ValueStack.hpp"
33 #include "ci/ciArrayKlass.hpp"
34 #include "ci/ciInstance.hpp"
35 #include "ci/ciObjArray.hpp"
36 #include "ci/ciUtilities.hpp"
37 #include "code/SCCache.hpp"
38 #include "compiler/compilerDefinitions.inline.hpp"
39 #include "compiler/compilerOracle.hpp"
40 #include "gc/shared/barrierSet.hpp"
41 #include "gc/shared/c1/barrierSetC1.hpp"
42 #include "oops/klass.inline.hpp"
43 #include "oops/methodCounters.hpp"
44 #include "runtime/sharedRuntime.hpp"
45 #include "runtime/stubRoutines.hpp"
46 #include "runtime/vm_version.hpp"
47 #include "utilities/bitMap.inline.hpp"
48 #include "utilities/macros.hpp"
49 #include "utilities/powerOfTwo.hpp"
50
51 #ifdef ASSERT
52 #define __ gen()->lir(__FILE__, __LINE__)->
53 #else
54 #define __ gen()->lir()->
55 #endif
56
57 #ifndef PATCHED_ADDR
3263 freq_log = CompilerConfig::scaled_freq_log(freq_log, scale);
3264 }
3265 increment_event_counter_impl(info, info->scope()->method(), step, right_n_bits(freq_log), bci, backedge, true);
3266 }
3267
3268 void LIRGenerator::increment_event_counter_impl(CodeEmitInfo* info,
3269 ciMethod *method, LIR_Opr step, int frequency,
3270 int bci, bool backedge, bool notify) {
3271 assert(frequency == 0 || is_power_of_2(frequency + 1), "Frequency must be x^2 - 1 or 0");
3272 int level = _compilation->env()->comp_level();
3273 assert(level > CompLevel_simple, "Shouldn't be here");
3274
3275 int offset = -1;
3276 LIR_Opr counter_holder;
3277 if (level == CompLevel_limited_profile) {
3278 MethodCounters* counters_adr = method->ensure_method_counters();
3279 if (counters_adr == nullptr) {
3280 bailout("method counters allocation failed");
3281 return;
3282 }
3283 if (SCCache::is_on()) {
3284 counter_holder = new_register(T_METADATA);
3285 __ metadata2reg(counters_adr, counter_holder);
3286 } else {
3287 counter_holder = new_pointer_register();
3288 __ move(LIR_OprFact::intptrConst(counters_adr), counter_holder);
3289 }
3290 offset = in_bytes(backedge ? MethodCounters::backedge_counter_offset() :
3291 MethodCounters::invocation_counter_offset());
3292 } else if (level == CompLevel_full_profile) {
3293 counter_holder = new_register(T_METADATA);
3294 offset = in_bytes(backedge ? MethodData::backedge_counter_offset() :
3295 MethodData::invocation_counter_offset());
3296 ciMethodData* md = method->method_data_or_null();
3297 assert(md != nullptr, "Sanity");
3298 __ metadata2reg(md->constant_encoding(), counter_holder);
3299 } else {
3300 ShouldNotReachHere();
3301 }
3302 LIR_Address* counter = new LIR_Address(counter_holder, offset, T_INT);
3303 LIR_Opr result = new_register(T_INT);
3304 __ load(counter, result);
3305 __ add(result, step, result);
3306 __ store(result, counter);
3307 if (notify && (!backedge || UseOnStackReplacement)) {
3308 LIR_Opr meth = LIR_OprFact::metadataConst(method->constant_encoding());
3309 // The bci for info can point to cmp for if's we want the if bci
|