--- old/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MethodCounters.java 2016-03-28 10:28:20.255683686 -0700 +++ new/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MethodCounters.java 2016-03-28 10:28:20.189683491 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,8 +47,10 @@ private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { Type type = db.lookupType("MethodCounters"); - interpreterInvocationCountField = new CIntField(type.getCIntegerField("_interpreter_invocation_count"), 0); - interpreterThrowoutCountField = new CIntField(type.getCIntegerField("_interpreter_throwout_count"), 0); + if (VM.getVM().isServerCompiler()) { + interpreterInvocationCountField = new CIntField(type.getCIntegerField("_interpreter_invocation_count"), 0); + interpreterThrowoutCountField = new CIntField(type.getCIntegerField("_interpreter_throwout_count"), 0); + } if (!VM.getVM().isCore()) { invocationCounter = new CIntField(type.getCIntegerField("_invocation_counter"), 0); backedgeCounter = new CIntField(type.getCIntegerField("_backedge_counter"), 0); @@ -61,11 +63,19 @@ private static CIntField backedgeCounter; public int interpreterInvocationCount() { - return (int) interpreterInvocationCountField.getValue(this); + if (interpreterInvocationCountField != null) { + return (int) interpreterInvocationCountField.getValue(this); + } else { + return 0; + } } public int interpreterThrowoutCount() { - return (int) interpreterThrowoutCountField.getValue(this); + if (interpreterThrowoutCountField != null) { + return (int) interpreterThrowoutCountField.getValue(this); + } else { + return 0; + } } public long getInvocationCounter() { if (Assert.ASSERTS_ENABLED) { --- old/src/share/vm/interpreter/bytecodeInterpreter.cpp 2016-03-28 10:28:20.572684620 -0700 +++ new/src/share/vm/interpreter/bytecodeInterpreter.cpp 2016-03-28 10:28:20.501684411 -0700 @@ -632,9 +632,11 @@ if (_compiling) { MethodCounters* mcs; GET_METHOD_COUNTERS(mcs); +#if COMPILER2_OR_JVMCI if (ProfileInterpreter) { METHOD->increment_interpreter_invocation_count(THREAD); } +#endif mcs->invocation_counter()->increment(); if (mcs->invocation_counter()->reached_InvocationLimit(mcs->backedge_counter())) { CALL_VM((void)InterpreterRuntime::frequency_counter_overflow(THREAD, NULL), handle_exception); --- old/src/share/vm/interpreter/interpreterRuntime.cpp 2016-03-28 10:28:20.893685566 -0700 +++ new/src/share/vm/interpreter/interpreterRuntime.cpp 2016-03-28 10:28:20.812685327 -0700 @@ -523,8 +523,10 @@ #ifndef CC_INTERP continuation = Interpreter::remove_activation_entry(); #endif +#if COMPILER2_OR_JVMCI // Count this for compilation purposes h_method->interpreter_throwout_increment(THREAD); +#endif } else { // handler in this method => change bci/bcp to handler bci/bcp and continue there handler_pc = h_method->code_base() + handler_bci; --- old/src/share/vm/oops/method.hpp 2016-03-28 10:28:21.197686462 -0700 +++ new/src/share/vm/oops/method.hpp 2016-03-28 10:28:21.102686182 -0700 @@ -264,6 +264,7 @@ int highest_osr_comp_level() const; void set_highest_osr_comp_level(int level); +#if defined(COMPILER2) || INCLUDE_JVMCI // Count of times method was exited via exception while interpreting void interpreter_throwout_increment(TRAPS) { MethodCounters* mcs = get_method_counters(CHECK); @@ -271,6 +272,7 @@ mcs->interpreter_throwout_increment(); } } +#endif int interpreter_throwout_count() const { MethodCounters* mcs = method_counters(); @@ -407,11 +409,13 @@ return (mcs == NULL) ? 0 : mcs->interpreter_invocation_count(); } } +#if defined(COMPILER2) || INCLUDE_JVMCI int increment_interpreter_invocation_count(TRAPS) { if (TieredCompilation) ShouldNotReachHere(); MethodCounters* mcs = get_method_counters(CHECK_0); return (mcs == NULL) ? 0 : mcs->increment_interpreter_invocation_count(); } +#endif #ifndef PRODUCT int compiled_invocation_count() const { return _compiled_invocation_count; } --- old/src/share/vm/oops/methodCounters.hpp 2016-03-28 10:28:21.457687228 -0700 +++ new/src/share/vm/oops/methodCounters.hpp 2016-03-28 10:28:21.392687036 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,8 +34,10 @@ friend class VMStructs; friend class JVMCIVMStructs; private: +#if defined(COMPILER2) || INCLUDE_JVMCI int _interpreter_invocation_count; // Count of times invoked (reused as prev_event_count in tiered) u2 _interpreter_throwout_count; // Count of times method was exited via exception while interpreting +#endif u2 _number_of_breakpoints; // fullspeed debugging support InvocationCounter _invocation_counter; // Incremented before each activation of the method - used to trigger frequency-based optimizations InvocationCounter _backedge_counter; // Incremented before each backedge taken - used to trigger frequencey-based optimizations @@ -60,9 +62,7 @@ u1 _highest_osr_comp_level; // Same for OSR level #endif - MethodCounters(methodHandle mh) : _interpreter_invocation_count(0), - _interpreter_throwout_count(0), - _number_of_breakpoints(0), + MethodCounters(methodHandle mh) : _number_of_breakpoints(0), _nmethod_age(INT_MAX) #ifdef TIERED , _rate(0), @@ -71,6 +71,8 @@ _highest_osr_comp_level(0) #endif { + set_interpreter_invocation_count(0); + set_interpreter_throwout_count(0); invocation_counter()->init(); backedge_counter()->init(); @@ -109,6 +111,8 @@ void clear_counters(); +#if defined(COMPILER2) || INCLUDE_JVMCI + int interpreter_invocation_count() { return _interpreter_invocation_count; } @@ -131,6 +135,24 @@ _interpreter_throwout_count = count; } +#else // defined(COMPILER2) || INCLUDE_JVMCI + + int interpreter_invocation_count() { + return 0; + } + void set_interpreter_invocation_count(int count) { + assert(count == 0, "count must be 0"); + } + + int interpreter_throwout_count() const { + return 0; + } + void set_interpreter_throwout_count(int count) { + assert(count == 0, "count must be 0"); + } + +#endif // defined(COMPILER2) || INCLUDE_JVMCI + u2 number_of_breakpoints() const { return _number_of_breakpoints; } void incr_number_of_breakpoints() { ++_number_of_breakpoints; } void decr_number_of_breakpoints() { --_number_of_breakpoints; } @@ -170,10 +192,25 @@ return byte_offset_of(MethodCounters, _nmethod_age); } +#if defined(COMPILER2) || INCLUDE_JVMCI + static ByteSize interpreter_invocation_counter_offset() { return byte_offset_of(MethodCounters, _interpreter_invocation_count); } + static int interpreter_invocation_counter_offset_in_bytes() { + return offset_of(MethodCounters, _interpreter_invocation_count); + } + +#else // defined(COMPILER2) || INCLUDE_JVMCI + + static ByteSize interpreter_invocation_counter_offset() { + ShouldNotReachHere(); + return in_ByteSize(0); + } + +#endif // defined(COMPILER2) || INCLUDE_JVMCI + static ByteSize invocation_counter_offset() { return byte_offset_of(MethodCounters, _invocation_counter); } @@ -182,10 +219,6 @@ return byte_offset_of(MethodCounters, _backedge_counter); } - static int interpreter_invocation_counter_offset_in_bytes() { - return offset_of(MethodCounters, _interpreter_invocation_count); - } - static ByteSize interpreter_invocation_limit_offset() { return byte_offset_of(MethodCounters, _interpreter_invocation_limit); } --- old/src/share/vm/runtime/arguments.cpp 2016-03-28 10:28:21.750688091 -0700 +++ new/src/share/vm/runtime/arguments.cpp 2016-03-28 10:28:21.654687809 -0700 @@ -3595,6 +3595,11 @@ } #endif +#if !defined(COMPILER2) && !INCLUDE_JVMCI + UNSUPPORTED_OPTION(ProfileInterpreter, "ProfileInterpreter"); + NOT_PRODUCT(UNSUPPORTED_OPTION(TraceProfileInterpreter, "TraceProfileInterpreter")); +#endif + #ifndef TIERED // Tiered compilation is undefined. UNSUPPORTED_OPTION(TieredCompilation, "TieredCompilation"); --- old/src/share/vm/runtime/vmStructs.cpp 2016-03-28 10:28:22.062689010 -0700 +++ new/src/share/vm/runtime/vmStructs.cpp 2016-03-28 10:28:21.977688760 -0700 @@ -384,8 +384,8 @@ nonstatic_field(MethodCounters, _interpreter_profile_limit, int) \ nonstatic_field(MethodCounters, _invoke_mask, int) \ nonstatic_field(MethodCounters, _backedge_mask, int) \ - nonstatic_field(MethodCounters, _interpreter_invocation_count, int) \ - nonstatic_field(MethodCounters, _interpreter_throwout_count, u2) \ + COMPILER2_OR_JVMCI_PRESENT(nonstatic_field(MethodCounters, _interpreter_invocation_count, int)) \ + COMPILER2_OR_JVMCI_PRESENT(nonstatic_field(MethodCounters, _interpreter_throwout_count, u2)) \ nonstatic_field(MethodCounters, _number_of_breakpoints, u2) \ nonstatic_field(MethodCounters, _invocation_counter, InvocationCounter) \ nonstatic_field(MethodCounters, _backedge_counter, InvocationCounter) \ --- old/src/share/vm/utilities/macros.hpp 2016-03-28 10:28:22.372689923 -0700 +++ new/src/share/vm/utilities/macros.hpp 2016-03-28 10:28:22.278689647 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -206,6 +206,17 @@ #define NOT_COMPILER2(code) code #endif // COMPILER2 +// COMPILER2 or JVMCI +#if defined(COMPILER2) || INCLUDE_JVMCI +#define COMPILER2_OR_JVMCI 1 +#define COMPILER2_OR_JVMCI_PRESENT(code) code +#define NOT_COMPILER2_OR_JVMCI(code) +#else +#define COMPILER2_OR_JVMCI 0 +#define COMPILER2_OR_JVMCI_PRESENT(code) +#define NOT_COMPILER2_OR_JVMCI(code) code +#endif + #ifdef TIERED #define TIERED_ONLY(code) code #define NOT_TIERED(code)