76
77 int size = Method::size(access_flags.is_native());
78
79 return new (loader_data, size, false, MetaspaceObj::MethodType, THREAD) Method(cm, access_flags, size);
80 }
81
82 Method::Method(ConstMethod* xconst, AccessFlags access_flags, int size) {
83 No_Safepoint_Verifier no_safepoint;
84 set_constMethod(xconst);
85 set_access_flags(access_flags);
86 set_method_size(size);
87 #ifdef CC_INTERP
88 set_result_index(T_VOID);
89 #endif
90 set_intrinsic_id(vmIntrinsics::_none);
91 set_jfr_towrite(false);
92 set_force_inline(false);
93 set_hidden(false);
94 set_dont_inline(false);
95 set_method_data(NULL);
96 set_method_counters(NULL);
97 set_vtable_index(Method::garbage_vtable_index);
98
99 // Fix and bury in Method*
100 set_interpreter_entry(NULL); // sets i2i entry and from_int
101 set_adapter_entry(NULL);
102 clear_code(); // from_c/from_i get set to c2i/i2i
103
104 if (access_flags.is_native()) {
105 clear_native_function();
106 set_signature_handler(NULL);
107 }
108
109 NOT_PRODUCT(set_compiled_invocation_count(0);)
110 }
111
112 // Release Method*. The nmethod will be gone when we get here because
113 // we've walked the code cache.
114 void Method::deallocate_contents(ClassLoaderData* loader_data) {
115 MetadataFactory::free_metadata(loader_data, constMethod());
116 set_constMethod(NULL);
117 MetadataFactory::free_metadata(loader_data, method_data());
118 set_method_data(NULL);
119 MetadataFactory::free_metadata(loader_data, method_counters());
120 set_method_counters(NULL);
121 // The nmethod will be gone when we get here.
122 if (code() != NULL) _code = NULL;
123 }
124
125 address Method::get_i2c_entry() {
126 assert(_adapter != NULL, "must have");
127 return _adapter->get_i2c_entry();
128 }
129
130 address Method::get_c2i_entry() {
131 assert(_adapter != NULL, "must have");
132 return _adapter->get_c2i_entry();
133 }
134
135 address Method::get_c2i_unverified_entry() {
136 assert(_adapter != NULL, "must have");
137 return _adapter->get_c2i_unverified_entry();
138 }
139
140 char* Method::name_and_sig_as_C_string() const {
371 // MethodData*s from being created.
372 MutexLocker ml(MethodData_lock, THREAD);
373 if (method->method_data() == NULL) {
374 ClassLoaderData* loader_data = method->method_holder()->class_loader_data();
375 MethodData* method_data = MethodData::allocate(loader_data, method, CHECK);
376 method->set_method_data(method_data);
377 if (PrintMethodData && (Verbose || WizardMode)) {
378 ResourceMark rm(THREAD);
379 tty->print("build_interpreter_method_data for ");
380 method->print_name(tty);
381 tty->cr();
382 // At the end of the run, the MDO, full of data, will be dumped.
383 }
384 }
385 }
386
387 MethodCounters* Method::build_method_counters(Method* m, TRAPS) {
388 methodHandle mh(m);
389 ClassLoaderData* loader_data = mh->method_holder()->class_loader_data();
390 MethodCounters* counters = MethodCounters::allocate(loader_data, CHECK_NULL);
391 if (mh->method_counters() == NULL) {
392 mh->set_method_counters(counters);
393 } else {
394 MetadataFactory::free_metadata(loader_data, counters);
395 }
396 return mh->method_counters();
397 }
398
399 void Method::cleanup_inline_caches() {
400 // The current system doesn't use inline caches in the interpreter
401 // => nothing to do (keep this method around for future use)
402 }
403
404
405 int Method::extra_stack_words() {
406 // not an inline function, to avoid a header dependency on Interpreter
407 return extra_stack_entries() * Interpreter::stackElementSize;
408 }
409
410
411 void Method::compute_size_of_parameters(Thread *thread) {
412 ArgumentSizeComputer asc(signature());
413 set_size_of_parameters(asc.size() + (is_static() ? 0 : 1));
835 _code = NULL;
836 _i2i_entry = NULL;
837 _from_interpreted_entry = NULL;
838 if (is_native()) {
839 *native_function_addr() = NULL;
840 set_signature_handler(NULL);
841 }
842 NOT_PRODUCT(set_compiled_invocation_count(0);)
843 _adapter = NULL;
844 _from_compiled_entry = NULL;
845
846 // In case of DumpSharedSpaces, _method_data should always be NULL.
847 //
848 // During runtime (!DumpSharedSpaces), when we are cleaning a
849 // shared class that failed to load, this->link_method() may
850 // have already been called (before an exception happened), so
851 // this->_method_data may not be NULL.
852 assert(!DumpSharedSpaces || _method_data == NULL, "unexpected method data?");
853
854 set_method_data(NULL);
855 set_method_counters(NULL);
856 }
857
858 // Called when the method_holder is getting linked. Setup entrypoints so the method
859 // is ready to be called from interpreter, compiler, and vtables.
860 void Method::link_method(methodHandle h_method, TRAPS) {
861 // If the code cache is full, we may reenter this function for the
862 // leftover methods that weren't linked.
863 if (_i2i_entry != NULL) return;
864
865 assert(_adapter == NULL, "init'd to NULL" );
866 assert( _code == NULL, "nothing compiled yet" );
867
868 // Setup interpreter entrypoint
869 assert(this == h_method(), "wrong h_method()" );
870 address entry = Interpreter::entry_for_method(h_method);
871 assert(entry != NULL, "interpreter entry must be non-null");
872 // Sets both _i2i_entry and _from_interpreted_entry
873 set_interpreter_entry(entry);
874
875 // Don't overwrite already registered native entries.
|
76
77 int size = Method::size(access_flags.is_native());
78
79 return new (loader_data, size, false, MetaspaceObj::MethodType, THREAD) Method(cm, access_flags, size);
80 }
81
82 Method::Method(ConstMethod* xconst, AccessFlags access_flags, int size) {
83 No_Safepoint_Verifier no_safepoint;
84 set_constMethod(xconst);
85 set_access_flags(access_flags);
86 set_method_size(size);
87 #ifdef CC_INTERP
88 set_result_index(T_VOID);
89 #endif
90 set_intrinsic_id(vmIntrinsics::_none);
91 set_jfr_towrite(false);
92 set_force_inline(false);
93 set_hidden(false);
94 set_dont_inline(false);
95 set_method_data(NULL);
96 clear_method_counters();
97 set_vtable_index(Method::garbage_vtable_index);
98
99 // Fix and bury in Method*
100 set_interpreter_entry(NULL); // sets i2i entry and from_int
101 set_adapter_entry(NULL);
102 clear_code(); // from_c/from_i get set to c2i/i2i
103
104 if (access_flags.is_native()) {
105 clear_native_function();
106 set_signature_handler(NULL);
107 }
108
109 NOT_PRODUCT(set_compiled_invocation_count(0);)
110 }
111
112 // Release Method*. The nmethod will be gone when we get here because
113 // we've walked the code cache.
114 void Method::deallocate_contents(ClassLoaderData* loader_data) {
115 MetadataFactory::free_metadata(loader_data, constMethod());
116 set_constMethod(NULL);
117 MetadataFactory::free_metadata(loader_data, method_data());
118 set_method_data(NULL);
119 MetadataFactory::free_metadata(loader_data, method_counters());
120 clear_method_counters();
121 // The nmethod will be gone when we get here.
122 if (code() != NULL) _code = NULL;
123 }
124
125 address Method::get_i2c_entry() {
126 assert(_adapter != NULL, "must have");
127 return _adapter->get_i2c_entry();
128 }
129
130 address Method::get_c2i_entry() {
131 assert(_adapter != NULL, "must have");
132 return _adapter->get_c2i_entry();
133 }
134
135 address Method::get_c2i_unverified_entry() {
136 assert(_adapter != NULL, "must have");
137 return _adapter->get_c2i_unverified_entry();
138 }
139
140 char* Method::name_and_sig_as_C_string() const {
371 // MethodData*s from being created.
372 MutexLocker ml(MethodData_lock, THREAD);
373 if (method->method_data() == NULL) {
374 ClassLoaderData* loader_data = method->method_holder()->class_loader_data();
375 MethodData* method_data = MethodData::allocate(loader_data, method, CHECK);
376 method->set_method_data(method_data);
377 if (PrintMethodData && (Verbose || WizardMode)) {
378 ResourceMark rm(THREAD);
379 tty->print("build_interpreter_method_data for ");
380 method->print_name(tty);
381 tty->cr();
382 // At the end of the run, the MDO, full of data, will be dumped.
383 }
384 }
385 }
386
387 MethodCounters* Method::build_method_counters(Method* m, TRAPS) {
388 methodHandle mh(m);
389 ClassLoaderData* loader_data = mh->method_holder()->class_loader_data();
390 MethodCounters* counters = MethodCounters::allocate(loader_data, CHECK_NULL);
391 if (!mh->init_method_counters(counters)) {
392 MetadataFactory::free_metadata(loader_data, counters);
393 }
394 return mh->method_counters();
395 }
396
397 void Method::cleanup_inline_caches() {
398 // The current system doesn't use inline caches in the interpreter
399 // => nothing to do (keep this method around for future use)
400 }
401
402
403 int Method::extra_stack_words() {
404 // not an inline function, to avoid a header dependency on Interpreter
405 return extra_stack_entries() * Interpreter::stackElementSize;
406 }
407
408
409 void Method::compute_size_of_parameters(Thread *thread) {
410 ArgumentSizeComputer asc(signature());
411 set_size_of_parameters(asc.size() + (is_static() ? 0 : 1));
833 _code = NULL;
834 _i2i_entry = NULL;
835 _from_interpreted_entry = NULL;
836 if (is_native()) {
837 *native_function_addr() = NULL;
838 set_signature_handler(NULL);
839 }
840 NOT_PRODUCT(set_compiled_invocation_count(0);)
841 _adapter = NULL;
842 _from_compiled_entry = NULL;
843
844 // In case of DumpSharedSpaces, _method_data should always be NULL.
845 //
846 // During runtime (!DumpSharedSpaces), when we are cleaning a
847 // shared class that failed to load, this->link_method() may
848 // have already been called (before an exception happened), so
849 // this->_method_data may not be NULL.
850 assert(!DumpSharedSpaces || _method_data == NULL, "unexpected method data?");
851
852 set_method_data(NULL);
853 clear_method_counters();
854 }
855
856 // Called when the method_holder is getting linked. Setup entrypoints so the method
857 // is ready to be called from interpreter, compiler, and vtables.
858 void Method::link_method(methodHandle h_method, TRAPS) {
859 // If the code cache is full, we may reenter this function for the
860 // leftover methods that weren't linked.
861 if (_i2i_entry != NULL) return;
862
863 assert(_adapter == NULL, "init'd to NULL" );
864 assert( _code == NULL, "nothing compiled yet" );
865
866 // Setup interpreter entrypoint
867 assert(this == h_method(), "wrong h_method()" );
868 address entry = Interpreter::entry_for_method(h_method);
869 assert(entry != NULL, "interpreter entry must be non-null");
870 // Sets both _i2i_entry and _from_interpreted_entry
871 set_interpreter_entry(entry);
872
873 // Don't overwrite already registered native entries.
|