86 _reserved_stack_access = 1 << 8
87 };
88 mutable u2 _flags;
89
90 #ifndef PRODUCT
91 int _compiled_invocation_count; // Number of nmethod invocations so far (for perf. debugging)
92 #endif
93 // Entry point for calling both from and to the interpreter.
94 address _i2i_entry; // All-args-on-stack calling convention
95 // Entry point for calling from compiled code, to compiled code if it exists
96 // or else the interpreter.
97 volatile address _from_compiled_entry; // Cache of: _code ? _code->entry_point() : _adapter->c2i_entry()
98 // The entry point for calling both from and to compiled code is
99 // "_code->entry_point()". Because of tiered compilation and de-opt, this
100 // field can come and go. It can transition from NULL to not-null at any
101 // time (whenever a compile completes). It can transition from not-null to
102 // NULL only at safepoints (because of a de-opt).
103 CompiledMethod* volatile _code; // Points to the corresponding piece of native code
104 volatile address _from_interpreted_entry; // Cache of _code ? _adapter->i2c_entry() : _i2i_entry
105
106 // Constructor
107 Method(ConstMethod* xconst, AccessFlags access_flags);
108 public:
109
110 static Method* allocate(ClassLoaderData* loader_data,
111 int byte_code_size,
112 AccessFlags access_flags,
113 InlineTableSizes* sizes,
114 ConstMethod::MethodType method_type,
115 TRAPS);
116
117 // CDS and vtbl checking can create an empty Method to get vtbl pointer.
118 Method(){}
119
120 // The Method vtable is restored by this call when the Method is in the
121 // shared archive. See patch_klass_vtables() in metaspaceShared.cpp for
122 // all the gory details. SA, dtrace and pstack helpers distinguish metadata
123 // by their vtable.
124 void restore_vtable() { guarantee(is_method(), "vtable restored by this call"); }
125 bool is_method() const volatile { return true; }
369 jlong prev_time() const {
370 MethodCounters* mcs = method_counters();
371 return mcs == NULL ? 0 : mcs->prev_time();
372 }
373 void set_prev_time(jlong time) {
374 MethodCounters* mcs = method_counters();
375 if (mcs != NULL) {
376 mcs->set_prev_time(time);
377 }
378 }
379 float rate() const {
380 MethodCounters* mcs = method_counters();
381 return mcs == NULL ? 0 : mcs->rate();
382 }
383 void set_rate(float rate) {
384 MethodCounters* mcs = method_counters();
385 if (mcs != NULL) {
386 mcs->set_rate(rate);
387 }
388 }
389 #endif
390 int nmethod_age() const {
391 if (method_counters() == NULL) {
392 return INT_MAX;
393 } else {
394 return method_counters()->nmethod_age();
395 }
396 }
397
398 int invocation_count();
399 int backedge_count();
400
401 bool was_executed_more_than(int n);
402 bool was_never_executed() { return !was_executed_more_than(0); }
403
404 static void build_interpreter_method_data(const methodHandle& method, TRAPS);
405
406 static MethodCounters* build_method_counters(Method* m, TRAPS);
407
408 int interpreter_invocation_count() {
409 if (TieredCompilation) {
631 bool is_constant_getter() const;
632
633 // returns true if the method is an initializer (<init> or <clinit>).
634 bool is_initializer() const;
635
636 // returns true if the method is static OR if the classfile version < 51
637 bool has_valid_initializer_flags() const;
638
639 // returns true if the method name is <clinit> and the method has
640 // valid static initializer flags.
641 bool is_static_initializer() const;
642
643 // returns true if the method name is <init>
644 bool is_object_initializer() const;
645
646 // compiled code support
647 // NOTE: code() is inherently racy as deopt can be clearing code
648 // simultaneously. Use with caution.
649 bool has_compiled_code() const { return code() != NULL; }
650
651 // sizing
652 static int header_size() { return sizeof(Method)/wordSize; }
653 static int size(bool is_native);
654 int size() const { return method_size(); }
655 #if INCLUDE_SERVICES
656 void collect_statistics(KlassSizeStats *sz) const;
657 #endif
658 void log_touched(TRAPS);
659 static void print_touched_methods(outputStream* out);
660
661 // interpreter support
662 static ByteSize const_offset() { return byte_offset_of(Method, _constMethod ); }
663 static ByteSize access_flags_offset() { return byte_offset_of(Method, _access_flags ); }
664 static ByteSize from_compiled_offset() { return byte_offset_of(Method, _from_compiled_entry); }
665 static ByteSize code_offset() { return byte_offset_of(Method, _code); }
666 static ByteSize method_data_offset() {
667 return byte_offset_of(Method, _method_data);
668 }
669 static ByteSize method_counters_offset() {
670 return byte_offset_of(Method, _method_counters);
|
86 _reserved_stack_access = 1 << 8
87 };
88 mutable u2 _flags;
89
90 #ifndef PRODUCT
91 int _compiled_invocation_count; // Number of nmethod invocations so far (for perf. debugging)
92 #endif
93 // Entry point for calling both from and to the interpreter.
94 address _i2i_entry; // All-args-on-stack calling convention
95 // Entry point for calling from compiled code, to compiled code if it exists
96 // or else the interpreter.
97 volatile address _from_compiled_entry; // Cache of: _code ? _code->entry_point() : _adapter->c2i_entry()
98 // The entry point for calling both from and to compiled code is
99 // "_code->entry_point()". Because of tiered compilation and de-opt, this
100 // field can come and go. It can transition from NULL to not-null at any
101 // time (whenever a compile completes). It can transition from not-null to
102 // NULL only at safepoints (because of a de-opt).
103 CompiledMethod* volatile _code; // Points to the corresponding piece of native code
104 volatile address _from_interpreted_entry; // Cache of _code ? _adapter->i2c_entry() : _i2i_entry
105
106 #if INCLUDE_AOT && defined(TIERED)
107 CompiledMethod* _aot_code;
108 #endif
109
110 // Constructor
111 Method(ConstMethod* xconst, AccessFlags access_flags);
112 public:
113
114 static Method* allocate(ClassLoaderData* loader_data,
115 int byte_code_size,
116 AccessFlags access_flags,
117 InlineTableSizes* sizes,
118 ConstMethod::MethodType method_type,
119 TRAPS);
120
121 // CDS and vtbl checking can create an empty Method to get vtbl pointer.
122 Method(){}
123
124 // The Method vtable is restored by this call when the Method is in the
125 // shared archive. See patch_klass_vtables() in metaspaceShared.cpp for
126 // all the gory details. SA, dtrace and pstack helpers distinguish metadata
127 // by their vtable.
128 void restore_vtable() { guarantee(is_method(), "vtable restored by this call"); }
129 bool is_method() const volatile { return true; }
373 jlong prev_time() const {
374 MethodCounters* mcs = method_counters();
375 return mcs == NULL ? 0 : mcs->prev_time();
376 }
377 void set_prev_time(jlong time) {
378 MethodCounters* mcs = method_counters();
379 if (mcs != NULL) {
380 mcs->set_prev_time(time);
381 }
382 }
383 float rate() const {
384 MethodCounters* mcs = method_counters();
385 return mcs == NULL ? 0 : mcs->rate();
386 }
387 void set_rate(float rate) {
388 MethodCounters* mcs = method_counters();
389 if (mcs != NULL) {
390 mcs->set_rate(rate);
391 }
392 }
393
394 #if INCLUDE_AOT
395 void set_aot_code(CompiledMethod* aot_code) {
396 _aot_code = aot_code;
397 }
398
399 CompiledMethod* aot_code() const {
400 return _aot_code;
401 }
402 #else
403 CompiledMethod* aot_code() const { return NULL; }
404 #endif // INCLUDE_AOT
405 #endif // TIERED
406
407 int nmethod_age() const {
408 if (method_counters() == NULL) {
409 return INT_MAX;
410 } else {
411 return method_counters()->nmethod_age();
412 }
413 }
414
415 int invocation_count();
416 int backedge_count();
417
418 bool was_executed_more_than(int n);
419 bool was_never_executed() { return !was_executed_more_than(0); }
420
421 static void build_interpreter_method_data(const methodHandle& method, TRAPS);
422
423 static MethodCounters* build_method_counters(Method* m, TRAPS);
424
425 int interpreter_invocation_count() {
426 if (TieredCompilation) {
648 bool is_constant_getter() const;
649
650 // returns true if the method is an initializer (<init> or <clinit>).
651 bool is_initializer() const;
652
653 // returns true if the method is static OR if the classfile version < 51
654 bool has_valid_initializer_flags() const;
655
656 // returns true if the method name is <clinit> and the method has
657 // valid static initializer flags.
658 bool is_static_initializer() const;
659
660 // returns true if the method name is <init>
661 bool is_object_initializer() const;
662
663 // compiled code support
664 // NOTE: code() is inherently racy as deopt can be clearing code
665 // simultaneously. Use with caution.
666 bool has_compiled_code() const { return code() != NULL; }
667
668 #ifdef TIERED
669 bool has_aot_code() const { return aot_code() != NULL; }
670 #endif
671
672 // sizing
673 static int header_size() { return sizeof(Method)/wordSize; }
674 static int size(bool is_native);
675 int size() const { return method_size(); }
676 #if INCLUDE_SERVICES
677 void collect_statistics(KlassSizeStats *sz) const;
678 #endif
679 void log_touched(TRAPS);
680 static void print_touched_methods(outputStream* out);
681
682 // interpreter support
683 static ByteSize const_offset() { return byte_offset_of(Method, _constMethod ); }
684 static ByteSize access_flags_offset() { return byte_offset_of(Method, _access_flags ); }
685 static ByteSize from_compiled_offset() { return byte_offset_of(Method, _from_compiled_entry); }
686 static ByteSize code_offset() { return byte_offset_of(Method, _code); }
687 static ByteSize method_data_offset() {
688 return byte_offset_of(Method, _method_data);
689 }
690 static ByteSize method_counters_offset() {
691 return byte_offset_of(Method, _method_counters);
|