231 warning("oopmap should only be accessed by the "
232 "VM, GC task or CMS threads (or during debugging)");
233 InterpreterOopMap local_mask;
234 method_holder()->mask_for(h_this, bci, &local_mask);
235 local_mask.print();
236 }
237 }
238 #endif
239 method_holder()->mask_for(h_this, bci, mask);
240 return;
241 }
242
243
244 int Method::bci_from(address bcp) const {
245 if (is_native() && bcp == 0) {
246 return 0;
247 }
248 #ifdef ASSERT
249 { ResourceMark rm;
250 assert(is_native() && bcp == code_base() || contains(bcp) || is_error_reported(),
251 err_msg("bcp doesn't belong to this method: bcp: " INTPTR_FORMAT ", method: %s", bcp, name_and_sig_as_C_string()));
252 }
253 #endif
254 return bcp - code_base();
255 }
256
257
258 int Method::validate_bci(int bci) const {
259 return (bci == 0 || bci < code_size()) ? bci : -1;
260 }
261
262 // Return bci if it appears to be a valid bcp
263 // Return -1 otherwise.
264 // Used by profiling code, when invalid data is a possibility.
265 // The caller is responsible for validating the Method* itself.
266 int Method::validate_bci_from_bcp(address bcp) const {
267 // keep bci as -1 if not a valid bci
268 int bci = -1;
269 if (bcp == 0 || bcp == code_base()) {
270 // code_size() may return 0 and we allow 0 here
271 // the method may be native
272 bci = 0;
273 } else if (contains(bcp)) {
274 bci = bcp - code_base();
275 }
276 // Assert that if we have dodged any asserts, bci is negative.
277 assert(bci == -1 || bci == bci_from(bcp_from(bci)), "sane bci if >=0");
278 return bci;
279 }
280
281 address Method::bcp_from(int bci) const {
282 assert((is_native() && bci == 0) || (!is_native() && 0 <= bci && bci < code_size()), err_msg("illegal bci: %d", bci));
283 address bcp = code_base() + bci;
284 assert(is_native() && bcp == code_base() || contains(bcp), "bcp doesn't belong to this method");
285 return bcp;
286 }
287
288 address Method::bcp_from(address bcp) const {
289 if (is_native() && bcp == NULL) {
290 return code_base();
291 } else {
292 return bcp;
293 }
294 }
295
296 int Method::size(bool is_native) {
297 // If native, then include pointers for native_function and signature_handler
298 int extra_bytes = (is_native) ? 2*sizeof(address*) : 0;
299 int extra_words = align_size_up(extra_bytes, BytesPerWord) / BytesPerWord;
300 return align_object_size(header_size() + extra_words);
301 }
302
556 bool Method::is_final_method() const {
557 return is_final_method(method_holder()->access_flags());
558 }
559
560 bool Method::is_default_method() const {
561 if (method_holder() != NULL &&
562 method_holder()->is_interface() &&
563 !is_abstract()) {
564 return true;
565 } else {
566 return false;
567 }
568 }
569
570 bool Method::can_be_statically_bound(AccessFlags class_access_flags) const {
571 if (is_final_method(class_access_flags)) return true;
572 #ifdef ASSERT
573 ResourceMark rm;
574 bool is_nonv = (vtable_index() == nonvirtual_vtable_index);
575 if (class_access_flags.is_interface()) {
576 assert(is_nonv == is_static(), err_msg("is_nonv=%s", name_and_sig_as_C_string()));
577 }
578 #endif
579 assert(valid_vtable_index() || valid_itable_index(), "method must be linked before we ask this question");
580 return vtable_index() == nonvirtual_vtable_index;
581 }
582
583 bool Method::can_be_statically_bound() const {
584 return can_be_statically_bound(method_holder()->access_flags());
585 }
586
587 bool Method::is_accessor() const {
588 if (code_size() != 5) return false;
589 if (size_of_parameters() != 1) return false;
590 if (java_code_at(0) != Bytecodes::_aload_0 ) return false;
591 if (java_code_at(1) != Bytecodes::_getfield) return false;
592 if (java_code_at(4) != Bytecodes::_areturn &&
593 java_code_at(4) != Bytecodes::_ireturn ) return false;
594 return true;
595 }
596
1555 _bci += read_signed_int();
1556 _line += read_signed_int();
1557 } else {
1558 // Single byte compression used
1559 _bci += next >> 3;
1560 _line += next & 0x7;
1561 }
1562 return true;
1563 }
1564
1565
1566 Bytecodes::Code Method::orig_bytecode_at(int bci) const {
1567 BreakpointInfo* bp = method_holder()->breakpoints();
1568 for (; bp != NULL; bp = bp->next()) {
1569 if (bp->match(this, bci)) {
1570 return bp->orig_bytecode();
1571 }
1572 }
1573 {
1574 ResourceMark rm;
1575 fatal(err_msg("no original bytecode found in %s at bci %d", name_and_sig_as_C_string(), bci));
1576 }
1577 return Bytecodes::_shouldnotreachhere;
1578 }
1579
1580 void Method::set_orig_bytecode_at(int bci, Bytecodes::Code code) {
1581 assert(code != Bytecodes::_breakpoint, "cannot patch breakpoints this way");
1582 BreakpointInfo* bp = method_holder()->breakpoints();
1583 for (; bp != NULL; bp = bp->next()) {
1584 if (bp->match(this, bci)) {
1585 bp->set_orig_bytecode(code);
1586 // and continue, in case there is more than one
1587 }
1588 }
1589 }
1590
1591 void Method::set_breakpoint(int bci) {
1592 InstanceKlass* ik = method_holder();
1593 BreakpointInfo *bp = new BreakpointInfo(this, bci);
1594 bp->set_next(ik->breakpoints());
1595 ik->set_breakpoints(bp);
|
231 warning("oopmap should only be accessed by the "
232 "VM, GC task or CMS threads (or during debugging)");
233 InterpreterOopMap local_mask;
234 method_holder()->mask_for(h_this, bci, &local_mask);
235 local_mask.print();
236 }
237 }
238 #endif
239 method_holder()->mask_for(h_this, bci, mask);
240 return;
241 }
242
243
244 int Method::bci_from(address bcp) const {
245 if (is_native() && bcp == 0) {
246 return 0;
247 }
248 #ifdef ASSERT
249 { ResourceMark rm;
250 assert(is_native() && bcp == code_base() || contains(bcp) || is_error_reported(),
251 "bcp doesn't belong to this method: bcp: " INTPTR_FORMAT ", method: %s", bcp, name_and_sig_as_C_string());
252 }
253 #endif
254 return bcp - code_base();
255 }
256
257
258 int Method::validate_bci(int bci) const {
259 return (bci == 0 || bci < code_size()) ? bci : -1;
260 }
261
262 // Return bci if it appears to be a valid bcp
263 // Return -1 otherwise.
264 // Used by profiling code, when invalid data is a possibility.
265 // The caller is responsible for validating the Method* itself.
266 int Method::validate_bci_from_bcp(address bcp) const {
267 // keep bci as -1 if not a valid bci
268 int bci = -1;
269 if (bcp == 0 || bcp == code_base()) {
270 // code_size() may return 0 and we allow 0 here
271 // the method may be native
272 bci = 0;
273 } else if (contains(bcp)) {
274 bci = bcp - code_base();
275 }
276 // Assert that if we have dodged any asserts, bci is negative.
277 assert(bci == -1 || bci == bci_from(bcp_from(bci)), "sane bci if >=0");
278 return bci;
279 }
280
281 address Method::bcp_from(int bci) const {
282 assert((is_native() && bci == 0) || (!is_native() && 0 <= bci && bci < code_size()), "illegal bci: %d", bci);
283 address bcp = code_base() + bci;
284 assert(is_native() && bcp == code_base() || contains(bcp), "bcp doesn't belong to this method");
285 return bcp;
286 }
287
288 address Method::bcp_from(address bcp) const {
289 if (is_native() && bcp == NULL) {
290 return code_base();
291 } else {
292 return bcp;
293 }
294 }
295
296 int Method::size(bool is_native) {
297 // If native, then include pointers for native_function and signature_handler
298 int extra_bytes = (is_native) ? 2*sizeof(address*) : 0;
299 int extra_words = align_size_up(extra_bytes, BytesPerWord) / BytesPerWord;
300 return align_object_size(header_size() + extra_words);
301 }
302
556 bool Method::is_final_method() const {
557 return is_final_method(method_holder()->access_flags());
558 }
559
560 bool Method::is_default_method() const {
561 if (method_holder() != NULL &&
562 method_holder()->is_interface() &&
563 !is_abstract()) {
564 return true;
565 } else {
566 return false;
567 }
568 }
569
570 bool Method::can_be_statically_bound(AccessFlags class_access_flags) const {
571 if (is_final_method(class_access_flags)) return true;
572 #ifdef ASSERT
573 ResourceMark rm;
574 bool is_nonv = (vtable_index() == nonvirtual_vtable_index);
575 if (class_access_flags.is_interface()) {
576 assert(is_nonv == is_static(), "is_nonv=%s", name_and_sig_as_C_string());
577 }
578 #endif
579 assert(valid_vtable_index() || valid_itable_index(), "method must be linked before we ask this question");
580 return vtable_index() == nonvirtual_vtable_index;
581 }
582
583 bool Method::can_be_statically_bound() const {
584 return can_be_statically_bound(method_holder()->access_flags());
585 }
586
587 bool Method::is_accessor() const {
588 if (code_size() != 5) return false;
589 if (size_of_parameters() != 1) return false;
590 if (java_code_at(0) != Bytecodes::_aload_0 ) return false;
591 if (java_code_at(1) != Bytecodes::_getfield) return false;
592 if (java_code_at(4) != Bytecodes::_areturn &&
593 java_code_at(4) != Bytecodes::_ireturn ) return false;
594 return true;
595 }
596
1555 _bci += read_signed_int();
1556 _line += read_signed_int();
1557 } else {
1558 // Single byte compression used
1559 _bci += next >> 3;
1560 _line += next & 0x7;
1561 }
1562 return true;
1563 }
1564
1565
1566 Bytecodes::Code Method::orig_bytecode_at(int bci) const {
1567 BreakpointInfo* bp = method_holder()->breakpoints();
1568 for (; bp != NULL; bp = bp->next()) {
1569 if (bp->match(this, bci)) {
1570 return bp->orig_bytecode();
1571 }
1572 }
1573 {
1574 ResourceMark rm;
1575 fatal("no original bytecode found in %s at bci %d", name_and_sig_as_C_string(), bci);
1576 }
1577 return Bytecodes::_shouldnotreachhere;
1578 }
1579
1580 void Method::set_orig_bytecode_at(int bci, Bytecodes::Code code) {
1581 assert(code != Bytecodes::_breakpoint, "cannot patch breakpoints this way");
1582 BreakpointInfo* bp = method_holder()->breakpoints();
1583 for (; bp != NULL; bp = bp->next()) {
1584 if (bp->match(this, bci)) {
1585 bp->set_orig_bytecode(code);
1586 // and continue, in case there is more than one
1587 }
1588 }
1589 }
1590
1591 void Method::set_breakpoint(int bci) {
1592 InstanceKlass* ik = method_holder();
1593 BreakpointInfo *bp = new BreakpointInfo(this, bci);
1594 bp->set_next(ik->breakpoints());
1595 ik->set_breakpoints(bp);
|