src/share/vm/oops/method.cpp

Print this page




 223                         myThread->is_ConcurrentGC_thread() ||
 224                         myThread->is_GC_task_thread();
 225 
 226   if (!has_capability) {
 227     if (!VerifyStack && !VerifyLastFrame) {
 228       // verify stack calls this outside VM thread
 229       warning("oopmap should only be accessed by the "
 230               "VM, GC task or CMS threads (or during debugging)");
 231       InterpreterOopMap local_mask;
 232       method_holder()->mask_for(h_this, bci, &local_mask);
 233       local_mask.print();
 234     }
 235   }
 236 #endif
 237   method_holder()->mask_for(h_this, bci, mask);
 238   return;
 239 }
 240 
 241 
 242 int Method::bci_from(address bcp) const {



 243 #ifdef ASSERT
 244   { ResourceMark rm;
 245   assert(is_native() && bcp == code_base() || contains(bcp) || is_error_reported(),
 246          err_msg("bcp doesn't belong to this method: bcp: " INTPTR_FORMAT ", method: %s", bcp, name_and_sig_as_C_string()));
 247   }
 248 #endif
 249   return bcp - code_base();
 250 }
 251 
 252 
 253 // Return (int)bcx if it appears to be a valid BCI.
 254 // Return bci_from((address)bcx) if it appears to be a valid BCP.



 255 // Return -1 otherwise.
 256 // Used by profiling code, when invalid data is a possibility.
 257 // The caller is responsible for validating the Method* itself.
 258 int Method::validate_bci_from_bcx(intptr_t bcx) const {
 259   // keep bci as -1 if not a valid bci
 260   int bci = -1;
 261   if (bcx == 0 || (address)bcx == code_base()) {
 262     // code_size() may return 0 and we allow 0 here
 263     // the method may be native
 264     bci = 0;
 265   } else if (frame::is_bci(bcx)) {
 266     if (bcx < code_size()) {
 267       bci = (int)bcx;
 268     }
 269   } else if (contains((address)bcx)) {
 270     bci = (address)bcx - code_base();
 271   }
 272   // Assert that if we have dodged any asserts, bci is negative.
 273   assert(bci == -1 || bci == bci_from(bcp_from(bci)), "sane bci if >=0");
 274   return bci;
 275 }
 276 
 277 address Method::bcp_from(int bci) const {
 278   assert((is_native() && bci == 0)  || (!is_native() && 0 <= bci && bci < code_size()), err_msg("illegal bci: %d", bci));
 279   address bcp = code_base() + bci;
 280   assert(is_native() && bcp == code_base() || contains(bcp), "bcp doesn't belong to this method");
 281   return bcp;
 282 }
 283 
 284 
 285 int Method::size(bool is_native) {
 286   // If native, then include pointers for native_function and signature_handler
 287   int extra_bytes = (is_native) ? 2*sizeof(address*) : 0;
 288   int extra_words = align_size_up(extra_bytes, BytesPerWord) / BytesPerWord;
 289   return align_object_size(header_size() + extra_words);
 290 }




 223                         myThread->is_ConcurrentGC_thread() ||
 224                         myThread->is_GC_task_thread();
 225 
 226   if (!has_capability) {
 227     if (!VerifyStack && !VerifyLastFrame) {
 228       // verify stack calls this outside VM thread
 229       warning("oopmap should only be accessed by the "
 230               "VM, GC task or CMS threads (or during debugging)");
 231       InterpreterOopMap local_mask;
 232       method_holder()->mask_for(h_this, bci, &local_mask);
 233       local_mask.print();
 234     }
 235   }
 236 #endif
 237   method_holder()->mask_for(h_this, bci, mask);
 238   return;
 239 }
 240 
 241 
 242 int Method::bci_from(address bcp) const {
 243   if (is_native() && bcp == 0) {
 244     return 0;
 245   }
 246 #ifdef ASSERT
 247   { ResourceMark rm;
 248   assert(is_native() && bcp == code_base() || contains(bcp) || is_error_reported(),
 249          err_msg("bcp doesn't belong to this method: bcp: " INTPTR_FORMAT ", method: %s", bcp, name_and_sig_as_C_string()));
 250   }
 251 #endif
 252   return bcp - code_base();
 253 }
 254 
 255 
 256 int Method::validate_bci(int bci) const {
 257   return (bci == 0 || bci < code_size()) ? bci : -1;
 258 }
 259 
 260 // Return bci if it appears to be a valid bcp
 261 // Return -1 otherwise.
 262 // Used by profiling code, when invalid data is a possibility.
 263 // The caller is responsible for validating the Method* itself.
 264 int Method::validate_bci_from_bcp(address bcp) const {
 265   // keep bci as -1 if not a valid bci
 266   int bci = -1;
 267   if (bcp == 0 || bcp == code_base()) {
 268     // code_size() may return 0 and we allow 0 here
 269     // the method may be native
 270     bci = 0;
 271   } else if (contains(bcp)) {
 272     bci = bcp - code_base();




 273   }
 274   // Assert that if we have dodged any asserts, bci is negative.
 275   assert(bci == -1 || bci == bci_from(bcp_from(bci)), "sane bci if >=0");
 276   return bci;
 277 }
 278 
 279 address Method::bcp_from(int bci) const {
 280   assert((is_native() && bci == 0)  || (!is_native() && 0 <= bci && bci < code_size()), err_msg("illegal bci: %d", bci));
 281   address bcp = code_base() + bci;
 282   assert(is_native() && bcp == code_base() || contains(bcp), "bcp doesn't belong to this method");
 283   return bcp;
 284 }
 285 
 286 
 287 int Method::size(bool is_native) {
 288   // If native, then include pointers for native_function and signature_handler
 289   int extra_bytes = (is_native) ? 2*sizeof(address*) : 0;
 290   int extra_words = align_size_up(extra_bytes, BytesPerWord) / BytesPerWord;
 291   return align_object_size(header_size() + extra_words);
 292 }