76
77 // Flags
78 enum Flags {
79 _jfr_towrite = 1 << 0,
80 _caller_sensitive = 1 << 1,
81 _force_inline = 1 << 2,
82 _dont_inline = 1 << 3,
83 _hidden = 1 << 4,
84 _has_injected_profile = 1 << 5,
85 _running_emcp = 1 << 6,
86 _intrinsic_candidate = 1 << 7,
87 _reserved_stack_access = 1 << 8
88 };
89 mutable u2 _flags;
90
91 #ifndef PRODUCT
92 int _compiled_invocation_count; // Number of nmethod invocations so far (for perf. debugging)
93 #endif
94 // Entry point for calling both from and to the interpreter.
95 address _i2i_entry; // All-args-on-stack calling convention
96 // Adapter blob (i2c/c2i) for this Method*. Set once when method is linked.
97 AdapterHandlerEntry* _adapter;
98 // Entry point for calling from compiled code, to compiled code if it exists
99 // or else the interpreter.
100 volatile address _from_compiled_entry; // Cache of: _code ? _code->entry_point() : _adapter->c2i_entry()
101 // The entry point for calling both from and to compiled code is
102 // "_code->entry_point()". Because of tiered compilation and de-opt, this
103 // field can come and go. It can transition from NULL to not-null at any
104 // time (whenever a compile completes). It can transition from not-null to
105 // NULL only at safepoints (because of a de-opt).
106 nmethod* volatile _code; // Points to the corresponding piece of native code
107 volatile address _from_interpreted_entry; // Cache of _code ? _adapter->i2c_entry() : _i2i_entry
108
109 // Constructor
110 Method(ConstMethod* xconst, AccessFlags access_flags);
111 public:
112
113 static Method* allocate(ClassLoaderData* loader_data,
114 int byte_code_size,
115 AccessFlags access_flags,
116 InlineTableSizes* sizes,
117 ConstMethod::MethodType method_type,
120 // CDS and vtbl checking can create an empty Method to get vtbl pointer.
121 Method(){}
122
123 // The Method vtable is restored by this call when the Method is in the
124 // shared archive. See patch_klass_vtables() in metaspaceShared.cpp for
125 // all the gory details. SA, dtrace and pstack helpers distinguish metadata
126 // by their vtable.
127 void restore_vtable() { guarantee(is_method(), "vtable restored by this call"); }
128 bool is_method() const volatile { return true; }
129
130 void restore_unshareable_info(TRAPS);
131
132 // accessors for instance variables
133
134 ConstMethod* constMethod() const { return _constMethod; }
135 void set_constMethod(ConstMethod* xconst) { _constMethod = xconst; }
136
137
138 static address make_adapters(methodHandle mh, TRAPS);
139 volatile address from_compiled_entry() const { return (address)OrderAccess::load_ptr_acquire(&_from_compiled_entry); }
140 volatile address from_interpreted_entry() const{ return (address)OrderAccess::load_ptr_acquire(&_from_interpreted_entry); }
141
142 // access flag
143 AccessFlags access_flags() const { return _access_flags; }
144 void set_access_flags(AccessFlags flags) { _access_flags = flags; }
145
146 // name
147 Symbol* name() const { return constants()->symbol_at(name_index()); }
148 int name_index() const { return constMethod()->name_index(); }
149 void set_name_index(int index) { constMethod()->set_name_index(index); }
150
151 // signature
152 Symbol* signature() const { return constants()->symbol_at(signature_index()); }
153 int signature_index() const { return constMethod()->signature_index(); }
154 void set_signature_index(int index) { constMethod()->set_signature_index(index); }
155
156 // generics support
157 Symbol* generic_signature() const { int idx = generic_signature_index(); return ((idx != 0) ? constants()->symbol_at(idx) : (Symbol*)NULL); }
158 int generic_signature_index() const { return constMethod()->generic_signature_index(); }
159 void set_generic_signature_index(int index) { constMethod()->set_generic_signature_index(index); }
414 }
415
416 #ifndef PRODUCT
417 int compiled_invocation_count() const { return _compiled_invocation_count; }
418 void set_compiled_invocation_count(int count) { _compiled_invocation_count = count; }
419 #else
420 // for PrintMethodData in a product build
421 int compiled_invocation_count() const { return 0; }
422 #endif // not PRODUCT
423
424 // Clear (non-shared space) pointers which could not be relevant
425 // if this (shared) method were mapped into another JVM.
426 void remove_unshareable_info();
427
428 // nmethod/verified compiler entry
429 address verified_code_entry();
430 bool check_code() const; // Not inline to avoid circular ref
431 nmethod* volatile code() const { assert( check_code(), "" ); return (nmethod *)OrderAccess::load_ptr_acquire(&_code); }
432 void clear_code(); // Clear out any compiled code
433 static void set_code(methodHandle mh, nmethod* code);
434 void set_adapter_entry(AdapterHandlerEntry* adapter) { _adapter = adapter; }
435 address get_i2c_entry();
436 address get_c2i_entry();
437 address get_c2i_unverified_entry();
438 AdapterHandlerEntry* adapter() { return _adapter; }
439 // setup entry points
440 void link_method(const methodHandle& method, TRAPS);
441 // clear entry points. Used by sharing code
442 void unlink_method();
443
444 // vtable index
445 enum VtableIndexFlag {
446 // Valid vtable indexes are non-negative (>= 0).
447 // These few negative values are used as sentinels.
448 itable_index_max = -10, // first itable index, growing downward
449 pending_itable_index = -9, // itable index will be assigned
450 invalid_vtable_index = -4, // distinct from any valid vtable index
451 garbage_vtable_index = -3, // not yet linked; no vtable layout yet
452 nonvirtual_vtable_index = -2 // there is no need for vtable dispatch
453 // 6330203 Note: Do not use -1, which was overloaded with many meanings.
454 };
455 DEBUG_ONLY(bool valid_vtable_index() const { return _vtable_index >= nonvirtual_vtable_index; })
456 bool has_vtable_index() const { return _vtable_index >= 0; }
457 int vtable_index() const { return _vtable_index; }
458 void set_vtable_index(int index) { _vtable_index = index; }
459 DEBUG_ONLY(bool valid_itable_index() const { return _vtable_index <= pending_itable_index; })
460 bool has_itable_index() const { return _vtable_index <= itable_index_max; }
461 int itable_index() const { assert(valid_itable_index(), "");
462 return itable_index_max - _vtable_index; }
463 void set_itable_index(int index) { _vtable_index = itable_index_max - index; assert(valid_itable_index(), ""); }
464
465 // interpreter entry
466 address interpreter_entry() const { return _i2i_entry; }
467 // Only used when first initialize so we can set _i2i_entry and _from_interpreted_entry
468 void set_interpreter_entry(address entry) { _i2i_entry = entry; _from_interpreted_entry = entry; }
469
470 // native function (used for native methods only)
471 enum {
472 native_bind_event_is_interesting = true
473 };
474 address native_function() const { return *(native_function_addr()); }
475 address critical_native_function();
476
477 // Must specify a real function (not NULL).
478 // Use clear_native_function() to unregister.
479 void set_native_function(address function, bool post_event_flag);
480 bool has_native_function() const;
481 void clear_native_function();
482
483 // signature handler (used for native methods only)
484 address signature_handler() const { return *(signature_handler_addr()); }
485 void set_signature_handler(address handler);
486
487 // Interpreter oopmap support
488 void mask_for(int bci, InterpreterOopMap* mask);
|
76
77 // Flags
78 enum Flags {
79 _jfr_towrite = 1 << 0,
80 _caller_sensitive = 1 << 1,
81 _force_inline = 1 << 2,
82 _dont_inline = 1 << 3,
83 _hidden = 1 << 4,
84 _has_injected_profile = 1 << 5,
85 _running_emcp = 1 << 6,
86 _intrinsic_candidate = 1 << 7,
87 _reserved_stack_access = 1 << 8
88 };
89 mutable u2 _flags;
90
91 #ifndef PRODUCT
92 int _compiled_invocation_count; // Number of nmethod invocations so far (for perf. debugging)
93 #endif
94 // Entry point for calling both from and to the interpreter.
95 address _i2i_entry; // All-args-on-stack calling convention
96 // Entry point for calling from compiled code, to compiled code if it exists
97 // or else the interpreter.
98 volatile address _from_compiled_entry; // Cache of: _code ? _code->entry_point() : _adapter->c2i_entry()
99 // The entry point for calling both from and to compiled code is
100 // "_code->entry_point()". Because of tiered compilation and de-opt, this
101 // field can come and go. It can transition from NULL to not-null at any
102 // time (whenever a compile completes). It can transition from not-null to
103 // NULL only at safepoints (because of a de-opt).
104 nmethod* volatile _code; // Points to the corresponding piece of native code
105 volatile address _from_interpreted_entry; // Cache of _code ? _adapter->i2c_entry() : _i2i_entry
106
107 // Constructor
108 Method(ConstMethod* xconst, AccessFlags access_flags);
109 public:
110
111 static Method* allocate(ClassLoaderData* loader_data,
112 int byte_code_size,
113 AccessFlags access_flags,
114 InlineTableSizes* sizes,
115 ConstMethod::MethodType method_type,
118 // CDS and vtbl checking can create an empty Method to get vtbl pointer.
119 Method(){}
120
121 // The Method vtable is restored by this call when the Method is in the
122 // shared archive. See patch_klass_vtables() in metaspaceShared.cpp for
123 // all the gory details. SA, dtrace and pstack helpers distinguish metadata
124 // by their vtable.
125 void restore_vtable() { guarantee(is_method(), "vtable restored by this call"); }
126 bool is_method() const volatile { return true; }
127
128 void restore_unshareable_info(TRAPS);
129
130 // accessors for instance variables
131
132 ConstMethod* constMethod() const { return _constMethod; }
133 void set_constMethod(ConstMethod* xconst) { _constMethod = xconst; }
134
135
136 static address make_adapters(methodHandle mh, TRAPS);
137 volatile address from_compiled_entry() const { return (address)OrderAccess::load_ptr_acquire(&_from_compiled_entry); }
138 volatile address from_compiled_entry_no_trampoline() const;
139 volatile address from_interpreted_entry() const{ return (address)OrderAccess::load_ptr_acquire(&_from_interpreted_entry); }
140
141 // access flag
142 AccessFlags access_flags() const { return _access_flags; }
143 void set_access_flags(AccessFlags flags) { _access_flags = flags; }
144
145 // name
146 Symbol* name() const { return constants()->symbol_at(name_index()); }
147 int name_index() const { return constMethod()->name_index(); }
148 void set_name_index(int index) { constMethod()->set_name_index(index); }
149
150 // signature
151 Symbol* signature() const { return constants()->symbol_at(signature_index()); }
152 int signature_index() const { return constMethod()->signature_index(); }
153 void set_signature_index(int index) { constMethod()->set_signature_index(index); }
154
155 // generics support
156 Symbol* generic_signature() const { int idx = generic_signature_index(); return ((idx != 0) ? constants()->symbol_at(idx) : (Symbol*)NULL); }
157 int generic_signature_index() const { return constMethod()->generic_signature_index(); }
158 void set_generic_signature_index(int index) { constMethod()->set_generic_signature_index(index); }
413 }
414
415 #ifndef PRODUCT
416 int compiled_invocation_count() const { return _compiled_invocation_count; }
417 void set_compiled_invocation_count(int count) { _compiled_invocation_count = count; }
418 #else
419 // for PrintMethodData in a product build
420 int compiled_invocation_count() const { return 0; }
421 #endif // not PRODUCT
422
423 // Clear (non-shared space) pointers which could not be relevant
424 // if this (shared) method were mapped into another JVM.
425 void remove_unshareable_info();
426
427 // nmethod/verified compiler entry
428 address verified_code_entry();
429 bool check_code() const; // Not inline to avoid circular ref
430 nmethod* volatile code() const { assert( check_code(), "" ); return (nmethod *)OrderAccess::load_ptr_acquire(&_code); }
431 void clear_code(); // Clear out any compiled code
432 static void set_code(methodHandle mh, nmethod* code);
433 void set_adapter_entry(AdapterHandlerEntry* adapter) {
434 constMethod()->set_adapter_entry(adapter);
435 }
436 void update_adapter_trampoline(AdapterHandlerEntry* adapter) {
437 constMethod()->update_adapter_trampoline(adapter);
438 }
439
440 address get_i2c_entry();
441 address get_c2i_entry();
442 address get_c2i_unverified_entry();
443 AdapterHandlerEntry* adapter() const {
444 return constMethod()->adapter();
445 }
446 // setup entry points
447 void link_method(const methodHandle& method, TRAPS);
448 // clear entry points. Used by sharing code
449 void unlink_method();
450
451 // vtable index
452 enum VtableIndexFlag {
453 // Valid vtable indexes are non-negative (>= 0).
454 // These few negative values are used as sentinels.
455 itable_index_max = -10, // first itable index, growing downward
456 pending_itable_index = -9, // itable index will be assigned
457 invalid_vtable_index = -4, // distinct from any valid vtable index
458 garbage_vtable_index = -3, // not yet linked; no vtable layout yet
459 nonvirtual_vtable_index = -2 // there is no need for vtable dispatch
460 // 6330203 Note: Do not use -1, which was overloaded with many meanings.
461 };
462 DEBUG_ONLY(bool valid_vtable_index() const { return _vtable_index >= nonvirtual_vtable_index; })
463 bool has_vtable_index() const { return _vtable_index >= 0; }
464 int vtable_index() const { return _vtable_index; }
465 void set_vtable_index(int index) { _vtable_index = index; }
466 DEBUG_ONLY(bool valid_itable_index() const { return _vtable_index <= pending_itable_index; })
467 bool has_itable_index() const { return _vtable_index <= itable_index_max; }
468 int itable_index() const { assert(valid_itable_index(), "");
469 return itable_index_max - _vtable_index; }
470 void set_itable_index(int index) { _vtable_index = itable_index_max - index; assert(valid_itable_index(), ""); }
471
472 // interpreter entry
473 address interpreter_entry() const { return _i2i_entry; }
474 // Only used when first initialize so we can set _i2i_entry and _from_interpreted_entry
475 void set_interpreter_entry(address entry) {
476 if (_i2i_entry != entry) {
477 _i2i_entry = entry;
478 }
479 if (_from_interpreted_entry != entry) {
480 _from_interpreted_entry = entry;
481 }
482 }
483
484 // native function (used for native methods only)
485 enum {
486 native_bind_event_is_interesting = true
487 };
488 address native_function() const { return *(native_function_addr()); }
489 address critical_native_function();
490
491 // Must specify a real function (not NULL).
492 // Use clear_native_function() to unregister.
493 void set_native_function(address function, bool post_event_flag);
494 bool has_native_function() const;
495 void clear_native_function();
496
497 // signature handler (used for native methods only)
498 address signature_handler() const { return *(signature_handler_addr()); }
499 void set_signature_handler(address handler);
500
501 // Interpreter oopmap support
502 void mask_for(int bci, InterpreterOopMap* mask);
|