< prev index next >

src/share/vm/code/compiledMethod.cpp

Print this page




  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/compiledIC.hpp"
  27 #include "code/scopeDesc.hpp"
  28 #include "code/codeCache.hpp"
  29 #include "prims/methodHandles.hpp"
  30 #include "interpreter/bytecode.hpp"
  31 #include "memory/resourceArea.hpp"
  32 #include "runtime/mutexLocker.hpp"

  33 
  34 CompiledMethod::CompiledMethod(Method* method, const char* name, CompilerType type, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments)
  35   : CodeBlob(name, type, layout, frame_complete_offset, frame_size, oop_maps, caller_must_gc_arguments),
  36   _method(method), _mark_for_deoptimization_status(not_marked) {
  37   init_defaults();
  38 }
  39 
  40 CompiledMethod::CompiledMethod(Method* method, const char* name, CompilerType type, int size, int header_size, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments)
  41   : CodeBlob(name, type, CodeBlobLayout((address) this, size, header_size, cb), cb, frame_complete_offset, frame_size, oop_maps, caller_must_gc_arguments),
  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 }


 291 
 292 // Method that knows how to preserve outgoing arguments at call. This method must be
 293 // called with a frame corresponding to a Java invoke
 294 void CompiledMethod::preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) {
 295 #ifndef SHARK
 296   if (method() != NULL && !method()->is_native()) {
 297     address pc = fr.pc();
 298     SimpleScopeDesc ssd(this, pc);
 299     Bytecode_invoke call(ssd.method(), ssd.bci());
 300     bool has_receiver = call.has_receiver();
 301     bool has_appendix = call.has_appendix();
 302     Symbol* signature = call.signature();
 303 
 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 




  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/compiledIC.hpp"
  27 #include "code/scopeDesc.hpp"
  28 #include "code/codeCache.hpp"
  29 #include "prims/methodHandles.hpp"
  30 #include "interpreter/bytecode.hpp"
  31 #include "memory/resourceArea.hpp"
  32 #include "runtime/mutexLocker.hpp"
  33 #include "runtime/sharedRuntime.hpp"
  34 
  35 CompiledMethod::CompiledMethod(Method* method, const char* name, CompilerType type, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments)
  36   : CodeBlob(name, type, layout, frame_complete_offset, frame_size, oop_maps, caller_must_gc_arguments),
  37   _method(method), _mark_for_deoptimization_status(not_marked) {
  38   init_defaults();
  39 }
  40 
  41 CompiledMethod::CompiledMethod(Method* method, const char* name, CompilerType type, int size, int header_size, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments)
  42   : CodeBlob(name, type, CodeBlobLayout((address) this, size, header_size, cb), cb, frame_complete_offset, frame_size, oop_maps, caller_must_gc_arguments),
  43   _method(method), _mark_for_deoptimization_status(not_marked) {
  44   init_defaults();
  45 }
  46 
  47 void CompiledMethod::init_defaults() {
  48   _has_unsafe_access          = 0;
  49   _has_method_handle_invokes  = 0;
  50   _lazy_critical_native       = 0;
  51   _has_wide_vectors           = 0;
  52   _unloading_clock            = 0;
  53 }


 292 
 293 // Method that knows how to preserve outgoing arguments at call. This method must be
 294 // called with a frame corresponding to a Java invoke
 295 void CompiledMethod::preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) {
 296 #ifndef SHARK
 297   if (method() != NULL && !method()->is_native()) {
 298     address pc = fr.pc();
 299     SimpleScopeDesc ssd(this, pc);
 300     Bytecode_invoke call(ssd.method(), ssd.bci());
 301     bool has_receiver = call.has_receiver();
 302     bool has_appendix = call.has_appendix();
 303     Symbol* signature = call.signature();
 304 
 305     // The method attached by JIT-compilers should be used, if present.
 306     // Bytecode can be inaccurate in such case.
 307     Method* callee = attached_method_before_pc(pc);
 308     if (callee != NULL) {
 309       has_receiver = !(callee->access_flags().is_static());
 310       has_appendix = false;
 311       signature = callee->signature();
 312     }
 313 
 314     // If value types are passed as fields, use the extended signature
 315     // which contains the types of all (oop) fields of the value type.
 316     if (ValueTypePassFieldsAsArgs) {
 317       // Check if receiver or one of the arguments is a value type
 318       bool has_value_receiver = (callee != NULL && callee->method_holder()->is_value());
 319       bool has_value_argument = has_value_receiver;
 320       const int len = signature->utf8_length();
 321       for (int i = 0; i < len && !has_value_argument; ++i) {
 322         if (signature->byte_at(i) == 'Q') {
 323           has_value_argument = true;
 324         }
 325       }
 326       if (has_value_argument) {
 327         // Get the extended signature from the callee's adapter through the attached method
 328         assert(callee != NULL, "must have attached method");
 329         signature = callee->adapter()->get_sig_extended();
 330         assert(signature != NULL, "signature is null");
 331         has_receiver = false; // The extended signature contains the receiver type
 332       }
 333     }
 334 
 335     fr.oops_compiled_arguments_do(signature, has_receiver, has_appendix, reg_map, f);
 336   }
 337 #endif // !SHARK
 338 }
 339 
 340 // -----------------------------------------------------------------------------
 341 // CompiledMethod::get_deopt_original_pc
 342 //
 343 // Return the original PC for the given PC if:
 344 // (a) the given PC belongs to a nmethod and
 345 // (b) it is a deopt PC
 346 address CompiledMethod::get_deopt_original_pc(const frame* fr) {
 347   if (fr->cb() == NULL)  return NULL;
 348 
 349   CompiledMethod* cm = fr->cb()->as_compiled_method_or_null();
 350   if (cm != NULL && cm->is_deopt_pc(fr->pc()))
 351     return cm->get_original_pc(fr);
 352 


< prev index next >