42 _method(method), _mark_for_deoptimization_status(not_marked) {
43 init_defaults();
44 }
45
46 void CompiledMethod::init_defaults() {
47 _has_unsafe_access = 0;
48 _has_method_handle_invokes = 0;
49 _lazy_critical_native = 0;
50 _has_wide_vectors = 0;
51 _unloading_clock = 0;
52 }
53
54 bool CompiledMethod::is_method_handle_return(address return_pc) {
55 if (!has_method_handle_invokes()) return false;
56 PcDesc* pd = pc_desc_at(return_pc);
57 if (pd == NULL)
58 return false;
59 return pd->is_method_handle_invoke();
60 }
61
62 // When using JVMCI the address might be off by the size of a call instruction.
63 bool CompiledMethod::is_deopt_entry(address pc) {
64 return pc == deopt_handler_begin()
65 #if INCLUDE_JVMCI
66 || (is_compiled_by_jvmci() && pc == (deopt_handler_begin() + NativeCall::instruction_size))
67 #endif
68 ;
69 }
70
71 // Returns a string version of the method state.
72 const char* CompiledMethod::state() const {
73 int state = get_state();
74 switch (state) {
75 case in_use:
76 return "in use";
77 case not_used:
78 return "not_used";
79 case not_entrant:
80 return "not_entrant";
81 case zombie:
82 return "zombie";
83 case unloaded:
84 return "unloaded";
85 default:
86 fatal("unexpected method state: %d", state);
87 return NULL;
88 }
89 }
90
304 // The method attached by JIT-compilers should be used, if present.
305 // Bytecode can be inaccurate in such case.
306 Method* callee = attached_method_before_pc(pc);
307 if (callee != NULL) {
308 has_receiver = !(callee->access_flags().is_static());
309 has_appendix = false;
310 signature = callee->signature();
311 }
312
313 fr.oops_compiled_arguments_do(signature, has_receiver, has_appendix, reg_map, f);
314 }
315 #endif // !SHARK
316 }
317
318 // -----------------------------------------------------------------------------
319 // CompiledMethod::get_deopt_original_pc
320 //
321 // Return the original PC for the given PC if:
322 // (a) the given PC belongs to a nmethod and
323 // (b) it is a deopt PC
324 address CompiledMethod::get_deopt_original_pc(const frame* fr) {
325 if (fr->cb() == NULL) return NULL;
326
327 CompiledMethod* cm = fr->cb()->as_compiled_method_or_null();
328 if (cm != NULL && cm->is_deopt_pc(fr->pc()))
329 return cm->get_original_pc(fr);
330
331 return NULL;
332 }
333
334 Method* CompiledMethod::attached_method(address call_instr) {
335 assert(code_contains(call_instr), "not part of the nmethod");
336 RelocIterator iter(this, call_instr, call_instr + 1);
337 while (iter.next()) {
338 if (iter.addr() == call_instr) {
339 switch(iter.type()) {
340 case relocInfo::static_call_type: return iter.static_call_reloc()->method_value();
341 case relocInfo::opt_virtual_call_type: return iter.opt_virtual_call_reloc()->method_value();
342 case relocInfo::virtual_call_type: return iter.virtual_call_reloc()->method_value();
343 }
344 }
345 }
346 return NULL; // not found
347 }
348
349 Method* CompiledMethod::attached_method_before_pc(address pc) {
350 if (NativeCall::is_call_before(pc)) {
351 NativeCall* ncall = nativeCall_before(pc);
352 return attached_method(ncall->instruction_address());
|
42 _method(method), _mark_for_deoptimization_status(not_marked) {
43 init_defaults();
44 }
45
46 void CompiledMethod::init_defaults() {
47 _has_unsafe_access = 0;
48 _has_method_handle_invokes = 0;
49 _lazy_critical_native = 0;
50 _has_wide_vectors = 0;
51 _unloading_clock = 0;
52 }
53
54 bool CompiledMethod::is_method_handle_return(address return_pc) {
55 if (!has_method_handle_invokes()) return false;
56 PcDesc* pd = pc_desc_at(return_pc);
57 if (pd == NULL)
58 return false;
59 return pd->is_method_handle_invoke();
60 }
61
62 // Returns a string version of the method state.
63 const char* CompiledMethod::state() const {
64 int state = get_state();
65 switch (state) {
66 case in_use:
67 return "in use";
68 case not_used:
69 return "not_used";
70 case not_entrant:
71 return "not_entrant";
72 case zombie:
73 return "zombie";
74 case unloaded:
75 return "unloaded";
76 default:
77 fatal("unexpected method state: %d", state);
78 return NULL;
79 }
80 }
81
295 // The method attached by JIT-compilers should be used, if present.
296 // Bytecode can be inaccurate in such case.
297 Method* callee = attached_method_before_pc(pc);
298 if (callee != NULL) {
299 has_receiver = !(callee->access_flags().is_static());
300 has_appendix = false;
301 signature = callee->signature();
302 }
303
304 fr.oops_compiled_arguments_do(signature, has_receiver, has_appendix, reg_map, f);
305 }
306 #endif // !SHARK
307 }
308
309 // -----------------------------------------------------------------------------
310 // CompiledMethod::get_deopt_original_pc
311 //
312 // Return the original PC for the given PC if:
313 // (a) the given PC belongs to a nmethod and
314 // (b) it is a deopt PC
315
316
317 Method* CompiledMethod::attached_method(address call_instr) {
318 assert(code_contains(call_instr), "not part of the nmethod");
319 RelocIterator iter(this, call_instr, call_instr + 1);
320 while (iter.next()) {
321 if (iter.addr() == call_instr) {
322 switch(iter.type()) {
323 case relocInfo::static_call_type: return iter.static_call_reloc()->method_value();
324 case relocInfo::opt_virtual_call_type: return iter.opt_virtual_call_reloc()->method_value();
325 case relocInfo::virtual_call_type: return iter.virtual_call_reloc()->method_value();
326 }
327 }
328 }
329 return NULL; // not found
330 }
331
332 Method* CompiledMethod::attached_method_before_pc(address pc) {
333 if (NativeCall::is_call_before(pc)) {
334 NativeCall* ncall = nativeCall_before(pc);
335 return attached_method(ncall->instruction_address());
|