2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2015-01-06 19:30:28 -05:00
|
|
|
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "precompiled.hpp"
|
2013-01-23 10:34:29 -05:00
|
|
|
#include "classfile/metadataOnStackMark.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "classfile/systemDictionary.hpp"
|
2015-01-06 19:30:28 -05:00
|
|
|
#include "code/codeCache.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "code/debugInfoRec.hpp"
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "gc/shared/collectedHeap.inline.hpp"
|
|
|
|
#include "gc/shared/gcLocker.hpp"
|
|
|
|
#include "gc/shared/generation.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "interpreter/bytecodeStream.hpp"
|
|
|
|
#include "interpreter/bytecodeTracer.hpp"
|
|
|
|
#include "interpreter/bytecodes.hpp"
|
|
|
|
#include "interpreter/interpreter.hpp"
|
|
|
|
#include "interpreter/oopMapCache.hpp"
|
2013-01-25 15:06:18 -05:00
|
|
|
#include "memory/heapInspection.hpp"
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#include "memory/metadataFactory.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "memory/oopFactory.hpp"
|
2012-10-11 12:25:42 -04:00
|
|
|
#include "oops/constMethod.hpp"
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#include "oops/method.hpp"
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "oops/methodData.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "oops/oop.inline.hpp"
|
2011-01-27 16:11:27 -08:00
|
|
|
#include "oops/symbol.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "prims/jvmtiExport.hpp"
|
2012-07-24 10:51:00 -07:00
|
|
|
#include "prims/methodHandles.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "prims/nativeLookup.hpp"
|
|
|
|
#include "runtime/arguments.hpp"
|
|
|
|
#include "runtime/compilationPolicy.hpp"
|
|
|
|
#include "runtime/frame.inline.hpp"
|
|
|
|
#include "runtime/handles.inline.hpp"
|
2014-04-29 15:17:27 +02:00
|
|
|
#include "runtime/orderAccess.inline.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "runtime/relocator.hpp"
|
|
|
|
#include "runtime/sharedRuntime.hpp"
|
|
|
|
#include "runtime/signature.hpp"
|
2011-06-28 14:23:27 +02:00
|
|
|
#include "utilities/quickSort.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "utilities/xmlstream.hpp"
|
2007-12-01 00:00:00 +00:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Implementation of Method
|
|
|
|
|
|
|
|
Method* Method::allocate(ClassLoaderData* loader_data,
|
2012-10-11 12:25:42 -04:00
|
|
|
int byte_code_size,
|
|
|
|
AccessFlags access_flags,
|
2013-02-11 14:06:22 -05:00
|
|
|
InlineTableSizes* sizes,
|
2012-10-11 12:25:42 -04:00
|
|
|
ConstMethod::MethodType method_type,
|
|
|
|
TRAPS) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
assert(!access_flags.is_native() || byte_code_size == 0,
|
|
|
|
"native methods should not contain byte codes");
|
|
|
|
ConstMethod* cm = ConstMethod::allocate(loader_data,
|
2012-10-11 12:25:42 -04:00
|
|
|
byte_code_size,
|
2013-02-11 14:06:22 -05:00
|
|
|
sizes,
|
2012-10-11 12:25:42 -04:00
|
|
|
method_type,
|
|
|
|
CHECK_NULL);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
int size = Method::size(access_flags.is_native());
|
2015-10-14 08:12:33 -07:00
|
|
|
return new (loader_data, size, false, MetaspaceObj::MethodType, THREAD) Method(cm, access_flags);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2015-10-14 08:12:33 -07:00
|
|
|
Method::Method(ConstMethod* xconst, AccessFlags access_flags) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
No_Safepoint_Verifier no_safepoint;
|
|
|
|
set_constMethod(xconst);
|
|
|
|
set_access_flags(access_flags);
|
|
|
|
#ifdef CC_INTERP
|
|
|
|
set_result_index(T_VOID);
|
|
|
|
#endif
|
|
|
|
set_intrinsic_id(vmIntrinsics::_none);
|
|
|
|
set_jfr_towrite(false);
|
2013-03-13 09:10:35 -04:00
|
|
|
set_force_inline(false);
|
|
|
|
set_hidden(false);
|
|
|
|
set_dont_inline(false);
|
2015-06-11 14:19:40 +03:00
|
|
|
set_has_injected_profile(false);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
set_method_data(NULL);
|
2014-09-17 21:15:03 -07:00
|
|
|
clear_method_counters();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
set_vtable_index(Method::garbage_vtable_index);
|
|
|
|
|
|
|
|
// Fix and bury in Method*
|
|
|
|
set_interpreter_entry(NULL); // sets i2i entry and from_int
|
|
|
|
set_adapter_entry(NULL);
|
|
|
|
clear_code(); // from_c/from_i get set to c2i/i2i
|
|
|
|
|
|
|
|
if (access_flags.is_native()) {
|
|
|
|
clear_native_function();
|
|
|
|
set_signature_handler(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
NOT_PRODUCT(set_compiled_invocation_count(0);)
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Release Method*. The nmethod will be gone when we get here because
|
|
|
|
// we've walked the code cache.
|
|
|
|
void Method::deallocate_contents(ClassLoaderData* loader_data) {
|
|
|
|
MetadataFactory::free_metadata(loader_data, constMethod());
|
|
|
|
set_constMethod(NULL);
|
|
|
|
MetadataFactory::free_metadata(loader_data, method_data());
|
|
|
|
set_method_data(NULL);
|
2013-04-09 17:17:41 -04:00
|
|
|
MetadataFactory::free_metadata(loader_data, method_counters());
|
2014-09-17 21:15:03 -07:00
|
|
|
clear_method_counters();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// The nmethod will be gone when we get here.
|
|
|
|
if (code() != NULL) _code = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
address Method::get_i2c_entry() {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(_adapter != NULL, "must have");
|
|
|
|
return _adapter->get_i2c_entry();
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
address Method::get_c2i_entry() {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(_adapter != NULL, "must have");
|
|
|
|
return _adapter->get_c2i_entry();
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
address Method::get_c2i_unverified_entry() {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(_adapter != NULL, "must have");
|
|
|
|
return _adapter->get_c2i_unverified_entry();
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
char* Method::name_and_sig_as_C_string() const {
|
2012-11-12 16:15:05 -05:00
|
|
|
return name_and_sig_as_C_string(constants()->pool_holder(), name(), signature());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
char* Method::name_and_sig_as_C_string(char* buf, int size) const {
|
2012-11-12 16:15:05 -05:00
|
|
|
return name_and_sig_as_C_string(constants()->pool_holder(), name(), signature(), buf, size);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
char* Method::name_and_sig_as_C_string(Klass* klass, Symbol* method_name, Symbol* signature) {
|
2007-12-01 00:00:00 +00:00
|
|
|
const char* klass_name = klass->external_name();
|
|
|
|
int klass_name_len = (int)strlen(klass_name);
|
|
|
|
int method_name_len = method_name->utf8_length();
|
|
|
|
int len = klass_name_len + 1 + method_name_len + signature->utf8_length();
|
|
|
|
char* dest = NEW_RESOURCE_ARRAY(char, len + 1);
|
|
|
|
strcpy(dest, klass_name);
|
|
|
|
dest[klass_name_len] = '.';
|
|
|
|
strcpy(&dest[klass_name_len + 1], method_name->as_C_string());
|
|
|
|
strcpy(&dest[klass_name_len + 1 + method_name_len], signature->as_C_string());
|
|
|
|
dest[len] = 0;
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
char* Method::name_and_sig_as_C_string(Klass* klass, Symbol* method_name, Symbol* signature, char* buf, int size) {
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* klass_name = klass->name();
|
2007-12-01 00:00:00 +00:00
|
|
|
klass_name->as_klass_external_name(buf, size);
|
|
|
|
int len = (int)strlen(buf);
|
|
|
|
|
|
|
|
if (len < size - 1) {
|
|
|
|
buf[len++] = '.';
|
|
|
|
|
|
|
|
method_name->as_C_string(&(buf[len]), size - len);
|
|
|
|
len = (int)strlen(buf);
|
|
|
|
|
|
|
|
signature->as_C_string(&(buf[len]), size - len);
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2013-01-08 13:01:19 -05:00
|
|
|
int Method::fast_exception_handler_bci_for(methodHandle mh, KlassHandle ex_klass, int throw_bci, TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// exception table holds quadruple entries of the form (beg_bci, end_bci, handler_bci, klass_index)
|
|
|
|
// access exception table
|
2013-01-08 13:01:19 -05:00
|
|
|
ExceptionTable table(mh());
|
2012-06-26 19:08:44 -04:00
|
|
|
int length = table.length();
|
2007-12-01 00:00:00 +00:00
|
|
|
// iterate through all entries sequentially
|
2013-01-08 13:01:19 -05:00
|
|
|
constantPoolHandle pool(THREAD, mh->constants());
|
2012-06-26 19:08:44 -04:00
|
|
|
for (int i = 0; i < length; i ++) {
|
|
|
|
//reacquire the table in case a GC happened
|
2013-01-08 13:01:19 -05:00
|
|
|
ExceptionTable table(mh());
|
2012-06-26 19:08:44 -04:00
|
|
|
int beg_bci = table.start_pc(i);
|
|
|
|
int end_bci = table.end_pc(i);
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(beg_bci <= end_bci, "inconsistent exception table");
|
|
|
|
if (beg_bci <= throw_bci && throw_bci < end_bci) {
|
|
|
|
// exception handler bci range covers throw_bci => investigate further
|
2012-06-26 19:08:44 -04:00
|
|
|
int handler_bci = table.handler_pc(i);
|
|
|
|
int klass_index = table.catch_type_index(i);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (klass_index == 0) {
|
|
|
|
return handler_bci;
|
|
|
|
} else if (ex_klass.is_null()) {
|
|
|
|
return handler_bci;
|
|
|
|
} else {
|
|
|
|
// we know the exception class => get the constraint class
|
|
|
|
// this may require loading of the constraint class; if verification
|
|
|
|
// fails or some other exception occurs, return handler_bci
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* k = pool->klass_at(klass_index, CHECK_(handler_bci));
|
2007-12-01 00:00:00 +00:00
|
|
|
KlassHandle klass = KlassHandle(THREAD, k);
|
|
|
|
assert(klass.not_null(), "klass not loaded");
|
|
|
|
if (ex_klass->is_subtype_of(klass())) {
|
|
|
|
return handler_bci;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::mask_for(int bci, InterpreterOopMap* mask) {
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
Thread* myThread = Thread::current();
|
|
|
|
methodHandle h_this(myThread, this);
|
2015-10-08 12:49:30 -10:00
|
|
|
#if defined(ASSERT) && !INCLUDE_JVMCI
|
2007-12-01 00:00:00 +00:00
|
|
|
bool has_capability = myThread->is_VM_thread() ||
|
|
|
|
myThread->is_ConcurrentGC_thread() ||
|
|
|
|
myThread->is_GC_task_thread();
|
|
|
|
|
|
|
|
if (!has_capability) {
|
|
|
|
if (!VerifyStack && !VerifyLastFrame) {
|
|
|
|
// verify stack calls this outside VM thread
|
|
|
|
warning("oopmap should only be accessed by the "
|
|
|
|
"VM, GC task or CMS threads (or during debugging)");
|
|
|
|
InterpreterOopMap local_mask;
|
2012-11-06 15:09:37 -05:00
|
|
|
method_holder()->mask_for(h_this, bci, &local_mask);
|
2007-12-01 00:00:00 +00:00
|
|
|
local_mask.print();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2012-11-06 15:09:37 -05:00
|
|
|
method_holder()->mask_for(h_this, bci, mask);
|
2007-12-01 00:00:00 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
int Method::bci_from(address bcp) const {
|
2014-07-17 15:45:46 -04:00
|
|
|
if (is_native() && bcp == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
2012-09-17 17:02:10 -07:00
|
|
|
#ifdef ASSERT
|
2015-09-29 11:02:08 +02:00
|
|
|
{
|
|
|
|
ResourceMark rm;
|
|
|
|
assert(is_native() && bcp == code_base() || contains(bcp) || is_error_reported(),
|
|
|
|
"bcp doesn't belong to this method: bcp: " INTPTR_FORMAT ", method: %s",
|
2015-10-09 09:42:33 +02:00
|
|
|
p2i(bcp), name_and_sig_as_C_string());
|
2012-09-17 17:02:10 -07:00
|
|
|
}
|
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
return bcp - code_base();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-17 15:45:46 -04:00
|
|
|
int Method::validate_bci(int bci) const {
|
|
|
|
return (bci == 0 || bci < code_size()) ? bci : -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return bci if it appears to be a valid bcp
|
2007-12-01 00:00:00 +00:00
|
|
|
// Return -1 otherwise.
|
|
|
|
// Used by profiling code, when invalid data is a possibility.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// The caller is responsible for validating the Method* itself.
|
2014-07-17 15:45:46 -04:00
|
|
|
int Method::validate_bci_from_bcp(address bcp) const {
|
2007-12-01 00:00:00 +00:00
|
|
|
// keep bci as -1 if not a valid bci
|
|
|
|
int bci = -1;
|
2014-07-17 15:45:46 -04:00
|
|
|
if (bcp == 0 || bcp == code_base()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// code_size() may return 0 and we allow 0 here
|
|
|
|
// the method may be native
|
|
|
|
bci = 0;
|
2014-07-17 15:45:46 -04:00
|
|
|
} else if (contains(bcp)) {
|
|
|
|
bci = bcp - code_base();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
// Assert that if we have dodged any asserts, bci is negative.
|
|
|
|
assert(bci == -1 || bci == bci_from(bcp_from(bci)), "sane bci if >=0");
|
|
|
|
return bci;
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
address Method::bcp_from(int bci) const {
|
2015-09-29 11:02:08 +02:00
|
|
|
assert((is_native() && bci == 0) || (!is_native() && 0 <= bci && bci < code_size()), "illegal bci: %d", bci);
|
2007-12-01 00:00:00 +00:00
|
|
|
address bcp = code_base() + bci;
|
|
|
|
assert(is_native() && bcp == code_base() || contains(bcp), "bcp doesn't belong to this method");
|
|
|
|
return bcp;
|
|
|
|
}
|
|
|
|
|
2014-07-31 00:50:55 +00:00
|
|
|
address Method::bcp_from(address bcp) const {
|
|
|
|
if (is_native() && bcp == NULL) {
|
|
|
|
return code_base();
|
|
|
|
} else {
|
|
|
|
return bcp;
|
|
|
|
}
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
int Method::size(bool is_native) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// If native, then include pointers for native_function and signature_handler
|
|
|
|
int extra_bytes = (is_native) ? 2*sizeof(address*) : 0;
|
|
|
|
int extra_words = align_size_up(extra_bytes, BytesPerWord) / BytesPerWord;
|
|
|
|
return align_object_size(header_size() + extra_words);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Symbol* Method::klass_name() const {
|
|
|
|
Klass* k = method_holder();
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(k->is_klass(), "must be klass");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
InstanceKlass* ik = (InstanceKlass*) k;
|
2007-12-01 00:00:00 +00:00
|
|
|
return ik->name();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Attempt to return method oop to original state. Clear any pointers
|
|
|
|
// (to objects outside the shared spaces). We won't be able to predict
|
|
|
|
// where they should point in a new JVM. Further initialize some
|
|
|
|
// entries now in order allow them to be write protected later.
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::remove_unshareable_info() {
|
2007-12-01 00:00:00 +00:00
|
|
|
unlink_method();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool Method::was_executed_more_than(int n) {
|
|
|
|
// Invocation counter is reset when the Method* is compiled.
|
2007-12-01 00:00:00 +00:00
|
|
|
// If the method has compiled code we therefore assume it has
|
|
|
|
// be excuted more than n times.
|
|
|
|
if (is_accessor() || is_empty_method() || (code() != NULL)) {
|
|
|
|
// interpreter doesn't bump invocation counter of trivial methods
|
|
|
|
// compiler does not bump invocation counter of compiled methods
|
|
|
|
return true;
|
2010-09-03 17:51:07 -07:00
|
|
|
}
|
2013-04-09 17:17:41 -04:00
|
|
|
else if ((method_counters() != NULL &&
|
|
|
|
method_counters()->invocation_counter()->carry()) ||
|
|
|
|
(method_data() != NULL &&
|
|
|
|
method_data()->invocation_counter()->carry())) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// The carry bit is set when the counter overflows and causes
|
|
|
|
// a compilation to occur. We don't know how many times
|
|
|
|
// the counter has been reset, so we simply assume it has
|
|
|
|
// been executed more than n times.
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return invocation_count() > n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::print_invocation_count() {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (is_static()) tty->print("static ");
|
|
|
|
if (is_final()) tty->print("final ");
|
|
|
|
if (is_synchronized()) tty->print("synchronized ");
|
|
|
|
if (is_native()) tty->print("native ");
|
2014-03-31 10:35:06 +02:00
|
|
|
tty->print("%s::", method_holder()->external_name());
|
2007-12-01 00:00:00 +00:00
|
|
|
name()->print_symbol_on(tty);
|
|
|
|
signature()->print_symbol_on(tty);
|
|
|
|
|
|
|
|
if (WizardMode) {
|
|
|
|
// dump the size of the byte codes
|
|
|
|
tty->print(" {%d}", code_size());
|
|
|
|
}
|
|
|
|
tty->cr();
|
|
|
|
|
|
|
|
tty->print_cr (" interpreter_invocation_count: %8d ", interpreter_invocation_count());
|
|
|
|
tty->print_cr (" invocation_counter: %8d ", invocation_count());
|
|
|
|
tty->print_cr (" backedge_counter: %8d ", backedge_count());
|
2014-03-31 10:35:06 +02:00
|
|
|
#ifndef PRODUCT
|
2007-12-01 00:00:00 +00:00
|
|
|
if (CountCompiledCalls) {
|
|
|
|
tty->print_cr (" compiled_invocation_count: %8d ", compiled_invocation_count());
|
|
|
|
}
|
|
|
|
#endif
|
2014-03-31 10:35:06 +02:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Build a MethodData* object to hold information about this method
|
2007-12-01 00:00:00 +00:00
|
|
|
// collected in the interpreter.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::build_interpreter_method_data(methodHandle method, TRAPS) {
|
2014-10-30 18:38:42 -04:00
|
|
|
// Do not profile the method if metaspace has hit an OOM previously
|
|
|
|
// allocating profiling data. Callers clear pending exception so don't
|
|
|
|
// add one here.
|
|
|
|
if (ClassLoaderDataGraph::has_metaspace_oom()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-12-10 12:13:03 -05:00
|
|
|
// Do not profile method if current thread holds the pending list lock,
|
|
|
|
// which avoids deadlock for acquiring the MethodData_lock.
|
2012-09-07 12:04:16 -04:00
|
|
|
if (InstanceRefKlass::owns_pending_list_lock((JavaThread*)THREAD)) {
|
2010-12-10 12:13:03 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Grab a lock here to prevent multiple
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// MethodData*s from being created.
|
2007-12-01 00:00:00 +00:00
|
|
|
MutexLocker ml(MethodData_lock, THREAD);
|
|
|
|
if (method->method_data() == NULL) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
ClassLoaderData* loader_data = method->method_holder()->class_loader_data();
|
2014-10-30 18:38:42 -04:00
|
|
|
MethodData* method_data = MethodData::allocate(loader_data, method, THREAD);
|
|
|
|
if (HAS_PENDING_EXCEPTION) {
|
|
|
|
CompileBroker::log_metaspace_failure();
|
|
|
|
ClassLoaderDataGraph::set_metaspace_oom(true);
|
|
|
|
return; // return the exception (which is cleared)
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
method->set_method_data(method_data);
|
|
|
|
if (PrintMethodData && (Verbose || WizardMode)) {
|
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
tty->print("build_interpreter_method_data for ");
|
|
|
|
method->print_name(tty);
|
|
|
|
tty->cr();
|
|
|
|
// At the end of the run, the MDO, full of data, will be dumped.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-09 17:17:41 -04:00
|
|
|
MethodCounters* Method::build_method_counters(Method* m, TRAPS) {
|
2014-10-30 18:38:42 -04:00
|
|
|
// Do not profile the method if metaspace has hit an OOM previously
|
|
|
|
if (ClassLoaderDataGraph::has_metaspace_oom()) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-04-09 17:17:41 -04:00
|
|
|
methodHandle mh(m);
|
2015-01-21 10:51:35 +01:00
|
|
|
MethodCounters* counters = MethodCounters::allocate(mh, THREAD);
|
2014-10-30 18:38:42 -04:00
|
|
|
if (HAS_PENDING_EXCEPTION) {
|
|
|
|
CompileBroker::log_metaspace_failure();
|
|
|
|
ClassLoaderDataGraph::set_metaspace_oom(true);
|
|
|
|
return NULL; // return the exception (which is cleared)
|
|
|
|
}
|
2014-09-17 21:15:03 -07:00
|
|
|
if (!mh->init_method_counters(counters)) {
|
2015-01-21 10:51:35 +01:00
|
|
|
MetadataFactory::free_metadata(mh->method_holder()->class_loader_data(), counters);
|
2013-04-09 17:17:41 -04:00
|
|
|
}
|
2015-07-15 12:24:41 -07:00
|
|
|
|
|
|
|
if (LogTouchedMethods) {
|
|
|
|
mh->log_touched(CHECK_NULL);
|
|
|
|
}
|
|
|
|
|
2013-04-09 17:17:41 -04:00
|
|
|
return mh->method_counters();
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::cleanup_inline_caches() {
|
2007-12-01 00:00:00 +00:00
|
|
|
// The current system doesn't use inline caches in the interpreter
|
|
|
|
// => nothing to do (keep this method around for future use)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
int Method::extra_stack_words() {
|
2009-04-08 10:56:49 -07:00
|
|
|
// not an inline function, to avoid a header dependency on Interpreter
|
2010-04-30 08:37:24 -07:00
|
|
|
return extra_stack_entries() * Interpreter::stackElementSize;
|
2009-04-08 10:56:49 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::compute_size_of_parameters(Thread *thread) {
|
2011-01-27 16:11:27 -08:00
|
|
|
ArgumentSizeComputer asc(signature());
|
2007-12-01 00:00:00 +00:00
|
|
|
set_size_of_parameters(asc.size() + (is_static() ? 0 : 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CC_INTERP
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::set_result_index(BasicType type) {
|
2007-12-01 00:00:00 +00:00
|
|
|
_result_index = Interpreter::BasicType_as_index(type);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
BasicType Method::result_type() const {
|
2007-12-01 00:00:00 +00:00
|
|
|
ResultTypeFinder rtf(signature());
|
|
|
|
return rtf.type();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool Method::is_empty_method() const {
|
2007-12-01 00:00:00 +00:00
|
|
|
return code_size() == 1
|
|
|
|
&& *code_base() == Bytecodes::_return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool Method::is_vanilla_constructor() const {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Returns true if this method is a vanilla constructor, i.e. an "<init>" "()V" method
|
|
|
|
// which only calls the superclass vanilla constructor and possibly does stores of
|
|
|
|
// zero constants to local fields:
|
|
|
|
//
|
|
|
|
// aload_0
|
|
|
|
// invokespecial
|
|
|
|
// indexbyte1
|
|
|
|
// indexbyte2
|
|
|
|
//
|
|
|
|
// followed by an (optional) sequence of:
|
|
|
|
//
|
|
|
|
// aload_0
|
|
|
|
// aconst_null / iconst_0 / fconst_0 / dconst_0
|
|
|
|
// putfield
|
|
|
|
// indexbyte1
|
|
|
|
// indexbyte2
|
|
|
|
//
|
|
|
|
// followed by:
|
|
|
|
//
|
|
|
|
// return
|
|
|
|
|
|
|
|
assert(name() == vmSymbols::object_initializer_name(), "Should only be called for default constructors");
|
|
|
|
assert(signature() == vmSymbols::void_method_signature(), "Should only be called for default constructors");
|
|
|
|
int size = code_size();
|
|
|
|
// Check if size match
|
|
|
|
if (size == 0 || size % 5 != 0) return false;
|
|
|
|
address cb = code_base();
|
|
|
|
int last = size - 1;
|
|
|
|
if (cb[0] != Bytecodes::_aload_0 || cb[1] != Bytecodes::_invokespecial || cb[last] != Bytecodes::_return) {
|
|
|
|
// Does not call superclass default constructor
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// Check optional sequence
|
|
|
|
for (int i = 4; i < last; i += 5) {
|
|
|
|
if (cb[i] != Bytecodes::_aload_0) return false;
|
|
|
|
if (!Bytecodes::is_zero_const(Bytecodes::cast(cb[i+1]))) return false;
|
|
|
|
if (cb[i+2] != Bytecodes::_putfield) return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool Method::compute_has_loops_flag() {
|
|
|
|
BytecodeStream bcs(this);
|
2007-12-01 00:00:00 +00:00
|
|
|
Bytecodes::Code bc;
|
|
|
|
|
|
|
|
while ((bc = bcs.next()) >= 0) {
|
|
|
|
switch( bc ) {
|
|
|
|
case Bytecodes::_ifeq:
|
|
|
|
case Bytecodes::_ifnull:
|
|
|
|
case Bytecodes::_iflt:
|
|
|
|
case Bytecodes::_ifle:
|
|
|
|
case Bytecodes::_ifne:
|
|
|
|
case Bytecodes::_ifnonnull:
|
|
|
|
case Bytecodes::_ifgt:
|
|
|
|
case Bytecodes::_ifge:
|
|
|
|
case Bytecodes::_if_icmpeq:
|
|
|
|
case Bytecodes::_if_icmpne:
|
|
|
|
case Bytecodes::_if_icmplt:
|
|
|
|
case Bytecodes::_if_icmpgt:
|
|
|
|
case Bytecodes::_if_icmple:
|
|
|
|
case Bytecodes::_if_icmpge:
|
|
|
|
case Bytecodes::_if_acmpeq:
|
|
|
|
case Bytecodes::_if_acmpne:
|
|
|
|
case Bytecodes::_goto:
|
|
|
|
case Bytecodes::_jsr:
|
|
|
|
if( bcs.dest() < bcs.next_bci() ) _access_flags.set_has_loops();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Bytecodes::_goto_w:
|
|
|
|
case Bytecodes::_jsr_w:
|
|
|
|
if( bcs.dest_w() < bcs.next_bci() ) _access_flags.set_has_loops();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_access_flags.set_loops_flag_init();
|
|
|
|
return _access_flags.has_loops();
|
|
|
|
}
|
|
|
|
|
2013-09-13 22:38:02 -04:00
|
|
|
bool Method::is_final_method(AccessFlags class_access_flags) const {
|
|
|
|
// or "does_not_require_vtable_entry"
|
2013-10-07 12:20:28 -04:00
|
|
|
// default method or overpass can occur, is not final (reuses vtable entry)
|
2013-09-13 22:38:02 -04:00
|
|
|
// private methods get vtable entries for backward class compatibility.
|
2013-10-07 12:20:28 -04:00
|
|
|
if (is_overpass() || is_default_method()) return false;
|
2013-09-13 22:38:02 -04:00
|
|
|
return is_final() || class_access_flags.is_final();
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool Method::is_final_method() const {
|
2013-09-13 22:38:02 -04:00
|
|
|
return is_final_method(method_holder()->access_flags());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2013-10-07 12:20:28 -04:00
|
|
|
bool Method::is_default_method() const {
|
|
|
|
if (method_holder() != NULL &&
|
|
|
|
method_holder()->is_interface() &&
|
|
|
|
!is_abstract()) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-13 22:38:02 -04:00
|
|
|
bool Method::can_be_statically_bound(AccessFlags class_access_flags) const {
|
|
|
|
if (is_final_method(class_access_flags)) return true;
|
|
|
|
#ifdef ASSERT
|
2013-10-07 12:20:28 -04:00
|
|
|
ResourceMark rm;
|
2013-09-13 22:38:02 -04:00
|
|
|
bool is_nonv = (vtable_index() == nonvirtual_vtable_index);
|
2013-10-07 12:20:28 -04:00
|
|
|
if (class_access_flags.is_interface()) {
|
2015-09-29 11:02:08 +02:00
|
|
|
assert(is_nonv == is_static(), "is_nonv=%s", name_and_sig_as_C_string());
|
2013-10-07 12:20:28 -04:00
|
|
|
}
|
2013-09-13 22:38:02 -04:00
|
|
|
#endif
|
|
|
|
assert(valid_vtable_index() || valid_itable_index(), "method must be linked before we ask this question");
|
|
|
|
return vtable_index() == nonvirtual_vtable_index;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool Method::can_be_statically_bound() const {
|
2013-09-13 22:38:02 -04:00
|
|
|
return can_be_statically_bound(method_holder()->access_flags());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool Method::is_accessor() const {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (code_size() != 5) return false;
|
|
|
|
if (size_of_parameters() != 1) return false;
|
2011-01-13 22:15:41 -08:00
|
|
|
if (java_code_at(0) != Bytecodes::_aload_0 ) return false;
|
|
|
|
if (java_code_at(1) != Bytecodes::_getfield) return false;
|
|
|
|
if (java_code_at(4) != Bytecodes::_areturn &&
|
|
|
|
java_code_at(4) != Bytecodes::_ireturn ) return false;
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-11-11 11:05:41 +01:00
|
|
|
bool Method::is_constant_getter() const {
|
|
|
|
int last_index = code_size() - 1;
|
|
|
|
// Check if the first 1-3 bytecodes are a constant push
|
|
|
|
// and the last bytecode is a return.
|
|
|
|
return (2 <= code_size() && code_size() <= 4 &&
|
|
|
|
Bytecodes::is_const(java_code_at(0)) &&
|
|
|
|
Bytecodes::length_for(java_code_at(0)) == last_index &&
|
|
|
|
Bytecodes::is_return(java_code_at(last_index)));
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool Method::is_initializer() const {
|
2011-03-04 14:40:46 -05:00
|
|
|
return name() == vmSymbols::object_initializer_name() || is_static_initializer();
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool Method::has_valid_initializer_flags() const {
|
2011-03-04 14:40:46 -05:00
|
|
|
return (is_static() ||
|
2012-11-06 15:09:37 -05:00
|
|
|
method_holder()->major_version() < 51);
|
2011-03-04 14:40:46 -05:00
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool Method::is_static_initializer() const {
|
2011-03-04 14:40:46 -05:00
|
|
|
// For classfiles version 51 or greater, ensure that the clinit method is
|
|
|
|
// static. Non-static methods with the name "<clinit>" are not static
|
|
|
|
// initializers. (older classfiles exempted for backward compatibility)
|
|
|
|
return name() == vmSymbols::class_initializer_name() &&
|
|
|
|
has_valid_initializer_flags();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-26 21:47:45 -04:00
|
|
|
objArrayHandle Method::resolved_checked_exceptions_impl(Method* method, TRAPS) {
|
|
|
|
int length = method->checked_exceptions_length();
|
2007-12-01 00:00:00 +00:00
|
|
|
if (length == 0) { // common case
|
|
|
|
return objArrayHandle(THREAD, Universe::the_empty_class_klass_array());
|
|
|
|
} else {
|
2014-03-26 21:47:45 -04:00
|
|
|
methodHandle h_this(THREAD, method);
|
2010-01-06 14:22:39 -08:00
|
|
|
objArrayOop m_oop = oopFactory::new_objArray(SystemDictionary::Class_klass(), length, CHECK_(objArrayHandle()));
|
2007-12-01 00:00:00 +00:00
|
|
|
objArrayHandle mirrors (THREAD, m_oop);
|
|
|
|
for (int i = 0; i < length; i++) {
|
|
|
|
CheckedExceptionElement* table = h_this->checked_exceptions_start(); // recompute on each iteration, not gc safe
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* k = h_this->constants()->klass_at(table[i].class_cp_index, CHECK_(objArrayHandle()));
|
2012-11-12 16:15:05 -05:00
|
|
|
assert(k->is_subclass_of(SystemDictionary::Throwable_klass()), "invalid exception class");
|
|
|
|
mirrors->obj_at_put(i, k->java_mirror());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
return mirrors;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
int Method::line_number_from_bci(int bci) const {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (bci == SynchronizationEntryBCI) bci = 0;
|
|
|
|
assert(bci == 0 || 0 <= bci && bci < code_size(), "illegal bci");
|
|
|
|
int best_bci = 0;
|
|
|
|
int best_line = -1;
|
|
|
|
|
|
|
|
if (has_linenumber_table()) {
|
|
|
|
// The line numbers are a short array of 2-tuples [start_pc, line_number].
|
|
|
|
// Not necessarily sorted and not necessarily one-to-one.
|
|
|
|
CompressedLineNumberReadStream stream(compressed_linenumber_table());
|
|
|
|
while (stream.read_pair()) {
|
|
|
|
if (stream.bci() == bci) {
|
|
|
|
// perfect match
|
|
|
|
return stream.line();
|
|
|
|
} else {
|
|
|
|
// update best_bci/line
|
|
|
|
if (stream.bci() < bci && stream.bci() >= best_bci) {
|
|
|
|
best_bci = stream.bci();
|
|
|
|
best_line = stream.line();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return best_line;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool Method::is_klass_loaded_by_klass_index(int klass_index) const {
|
2012-06-06 14:33:43 -04:00
|
|
|
if( constants()->tag_at(klass_index).is_unresolved_klass() ) {
|
2007-12-01 00:00:00 +00:00
|
|
|
Thread *thread = Thread::current();
|
2012-06-06 14:33:43 -04:00
|
|
|
Symbol* klass_name = constants()->klass_name_at(klass_index);
|
2012-11-06 15:09:37 -05:00
|
|
|
Handle loader(thread, method_holder()->class_loader());
|
2012-11-12 16:15:05 -05:00
|
|
|
Handle prot (thread, method_holder()->protection_domain());
|
2007-12-01 00:00:00 +00:00
|
|
|
return SystemDictionary::find(klass_name, loader, prot, thread) != NULL;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool Method::is_klass_loaded(int refinfo_index, bool must_be_resolved) const {
|
2012-06-06 14:33:43 -04:00
|
|
|
int klass_index = constants()->klass_ref_index_at(refinfo_index);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (must_be_resolved) {
|
|
|
|
// Make sure klass is resolved in constantpool.
|
|
|
|
if (constants()->tag_at(klass_index).is_unresolved_klass()) return false;
|
|
|
|
}
|
|
|
|
return is_klass_loaded_by_klass_index(klass_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::set_native_function(address function, bool post_event_flag) {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(function != NULL, "use clear_native_function to unregister natives");
|
2012-07-24 10:51:00 -07:00
|
|
|
assert(!is_method_handle_intrinsic() || function == SharedRuntime::native_method_throw_unsatisfied_link_error_entry(), "");
|
2007-12-01 00:00:00 +00:00
|
|
|
address* native_function = native_function_addr();
|
|
|
|
|
|
|
|
// We can see racers trying to place the same native function into place. Once
|
|
|
|
// is plenty.
|
|
|
|
address current = *native_function;
|
|
|
|
if (current == function) return;
|
|
|
|
if (post_event_flag && JvmtiExport::should_post_native_method_bind() &&
|
|
|
|
function != NULL) {
|
|
|
|
// native_method_throw_unsatisfied_link_error_entry() should only
|
|
|
|
// be passed when post_event_flag is false.
|
|
|
|
assert(function !=
|
|
|
|
SharedRuntime::native_method_throw_unsatisfied_link_error_entry(),
|
|
|
|
"post_event_flag mis-match");
|
|
|
|
|
|
|
|
// post the bind event, and possible change the bind function
|
|
|
|
JvmtiExport::post_native_method_bind(this, &function);
|
|
|
|
}
|
|
|
|
*native_function = function;
|
|
|
|
// This function can be called more than once. We must make sure that we always
|
|
|
|
// use the latest registered method -> check if a stub already has been generated.
|
|
|
|
// If so, we have to make it not_entrant.
|
|
|
|
nmethod* nm = code(); // Put it into local variable to guard against concurrent updates
|
|
|
|
if (nm != NULL) {
|
|
|
|
nm->make_not_entrant();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool Method::has_native_function() const {
|
2012-07-27 16:14:15 -07:00
|
|
|
if (is_method_handle_intrinsic())
|
|
|
|
return false; // special-cased in SharedRuntime::generate_native_wrapper
|
2007-12-01 00:00:00 +00:00
|
|
|
address func = native_function();
|
|
|
|
return (func != NULL && func != SharedRuntime::native_method_throw_unsatisfied_link_error_entry());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::clear_native_function() {
|
2012-07-24 10:51:00 -07:00
|
|
|
// Note: is_method_handle_intrinsic() is allowed here.
|
2007-12-01 00:00:00 +00:00
|
|
|
set_native_function(
|
|
|
|
SharedRuntime::native_method_throw_unsatisfied_link_error_entry(),
|
|
|
|
!native_bind_event_is_interesting);
|
|
|
|
clear_code();
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
address Method::critical_native_function() {
|
2012-02-01 16:57:08 -08:00
|
|
|
methodHandle mh(this);
|
|
|
|
return NativeLookup::lookup_critical_entry(mh);
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::set_signature_handler(address handler) {
|
2007-12-01 00:00:00 +00:00
|
|
|
address* signature_handler = signature_handler_addr();
|
|
|
|
*signature_handler = handler;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-05 08:25:51 -08:00
|
|
|
void Method::print_made_not_compilable(int comp_level, bool is_osr, bool report, const char* reason) {
|
2010-02-03 15:03:22 -08:00
|
|
|
if (PrintCompilation && report) {
|
2010-02-01 16:49:49 -08:00
|
|
|
ttyLocker ttyl;
|
2012-09-24 17:59:24 -07:00
|
|
|
tty->print("made not %scompilable on ", is_osr ? "OSR " : "");
|
|
|
|
if (comp_level == CompLevel_all) {
|
|
|
|
tty->print("all levels ");
|
|
|
|
} else {
|
|
|
|
tty->print("levels ");
|
|
|
|
for (int i = (int)CompLevel_none; i <= comp_level; i++) {
|
|
|
|
tty->print("%d ", i);
|
|
|
|
}
|
|
|
|
}
|
2010-02-01 16:49:49 -08:00
|
|
|
this->print_short_name(tty);
|
|
|
|
int size = this->code_size();
|
2013-02-05 08:25:51 -08:00
|
|
|
if (size > 0) {
|
2010-02-01 16:49:49 -08:00
|
|
|
tty->print(" (%d bytes)", size);
|
2013-02-05 08:25:51 -08:00
|
|
|
}
|
|
|
|
if (reason != NULL) {
|
|
|
|
tty->print(" %s", reason);
|
|
|
|
}
|
2010-02-01 16:49:49 -08:00
|
|
|
tty->cr();
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
if ((TraceDeoptimization || LogCompilation) && (xtty != NULL)) {
|
|
|
|
ttyLocker ttyl;
|
2014-07-14 03:27:21 -07:00
|
|
|
xtty->begin_elem("make_not_compilable thread='" UINTX_FORMAT "' osr='%d' level='%d'",
|
|
|
|
os::current_thread_id(), is_osr, comp_level);
|
2013-02-05 08:25:51 -08:00
|
|
|
if (reason != NULL) {
|
|
|
|
xtty->print(" reason=\'%s\'", reason);
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
xtty->method(this);
|
2007-12-01 00:00:00 +00:00
|
|
|
xtty->stamp();
|
|
|
|
xtty->end_elem();
|
|
|
|
}
|
2012-09-24 17:59:24 -07:00
|
|
|
}
|
|
|
|
|
2013-08-29 22:44:19 +04:00
|
|
|
bool Method::is_always_compilable() const {
|
|
|
|
// Generated adapters must be compiled
|
|
|
|
if (is_method_handle_intrinsic() && is_synthetic()) {
|
|
|
|
assert(!is_not_c1_compilable(), "sanity check");
|
|
|
|
assert(!is_not_c2_compilable(), "sanity check");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-09-24 17:59:24 -07:00
|
|
|
bool Method::is_not_compilable(int comp_level) const {
|
|
|
|
if (number_of_breakpoints() > 0)
|
|
|
|
return true;
|
2013-08-29 22:44:19 +04:00
|
|
|
if (is_always_compilable())
|
|
|
|
return false;
|
2012-09-24 17:59:24 -07:00
|
|
|
if (comp_level == CompLevel_any)
|
|
|
|
return is_not_c1_compilable() || is_not_c2_compilable();
|
|
|
|
if (is_c1_compile(comp_level))
|
|
|
|
return is_not_c1_compilable();
|
|
|
|
if (is_c2_compile(comp_level))
|
|
|
|
return is_not_c2_compilable();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// call this when compiler finds that this method is not compilable
|
2013-02-05 08:25:51 -08:00
|
|
|
void Method::set_not_compilable(int comp_level, bool report, const char* reason) {
|
2013-08-29 22:44:19 +04:00
|
|
|
if (is_always_compilable()) {
|
|
|
|
// Don't mark a method which should be always compilable
|
|
|
|
return;
|
|
|
|
}
|
2013-02-05 08:25:51 -08:00
|
|
|
print_made_not_compilable(comp_level, /*is_osr*/ false, report, reason);
|
2010-09-03 17:51:07 -07:00
|
|
|
if (comp_level == CompLevel_all) {
|
|
|
|
set_not_c1_compilable();
|
|
|
|
set_not_c2_compilable();
|
|
|
|
} else {
|
2012-09-24 17:59:24 -07:00
|
|
|
if (is_c1_compile(comp_level))
|
2010-09-03 17:51:07 -07:00
|
|
|
set_not_c1_compilable();
|
2012-09-24 17:59:24 -07:00
|
|
|
if (is_c2_compile(comp_level))
|
|
|
|
set_not_c2_compilable();
|
|
|
|
}
|
|
|
|
CompilationPolicy::policy()->disable_compilation(this);
|
2013-08-14 23:50:23 +04:00
|
|
|
assert(!CompilationPolicy::can_be_compiled(this, comp_level), "sanity check");
|
2012-09-24 17:59:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Method::is_not_osr_compilable(int comp_level) const {
|
|
|
|
if (is_not_compilable(comp_level))
|
|
|
|
return true;
|
|
|
|
if (comp_level == CompLevel_any)
|
|
|
|
return is_not_c1_osr_compilable() || is_not_c2_osr_compilable();
|
|
|
|
if (is_c1_compile(comp_level))
|
|
|
|
return is_not_c1_osr_compilable();
|
|
|
|
if (is_c2_compile(comp_level))
|
|
|
|
return is_not_c2_osr_compilable();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-02-05 08:25:51 -08:00
|
|
|
void Method::set_not_osr_compilable(int comp_level, bool report, const char* reason) {
|
|
|
|
print_made_not_compilable(comp_level, /*is_osr*/ true, report, reason);
|
2012-09-24 17:59:24 -07:00
|
|
|
if (comp_level == CompLevel_all) {
|
|
|
|
set_not_c1_osr_compilable();
|
|
|
|
set_not_c2_osr_compilable();
|
|
|
|
} else {
|
|
|
|
if (is_c1_compile(comp_level))
|
|
|
|
set_not_c1_osr_compilable();
|
|
|
|
if (is_c2_compile(comp_level))
|
|
|
|
set_not_c2_osr_compilable();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2010-09-03 17:51:07 -07:00
|
|
|
CompilationPolicy::policy()->disable_compilation(this);
|
2013-08-14 23:50:23 +04:00
|
|
|
assert(!CompilationPolicy::can_be_osr_compiled(this, comp_level), "sanity check");
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Revert to using the interpreter and clear out the nmethod
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::clear_code() {
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// this may be NULL if c2i adapters have not been made yet
|
|
|
|
// Only should happen at allocate time.
|
|
|
|
if (_adapter == NULL) {
|
|
|
|
_from_compiled_entry = NULL;
|
|
|
|
} else {
|
|
|
|
_from_compiled_entry = _adapter->get_c2i_entry();
|
|
|
|
}
|
|
|
|
OrderAccess::storestore();
|
|
|
|
_from_interpreted_entry = _i2i_entry;
|
|
|
|
OrderAccess::storestore();
|
|
|
|
_code = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Called by class data sharing to remove any entry points (which are not shared)
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::unlink_method() {
|
2007-12-01 00:00:00 +00:00
|
|
|
_code = NULL;
|
|
|
|
_i2i_entry = NULL;
|
|
|
|
_from_interpreted_entry = NULL;
|
|
|
|
if (is_native()) {
|
|
|
|
*native_function_addr() = NULL;
|
|
|
|
set_signature_handler(NULL);
|
|
|
|
}
|
|
|
|
NOT_PRODUCT(set_compiled_invocation_count(0);)
|
|
|
|
_adapter = NULL;
|
|
|
|
_from_compiled_entry = NULL;
|
2013-03-15 17:24:40 -04:00
|
|
|
|
|
|
|
// In case of DumpSharedSpaces, _method_data should always be NULL.
|
|
|
|
//
|
|
|
|
// During runtime (!DumpSharedSpaces), when we are cleaning a
|
|
|
|
// shared class that failed to load, this->link_method() may
|
|
|
|
// have already been called (before an exception happened), so
|
|
|
|
// this->_method_data may not be NULL.
|
|
|
|
assert(!DumpSharedSpaces || _method_data == NULL, "unexpected method data?");
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
set_method_data(NULL);
|
2014-09-17 21:15:03 -07:00
|
|
|
clear_method_counters();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Called when the method_holder is getting linked. Setup entrypoints so the method
|
|
|
|
// is ready to be called from interpreter, compiler, and vtables.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::link_method(methodHandle h_method, TRAPS) {
|
2011-05-21 15:39:54 -07:00
|
|
|
// If the code cache is full, we may reenter this function for the
|
|
|
|
// leftover methods that weren't linked.
|
|
|
|
if (_i2i_entry != NULL) return;
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(_adapter == NULL, "init'd to NULL" );
|
|
|
|
assert( _code == NULL, "nothing compiled yet" );
|
|
|
|
|
|
|
|
// Setup interpreter entrypoint
|
|
|
|
assert(this == h_method(), "wrong h_method()" );
|
|
|
|
address entry = Interpreter::entry_for_method(h_method);
|
|
|
|
assert(entry != NULL, "interpreter entry must be non-null");
|
|
|
|
// Sets both _i2i_entry and _from_interpreted_entry
|
|
|
|
set_interpreter_entry(entry);
|
2013-05-06 13:53:13 -07:00
|
|
|
|
|
|
|
// Don't overwrite already registered native entries.
|
|
|
|
if (is_native() && !has_native_function()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
set_native_function(
|
|
|
|
SharedRuntime::native_method_throw_unsatisfied_link_error_entry(),
|
|
|
|
!native_bind_event_is_interesting);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Setup compiler entrypoint. This is made eagerly, so we do not need
|
|
|
|
// special handling of vtables. An alternative is to make adapters more
|
|
|
|
// lazily by calling make_adapter() from from_compiled_entry() for the
|
|
|
|
// normal calls. For vtable calls life gets more complicated. When a
|
|
|
|
// call-site goes mega-morphic we need adapters in all methods which can be
|
|
|
|
// called from the vtable. We need adapters on such methods that get loaded
|
|
|
|
// later. Ditto for mega-morphic itable calls. If this proves to be a
|
|
|
|
// problem we'll make these lazily later.
|
2011-06-02 14:17:48 -04:00
|
|
|
(void) make_adapters(h_method, CHECK);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// ONLY USE the h_method now as make_adapter may have blocked
|
|
|
|
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
address Method::make_adapters(methodHandle mh, TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Adapters for compiled code are made eagerly here. They are fairly
|
|
|
|
// small (generally < 100 bytes) and quick to make (and cached and shared)
|
|
|
|
// so making them eagerly shouldn't be too expensive.
|
|
|
|
AdapterHandlerEntry* adapter = AdapterHandlerLibrary::get_adapter(mh);
|
|
|
|
if (adapter == NULL ) {
|
2014-12-04 09:52:15 +01:00
|
|
|
THROW_MSG_NULL(vmSymbols::java_lang_VirtualMachineError(), "Out of space in CodeCache for adapters");
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mh->set_adapter_entry(adapter);
|
|
|
|
mh->_from_compiled_entry = adapter->get_c2i_entry();
|
|
|
|
return adapter->get_c2i_entry();
|
|
|
|
}
|
|
|
|
|
2014-04-08 13:58:38 -04:00
|
|
|
void Method::restore_unshareable_info(TRAPS) {
|
|
|
|
// Since restore_unshareable_info can be called more than once for a method, don't
|
|
|
|
// redo any work. If this field is restored, there is nothing to do.
|
|
|
|
if (_from_compiled_entry == NULL) {
|
|
|
|
// restore method's vtable by calling a virtual function
|
|
|
|
restore_vtable();
|
|
|
|
|
|
|
|
methodHandle mh(THREAD, this);
|
|
|
|
link_method(mh, CHECK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// The verified_code_entry() must be called when a invoke is resolved
|
|
|
|
// on this method.
|
|
|
|
|
|
|
|
// It returns the compiled code entry point, after asserting not null.
|
|
|
|
// This function is called after potential safepoints so that nmethod
|
|
|
|
// or adapter that it points to is still live and valid.
|
|
|
|
// This function must not hit a safepoint!
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
address Method::verified_code_entry() {
|
2007-12-01 00:00:00 +00:00
|
|
|
debug_only(No_Safepoint_Verifier nsv;)
|
|
|
|
assert(_from_compiled_entry != NULL, "must be set");
|
|
|
|
return _from_compiled_entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check that if an nmethod ref exists, it has a backlink to this or no backlink at all
|
|
|
|
// (could be racing a deopt).
|
|
|
|
// Not inline to avoid circular ref.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool Method::check_code() const {
|
2007-12-01 00:00:00 +00:00
|
|
|
// cached in a register or local. There's a race on the value of the field.
|
|
|
|
nmethod *code = (nmethod *)OrderAccess::load_ptr_acquire(&_code);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
return code == NULL || (code->method() == NULL) || (code->method() == (Method*)this && !code->is_osr_method());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Install compiled code. Instantly it can execute.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::set_code(methodHandle mh, nmethod *code) {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert( code, "use clear_code to remove code" );
|
|
|
|
assert( mh->check_code(), "" );
|
|
|
|
|
|
|
|
guarantee(mh->adapter() != NULL, "Adapter blob must already exist!");
|
|
|
|
|
|
|
|
// These writes must happen in this order, because the interpreter will
|
|
|
|
// directly jump to from_interpreted_entry which jumps to an i2c adapter
|
|
|
|
// which jumps to _from_compiled_entry.
|
|
|
|
mh->_code = code; // Assign before allowing compiled code to exec
|
|
|
|
|
|
|
|
int comp_level = code->comp_level();
|
|
|
|
// In theory there could be a race here. In practice it is unlikely
|
|
|
|
// and not worth worrying about.
|
2010-09-03 17:51:07 -07:00
|
|
|
if (comp_level > mh->highest_comp_level()) {
|
|
|
|
mh->set_highest_comp_level(comp_level);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
OrderAccess::storestore();
|
2010-08-11 05:51:21 -07:00
|
|
|
#ifdef SHARK
|
2010-10-08 02:42:17 -07:00
|
|
|
mh->_from_interpreted_entry = code->insts_begin();
|
2012-07-24 10:51:00 -07:00
|
|
|
#else //!SHARK
|
2007-12-01 00:00:00 +00:00
|
|
|
mh->_from_compiled_entry = code->verified_entry_point();
|
|
|
|
OrderAccess::storestore();
|
|
|
|
// Instantly compiled code can execute.
|
2012-07-24 10:51:00 -07:00
|
|
|
if (!mh->is_method_handle_intrinsic())
|
|
|
|
mh->_from_interpreted_entry = mh->get_i2c_entry();
|
|
|
|
#endif //!SHARK
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool Method::is_overridden_in(Klass* k) const {
|
|
|
|
InstanceKlass* ik = InstanceKlass::cast(k);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (ik->is_interface()) return false;
|
|
|
|
|
|
|
|
// If method is an interface, we skip it - except if it
|
|
|
|
// is a miranda method
|
2012-11-06 15:09:37 -05:00
|
|
|
if (method_holder()->is_interface()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Check that method is not a miranda method
|
|
|
|
if (ik->lookup_method(name(), signature()) == NULL) {
|
|
|
|
// No implementation exist - so miranda method
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(ik->is_subclass_of(method_holder()), "should be subklass");
|
|
|
|
assert(ik->vtable() != NULL, "vtable should exist");
|
2013-09-13 22:38:02 -04:00
|
|
|
if (!has_vtable_index()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return false;
|
|
|
|
} else {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Method* vt_m = ik->method_at_vtable(vtable_index());
|
|
|
|
return vt_m != this;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// give advice about whether this Method* should be cached or not
|
|
|
|
bool Method::should_not_be_cached() const {
|
2008-03-12 18:07:46 -07:00
|
|
|
if (is_old()) {
|
|
|
|
// This method has been redefined. It is either EMCP or obsolete
|
|
|
|
// and we don't want to cache it because that would pin the method
|
|
|
|
// down and prevent it from being collectible if and when it
|
|
|
|
// finishes executing.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// caching this method should be just fine
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-03-25 17:13:26 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if this is one of the specially treated methods for
|
|
|
|
* security related stack walks (like Reflection.getCallerClass).
|
|
|
|
*/
|
|
|
|
bool Method::is_ignored_by_security_stack_walk() const {
|
|
|
|
if (intrinsic_id() == vmIntrinsics::_invoke) {
|
|
|
|
// This is Method.invoke() -- ignore it
|
|
|
|
return true;
|
|
|
|
}
|
2014-06-11 09:58:23 -04:00
|
|
|
if (method_holder()->is_subclass_of(SystemDictionary::reflect_MethodAccessorImpl_klass())) {
|
2013-03-25 17:13:26 -07:00
|
|
|
// This is an auxilary frame -- ignore it
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (is_method_handle_intrinsic() || is_compiled_lambda_form()) {
|
|
|
|
// This is an internal adapter frame for method handles -- ignore it
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-08 10:56:49 -07:00
|
|
|
// Constant pool structure for invoke methods:
|
|
|
|
enum {
|
2012-07-24 10:51:00 -07:00
|
|
|
_imcp_invoke_name = 1, // utf8: 'invokeExact', etc.
|
2011-01-27 16:11:27 -08:00
|
|
|
_imcp_invoke_signature, // utf8: (variable Symbol*)
|
2009-04-08 10:56:49 -07:00
|
|
|
_imcp_limit
|
|
|
|
};
|
|
|
|
|
2012-07-24 10:51:00 -07:00
|
|
|
// Test if this method is an MH adapter frame generated by Java code.
|
|
|
|
// Cf. java/lang/invoke/InvokerBytecodeGenerator
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool Method::is_compiled_lambda_form() const {
|
2012-07-24 10:51:00 -07:00
|
|
|
return intrinsic_id() == vmIntrinsics::_compiledLambdaForm;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test if this method is an internal MH primitive method.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool Method::is_method_handle_intrinsic() const {
|
2012-07-24 10:51:00 -07:00
|
|
|
vmIntrinsics::ID iid = intrinsic_id();
|
|
|
|
return (MethodHandles::is_signature_polymorphic(iid) &&
|
|
|
|
MethodHandles::is_signature_polymorphic_intrinsic(iid));
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool Method::has_member_arg() const {
|
2012-07-24 10:51:00 -07:00
|
|
|
vmIntrinsics::ID iid = intrinsic_id();
|
|
|
|
return (MethodHandles::is_signature_polymorphic(iid) &&
|
|
|
|
MethodHandles::has_member_arg(iid));
|
2010-01-08 11:09:46 +01:00
|
|
|
}
|
|
|
|
|
2012-07-24 10:51:00 -07:00
|
|
|
// Make an instance of a signature-polymorphic internal MH primitive.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
methodHandle Method::make_method_handle_intrinsic(vmIntrinsics::ID iid,
|
2012-07-24 10:51:00 -07:00
|
|
|
Symbol* signature,
|
|
|
|
TRAPS) {
|
2011-08-25 20:29:30 -07:00
|
|
|
ResourceMark rm;
|
2009-04-08 10:56:49 -07:00
|
|
|
methodHandle empty;
|
|
|
|
|
2012-07-24 10:51:00 -07:00
|
|
|
KlassHandle holder = SystemDictionary::MethodHandle_klass();
|
|
|
|
Symbol* name = MethodHandles::signature_polymorphic_intrinsic_name(iid);
|
|
|
|
assert(iid == MethodHandles::signature_polymorphic_name_id(name), "");
|
2009-04-08 10:56:49 -07:00
|
|
|
if (TraceMethodHandles) {
|
2012-07-24 10:51:00 -07:00
|
|
|
tty->print_cr("make_method_handle_intrinsic MH.%s%s", name->as_C_string(), signature->as_C_string());
|
2009-04-08 10:56:49 -07:00
|
|
|
}
|
|
|
|
|
2011-04-09 22:55:25 -07:00
|
|
|
// invariant: cp->symbol_at_put is preceded by a refcount increment (more usually a lookup)
|
|
|
|
name->increment_refcount();
|
|
|
|
signature->increment_refcount();
|
|
|
|
|
2012-07-24 10:51:00 -07:00
|
|
|
int cp_length = _imcp_limit;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
ClassLoaderData* loader_data = holder->class_loader_data();
|
2009-04-08 10:56:49 -07:00
|
|
|
constantPoolHandle cp;
|
|
|
|
{
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
ConstantPool* cp_oop = ConstantPool::allocate(loader_data, cp_length, CHECK_(empty));
|
2009-04-08 10:56:49 -07:00
|
|
|
cp = constantPoolHandle(THREAD, cp_oop);
|
|
|
|
}
|
2012-11-06 15:09:37 -05:00
|
|
|
cp->set_pool_holder(InstanceKlass::cast(holder()));
|
2011-01-27 16:11:27 -08:00
|
|
|
cp->symbol_at_put(_imcp_invoke_name, name);
|
|
|
|
cp->symbol_at_put(_imcp_invoke_signature, signature);
|
2013-01-23 10:34:29 -05:00
|
|
|
cp->set_has_preresolution();
|
2009-04-08 10:56:49 -07:00
|
|
|
|
2012-07-24 10:51:00 -07:00
|
|
|
// decide on access bits: public or not?
|
|
|
|
int flags_bits = (JVM_ACC_NATIVE | JVM_ACC_SYNTHETIC | JVM_ACC_FINAL);
|
|
|
|
bool must_be_static = MethodHandles::is_signature_polymorphic_static(iid);
|
|
|
|
if (must_be_static) flags_bits |= JVM_ACC_STATIC;
|
|
|
|
assert((flags_bits & JVM_ACC_PUBLIC) == 0, "do not expose these methods");
|
|
|
|
|
2009-04-08 10:56:49 -07:00
|
|
|
methodHandle m;
|
|
|
|
{
|
2013-02-11 14:06:22 -05:00
|
|
|
InlineTableSizes sizes;
|
2013-01-08 14:01:36 -05:00
|
|
|
Method* m_oop = Method::allocate(loader_data, 0,
|
2013-02-11 14:06:22 -05:00
|
|
|
accessFlags_from(flags_bits), &sizes,
|
2013-01-08 14:01:36 -05:00
|
|
|
ConstMethod::NORMAL, CHECK_(empty));
|
2009-04-08 10:56:49 -07:00
|
|
|
m = methodHandle(THREAD, m_oop);
|
|
|
|
}
|
|
|
|
m->set_constants(cp());
|
|
|
|
m->set_name_index(_imcp_invoke_name);
|
|
|
|
m->set_signature_index(_imcp_invoke_signature);
|
2012-07-24 10:51:00 -07:00
|
|
|
assert(MethodHandles::is_signature_polymorphic_name(m->name()), "");
|
2011-01-27 16:11:27 -08:00
|
|
|
assert(m->signature() == signature, "");
|
2009-04-08 10:56:49 -07:00
|
|
|
#ifdef CC_INTERP
|
2011-02-11 03:17:53 -08:00
|
|
|
ResultTypeFinder rtf(signature);
|
2009-04-08 10:56:49 -07:00
|
|
|
m->set_result_index(rtf.type());
|
|
|
|
#endif
|
|
|
|
m->compute_size_of_parameters(THREAD);
|
2010-09-13 23:24:30 -07:00
|
|
|
m->init_intrinsic_id();
|
2012-07-24 10:51:00 -07:00
|
|
|
assert(m->is_method_handle_intrinsic(), "");
|
|
|
|
#ifdef ASSERT
|
|
|
|
if (!MethodHandles::is_signature_polymorphic(m->intrinsic_id())) m->print();
|
|
|
|
assert(MethodHandles::is_signature_polymorphic(m->intrinsic_id()), "must be an invoker");
|
|
|
|
assert(m->intrinsic_id() == iid, "correctly predicted iid");
|
|
|
|
#endif //ASSERT
|
2009-04-08 10:56:49 -07:00
|
|
|
|
|
|
|
// Finally, set up its entry points.
|
|
|
|
assert(m->can_be_statically_bound(), "");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
m->set_vtable_index(Method::nonvirtual_vtable_index);
|
2009-04-08 10:56:49 -07:00
|
|
|
m->link_method(m, CHECK_(empty));
|
|
|
|
|
2009-10-17 19:51:05 -07:00
|
|
|
if (TraceMethodHandles && (Verbose || WizardMode))
|
2009-04-08 10:56:49 -07:00
|
|
|
m->print_on(tty);
|
|
|
|
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* Method::check_non_bcp_klass(Klass* klass) {
|
2012-11-12 16:15:05 -05:00
|
|
|
if (klass != NULL && klass->class_loader() != NULL) {
|
|
|
|
if (klass->oop_is_objArray())
|
2012-09-29 06:40:00 -04:00
|
|
|
klass = ObjArrayKlass::cast(klass)->bottom_klass();
|
2011-06-23 17:14:06 -07:00
|
|
|
return klass;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-04-08 10:56:49 -07:00
|
|
|
|
2008-03-12 18:07:46 -07:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
methodHandle Method::clone_with_new_data(methodHandle m, u_char* new_code, int new_code_length,
|
2007-12-01 00:00:00 +00:00
|
|
|
u_char* new_compressed_linenumber_table, int new_compressed_linenumber_size, TRAPS) {
|
|
|
|
// Code below does not work for native methods - they should never get rewritten anyway
|
|
|
|
assert(!m->is_native(), "cannot rewrite native methods");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Allocate new Method*
|
2007-12-01 00:00:00 +00:00
|
|
|
AccessFlags flags = m->access_flags();
|
2013-02-11 14:06:22 -05:00
|
|
|
|
|
|
|
ConstMethod* cm = m->constMethod();
|
|
|
|
int checked_exceptions_len = cm->checked_exceptions_length();
|
|
|
|
int localvariable_len = cm->localvariable_table_length();
|
|
|
|
int exception_table_len = cm->exception_table_length();
|
|
|
|
int method_parameters_len = cm->method_parameters_length();
|
|
|
|
int method_annotations_len = cm->method_annotations_length();
|
|
|
|
int parameter_annotations_len = cm->parameter_annotations_length();
|
|
|
|
int type_annotations_len = cm->type_annotations_length();
|
|
|
|
int default_annotations_len = cm->default_annotations_length();
|
|
|
|
|
|
|
|
InlineTableSizes sizes(
|
|
|
|
localvariable_len,
|
|
|
|
new_compressed_linenumber_size,
|
|
|
|
exception_table_len,
|
|
|
|
checked_exceptions_len,
|
|
|
|
method_parameters_len,
|
|
|
|
cm->generic_signature_index(),
|
|
|
|
method_annotations_len,
|
|
|
|
parameter_annotations_len,
|
|
|
|
type_annotations_len,
|
|
|
|
default_annotations_len,
|
|
|
|
0);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2012-10-11 12:25:42 -04:00
|
|
|
ClassLoaderData* loader_data = m->method_holder()->class_loader_data();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Method* newm_oop = Method::allocate(loader_data,
|
2012-10-11 12:25:42 -04:00
|
|
|
new_code_length,
|
|
|
|
flags,
|
2013-02-11 14:06:22 -05:00
|
|
|
&sizes,
|
2012-10-11 12:25:42 -04:00
|
|
|
m->method_type(),
|
|
|
|
CHECK_(methodHandle()));
|
2007-12-01 00:00:00 +00:00
|
|
|
methodHandle newm (THREAD, newm_oop);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// Create a shallow copy of Method part, but be careful to preserve the new ConstMethod*
|
|
|
|
ConstMethod* newcm = newm->constMethod();
|
|
|
|
int new_const_method_size = newm->constMethod()->size();
|
|
|
|
|
|
|
|
memcpy(newm(), m(), sizeof(Method));
|
|
|
|
|
|
|
|
// Create shallow copy of ConstMethod.
|
|
|
|
memcpy(newcm, m->constMethod(), sizeof(ConstMethod));
|
2011-02-07 22:19:57 -08:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Reset correct method/const method, method size, and parameter info
|
|
|
|
newm->set_constMethod(newcm);
|
|
|
|
newm->constMethod()->set_code_size(new_code_length);
|
|
|
|
newm->constMethod()->set_constMethod_size(new_const_method_size);
|
|
|
|
assert(newm->code_size() == new_code_length, "check");
|
2013-07-22 17:57:42 -04:00
|
|
|
assert(newm->method_parameters_length() == method_parameters_len, "check");
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(newm->checked_exceptions_length() == checked_exceptions_len, "check");
|
2012-07-05 20:54:45 -04:00
|
|
|
assert(newm->exception_table_length() == exception_table_len, "check");
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(newm->localvariable_table_length() == localvariable_len, "check");
|
|
|
|
// Copy new byte codes
|
|
|
|
memcpy(newm->code_base(), new_code, new_code_length);
|
|
|
|
// Copy line number table
|
|
|
|
if (new_compressed_linenumber_size > 0) {
|
|
|
|
memcpy(newm->compressed_linenumber_table(),
|
|
|
|
new_compressed_linenumber_table,
|
|
|
|
new_compressed_linenumber_size);
|
|
|
|
}
|
2013-07-22 17:57:42 -04:00
|
|
|
// Copy method_parameters
|
|
|
|
if (method_parameters_len > 0) {
|
|
|
|
memcpy(newm->method_parameters_start(),
|
|
|
|
m->method_parameters_start(),
|
|
|
|
method_parameters_len * sizeof(MethodParametersElement));
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
// Copy checked_exceptions
|
|
|
|
if (checked_exceptions_len > 0) {
|
|
|
|
memcpy(newm->checked_exceptions_start(),
|
|
|
|
m->checked_exceptions_start(),
|
|
|
|
checked_exceptions_len * sizeof(CheckedExceptionElement));
|
|
|
|
}
|
2012-07-05 20:54:45 -04:00
|
|
|
// Copy exception table
|
|
|
|
if (exception_table_len > 0) {
|
|
|
|
memcpy(newm->exception_table_start(),
|
|
|
|
m->exception_table_start(),
|
|
|
|
exception_table_len * sizeof(ExceptionTableElement));
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
// Copy local variable number table
|
|
|
|
if (localvariable_len > 0) {
|
|
|
|
memcpy(newm->localvariable_table_start(),
|
|
|
|
m->localvariable_table_start(),
|
|
|
|
localvariable_len * sizeof(LocalVariableTableElement));
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Copy stackmap table
|
|
|
|
if (m->has_stackmap_table()) {
|
|
|
|
int code_attribute_length = m->stackmap_data()->length();
|
|
|
|
Array<u1>* stackmap_data =
|
|
|
|
MetadataFactory::new_array<u1>(loader_data, code_attribute_length, 0, CHECK_NULL);
|
|
|
|
memcpy((void*)stackmap_data->adr_at(0),
|
|
|
|
(void*)m->stackmap_data()->adr_at(0), code_attribute_length);
|
|
|
|
newm->set_stackmap_data(stackmap_data);
|
|
|
|
}
|
2009-01-11 16:58:24 -08:00
|
|
|
|
2013-03-27 08:19:50 -04:00
|
|
|
// copy annotations over to new method
|
|
|
|
newcm->copy_annotations_from(cm);
|
2007-12-01 00:00:00 +00:00
|
|
|
return newm;
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
vmSymbols::SID Method::klass_id_for_intrinsics(Klass* holder) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// if loader is not the default loader (i.e., != NULL), we can't know the intrinsics
|
|
|
|
// because we are not loading from core libraries
|
2012-10-24 14:33:22 -07:00
|
|
|
// exception: the AES intrinsics come from lib/ext/sunjce_provider.jar
|
|
|
|
// which does not use the class default class loader so we check for its loader here
|
2013-03-25 17:13:26 -07:00
|
|
|
InstanceKlass* ik = InstanceKlass::cast(holder);
|
|
|
|
if ((ik->class_loader() != NULL) && !SystemDictionary::is_ext_class_loader(ik->class_loader())) {
|
2009-07-21 16:56:06 -07:00
|
|
|
return vmSymbols::NO_SID; // regardless of name, no intrinsics here
|
2012-10-24 14:33:22 -07:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// see if the klass name is well-known:
|
2013-03-25 17:13:26 -07:00
|
|
|
Symbol* klass_name = ik->name();
|
2009-07-21 16:56:06 -07:00
|
|
|
return vmSymbols::find_sid(klass_name);
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::init_intrinsic_id() {
|
2009-07-21 16:56:06 -07:00
|
|
|
assert(_intrinsic_id == vmIntrinsics::_none, "do this just once");
|
|
|
|
const uintptr_t max_id_uint = right_n_bits((int)(sizeof(_intrinsic_id) * BitsPerByte));
|
|
|
|
assert((uintptr_t)vmIntrinsics::ID_LIMIT <= max_id_uint, "else fix size");
|
2010-09-13 23:24:30 -07:00
|
|
|
assert(intrinsic_id_size_in_bytes() == sizeof(_intrinsic_id), "");
|
2009-07-21 16:56:06 -07:00
|
|
|
|
|
|
|
// the klass name is well-known:
|
|
|
|
vmSymbols::SID klass_id = klass_id_for_intrinsics(method_holder());
|
|
|
|
assert(klass_id != vmSymbols::NO_SID, "caller responsibility");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// ditto for method and signature:
|
|
|
|
vmSymbols::SID name_id = vmSymbols::find_sid(name());
|
2012-07-24 10:51:00 -07:00
|
|
|
if (klass_id != vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_MethodHandle)
|
|
|
|
&& name_id == vmSymbols::NO_SID)
|
|
|
|
return;
|
2007-12-01 00:00:00 +00:00
|
|
|
vmSymbols::SID sig_id = vmSymbols::find_sid(signature());
|
2011-03-11 22:34:57 -08:00
|
|
|
if (klass_id != vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_MethodHandle)
|
2010-09-13 23:24:30 -07:00
|
|
|
&& sig_id == vmSymbols::NO_SID) return;
|
2007-12-01 00:00:00 +00:00
|
|
|
jshort flags = access_flags().as_short();
|
|
|
|
|
2009-07-21 16:56:06 -07:00
|
|
|
vmIntrinsics::ID id = vmIntrinsics::find_id(klass_id, name_id, sig_id, flags);
|
|
|
|
if (id != vmIntrinsics::_none) {
|
|
|
|
set_intrinsic_id(id);
|
2014-10-31 16:51:57 -07:00
|
|
|
if (id == vmIntrinsics::_Class_cast) {
|
|
|
|
// Even if the intrinsic is rejected, we want to inline this simple method.
|
|
|
|
set_force_inline(true);
|
|
|
|
}
|
2009-07-21 16:56:06 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// A few slightly irregular cases:
|
|
|
|
switch (klass_id) {
|
|
|
|
case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_StrictMath):
|
|
|
|
// Second chance: check in regular Math.
|
|
|
|
switch (name_id) {
|
|
|
|
case vmSymbols::VM_SYMBOL_ENUM_NAME(min_name):
|
|
|
|
case vmSymbols::VM_SYMBOL_ENUM_NAME(max_name):
|
|
|
|
case vmSymbols::VM_SYMBOL_ENUM_NAME(sqrt_name):
|
|
|
|
// pretend it is the corresponding method in the non-strict class:
|
|
|
|
klass_id = vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_Math);
|
2009-07-21 16:56:06 -07:00
|
|
|
id = vmIntrinsics::find_id(klass_id, name_id, sig_id, flags);
|
2007-12-01 00:00:00 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-05-01 02:42:18 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
// Signature-polymorphic methods: MethodHandle.invoke*, InvokeDynamic.*.
|
2011-03-11 22:34:57 -08:00
|
|
|
case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_MethodHandle):
|
2012-07-24 10:51:00 -07:00
|
|
|
if (!is_native()) break;
|
|
|
|
id = MethodHandles::signature_polymorphic_name_id(method_holder(), name());
|
|
|
|
if (is_static() != MethodHandles::is_signature_polymorphic_static(id))
|
|
|
|
id = vmIntrinsics::_none;
|
2010-05-01 02:42:18 -07:00
|
|
|
break;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2009-07-21 16:56:06 -07:00
|
|
|
if (id != vmIntrinsics::_none) {
|
|
|
|
// Set up its iid. It is an alias method.
|
|
|
|
set_intrinsic_id(id);
|
|
|
|
return;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// These two methods are static since a GC may move the Method
|
|
|
|
bool Method::load_signature_classes(methodHandle m, TRAPS) {
|
2015-10-08 12:49:30 -10:00
|
|
|
if (!THREAD->can_call_java()) {
|
2012-07-24 10:51:00 -07:00
|
|
|
// There is nothing useful this routine can do from within the Compile thread.
|
|
|
|
// Hopefully, the signature contains only well-known classes.
|
|
|
|
// We could scan for this and return true/false, but the caller won't care.
|
|
|
|
return false;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
bool sig_is_loaded = true;
|
2012-11-06 15:09:37 -05:00
|
|
|
Handle class_loader(THREAD, m->method_holder()->class_loader());
|
|
|
|
Handle protection_domain(THREAD, m->method_holder()->protection_domain());
|
2011-01-27 16:11:27 -08:00
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
Symbol* signature = m->signature();
|
2007-12-01 00:00:00 +00:00
|
|
|
for(SignatureStream ss(signature); !ss.is_done(); ss.next()) {
|
|
|
|
if (ss.is_object()) {
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* sym = ss.as_symbol(CHECK_(false));
|
|
|
|
Symbol* name = sym;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* klass = SystemDictionary::resolve_or_null(name, class_loader,
|
2007-12-01 00:00:00 +00:00
|
|
|
protection_domain, THREAD);
|
2008-04-03 13:33:13 -07:00
|
|
|
// We are loading classes eagerly. If a ClassNotFoundException or
|
|
|
|
// a LinkageError was generated, be sure to ignore it.
|
2007-12-01 00:00:00 +00:00
|
|
|
if (HAS_PENDING_EXCEPTION) {
|
2010-01-06 14:22:39 -08:00
|
|
|
if (PENDING_EXCEPTION->is_a(SystemDictionary::ClassNotFoundException_klass()) ||
|
|
|
|
PENDING_EXCEPTION->is_a(SystemDictionary::LinkageError_klass())) {
|
2007-12-01 00:00:00 +00:00
|
|
|
CLEAR_PENDING_EXCEPTION;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( klass == NULL) { sig_is_loaded = false; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sig_is_loaded;
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
bool Method::has_unloaded_classes_in_signature(methodHandle m, TRAPS) {
|
2012-11-06 15:09:37 -05:00
|
|
|
Handle class_loader(THREAD, m->method_holder()->class_loader());
|
|
|
|
Handle protection_domain(THREAD, m->method_holder()->protection_domain());
|
2011-01-27 16:11:27 -08:00
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
Symbol* signature = m->signature();
|
2007-12-01 00:00:00 +00:00
|
|
|
for(SignatureStream ss(signature); !ss.is_done(); ss.next()) {
|
|
|
|
if (ss.type() == T_OBJECT) {
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* name = ss.as_symbol_or_null();
|
|
|
|
if (name == NULL) return true;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* klass = SystemDictionary::find(name, class_loader, protection_domain, THREAD);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (klass == NULL) return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Exposed so field engineers can debug VM
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::print_short_name(outputStream* st) {
|
2007-12-01 00:00:00 +00:00
|
|
|
ResourceMark rm;
|
|
|
|
#ifdef PRODUCT
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
st->print(" %s::", method_holder()->external_name());
|
2007-12-01 00:00:00 +00:00
|
|
|
#else
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
st->print(" %s::", method_holder()->internal_name());
|
2007-12-01 00:00:00 +00:00
|
|
|
#endif
|
|
|
|
name()->print_symbol_on(st);
|
|
|
|
if (WizardMode) signature()->print_symbol_on(st);
|
2012-07-24 10:51:00 -07:00
|
|
|
else if (MethodHandles::is_signature_polymorphic(intrinsic_id()))
|
|
|
|
MethodHandles::print_as_basic_type_signature_on(st, signature(), true);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-28 14:23:27 +02:00
|
|
|
// Comparer for sorting an object array containing
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Method*s.
|
|
|
|
static int method_comparator(Method* a, Method* b) {
|
|
|
|
return a->name()->fast_compare(b->name());
|
2011-09-13 20:28:00 -07:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// This is only done during class loading, so it is OK to assume method_idnum matches the methods() array
|
2013-10-07 12:20:28 -04:00
|
|
|
// default_methods also uses this without the ordering for fast find_method
|
|
|
|
void Method::sort_methods(Array<Method*>* methods, bool idempotent, bool set_idnums) {
|
2007-12-01 00:00:00 +00:00
|
|
|
int length = methods->length();
|
|
|
|
if (length > 1) {
|
2011-06-28 14:23:27 +02:00
|
|
|
{
|
|
|
|
No_Safepoint_Verifier nsv;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
QuickSort::sort<Method*>(methods->data(), length, method_comparator, idempotent);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
// Reset method ordering
|
2013-10-07 12:20:28 -04:00
|
|
|
if (set_idnums) {
|
|
|
|
for (int i = 0; i < length; i++) {
|
|
|
|
Method* m = methods->at(i);
|
|
|
|
m->set_method_idnum(i);
|
2015-02-25 00:30:54 -08:00
|
|
|
m->set_orig_method_idnum(i);
|
2013-10-07 12:20:28 -04:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------------
|
2013-02-06 14:31:37 -08:00
|
|
|
// Non-product code unless JVM/TI needs it
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2013-02-06 14:31:37 -08:00
|
|
|
#if !defined(PRODUCT) || INCLUDE_JVMTI
|
2007-12-01 00:00:00 +00:00
|
|
|
class SignatureTypePrinter : public SignatureTypeNames {
|
|
|
|
private:
|
|
|
|
outputStream* _st;
|
|
|
|
bool _use_separator;
|
|
|
|
|
|
|
|
void type_name(const char* name) {
|
|
|
|
if (_use_separator) _st->print(", ");
|
2014-05-09 16:50:54 -04:00
|
|
|
_st->print("%s", name);
|
2007-12-01 00:00:00 +00:00
|
|
|
_use_separator = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2011-01-27 16:11:27 -08:00
|
|
|
SignatureTypePrinter(Symbol* signature, outputStream* st) : SignatureTypeNames(signature) {
|
2007-12-01 00:00:00 +00:00
|
|
|
_st = st;
|
|
|
|
_use_separator = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void print_parameters() { _use_separator = false; iterate_parameters(); }
|
|
|
|
void print_returntype() { _use_separator = false; iterate_returntype(); }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::print_name(outputStream* st) {
|
2007-12-01 00:00:00 +00:00
|
|
|
Thread *thread = Thread::current();
|
|
|
|
ResourceMark rm(thread);
|
|
|
|
st->print("%s ", is_static() ? "static" : "virtual");
|
2015-10-08 12:49:30 -10:00
|
|
|
if (WizardMode) {
|
|
|
|
st->print("%s.", method_holder()->internal_name());
|
|
|
|
name()->print_symbol_on(st);
|
|
|
|
signature()->print_symbol_on(st);
|
|
|
|
} else {
|
|
|
|
SignatureTypePrinter sig(signature(), st);
|
|
|
|
sig.print_returntype();
|
|
|
|
st->print(" %s.", method_holder()->internal_name());
|
|
|
|
name()->print_symbol_on(st);
|
|
|
|
st->print("(");
|
|
|
|
sig.print_parameters();
|
|
|
|
st->print(")");
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2013-02-06 14:31:37 -08:00
|
|
|
#endif // !PRODUCT || INCLUDE_JVMTI
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::print_codes_on(outputStream* st) const {
|
2007-12-01 00:00:00 +00:00
|
|
|
print_codes_on(0, code_size(), st);
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::print_codes_on(int from, int to, outputStream* st) const {
|
2007-12-01 00:00:00 +00:00
|
|
|
Thread *thread = Thread::current();
|
|
|
|
ResourceMark rm(thread);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
methodHandle mh (thread, (Method*)this);
|
2007-12-01 00:00:00 +00:00
|
|
|
BytecodeStream s(mh);
|
|
|
|
s.set_interval(from, to);
|
|
|
|
BytecodeTracer::set_closure(BytecodeTracer::std_closure());
|
|
|
|
while (s.next() >= 0) BytecodeTracer::trace(mh, s.bcp(), st);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Simple compression of line number tables. We use a regular compressed stream, except that we compress deltas
|
|
|
|
// between (bci,line) pairs since they are smaller. If (bci delta, line delta) fits in (5-bit unsigned, 3-bit unsigned)
|
|
|
|
// we save it as one byte, otherwise we write a 0xFF escape character and use regular compression. 0x0 is used
|
|
|
|
// as end-of-stream terminator.
|
|
|
|
|
|
|
|
void CompressedLineNumberWriteStream::write_pair_regular(int bci_delta, int line_delta) {
|
|
|
|
// bci and line number does not compress into single byte.
|
|
|
|
// Write out escape character and use regular compression for bci and line number.
|
|
|
|
write_byte((jubyte)0xFF);
|
|
|
|
write_signed_int(bci_delta);
|
|
|
|
write_signed_int(line_delta);
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// See comment in method.hpp which explains why this exists.
|
2011-02-10 13:03:22 +01:00
|
|
|
#if defined(_M_AMD64) && _MSC_VER >= 1400
|
2007-12-01 00:00:00 +00:00
|
|
|
#pragma optimize("", off)
|
|
|
|
void CompressedLineNumberWriteStream::write_pair(int bci, int line) {
|
|
|
|
write_pair_inline(bci, line);
|
|
|
|
}
|
|
|
|
#pragma optimize("", on)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
CompressedLineNumberReadStream::CompressedLineNumberReadStream(u_char* buffer) : CompressedReadStream(buffer) {
|
|
|
|
_bci = 0;
|
|
|
|
_line = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
bool CompressedLineNumberReadStream::read_pair() {
|
|
|
|
jubyte next = read_byte();
|
|
|
|
// Check for terminator
|
|
|
|
if (next == 0) return false;
|
|
|
|
if (next == 0xFF) {
|
|
|
|
// Escape character, regular compression used
|
|
|
|
_bci += read_signed_int();
|
|
|
|
_line += read_signed_int();
|
|
|
|
} else {
|
|
|
|
// Single byte compression used
|
|
|
|
_bci += next >> 3;
|
|
|
|
_line += next & 0x7;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Bytecodes::Code Method::orig_bytecode_at(int bci) const {
|
2012-11-06 15:09:37 -05:00
|
|
|
BreakpointInfo* bp = method_holder()->breakpoints();
|
2007-12-01 00:00:00 +00:00
|
|
|
for (; bp != NULL; bp = bp->next()) {
|
|
|
|
if (bp->match(this, bci)) {
|
|
|
|
return bp->orig_bytecode();
|
|
|
|
}
|
|
|
|
}
|
2013-10-24 16:23:07 -07:00
|
|
|
{
|
|
|
|
ResourceMark rm;
|
2015-09-29 11:02:08 +02:00
|
|
|
fatal("no original bytecode found in %s at bci %d", name_and_sig_as_C_string(), bci);
|
2013-10-24 16:23:07 -07:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
return Bytecodes::_shouldnotreachhere;
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::set_orig_bytecode_at(int bci, Bytecodes::Code code) {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(code != Bytecodes::_breakpoint, "cannot patch breakpoints this way");
|
2012-11-06 15:09:37 -05:00
|
|
|
BreakpointInfo* bp = method_holder()->breakpoints();
|
2007-12-01 00:00:00 +00:00
|
|
|
for (; bp != NULL; bp = bp->next()) {
|
|
|
|
if (bp->match(this, bci)) {
|
|
|
|
bp->set_orig_bytecode(code);
|
|
|
|
// and continue, in case there is more than one
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::set_breakpoint(int bci) {
|
2012-11-06 15:09:37 -05:00
|
|
|
InstanceKlass* ik = method_holder();
|
2007-12-01 00:00:00 +00:00
|
|
|
BreakpointInfo *bp = new BreakpointInfo(this, bci);
|
|
|
|
bp->set_next(ik->breakpoints());
|
|
|
|
ik->set_breakpoints(bp);
|
|
|
|
// do this last:
|
|
|
|
bp->set(this);
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
static void clear_matches(Method* m, int bci) {
|
2012-11-06 15:09:37 -05:00
|
|
|
InstanceKlass* ik = m->method_holder();
|
2007-12-01 00:00:00 +00:00
|
|
|
BreakpointInfo* prev_bp = NULL;
|
|
|
|
BreakpointInfo* next_bp;
|
|
|
|
for (BreakpointInfo* bp = ik->breakpoints(); bp != NULL; bp = next_bp) {
|
|
|
|
next_bp = bp->next();
|
|
|
|
// bci value of -1 is used to delete all breakpoints in method m (ex: clear_all_breakpoint).
|
|
|
|
if (bci >= 0 ? bp->match(m, bci) : bp->match(m)) {
|
|
|
|
// do this first:
|
|
|
|
bp->clear(m);
|
|
|
|
// unhook it
|
|
|
|
if (prev_bp != NULL)
|
|
|
|
prev_bp->set_next(next_bp);
|
|
|
|
else
|
|
|
|
ik->set_breakpoints(next_bp);
|
|
|
|
delete bp;
|
|
|
|
// When class is redefined JVMTI sets breakpoint in all versions of EMCP methods
|
|
|
|
// at same location. So we have multiple matching (method_index and bci)
|
|
|
|
// BreakpointInfo nodes in BreakpointInfo list. We should just delete one
|
|
|
|
// breakpoint for clear_breakpoint request and keep all other method versions
|
|
|
|
// BreakpointInfo for future clear_breakpoint request.
|
|
|
|
// bcivalue of -1 is used to clear all breakpoints (see clear_all_breakpoints)
|
|
|
|
// which is being called when class is unloaded. We delete all the Breakpoint
|
|
|
|
// information for all versions of method. We may not correctly restore the original
|
|
|
|
// bytecode in all method versions, but that is ok. Because the class is being unloaded
|
|
|
|
// so these methods won't be used anymore.
|
|
|
|
if (bci >= 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// This one is a keeper.
|
|
|
|
prev_bp = bp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::clear_breakpoint(int bci) {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(bci >= 0, "");
|
|
|
|
clear_matches(this, bci);
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::clear_all_breakpoints() {
|
2007-12-01 00:00:00 +00:00
|
|
|
clear_matches(this, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
int Method::invocation_count() {
|
2013-04-09 17:17:41 -04:00
|
|
|
MethodCounters *mcs = method_counters();
|
2010-09-03 17:51:07 -07:00
|
|
|
if (TieredCompilation) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
MethodData* const mdo = method_data();
|
2013-04-09 17:17:41 -04:00
|
|
|
if (((mcs != NULL) ? mcs->invocation_counter()->carry() : false) ||
|
|
|
|
((mdo != NULL) ? mdo->invocation_counter()->carry() : false)) {
|
2010-09-03 17:51:07 -07:00
|
|
|
return InvocationCounter::count_limit;
|
|
|
|
} else {
|
2013-04-09 17:17:41 -04:00
|
|
|
return ((mcs != NULL) ? mcs->invocation_counter()->count() : 0) +
|
|
|
|
((mdo != NULL) ? mdo->invocation_counter()->count() : 0);
|
2010-09-03 17:51:07 -07:00
|
|
|
}
|
|
|
|
} else {
|
2013-04-09 17:17:41 -04:00
|
|
|
return (mcs == NULL) ? 0 : mcs->invocation_counter()->count();
|
2010-09-03 17:51:07 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
int Method::backedge_count() {
|
2013-04-09 17:17:41 -04:00
|
|
|
MethodCounters *mcs = method_counters();
|
2010-09-03 17:51:07 -07:00
|
|
|
if (TieredCompilation) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
MethodData* const mdo = method_data();
|
2013-04-09 17:17:41 -04:00
|
|
|
if (((mcs != NULL) ? mcs->backedge_counter()->carry() : false) ||
|
|
|
|
((mdo != NULL) ? mdo->backedge_counter()->carry() : false)) {
|
2010-09-03 17:51:07 -07:00
|
|
|
return InvocationCounter::count_limit;
|
|
|
|
} else {
|
2013-04-09 17:17:41 -04:00
|
|
|
return ((mcs != NULL) ? mcs->backedge_counter()->count() : 0) +
|
|
|
|
((mdo != NULL) ? mdo->backedge_counter()->count() : 0);
|
2010-09-03 17:51:07 -07:00
|
|
|
}
|
|
|
|
} else {
|
2013-04-09 17:17:41 -04:00
|
|
|
return (mcs == NULL) ? 0 : mcs->backedge_counter()->count();
|
2010-09-03 17:51:07 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
int Method::highest_comp_level() const {
|
2014-09-11 00:04:50 -07:00
|
|
|
const MethodCounters* mcs = method_counters();
|
|
|
|
if (mcs != NULL) {
|
|
|
|
return mcs->highest_comp_level();
|
2010-09-03 17:51:07 -07:00
|
|
|
} else {
|
|
|
|
return CompLevel_none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
int Method::highest_osr_comp_level() const {
|
2014-09-11 00:04:50 -07:00
|
|
|
const MethodCounters* mcs = method_counters();
|
|
|
|
if (mcs != NULL) {
|
|
|
|
return mcs->highest_osr_comp_level();
|
2010-09-03 17:51:07 -07:00
|
|
|
} else {
|
|
|
|
return CompLevel_none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::set_highest_comp_level(int level) {
|
2014-09-11 00:04:50 -07:00
|
|
|
MethodCounters* mcs = method_counters();
|
|
|
|
if (mcs != NULL) {
|
|
|
|
mcs->set_highest_comp_level(level);
|
2010-09-03 17:51:07 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void Method::set_highest_osr_comp_level(int level) {
|
2014-09-11 00:04:50 -07:00
|
|
|
MethodCounters* mcs = method_counters();
|
|
|
|
if (mcs != NULL) {
|
|
|
|
mcs->set_highest_osr_comp_level(level);
|
2010-09-03 17:51:07 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
BreakpointInfo::BreakpointInfo(Method* m, int bci) {
|
2007-12-01 00:00:00 +00:00
|
|
|
_bci = bci;
|
|
|
|
_name_index = m->name_index();
|
|
|
|
_signature_index = m->signature_index();
|
|
|
|
_orig_bytecode = (Bytecodes::Code) *m->bcp_from(_bci);
|
|
|
|
if (_orig_bytecode == Bytecodes::_breakpoint)
|
|
|
|
_orig_bytecode = m->orig_bytecode_at(_bci);
|
|
|
|
_next = NULL;
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void BreakpointInfo::set(Method* method) {
|
2007-12-01 00:00:00 +00:00
|
|
|
#ifdef ASSERT
|
|
|
|
{
|
|
|
|
Bytecodes::Code code = (Bytecodes::Code) *method->bcp_from(_bci);
|
|
|
|
if (code == Bytecodes::_breakpoint)
|
|
|
|
code = method->orig_bytecode_at(_bci);
|
|
|
|
assert(orig_bytecode() == code, "original bytecode must be the same");
|
|
|
|
}
|
|
|
|
#endif
|
2013-04-09 17:17:41 -04:00
|
|
|
Thread *thread = Thread::current();
|
2007-12-01 00:00:00 +00:00
|
|
|
*method->bcp_from(_bci) = Bytecodes::_breakpoint;
|
2013-04-09 17:17:41 -04:00
|
|
|
method->incr_number_of_breakpoints(thread);
|
2007-12-01 00:00:00 +00:00
|
|
|
SystemDictionary::notice_modification();
|
|
|
|
{
|
|
|
|
// Deoptimize all dependents on this method
|
|
|
|
HandleMark hm(thread);
|
|
|
|
methodHandle mh(thread, method);
|
2015-01-06 19:30:28 -05:00
|
|
|
CodeCache::flush_dependents_on_method(mh);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void BreakpointInfo::clear(Method* method) {
|
2007-12-01 00:00:00 +00:00
|
|
|
*method->bcp_from(_bci) = orig_bytecode();
|
|
|
|
assert(method->number_of_breakpoints() > 0, "must not go negative");
|
2013-04-09 17:17:41 -04:00
|
|
|
method->decr_number_of_breakpoints(Thread::current());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// jmethodID handling
|
|
|
|
|
|
|
|
// This is a block allocating object, sort of like JNIHandleBlock, only a
|
2014-11-05 16:47:37 -08:00
|
|
|
// lot simpler.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// It's allocated on the CHeap because once we allocate a jmethodID, we can
|
|
|
|
// never get rid of it.
|
|
|
|
|
2014-11-05 16:47:37 -08:00
|
|
|
static const int min_block_size = 8;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2014-11-05 16:47:37 -08:00
|
|
|
class JNIMethodBlockNode : public CHeapObj<mtClass> {
|
|
|
|
friend class JNIMethodBlock;
|
|
|
|
Method** _methods;
|
|
|
|
int _number_of_methods;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
int _top;
|
2014-11-05 16:47:37 -08:00
|
|
|
JNIMethodBlockNode* _next;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
JNIMethodBlockNode(int num_methods = min_block_size);
|
|
|
|
|
2014-12-01 12:16:15 -05:00
|
|
|
~JNIMethodBlockNode() { FREE_C_HEAP_ARRAY(Method*, _methods); }
|
2014-11-05 16:47:37 -08:00
|
|
|
|
|
|
|
void ensure_methods(int num_addl_methods) {
|
|
|
|
if (_top < _number_of_methods) {
|
|
|
|
num_addl_methods -= _number_of_methods - _top;
|
|
|
|
if (num_addl_methods <= 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (_next == NULL) {
|
|
|
|
_next = new JNIMethodBlockNode(MAX2(num_addl_methods, min_block_size));
|
|
|
|
} else {
|
|
|
|
_next->ensure_methods(num_addl_methods);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class JNIMethodBlock : public CHeapObj<mtClass> {
|
|
|
|
JNIMethodBlockNode _head;
|
|
|
|
JNIMethodBlockNode *_last_free;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
public:
|
|
|
|
static Method* const _free_method;
|
|
|
|
|
2014-11-05 16:47:37 -08:00
|
|
|
JNIMethodBlock(int initial_capacity = min_block_size)
|
|
|
|
: _head(initial_capacity), _last_free(&_head) {}
|
|
|
|
|
|
|
|
void ensure_methods(int num_addl_methods) {
|
|
|
|
_last_free->ensure_methods(num_addl_methods);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Method** add_method(Method* m) {
|
2014-11-05 16:47:37 -08:00
|
|
|
for (JNIMethodBlockNode* b = _last_free; b != NULL; b = b->_next) {
|
|
|
|
if (b->_top < b->_number_of_methods) {
|
|
|
|
// top points to the next free entry.
|
|
|
|
int i = b->_top;
|
|
|
|
b->_methods[i] = m;
|
|
|
|
b->_top++;
|
|
|
|
_last_free = b;
|
|
|
|
return &(b->_methods[i]);
|
|
|
|
} else if (b->_top == b->_number_of_methods) {
|
|
|
|
// if the next free entry ran off the block see if there's a free entry
|
|
|
|
for (int i = 0; i < b->_number_of_methods; i++) {
|
|
|
|
if (b->_methods[i] == _free_method) {
|
|
|
|
b->_methods[i] = m;
|
|
|
|
_last_free = b;
|
|
|
|
return &(b->_methods[i]);
|
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2014-11-05 16:47:37 -08:00
|
|
|
// Only check each block once for frees. They're very unlikely.
|
|
|
|
// Increment top past the end of the block.
|
|
|
|
b->_top++;
|
|
|
|
}
|
|
|
|
// need to allocate a next block.
|
|
|
|
if (b->_next == NULL) {
|
|
|
|
b->_next = _last_free = new JNIMethodBlockNode();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
}
|
2014-11-05 16:47:37 -08:00
|
|
|
guarantee(false, "Should always allocate a free block");
|
|
|
|
return NULL;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool contains(Method** m) {
|
2014-11-05 16:47:37 -08:00
|
|
|
if (m == NULL) return false;
|
|
|
|
for (JNIMethodBlockNode* b = &_head; b != NULL; b = b->_next) {
|
|
|
|
if (b->_methods <= m && m < b->_methods + b->_number_of_methods) {
|
|
|
|
// This is a bit of extra checking, for two reasons. One is
|
|
|
|
// that contains() deals with pointers that are passed in by
|
|
|
|
// JNI code, so making sure that the pointer is aligned
|
|
|
|
// correctly is valuable. The other is that <= and > are
|
|
|
|
// technically not defined on pointers, so the if guard can
|
|
|
|
// pass spuriously; no modern compiler is likely to make that
|
|
|
|
// a problem, though (and if one did, the guard could also
|
|
|
|
// fail spuriously, which would be bad).
|
|
|
|
ptrdiff_t idx = m - b->_methods;
|
|
|
|
if (b->_methods + idx == m) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false; // not found
|
|
|
|
}
|
|
|
|
|
|
|
|
// Doesn't really destroy it, just marks it as free so it can be reused.
|
|
|
|
void destroy_method(Method** m) {
|
|
|
|
#ifdef ASSERT
|
|
|
|
assert(contains(m), "should be a methodID");
|
|
|
|
#endif // ASSERT
|
|
|
|
*m = _free_method;
|
|
|
|
}
|
|
|
|
|
|
|
|
// During class unloading the methods are cleared, which is different
|
|
|
|
// than freed.
|
|
|
|
void clear_all_methods() {
|
2014-11-05 16:47:37 -08:00
|
|
|
for (JNIMethodBlockNode* b = &_head; b != NULL; b = b->_next) {
|
|
|
|
for (int i = 0; i< b->_number_of_methods; i++) {
|
|
|
|
b->_methods[i] = NULL;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifndef PRODUCT
|
|
|
|
int count_methods() {
|
|
|
|
// count all allocated methods
|
|
|
|
int count = 0;
|
2014-11-05 16:47:37 -08:00
|
|
|
for (JNIMethodBlockNode* b = &_head; b != NULL; b = b->_next) {
|
|
|
|
for (int i = 0; i< b->_number_of_methods; i++) {
|
|
|
|
if (b->_methods[i] != _free_method) count++;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
#endif // PRODUCT
|
|
|
|
};
|
|
|
|
|
|
|
|
// Something that can't be mistaken for an address or a markOop
|
|
|
|
Method* const JNIMethodBlock::_free_method = (Method*)55;
|
|
|
|
|
2014-11-05 16:47:37 -08:00
|
|
|
JNIMethodBlockNode::JNIMethodBlockNode(int num_methods) : _next(NULL), _top(0) {
|
|
|
|
_number_of_methods = MAX2(num_methods, min_block_size);
|
|
|
|
_methods = NEW_C_HEAP_ARRAY(Method*, _number_of_methods, mtInternal);
|
|
|
|
for (int i = 0; i < _number_of_methods; i++) {
|
|
|
|
_methods[i] = JNIMethodBlock::_free_method;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Method::ensure_jmethod_ids(ClassLoaderData* loader_data, int capacity) {
|
|
|
|
ClassLoaderData* cld = loader_data;
|
|
|
|
if (!SafepointSynchronize::is_at_safepoint()) {
|
|
|
|
// Have to add jmethod_ids() to class loader data thread-safely.
|
|
|
|
// Also have to add the method to the list safely, which the cld lock
|
|
|
|
// protects as well.
|
|
|
|
MutexLockerEx ml(cld->metaspace_lock(), Mutex::_no_safepoint_check_flag);
|
|
|
|
if (cld->jmethod_ids() == NULL) {
|
|
|
|
cld->set_jmethod_ids(new JNIMethodBlock(capacity));
|
|
|
|
} else {
|
|
|
|
cld->jmethod_ids()->ensure_methods(capacity);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// At safepoint, we are single threaded and can set this.
|
|
|
|
if (cld->jmethod_ids() == NULL) {
|
|
|
|
cld->set_jmethod_ids(new JNIMethodBlock(capacity));
|
|
|
|
} else {
|
|
|
|
cld->jmethod_ids()->ensure_methods(capacity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Add a method id to the jmethod_ids
|
|
|
|
jmethodID Method::make_jmethod_id(ClassLoaderData* loader_data, Method* m) {
|
|
|
|
ClassLoaderData* cld = loader_data;
|
|
|
|
|
|
|
|
if (!SafepointSynchronize::is_at_safepoint()) {
|
|
|
|
// Have to add jmethod_ids() to class loader data thread-safely.
|
|
|
|
// Also have to add the method to the list safely, which the cld lock
|
|
|
|
// protects as well.
|
|
|
|
MutexLockerEx ml(cld->metaspace_lock(), Mutex::_no_safepoint_check_flag);
|
|
|
|
if (cld->jmethod_ids() == NULL) {
|
|
|
|
cld->set_jmethod_ids(new JNIMethodBlock());
|
|
|
|
}
|
|
|
|
// jmethodID is a pointer to Method*
|
|
|
|
return (jmethodID)cld->jmethod_ids()->add_method(m);
|
|
|
|
} else {
|
|
|
|
// At safepoint, we are single threaded and can set this.
|
|
|
|
if (cld->jmethod_ids() == NULL) {
|
|
|
|
cld->set_jmethod_ids(new JNIMethodBlock());
|
|
|
|
}
|
|
|
|
// jmethodID is a pointer to Method*
|
|
|
|
return (jmethodID)cld->jmethod_ids()->add_method(m);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mark a jmethodID as free. This is called when there is a data race in
|
|
|
|
// InstanceKlass while creating the jmethodID cache.
|
|
|
|
void Method::destroy_jmethod_id(ClassLoaderData* loader_data, jmethodID m) {
|
|
|
|
ClassLoaderData* cld = loader_data;
|
|
|
|
Method** ptr = (Method**)m;
|
|
|
|
assert(cld->jmethod_ids() != NULL, "should have method handles");
|
|
|
|
cld->jmethod_ids()->destroy_method(ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Method::change_method_associated_with_jmethod_id(jmethodID jmid, Method* new_method) {
|
|
|
|
// Can't assert the method_holder is the same because the new method has the
|
|
|
|
// scratch method holder.
|
|
|
|
assert(resolve_jmethod_id(jmid)->method_holder()->class_loader()
|
|
|
|
== new_method->method_holder()->class_loader(),
|
|
|
|
"changing to a different class loader");
|
|
|
|
// Just change the method in place, jmethodID pointer doesn't change.
|
|
|
|
*((Method**)jmid) = new_method;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Method::is_method_id(jmethodID mid) {
|
|
|
|
Method* m = resolve_jmethod_id(mid);
|
|
|
|
assert(m != NULL, "should be called with non-null method");
|
2012-11-06 15:09:37 -05:00
|
|
|
InstanceKlass* ik = m->method_holder();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
ClassLoaderData* cld = ik->class_loader_data();
|
|
|
|
if (cld->jmethod_ids() == NULL) return false;
|
|
|
|
return (cld->jmethod_ids()->contains((Method**)mid));
|
|
|
|
}
|
|
|
|
|
|
|
|
Method* Method::checked_resolve_jmethod_id(jmethodID mid) {
|
|
|
|
if (mid == NULL) return NULL;
|
|
|
|
Method* o = resolve_jmethod_id(mid);
|
|
|
|
if (o == NULL || o == JNIMethodBlock::_free_method || !((Metadata*)o)->is_method()) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return o;
|
|
|
|
};
|
|
|
|
|
|
|
|
void Method::set_on_stack(const bool value) {
|
|
|
|
// Set both the method itself and its constant pool. The constant pool
|
|
|
|
// on stack means some method referring to it is also on the stack.
|
|
|
|
constants()->set_on_stack(value);
|
2014-10-02 10:55:36 +02:00
|
|
|
|
2015-03-13 12:40:39 -04:00
|
|
|
bool already_set = on_stack();
|
|
|
|
_access_flags.set_on_stack(value);
|
|
|
|
if (value && !already_set) {
|
|
|
|
MetadataOnStackMark::record(this);
|
2014-10-02 10:55:36 +02:00
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Called when the class loader is unloaded to make all methods weak.
|
|
|
|
void Method::clear_jmethod_ids(ClassLoaderData* loader_data) {
|
|
|
|
loader_data->jmethod_ids()->clear_all_methods();
|
|
|
|
}
|
|
|
|
|
2014-05-15 18:23:26 -04:00
|
|
|
bool Method::has_method_vptr(const void* ptr) {
|
|
|
|
Method m;
|
|
|
|
// This assumes that the vtbl pointer is the first word of a C++ object.
|
|
|
|
// This assumption is also in universe.cpp patch_klass_vtble
|
|
|
|
void* vtbl2 = dereference_vptr((const void*)&m);
|
|
|
|
void* this_vtbl = dereference_vptr(ptr);
|
|
|
|
return vtbl2 == this_vtbl;
|
|
|
|
}
|
2012-11-28 17:50:21 -05:00
|
|
|
|
|
|
|
// Check that this pointer is valid by checking that the vtbl pointer matches
|
|
|
|
bool Method::is_valid_method() const {
|
|
|
|
if (this == NULL) {
|
|
|
|
return false;
|
|
|
|
} else if (!is_metaspace_object()) {
|
|
|
|
return false;
|
|
|
|
} else {
|
2014-05-15 18:23:26 -04:00
|
|
|
return has_method_vptr((const void*)this);
|
2012-11-28 17:50:21 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#ifndef PRODUCT
|
|
|
|
void Method::print_jmethod_ids(ClassLoaderData* loader_data, outputStream* out) {
|
|
|
|
out->print_cr("jni_method_id count = %d", loader_data->jmethod_ids()->count_methods());
|
|
|
|
}
|
|
|
|
#endif // PRODUCT
|
|
|
|
|
|
|
|
|
|
|
|
// Printing
|
|
|
|
|
|
|
|
#ifndef PRODUCT
|
|
|
|
|
|
|
|
void Method::print_on(outputStream* st) const {
|
|
|
|
ResourceMark rm;
|
|
|
|
assert(is_method(), "must be method");
|
2014-05-09 16:50:54 -04:00
|
|
|
st->print_cr("%s", internal_name());
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// get the effect of PrintOopAddress, always, for methods:
|
2015-10-09 09:42:33 +02:00
|
|
|
st->print_cr(" - this oop: " INTPTR_FORMAT, p2i(this));
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
st->print (" - method holder: "); method_holder()->print_value_on(st); st->cr();
|
2015-10-09 09:42:33 +02:00
|
|
|
st->print (" - constants: " INTPTR_FORMAT " ", p2i(constants()));
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
constants()->print_value_on(st); st->cr();
|
|
|
|
st->print (" - access: 0x%x ", access_flags().as_int()); access_flags().print_on(st); st->cr();
|
|
|
|
st->print (" - name: "); name()->print_value_on(st); st->cr();
|
|
|
|
st->print (" - signature: "); signature()->print_value_on(st); st->cr();
|
|
|
|
st->print_cr(" - max stack: %d", max_stack());
|
|
|
|
st->print_cr(" - max locals: %d", max_locals());
|
|
|
|
st->print_cr(" - size of params: %d", size_of_parameters());
|
|
|
|
st->print_cr(" - method size: %d", method_size());
|
|
|
|
if (intrinsic_id() != vmIntrinsics::_none)
|
|
|
|
st->print_cr(" - intrinsic id: %d %s", intrinsic_id(), vmIntrinsics::name_at(intrinsic_id()));
|
|
|
|
if (highest_comp_level() != CompLevel_none)
|
|
|
|
st->print_cr(" - highest level: %d", highest_comp_level());
|
|
|
|
st->print_cr(" - vtable index: %d", _vtable_index);
|
2015-10-09 09:42:33 +02:00
|
|
|
st->print_cr(" - i2i entry: " INTPTR_FORMAT, p2i(interpreter_entry()));
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
st->print( " - adapters: ");
|
|
|
|
AdapterHandlerEntry* a = ((Method*)this)->adapter();
|
|
|
|
if (a == NULL)
|
2015-10-09 09:42:33 +02:00
|
|
|
st->print_cr(INTPTR_FORMAT, p2i(a));
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
else
|
|
|
|
a->print_adapter_on(st);
|
2015-10-09 09:42:33 +02:00
|
|
|
st->print_cr(" - compiled entry " INTPTR_FORMAT, p2i(from_compiled_entry()));
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
st->print_cr(" - code size: %d", code_size());
|
|
|
|
if (code_size() != 0) {
|
2015-10-09 09:42:33 +02:00
|
|
|
st->print_cr(" - code start: " INTPTR_FORMAT, p2i(code_base()));
|
|
|
|
st->print_cr(" - code end (excl): " INTPTR_FORMAT, p2i(code_base() + code_size()));
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
if (method_data() != NULL) {
|
2015-10-09 09:42:33 +02:00
|
|
|
st->print_cr(" - method data: " INTPTR_FORMAT, p2i(method_data()));
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
st->print_cr(" - checked ex length: %d", checked_exceptions_length());
|
|
|
|
if (checked_exceptions_length() > 0) {
|
|
|
|
CheckedExceptionElement* table = checked_exceptions_start();
|
2015-10-09 09:42:33 +02:00
|
|
|
st->print_cr(" - checked ex start: " INTPTR_FORMAT, p2i(table));
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (Verbose) {
|
|
|
|
for (int i = 0; i < checked_exceptions_length(); i++) {
|
|
|
|
st->print_cr(" - throws %s", constants()->printable_name_at(table[i].class_cp_index));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (has_linenumber_table()) {
|
|
|
|
u_char* table = compressed_linenumber_table();
|
2015-10-09 09:42:33 +02:00
|
|
|
st->print_cr(" - linenumber start: " INTPTR_FORMAT, p2i(table));
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (Verbose) {
|
|
|
|
CompressedLineNumberReadStream stream(table);
|
|
|
|
while (stream.read_pair()) {
|
|
|
|
st->print_cr(" - line %d: %d", stream.line(), stream.bci());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
st->print_cr(" - localvar length: %d", localvariable_table_length());
|
|
|
|
if (localvariable_table_length() > 0) {
|
|
|
|
LocalVariableTableElement* table = localvariable_table_start();
|
2015-10-09 09:42:33 +02:00
|
|
|
st->print_cr(" - localvar start: " INTPTR_FORMAT, p2i(table));
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (Verbose) {
|
|
|
|
for (int i = 0; i < localvariable_table_length(); i++) {
|
|
|
|
int bci = table[i].start_bci;
|
|
|
|
int len = table[i].length;
|
|
|
|
const char* name = constants()->printable_name_at(table[i].name_cp_index);
|
|
|
|
const char* desc = constants()->printable_name_at(table[i].descriptor_cp_index);
|
|
|
|
int slot = table[i].slot;
|
|
|
|
st->print_cr(" - %s %s bci=%d len=%d slot=%d", desc, name, bci, len, slot);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (code() != NULL) {
|
|
|
|
st->print (" - compiled code: ");
|
|
|
|
code()->print_value_on(st);
|
|
|
|
}
|
|
|
|
if (is_native()) {
|
2015-10-09 09:42:33 +02:00
|
|
|
st->print_cr(" - native function: " INTPTR_FORMAT, p2i(native_function()));
|
|
|
|
st->print_cr(" - signature handler: " INTPTR_FORMAT, p2i(signature_handler()));
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //PRODUCT
|
|
|
|
|
|
|
|
void Method::print_value_on(outputStream* st) const {
|
|
|
|
assert(is_method(), "must be method");
|
2014-05-09 16:50:54 -04:00
|
|
|
st->print("%s", internal_name());
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
print_address_on(st);
|
|
|
|
st->print(" ");
|
|
|
|
name()->print_value_on(st);
|
|
|
|
st->print(" ");
|
|
|
|
signature()->print_value_on(st);
|
|
|
|
st->print(" in ");
|
|
|
|
method_holder()->print_value_on(st);
|
2013-09-13 22:38:02 -04:00
|
|
|
if (WizardMode) st->print("#%d", _vtable_index);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (WizardMode) st->print("[%d,%d]", size_of_parameters(), max_locals());
|
|
|
|
if (WizardMode && code() != NULL) st->print(" ((nmethod*)%p)", code());
|
|
|
|
}
|
|
|
|
|
2013-01-25 15:06:18 -05:00
|
|
|
#if INCLUDE_SERVICES
|
|
|
|
// Size Statistics
|
|
|
|
void Method::collect_statistics(KlassSizeStats *sz) const {
|
|
|
|
int mysize = sz->count(this);
|
|
|
|
sz->_method_bytes += mysize;
|
|
|
|
sz->_method_all_bytes += mysize;
|
|
|
|
sz->_rw_bytes += mysize;
|
|
|
|
|
|
|
|
if (constMethod()) {
|
|
|
|
constMethod()->collect_statistics(sz);
|
|
|
|
}
|
|
|
|
if (method_data()) {
|
|
|
|
method_data()->collect_statistics(sz);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // INCLUDE_SERVICES
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2015-07-15 12:24:41 -07:00
|
|
|
// LogTouchedMethods and PrintTouchedMethods
|
|
|
|
|
|
|
|
// TouchedMethodRecord -- we can't use a HashtableEntry<Method*> because
|
|
|
|
// the Method may be garbage collected. Let's roll our own hash table.
|
|
|
|
class TouchedMethodRecord : CHeapObj<mtTracing> {
|
|
|
|
public:
|
|
|
|
// It's OK to store Symbols here because they will NOT be GC'ed if
|
|
|
|
// LogTouchedMethods is enabled.
|
|
|
|
TouchedMethodRecord* _next;
|
|
|
|
Symbol* _class_name;
|
|
|
|
Symbol* _method_name;
|
|
|
|
Symbol* _method_signature;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const int TOUCHED_METHOD_TABLE_SIZE = 20011;
|
|
|
|
static TouchedMethodRecord** _touched_method_table = NULL;
|
|
|
|
|
|
|
|
void Method::log_touched(TRAPS) {
|
|
|
|
|
|
|
|
const int table_size = TOUCHED_METHOD_TABLE_SIZE;
|
|
|
|
Symbol* my_class = klass_name();
|
|
|
|
Symbol* my_name = name();
|
|
|
|
Symbol* my_sig = signature();
|
|
|
|
|
|
|
|
unsigned int hash = my_class->identity_hash() +
|
|
|
|
my_name->identity_hash() +
|
|
|
|
my_sig->identity_hash();
|
|
|
|
juint index = juint(hash) % table_size;
|
|
|
|
|
|
|
|
MutexLocker ml(TouchedMethodLog_lock, THREAD);
|
|
|
|
if (_touched_method_table == NULL) {
|
|
|
|
_touched_method_table = NEW_C_HEAP_ARRAY2(TouchedMethodRecord*, table_size,
|
|
|
|
mtTracing, CURRENT_PC);
|
|
|
|
memset(_touched_method_table, 0, sizeof(TouchedMethodRecord*)*table_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
TouchedMethodRecord* ptr = _touched_method_table[index];
|
|
|
|
while (ptr) {
|
|
|
|
if (ptr->_class_name == my_class &&
|
|
|
|
ptr->_method_name == my_name &&
|
|
|
|
ptr->_method_signature == my_sig) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (ptr->_next == NULL) break;
|
|
|
|
ptr = ptr->_next;
|
|
|
|
}
|
|
|
|
TouchedMethodRecord* nptr = NEW_C_HEAP_OBJ(TouchedMethodRecord, mtTracing);
|
|
|
|
my_class->set_permanent(); // prevent reclaimed by GC
|
|
|
|
my_name->set_permanent();
|
|
|
|
my_sig->set_permanent();
|
|
|
|
nptr->_class_name = my_class;
|
|
|
|
nptr->_method_name = my_name;
|
|
|
|
nptr->_method_signature = my_sig;
|
|
|
|
nptr->_next = NULL;
|
|
|
|
|
|
|
|
if (ptr == NULL) {
|
|
|
|
// first
|
|
|
|
_touched_method_table[index] = nptr;
|
|
|
|
} else {
|
|
|
|
ptr->_next = nptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Method::print_touched_methods(outputStream* out) {
|
|
|
|
MutexLockerEx ml(Thread::current()->is_VM_thread() ? NULL : TouchedMethodLog_lock);
|
|
|
|
out->print_cr("# Method::print_touched_methods version 1");
|
|
|
|
if (_touched_method_table) {
|
|
|
|
for (int i = 0; i < TOUCHED_METHOD_TABLE_SIZE; i++) {
|
|
|
|
TouchedMethodRecord* ptr = _touched_method_table[i];
|
|
|
|
while(ptr) {
|
|
|
|
ptr->_class_name->print_symbol_on(out); out->print(".");
|
|
|
|
ptr->_method_name->print_symbol_on(out); out->print(":");
|
|
|
|
ptr->_method_signature->print_symbol_on(out); out->cr();
|
|
|
|
ptr = ptr->_next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Verification
|
|
|
|
|
|
|
|
void Method::verify_on(outputStream* st) {
|
|
|
|
guarantee(is_method(), "object must be method");
|
|
|
|
guarantee(constants()->is_constantPool(), "should be constant pool");
|
|
|
|
guarantee(constMethod()->is_constMethod(), "should be ConstMethod*");
|
|
|
|
MethodData* md = method_data();
|
|
|
|
guarantee(md == NULL ||
|
|
|
|
md->is_methodData(), "should be method data");
|
|
|
|
}
|