43 Reason_none = 0, // indicates absence of a relevant deopt.
44 // Next 7 reasons are recorded per bytecode in DataLayout::trap_bits
45 Reason_null_check, // saw unexpected null or zero divisor (@bci)
46 Reason_null_assert, // saw unexpected non-null or non-zero (@bci)
47 Reason_range_check, // saw unexpected array index (@bci)
48 Reason_class_check, // saw unexpected object class (@bci)
49 Reason_array_check, // saw unexpected array class (aastore @bci)
50 Reason_intrinsic, // saw unexpected operand to intrinsic (@bci)
51 Reason_bimorphic, // saw unexpected object class in bimorphic inlining (@bci)
52
53 Reason_unloaded, // unloaded class or constant pool entry
54 Reason_uninitialized, // bad class state (uninitialized)
55 Reason_unreached, // code is not reached, compiler
56 Reason_unhandled, // arbitrary compiler limitation
57 Reason_constraint, // arbitrary runtime constraint violated
58 Reason_div0_check, // a null_check due to division by zero
59 Reason_age, // nmethod too old; tier threshold reached
60 Reason_predicate, // compiler generated predicate failed
61 Reason_loop_limit_check, // compiler generated loop limits check failed
62 Reason_speculate_class_check, // saw unexpected object class from type speculation
63 Reason_LIMIT,
64 // Note: Keep this enum in sync. with _trap_reason_name.
65 Reason_RECORDED_LIMIT = Reason_bimorphic // some are not recorded per bc
66 // Note: Reason_RECORDED_LIMIT should be < 8 to fit into 3 bits of
67 // DataLayout::trap_bits. This dependency is enforced indirectly
68 // via asserts, to avoid excessive direct header-to-header dependencies.
69 // See Deoptimization::trap_state_reason and class DataLayout.
70 };
71
72 // What action must be taken by the runtime?
73 enum DeoptAction {
74 Action_none, // just interpret, do not invalidate nmethod
75 Action_maybe_recompile, // recompile the nmethod; need not invalidate
76 Action_reinterpret, // invalidate the nmethod, reset IC, maybe recompile
77 Action_make_not_entrant, // invalidate the nmethod, recompile (probably)
78 Action_make_not_compilable, // invalidate the nmethod and do not compile
79 Action_LIMIT
80 // Note: Keep this enum in sync. with _trap_action_name.
81 };
82
297 // Note that not all reasons are recorded per-bci.
298 static DeoptReason trap_state_reason(int trap_state);
299 static int trap_state_has_reason(int trap_state, int reason);
300 static int trap_state_add_reason(int trap_state, int reason);
301 static bool trap_state_is_recompiled(int trap_state);
302 static int trap_state_set_recompiled(int trap_state, bool z);
303 static const char* format_trap_state(char* buf, size_t buflen,
304 int trap_state);
305
306 static bool reason_is_recorded_per_bytecode(DeoptReason reason) {
307 return reason > Reason_none && reason <= Reason_RECORDED_LIMIT;
308 }
309
310 static DeoptReason reason_recorded_per_bytecode_if_any(DeoptReason reason) {
311 if (reason_is_recorded_per_bytecode(reason))
312 return reason;
313 else if (reason == Reason_div0_check) // null check due to divide-by-zero?
314 return Reason_null_check; // recorded per BCI as a null check
315 else if (reason == Reason_speculate_class_check)
316 return Reason_class_check;
317 else
318 return Reason_none;
319 }
320
321 static bool reason_is_speculate(int reason) {
322 if (reason == Reason_speculate_class_check) {
323 return true;
324 }
325 return false;
326 }
327
328 static uint per_method_trap_limit(int reason) {
329 return reason_is_speculate(reason) ? (uint)PerMethodSpecTrapLimit : (uint)PerMethodTrapLimit;
330 }
331
332 static const char* trap_reason_name(int reason);
333 static const char* trap_action_name(int action);
334 // Format like reason='foo' action='bar' index='123'.
335 // This is suitable both for XML and for tty output.
336 static const char* format_trap_request(char* buf, size_t buflen,
337 int trap_request);
338
339 static jint total_deoptimization_count();
340 static jint deoptimization_count(DeoptReason reason);
341
342 // JVMTI PopFrame support
|
43 Reason_none = 0, // indicates absence of a relevant deopt.
44 // Next 7 reasons are recorded per bytecode in DataLayout::trap_bits
45 Reason_null_check, // saw unexpected null or zero divisor (@bci)
46 Reason_null_assert, // saw unexpected non-null or non-zero (@bci)
47 Reason_range_check, // saw unexpected array index (@bci)
48 Reason_class_check, // saw unexpected object class (@bci)
49 Reason_array_check, // saw unexpected array class (aastore @bci)
50 Reason_intrinsic, // saw unexpected operand to intrinsic (@bci)
51 Reason_bimorphic, // saw unexpected object class in bimorphic inlining (@bci)
52
53 Reason_unloaded, // unloaded class or constant pool entry
54 Reason_uninitialized, // bad class state (uninitialized)
55 Reason_unreached, // code is not reached, compiler
56 Reason_unhandled, // arbitrary compiler limitation
57 Reason_constraint, // arbitrary runtime constraint violated
58 Reason_div0_check, // a null_check due to division by zero
59 Reason_age, // nmethod too old; tier threshold reached
60 Reason_predicate, // compiler generated predicate failed
61 Reason_loop_limit_check, // compiler generated loop limits check failed
62 Reason_speculate_class_check, // saw unexpected object class from type speculation
63 Reason_speculate_null_check, // saw unexpected null from type speculation
64 Reason_LIMIT,
65 // Note: Keep this enum in sync. with _trap_reason_name.
66 Reason_RECORDED_LIMIT = Reason_bimorphic // some are not recorded per bc
67 // Note: Reason_RECORDED_LIMIT should be < 8 to fit into 3 bits of
68 // DataLayout::trap_bits. This dependency is enforced indirectly
69 // via asserts, to avoid excessive direct header-to-header dependencies.
70 // See Deoptimization::trap_state_reason and class DataLayout.
71 };
72
73 // What action must be taken by the runtime?
74 enum DeoptAction {
75 Action_none, // just interpret, do not invalidate nmethod
76 Action_maybe_recompile, // recompile the nmethod; need not invalidate
77 Action_reinterpret, // invalidate the nmethod, reset IC, maybe recompile
78 Action_make_not_entrant, // invalidate the nmethod, recompile (probably)
79 Action_make_not_compilable, // invalidate the nmethod and do not compile
80 Action_LIMIT
81 // Note: Keep this enum in sync. with _trap_action_name.
82 };
83
298 // Note that not all reasons are recorded per-bci.
299 static DeoptReason trap_state_reason(int trap_state);
300 static int trap_state_has_reason(int trap_state, int reason);
301 static int trap_state_add_reason(int trap_state, int reason);
302 static bool trap_state_is_recompiled(int trap_state);
303 static int trap_state_set_recompiled(int trap_state, bool z);
304 static const char* format_trap_state(char* buf, size_t buflen,
305 int trap_state);
306
307 static bool reason_is_recorded_per_bytecode(DeoptReason reason) {
308 return reason > Reason_none && reason <= Reason_RECORDED_LIMIT;
309 }
310
311 static DeoptReason reason_recorded_per_bytecode_if_any(DeoptReason reason) {
312 if (reason_is_recorded_per_bytecode(reason))
313 return reason;
314 else if (reason == Reason_div0_check) // null check due to divide-by-zero?
315 return Reason_null_check; // recorded per BCI as a null check
316 else if (reason == Reason_speculate_class_check)
317 return Reason_class_check;
318 else if (reason == Reason_speculate_null_check)
319 return Reason_null_check;
320 else
321 return Reason_none;
322 }
323
324 static bool reason_is_speculate(int reason) {
325 if (reason == Reason_speculate_class_check || reason == Reason_speculate_null_check) {
326 return true;
327 }
328 return false;
329 }
330
331 static uint per_method_trap_limit(int reason) {
332 return reason_is_speculate(reason) ? (uint)PerMethodSpecTrapLimit : (uint)PerMethodTrapLimit;
333 }
334
335 static const char* trap_reason_name(int reason);
336 static const char* trap_action_name(int action);
337 // Format like reason='foo' action='bar' index='123'.
338 // This is suitable both for XML and for tty output.
339 static const char* format_trap_request(char* buf, size_t buflen,
340 int trap_request);
341
342 static jint total_deoptimization_count();
343 static jint deoptimization_count(DeoptReason reason);
344
345 // JVMTI PopFrame support
|