Mercurial > hg > graal-jvmci-8
comparison src/share/vm/runtime/deoptimization.hpp @ 7154:5d0bb7d52783
changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 12 Dec 2012 21:36:40 +0100 |
parents | e522a00b91aa |
children | b8f261ba79c6 |
comparison
equal
deleted
inserted
replaced
7153:c421c19b7bf8 | 7154:5d0bb7d52783 |
---|---|
37 friend class VMStructs; | 37 friend class VMStructs; |
38 | 38 |
39 public: | 39 public: |
40 // What condition caused the deoptimization | 40 // What condition caused the deoptimization |
41 enum DeoptReason { | 41 enum DeoptReason { |
42 #ifdef GRAAL | |
43 Reason_many = -1, // indicates presence of several reasons | 42 Reason_many = -1, // indicates presence of several reasons |
44 Reason_none = 0, // indicates absence of a relevant deopt. | 43 Reason_none = 0, // indicates absence of a relevant deopt. |
45 // Next 7 reasons are recorded per bytecode in DataLayout::trap_bits. | 44 // Next 7 reasons are recorded per bytecode in DataLayout::trap_bits. |
46 // This is more complicated for Graal as Graal may deoptimize to *some* bytecode before the | 45 // This is more complicated for Graal as Graal may deoptimize to *some* bytecode before the |
47 // bytecode that actually caused the deopt (with inlining, Graal may even deoptimize to a | 46 // bytecode that actually caused the deopt (with inlining, Graal may even deoptimize to a |
48 // bytecode in another method): | 47 // bytecode in another method): |
49 // - bytecode y in method b() causes deopt | 48 // - bytecode y in method b() causes deopt |
50 // - Graal deoptimizes to bytecode x in method a() | 49 // - Graal deoptimizes to bytecode x in method a() |
51 // -> the deopt reason will be recorded for method a() at bytecode x | 50 // -> the deopt reason will be recorded for method a() at bytecode x |
52 Reason_null_check, | |
53 Reason_range_check, | |
54 Reason_class_check, | |
55 Reason_array_check, | |
56 Reason_unreached, | |
57 Reason_type_checked_inlining, | |
58 Reason_optimized_type_check, | |
59 | |
60 // recorded per method | |
61 Reason_not_compiled_exception_handler, | |
62 Reason_unresolved, | |
63 Reason_jsr_mismatch, | |
64 Reason_div0_check, | |
65 Reason_constraint, | |
66 Reason_LIMIT, | |
67 Reason_RECORDED_LIMIT = Reason_optimized_type_check | |
68 #else | |
69 Reason_many = -1, // indicates presence of several reasons | |
70 Reason_none = 0, // indicates absence of a relevant deopt. | |
71 // Next 7 reasons are recorded per bytecode in DataLayout::trap_bits | |
72 Reason_null_check, // saw unexpected null or zero divisor (@bci) | 51 Reason_null_check, // saw unexpected null or zero divisor (@bci) |
73 Reason_null_assert, // saw unexpected non-null or non-zero (@bci) | 52 Reason_null_assert, // saw unexpected non-null or non-zero (@bci) |
74 Reason_range_check, // saw unexpected array index (@bci) | 53 Reason_range_check, // saw unexpected array index (@bci) |
75 Reason_class_check, // saw unexpected object class (@bci) | 54 Reason_class_check, // saw unexpected object class (@bci) |
76 Reason_array_check, // saw unexpected array class (aastore @bci) | 55 Reason_array_check, // saw unexpected array class (aastore @bci) |
77 Reason_intrinsic, // saw unexpected operand to intrinsic (@bci) | 56 Reason_intrinsic, // saw unexpected operand to intrinsic (@bci) |
78 Reason_bimorphic, // saw unexpected object class in bimorphic inlining (@bci) | 57 Reason_bimorphic, // saw unexpected object class in bimorphic inlining (@bci) |
79 | 58 |
59 #ifdef GRAAL | |
60 Reason_unreached0 = Reason_null_assert, | |
61 Reason_type_checked_inlining = Reason_intrinsic, | |
62 Reason_optimized_type_check = Reason_bimorphic, | |
63 #endif | |
64 | |
65 // recorded per method | |
80 Reason_unloaded, // unloaded or class constant pool entry | 66 Reason_unloaded, // unloaded or class constant pool entry |
81 Reason_uninitialized, // bad class state (uninitialized) | 67 Reason_uninitialized, // bad class state (uninitialized) |
82 Reason_unreached, // code is not reached, compiler | 68 Reason_unreached, // code is not reached, compiler |
83 Reason_unhandled, // arbitrary compiler limitation | 69 Reason_unhandled, // arbitrary compiler limitation |
84 Reason_constraint, // arbitrary runtime constraint violated | 70 Reason_constraint, // arbitrary runtime constraint violated |
85 Reason_div0_check, // a null_check due to division by zero | 71 Reason_div0_check, // a null_check due to division by zero |
86 Reason_age, // nmethod too old; tier threshold reached | 72 Reason_age, // nmethod too old; tier threshold reached |
87 Reason_predicate, // compiler generated predicate failed | 73 Reason_predicate, // compiler generated predicate failed |
88 Reason_loop_limit_check, // compiler generated loop limits check failed | 74 Reason_loop_limit_check, // compiler generated loop limits check failed |
89 Reason_LIMIT, | 75 Reason_LIMIT, |
76 | |
77 #ifdef GRAAL | |
78 Reason_not_compiled_exception_handler = Reason_unhandled, | |
79 Reason_unresolved = Reason_uninitialized, | |
80 Reason_jsr_mismatch = Reason_age, | |
81 #endif | |
82 | |
90 Reason_RECORDED_LIMIT = Reason_bimorphic // some are not recorded per bc | 83 Reason_RECORDED_LIMIT = Reason_bimorphic // some are not recorded per bc |
91 #endif // GRAAL | |
92 // Note: Keep this enum in sync. with _trap_reason_name. | 84 // Note: Keep this enum in sync. with _trap_reason_name. |
93 // Note: Reason_RECORDED_LIMIT should be < 8 to fit into 3 bits of | 85 // Note: Reason_RECORDED_LIMIT should be < 8 to fit into 3 bits of |
94 // DataLayout::trap_bits. This dependency is enforced indirectly | 86 // DataLayout::trap_bits. This dependency is enforced indirectly |
95 // via asserts, to avoid excessive direct header-to-header dependencies. | 87 // via asserts, to avoid excessive direct header-to-header dependencies. |
96 // See Deoptimization::trap_state_reason and class DataLayout | 88 // See Deoptimization::trap_state_reason and class DataLayout |
281 static DeoptReason trap_request_reason(int trap_request) { | 273 static DeoptReason trap_request_reason(int trap_request) { |
282 if (trap_request < 0) { | 274 if (trap_request < 0) { |
283 return (DeoptReason) | 275 return (DeoptReason) |
284 ((~(trap_request) >> _reason_shift) & right_n_bits(_reason_bits)); | 276 ((~(trap_request) >> _reason_shift) & right_n_bits(_reason_bits)); |
285 } else { | 277 } else { |
286 #ifdef GRAAL | 278 #ifdef GRAALVM |
287 ShouldNotReachHere(); | 279 ShouldNotReachHere(); |
288 return Reason_none; | 280 return Reason_none; |
289 #else | 281 #else |
290 // standard reason for unloaded CP entry | 282 // standard reason for unloaded CP entry |
291 return Reason_unloaded; | 283 return Reason_unloaded; |
295 static DeoptAction trap_request_action(int trap_request) { | 287 static DeoptAction trap_request_action(int trap_request) { |
296 if (trap_request < 0) { | 288 if (trap_request < 0) { |
297 return (DeoptAction) | 289 return (DeoptAction) |
298 ((~(trap_request) >> _action_shift) & right_n_bits(_action_bits)); | 290 ((~(trap_request) >> _action_shift) & right_n_bits(_action_bits)); |
299 } else { | 291 } else { |
300 #ifdef GRAAL | 292 #ifdef GRAALVM |
301 ShouldNotReachHere(); | 293 ShouldNotReachHere(); |
302 return Action_make_not_compilable; | 294 return Action_make_not_compilable; |
303 #else | 295 #else |
304 // standard action for unloaded CP entry | 296 // standard action for unloaded CP entry |
305 return _unloaded_action; | 297 return _unloaded_action; |
308 } | 300 } |
309 static int trap_request_index(int trap_request) { | 301 static int trap_request_index(int trap_request) { |
310 if (trap_request < 0) { | 302 if (trap_request < 0) { |
311 return -1; | 303 return -1; |
312 } else { | 304 } else { |
313 #ifdef GRAAL | 305 #ifdef GRAALVM |
314 ShouldNotReachHere(); | 306 ShouldNotReachHere(); |
315 return -1; | 307 return -1; |
316 #else | 308 #else |
317 return trap_request; | 309 return trap_request; |
318 #endif // GRAAL | 310 #endif // GRAAL |
319 } | 311 } |
320 } | 312 } |
321 static int make_trap_request(DeoptReason reason, DeoptAction action, | 313 static int make_trap_request(DeoptReason reason, DeoptAction action, |
322 int index = -1) { | 314 int index = -1) { |
323 #ifdef GRAAL | 315 #ifdef GRAALVM |
324 assert(index == -1, "Graal does not use index"); | 316 assert(index == -1, "Graal does not use index"); |
325 #endif | 317 #endif |
326 | 318 |
327 assert((1 << _reason_bits) >= Reason_LIMIT, "enough bits"); | 319 assert((1 << _reason_bits) >= Reason_LIMIT, "enough bits"); |
328 assert((1 << _action_bits) >= Action_LIMIT, "enough bits"); | 320 assert((1 << _action_bits) >= Action_LIMIT, "enough bits"); |