1932 // in the array corresponding to the current bci. In the course of
1933 // intepretation, when a bytecode is encountered that has profile data
1934 // associated with it, the entry pointed to by mdp is updated, then the
1935 // mdp is adjusted to point to the next appropriate DataLayout. If mdp
1936 // is NULL to begin with, the interpreter assumes that the current method
1937 // is not (yet) being profiled.
1938 //
1939 // In MethodData* parlance, "dp" is a "data pointer", the actual address
1940 // of a DataLayout element. A "di" is a "data index", the offset in bytes
1941 // from the base of the data entry array. A "displacement" is the byte offset
1942 // in certain ProfileData objects that indicate the amount the mdp must be
1943 // adjusted in the event of a change in control flow.
1944 //
1945
1946 class CleanExtraDataClosure : public StackObj {
1947 public:
1948 virtual bool is_live(Method* m) = 0;
1949 };
1950
1951
1952 class MethodData : public Metadata {
1953 friend class VMStructs;
1954 friend class JVMCIVMStructs;
1955 private:
1956 friend class ProfileData;
1957 friend class TypeEntriesAtCall;
1958
1959 // If you add a new field that points to any metaspace object, you
1960 // must add this field to MethodData::metaspace_pointers_do().
1961
1962 // Back pointer to the Method*
1963 Method* _method;
1964
1965 // Size of this oop in bytes
1966 int _size;
1967
1968 // Cached hint for bci_to_dp and bci_to_data
1969 int _hint_di;
1970
1971 Mutex _extra_data_lock;
2014 uint _tenure_traps;
2015 int _invoke_mask; // per-method Tier0InvokeNotifyFreqLog
2016 int _backedge_mask; // per-method Tier0BackedgeNotifyFreqLog
2017
2018 #if INCLUDE_RTM_OPT
2019 // State of RTM code generation during compilation of the method
2020 int _rtm_state;
2021 #endif
2022
2023 // Number of loops and blocks is computed when compiling the first
2024 // time with C1. It is used to determine if method is trivial.
2025 short _num_loops;
2026 short _num_blocks;
2027 // Does this method contain anything worth profiling?
2028 enum WouldProfile {unknown, no_profile, profile};
2029 WouldProfile _would_profile;
2030
2031 #if INCLUDE_JVMCI
2032 // Support for HotSpotMethodData.setCompiledIRSize(int)
2033 int _jvmci_ir_size;
2034 #endif
2035
2036 // Size of _data array in bytes. (Excludes header and extra_data fields.)
2037 int _data_size;
2038
2039 // data index for the area dedicated to parameters. -1 if no
2040 // parameter profiling.
2041 enum { no_parameters = -2, parameters_uninitialized = -1 };
2042 int _parameters_type_data_di;
2043 int parameters_size_in_bytes() const {
2044 ParametersTypeData* param = parameters_type_data();
2045 return param == NULL ? 0 : param->size_in_bytes();
2046 }
2047
2048 // Beginning of the data entries
2049 intptr_t _data[1];
2050
2051 // Helper for size computation
2052 static int compute_data_size(BytecodeStream* stream);
2053 static int bytecode_cell_count(Bytecodes::Code code);
2174 }
2175
2176 int backedge_count_start() {
2177 if (backedge_counter()->carry()) {
2178 return 0;
2179 }
2180 return _backedge_counter_start;
2181 }
2182
2183 int invocation_count_delta() { return invocation_count() - invocation_count_start(); }
2184 int backedge_count_delta() { return backedge_count() - backedge_count_start(); }
2185
2186 void reset_start_counters() {
2187 _invocation_counter_start = invocation_count();
2188 _backedge_counter_start = backedge_count();
2189 }
2190
2191 InvocationCounter* invocation_counter() { return &_invocation_counter; }
2192 InvocationCounter* backedge_counter() { return &_backedge_counter; }
2193
2194 #if INCLUDE_RTM_OPT
2195 int rtm_state() const {
2196 return _rtm_state;
2197 }
2198 void set_rtm_state(RTMState rstate) {
2199 _rtm_state = (int)rstate;
2200 }
2201 void atomic_set_rtm_state(RTMState rstate) {
2202 Atomic::store((int)rstate, &_rtm_state);
2203 }
2204
2205 static int rtm_state_offset_in_bytes() {
2206 return offset_of(MethodData, _rtm_state);
2207 }
2208 #endif
2209
2210 void set_would_profile(bool p) { _would_profile = p ? profile : no_profile; }
2211 bool would_profile() const { return _would_profile != no_profile; }
2212
2213 int num_loops() const { return _num_loops; }
|
1932 // in the array corresponding to the current bci. In the course of
1933 // intepretation, when a bytecode is encountered that has profile data
1934 // associated with it, the entry pointed to by mdp is updated, then the
1935 // mdp is adjusted to point to the next appropriate DataLayout. If mdp
1936 // is NULL to begin with, the interpreter assumes that the current method
1937 // is not (yet) being profiled.
1938 //
1939 // In MethodData* parlance, "dp" is a "data pointer", the actual address
1940 // of a DataLayout element. A "di" is a "data index", the offset in bytes
1941 // from the base of the data entry array. A "displacement" is the byte offset
1942 // in certain ProfileData objects that indicate the amount the mdp must be
1943 // adjusted in the event of a change in control flow.
1944 //
1945
1946 class CleanExtraDataClosure : public StackObj {
1947 public:
1948 virtual bool is_live(Method* m) = 0;
1949 };
1950
1951
1952 #if INCLUDE_JVMCI
1953 // Encapsulates an encoded speculation reason. These are linked together in
1954 // a list that is atomically appended to during deoptimization. Entries are
1955 // never removed from the list.
1956 // @see jdk.vm.ci.hotspot.HotSpotSpeculationLog.HotSpotSpeculationEncoding
1957 class FailedSpeculation: public CHeapObj<mtCompiler> {
1958 private:
1959 // The length of HotSpotSpeculationEncoding.toByteArray(). The data itself
1960 // is an array embedded at the end of this object.
1961 int _data_len;
1962
1963 // Next entry in a linked list.
1964 FailedSpeculation* _next;
1965
1966 FailedSpeculation(address data, int data_len);
1967
1968 FailedSpeculation** next_adr() { return &_next; }
1969
1970 // Placement new operator for inlining the speculation data into
1971 // the FailedSpeculation object.
1972 void* operator new(size_t size, size_t fs_size) throw();
1973
1974 public:
1975 char* data() { return (char*)(((address) this) + sizeof(FailedSpeculation)); }
1976 int data_len() const { return _data_len; }
1977 FailedSpeculation* next() const { return _next; }
1978
1979 // Atomically appends a speculation from nm to the list whose head is at (*failed_speculations_address).
1980 // Returns false if the FailedSpeculation object could not be allocated.
1981 static bool add_failed_speculation(nmethod* nm, FailedSpeculation** failed_speculations_address, address speculation, int speculation_len);
1982
1983 // Frees all entries in the linked list whose head is at (*failed_speculations_address).
1984 static void free_failed_speculations(FailedSpeculation** failed_speculations_address);
1985 };
1986 #endif
1987
1988 class MethodData : public Metadata {
1989 friend class VMStructs;
1990 friend class JVMCIVMStructs;
1991 private:
1992 friend class ProfileData;
1993 friend class TypeEntriesAtCall;
1994
1995 // If you add a new field that points to any metaspace object, you
1996 // must add this field to MethodData::metaspace_pointers_do().
1997
1998 // Back pointer to the Method*
1999 Method* _method;
2000
2001 // Size of this oop in bytes
2002 int _size;
2003
2004 // Cached hint for bci_to_dp and bci_to_data
2005 int _hint_di;
2006
2007 Mutex _extra_data_lock;
2050 uint _tenure_traps;
2051 int _invoke_mask; // per-method Tier0InvokeNotifyFreqLog
2052 int _backedge_mask; // per-method Tier0BackedgeNotifyFreqLog
2053
2054 #if INCLUDE_RTM_OPT
2055 // State of RTM code generation during compilation of the method
2056 int _rtm_state;
2057 #endif
2058
2059 // Number of loops and blocks is computed when compiling the first
2060 // time with C1. It is used to determine if method is trivial.
2061 short _num_loops;
2062 short _num_blocks;
2063 // Does this method contain anything worth profiling?
2064 enum WouldProfile {unknown, no_profile, profile};
2065 WouldProfile _would_profile;
2066
2067 #if INCLUDE_JVMCI
2068 // Support for HotSpotMethodData.setCompiledIRSize(int)
2069 int _jvmci_ir_size;
2070 FailedSpeculation* _failed_speculations;
2071 #endif
2072
2073 // Size of _data array in bytes. (Excludes header and extra_data fields.)
2074 int _data_size;
2075
2076 // data index for the area dedicated to parameters. -1 if no
2077 // parameter profiling.
2078 enum { no_parameters = -2, parameters_uninitialized = -1 };
2079 int _parameters_type_data_di;
2080 int parameters_size_in_bytes() const {
2081 ParametersTypeData* param = parameters_type_data();
2082 return param == NULL ? 0 : param->size_in_bytes();
2083 }
2084
2085 // Beginning of the data entries
2086 intptr_t _data[1];
2087
2088 // Helper for size computation
2089 static int compute_data_size(BytecodeStream* stream);
2090 static int bytecode_cell_count(Bytecodes::Code code);
2211 }
2212
2213 int backedge_count_start() {
2214 if (backedge_counter()->carry()) {
2215 return 0;
2216 }
2217 return _backedge_counter_start;
2218 }
2219
2220 int invocation_count_delta() { return invocation_count() - invocation_count_start(); }
2221 int backedge_count_delta() { return backedge_count() - backedge_count_start(); }
2222
2223 void reset_start_counters() {
2224 _invocation_counter_start = invocation_count();
2225 _backedge_counter_start = backedge_count();
2226 }
2227
2228 InvocationCounter* invocation_counter() { return &_invocation_counter; }
2229 InvocationCounter* backedge_counter() { return &_backedge_counter; }
2230
2231 #if INCLUDE_JVMCI
2232 FailedSpeculation** get_failed_speculations_address() {
2233 return &_failed_speculations;
2234 }
2235 #endif
2236
2237 #if INCLUDE_RTM_OPT
2238 int rtm_state() const {
2239 return _rtm_state;
2240 }
2241 void set_rtm_state(RTMState rstate) {
2242 _rtm_state = (int)rstate;
2243 }
2244 void atomic_set_rtm_state(RTMState rstate) {
2245 Atomic::store((int)rstate, &_rtm_state);
2246 }
2247
2248 static int rtm_state_offset_in_bytes() {
2249 return offset_of(MethodData, _rtm_state);
2250 }
2251 #endif
2252
2253 void set_would_profile(bool p) { _would_profile = p ? profile : no_profile; }
2254 bool would_profile() const { return _would_profile != no_profile; }
2255
2256 int num_loops() const { return _num_loops; }
|