2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2013-04-09 17:17:41 -04:00
|
|
|
* Copyright (c) 1999, 2013, 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"
|
|
|
|
#include "ci/ciCallProfile.hpp"
|
|
|
|
#include "ci/ciExceptionHandler.hpp"
|
|
|
|
#include "ci/ciInstanceKlass.hpp"
|
|
|
|
#include "ci/ciMethod.hpp"
|
|
|
|
#include "ci/ciMethodBlocks.hpp"
|
|
|
|
#include "ci/ciMethodData.hpp"
|
|
|
|
#include "ci/ciStreams.hpp"
|
|
|
|
#include "ci/ciSymbol.hpp"
|
2012-11-12 14:03:53 -08:00
|
|
|
#include "ci/ciReplay.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "ci/ciUtilities.hpp"
|
|
|
|
#include "classfile/systemDictionary.hpp"
|
|
|
|
#include "compiler/abstractCompiler.hpp"
|
|
|
|
#include "compiler/compilerOracle.hpp"
|
|
|
|
#include "compiler/methodLiveness.hpp"
|
|
|
|
#include "interpreter/interpreter.hpp"
|
|
|
|
#include "interpreter/linkResolver.hpp"
|
|
|
|
#include "interpreter/oopMapCache.hpp"
|
|
|
|
#include "memory/allocation.inline.hpp"
|
|
|
|
#include "memory/resourceArea.hpp"
|
|
|
|
#include "oops/generateOopMap.hpp"
|
|
|
|
#include "oops/oop.inline.hpp"
|
|
|
|
#include "prims/nativeLookup.hpp"
|
|
|
|
#include "runtime/deoptimization.hpp"
|
|
|
|
#include "utilities/bitMap.inline.hpp"
|
|
|
|
#include "utilities/xmlstream.hpp"
|
|
|
|
#ifdef COMPILER2
|
|
|
|
#include "ci/bcEscapeAnalyzer.hpp"
|
|
|
|
#include "ci/ciTypeFlow.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"
|
2010-11-23 13:22:55 -08:00
|
|
|
#endif
|
|
|
|
#ifdef SHARK
|
|
|
|
#include "ci/ciTypeFlow.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"
|
2010-11-23 13:22:55 -08:00
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// ciMethod
|
|
|
|
//
|
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
|
|
|
// This class represents a Method* in the HotSpot virtual
|
2007-12-01 00:00:00 +00:00
|
|
|
// machine.
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::ciMethod
|
|
|
|
//
|
|
|
|
// Loaded 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
|
|
|
ciMethod::ciMethod(methodHandle h_m) : ciMetadata(h_m()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(h_m() != NULL, "no null method");
|
|
|
|
|
|
|
|
// These fields are always filled in in loaded methods.
|
|
|
|
_flags = ciFlags(h_m()->access_flags());
|
|
|
|
|
|
|
|
// Easy to compute, so fill them in now.
|
|
|
|
_max_stack = h_m()->max_stack();
|
|
|
|
_max_locals = h_m()->max_locals();
|
|
|
|
_code_size = h_m()->code_size();
|
|
|
|
_intrinsic_id = h_m()->intrinsic_id();
|
2012-06-26 19:08:44 -04:00
|
|
|
_handler_count = h_m()->exception_table_length();
|
2007-12-01 00:00:00 +00:00
|
|
|
_uses_monitors = h_m()->access_flags().has_monitor_bytecodes();
|
|
|
|
_balanced_monitors = !_uses_monitors || h_m()->access_flags().is_monitor_matching();
|
2010-09-03 17:51:07 -07:00
|
|
|
_is_c1_compilable = !h_m()->is_not_c1_compilable();
|
|
|
|
_is_c2_compilable = !h_m()->is_not_c2_compilable();
|
2007-12-01 00:00:00 +00:00
|
|
|
// Lazy fields, filled in on demand. Require allocation.
|
|
|
|
_code = NULL;
|
|
|
|
_exception_handlers = NULL;
|
|
|
|
_liveness = NULL;
|
|
|
|
_method_blocks = NULL;
|
2010-08-11 05:51:21 -07:00
|
|
|
#if defined(COMPILER2) || defined(SHARK)
|
2007-12-01 00:00:00 +00:00
|
|
|
_flow = NULL;
|
2010-07-14 14:47:34 -07:00
|
|
|
_bcea = NULL;
|
2010-08-11 05:51:21 -07:00
|
|
|
#endif // COMPILER2 || SHARK
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2009-05-08 10:44:20 -07:00
|
|
|
ciEnv *env = CURRENT_ENV;
|
2010-09-03 17:51:07 -07:00
|
|
|
if (env->jvmti_can_hotswap_or_post_breakpoint() && can_be_compiled()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// 6328518 check hotswap conditions under the right lock.
|
|
|
|
MutexLocker locker(Compile_lock);
|
|
|
|
if (Dependencies::check_evol_method(h_m()) != NULL) {
|
2010-09-03 17:51:07 -07:00
|
|
|
_is_c1_compilable = false;
|
|
|
|
_is_c2_compilable = false;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
|
|
|
|
}
|
|
|
|
|
2012-11-06 15:09:37 -05:00
|
|
|
if (h_m()->method_holder()->is_linked()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
_can_be_statically_bound = h_m()->can_be_statically_bound();
|
|
|
|
} else {
|
|
|
|
// Have to use a conservative value in this case.
|
|
|
|
_can_be_statically_bound = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Adjust the definition of this condition to be more useful:
|
|
|
|
// %%% take these conditions into account in vtable generation
|
|
|
|
if (!_can_be_statically_bound && h_m()->is_private())
|
|
|
|
_can_be_statically_bound = true;
|
|
|
|
if (_can_be_statically_bound && h_m()->is_abstract())
|
|
|
|
_can_be_statically_bound = false;
|
|
|
|
|
|
|
|
// generating _signature may allow GC and therefore move m.
|
|
|
|
// These fields are always filled in.
|
2011-01-27 16:11:27 -08:00
|
|
|
_name = env->get_symbol(h_m()->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
|
|
|
_holder = env->get_instance_klass(h_m()->method_holder());
|
2011-01-27 16:11:27 -08:00
|
|
|
ciSymbol* sig_symbol = env->get_symbol(h_m()->signature());
|
2011-06-23 17:14:06 -07:00
|
|
|
constantPoolHandle cpool = h_m()->constants();
|
|
|
|
_signature = new (env->arena()) ciSignature(_holder, cpool, sig_symbol);
|
2007-12-01 00:00:00 +00:00
|
|
|
_method_data = NULL;
|
|
|
|
// Take a snapshot of these values, so they will be commensurate with the MDO.
|
2010-09-03 17:51:07 -07:00
|
|
|
if (ProfileInterpreter || TieredCompilation) {
|
2007-12-01 00:00:00 +00:00
|
|
|
int invcnt = h_m()->interpreter_invocation_count();
|
|
|
|
// if the value overflowed report it as max int
|
|
|
|
_interpreter_invocation_count = invcnt < 0 ? max_jint : invcnt ;
|
|
|
|
_interpreter_throwout_count = h_m()->interpreter_throwout_count();
|
|
|
|
} else {
|
|
|
|
_interpreter_invocation_count = 0;
|
|
|
|
_interpreter_throwout_count = 0;
|
|
|
|
}
|
|
|
|
if (_interpreter_invocation_count == 0)
|
|
|
|
_interpreter_invocation_count = 1;
|
2012-11-12 14:03:53 -08:00
|
|
|
_instructions_size = -1;
|
|
|
|
#ifdef ASSERT
|
|
|
|
if (ReplayCompiles) {
|
|
|
|
ciReplay::initialize(this);
|
|
|
|
}
|
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::ciMethod
|
|
|
|
//
|
|
|
|
// Unloaded method.
|
|
|
|
ciMethod::ciMethod(ciInstanceKlass* holder,
|
2011-10-12 21:00:13 -07:00
|
|
|
ciSymbol* name,
|
|
|
|
ciSymbol* signature,
|
|
|
|
ciInstanceKlass* accessor) :
|
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
|
|
|
ciMetadata((Metadata*)NULL),
|
2011-10-12 21:00:13 -07:00
|
|
|
_name( name),
|
|
|
|
_holder( holder),
|
|
|
|
_intrinsic_id( vmIntrinsics::_none),
|
|
|
|
_liveness( NULL),
|
|
|
|
_can_be_statically_bound(false),
|
|
|
|
_method_blocks( NULL),
|
|
|
|
_method_data( NULL)
|
2010-08-11 05:51:21 -07:00
|
|
|
#if defined(COMPILER2) || defined(SHARK)
|
2011-10-12 21:00:13 -07:00
|
|
|
,
|
|
|
|
_flow( NULL),
|
2012-11-12 14:03:53 -08:00
|
|
|
_bcea( NULL),
|
|
|
|
_instructions_size(-1)
|
2010-08-11 05:51:21 -07:00
|
|
|
#endif // COMPILER2 || SHARK
|
2011-10-12 21:00:13 -07:00
|
|
|
{
|
|
|
|
// Usually holder and accessor are the same type but in some cases
|
|
|
|
// the holder has the wrong class loader (e.g. invokedynamic call
|
|
|
|
// sites) so we pass the accessor.
|
|
|
|
_signature = new (CURRENT_ENV->arena()) ciSignature(accessor, constantPoolHandle(), signature);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::load_code
|
|
|
|
//
|
|
|
|
// Load the bytecodes and exception handler table for this method.
|
|
|
|
void ciMethod::load_code() {
|
|
|
|
VM_ENTRY_MARK;
|
|
|
|
assert(is_loaded(), "only loaded methods have 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
|
|
|
Method* me = get_Method();
|
2007-12-01 00:00:00 +00:00
|
|
|
Arena* arena = CURRENT_THREAD_ENV->arena();
|
|
|
|
|
|
|
|
// Load the bytecodes.
|
|
|
|
_code = (address)arena->Amalloc(code_size());
|
|
|
|
memcpy(_code, me->code_base(), code_size());
|
|
|
|
|
|
|
|
// Revert any breakpoint bytecodes in ci's copy
|
2008-02-21 19:03:44 -08:00
|
|
|
if (me->number_of_breakpoints() > 0) {
|
2012-11-06 15:09:37 -05:00
|
|
|
BreakpointInfo* bp = me->method_holder()->breakpoints();
|
2007-12-01 00:00:00 +00:00
|
|
|
for (; bp != NULL; bp = bp->next()) {
|
|
|
|
if (bp->match(me)) {
|
|
|
|
code_at_put(bp->bci(), bp->orig_bytecode());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// And load the exception table.
|
2012-06-26 19:08:44 -04:00
|
|
|
ExceptionTable exc_table(me);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Allocate one extra spot in our list of exceptions. This
|
|
|
|
// last entry will be used to represent the possibility that
|
|
|
|
// an exception escapes the method. See ciExceptionHandlerStream
|
|
|
|
// for details.
|
|
|
|
_exception_handlers =
|
|
|
|
(ciExceptionHandler**)arena->Amalloc(sizeof(ciExceptionHandler*)
|
|
|
|
* (_handler_count + 1));
|
|
|
|
if (_handler_count > 0) {
|
|
|
|
for (int i=0; i<_handler_count; i++) {
|
|
|
|
_exception_handlers[i] = new (arena) ciExceptionHandler(
|
|
|
|
holder(),
|
2012-06-26 19:08:44 -04:00
|
|
|
/* start */ exc_table.start_pc(i),
|
|
|
|
/* limit */ exc_table.end_pc(i),
|
|
|
|
/* goto pc */ exc_table.handler_pc(i),
|
|
|
|
/* cp index */ exc_table.catch_type_index(i));
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Put an entry at the end of our list to represent the possibility
|
|
|
|
// of exceptional exit.
|
|
|
|
_exception_handlers[_handler_count] =
|
|
|
|
new (arena) ciExceptionHandler(holder(), 0, code_size(), -1, 0);
|
|
|
|
|
|
|
|
if (CIPrintMethodCodes) {
|
|
|
|
print_codes();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::has_linenumber_table
|
|
|
|
//
|
|
|
|
// length unknown until decompression
|
|
|
|
bool ciMethod::has_linenumber_table() const {
|
|
|
|
check_is_loaded();
|
|
|
|
VM_ENTRY_MARK;
|
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 get_Method()->has_linenumber_table();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::compressed_linenumber_table
|
|
|
|
u_char* ciMethod::compressed_linenumber_table() const {
|
|
|
|
check_is_loaded();
|
|
|
|
VM_ENTRY_MARK;
|
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 get_Method()->compressed_linenumber_table();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::line_number_from_bci
|
|
|
|
int ciMethod::line_number_from_bci(int bci) const {
|
|
|
|
check_is_loaded();
|
|
|
|
VM_ENTRY_MARK;
|
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 get_Method()->line_number_from_bci(bci);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::vtable_index
|
|
|
|
//
|
|
|
|
// Get the position of this method's entry in the vtable, if any.
|
|
|
|
int ciMethod::vtable_index() {
|
|
|
|
check_is_loaded();
|
|
|
|
assert(holder()->is_linked(), "must be linked");
|
|
|
|
VM_ENTRY_MARK;
|
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 get_Method()->vtable_index();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-11 05:51:21 -07:00
|
|
|
#ifdef SHARK
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::itable_index
|
|
|
|
//
|
|
|
|
// Get the position of this method's entry in the itable, if any.
|
|
|
|
int ciMethod::itable_index() {
|
|
|
|
check_is_loaded();
|
|
|
|
assert(holder()->is_linked(), "must be linked");
|
|
|
|
VM_ENTRY_MARK;
|
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 klassItable::compute_itable_index(get_Method());
|
2010-08-11 05:51:21 -07:00
|
|
|
}
|
|
|
|
#endif // SHARK
|
|
|
|
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::native_entry
|
|
|
|
//
|
|
|
|
// Get the address of this method's native code, if any.
|
|
|
|
address ciMethod::native_entry() {
|
|
|
|
check_is_loaded();
|
|
|
|
assert(flags().is_native(), "must be native method");
|
|
|
|
VM_ENTRY_MARK;
|
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* method = get_Method();
|
2007-12-01 00:00:00 +00:00
|
|
|
address entry = method->native_function();
|
|
|
|
assert(entry != NULL, "must be valid entry point");
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::interpreter_entry
|
|
|
|
//
|
|
|
|
// Get the entry point for running this method in the interpreter.
|
|
|
|
address ciMethod::interpreter_entry() {
|
|
|
|
check_is_loaded();
|
|
|
|
VM_ENTRY_MARK;
|
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, get_Method());
|
2007-12-01 00:00:00 +00:00
|
|
|
return Interpreter::entry_for_method(mh);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::uses_balanced_monitors
|
|
|
|
//
|
|
|
|
// Does this method use monitors in a strict stack-disciplined manner?
|
|
|
|
bool ciMethod::has_balanced_monitors() {
|
|
|
|
check_is_loaded();
|
|
|
|
if (_balanced_monitors) return true;
|
|
|
|
|
|
|
|
// Analyze the method to see if monitors are used properly.
|
|
|
|
VM_ENTRY_MARK;
|
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(THREAD, get_Method());
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(method->has_monitor_bytecodes(), "should have checked this");
|
|
|
|
|
|
|
|
// Check to see if a previous compilation computed the
|
|
|
|
// monitor-matching analysis.
|
|
|
|
if (method->guaranteed_monitor_matching()) {
|
|
|
|
_balanced_monitors = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
EXCEPTION_MARK;
|
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
GeneratePairingInfo gpi(method);
|
|
|
|
gpi.compute_map(CATCH);
|
|
|
|
if (!gpi.monitor_safe()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
method->set_guaranteed_monitor_matching();
|
|
|
|
_balanced_monitors = true;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::get_flow_analysis
|
|
|
|
ciTypeFlow* ciMethod::get_flow_analysis() {
|
2010-08-11 05:51:21 -07:00
|
|
|
#if defined(COMPILER2) || defined(SHARK)
|
2007-12-01 00:00:00 +00:00
|
|
|
if (_flow == NULL) {
|
|
|
|
ciEnv* env = CURRENT_ENV;
|
|
|
|
_flow = new (env->arena()) ciTypeFlow(env, this);
|
|
|
|
_flow->do_flow();
|
|
|
|
}
|
|
|
|
return _flow;
|
2010-08-11 05:51:21 -07:00
|
|
|
#else // COMPILER2 || SHARK
|
2007-12-01 00:00:00 +00:00
|
|
|
ShouldNotReachHere();
|
|
|
|
return NULL;
|
2010-08-11 05:51:21 -07:00
|
|
|
#endif // COMPILER2 || SHARK
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::get_osr_flow_analysis
|
|
|
|
ciTypeFlow* ciMethod::get_osr_flow_analysis(int osr_bci) {
|
2010-08-11 05:51:21 -07:00
|
|
|
#if defined(COMPILER2) || defined(SHARK)
|
2007-12-01 00:00:00 +00:00
|
|
|
// OSR entry points are always place after a call bytecode of some sort
|
|
|
|
assert(osr_bci >= 0, "must supply valid OSR entry point");
|
|
|
|
ciEnv* env = CURRENT_ENV;
|
|
|
|
ciTypeFlow* flow = new (env->arena()) ciTypeFlow(env, this, osr_bci);
|
|
|
|
flow->do_flow();
|
|
|
|
return flow;
|
2010-08-11 05:51:21 -07:00
|
|
|
#else // COMPILER2 || SHARK
|
2007-12-01 00:00:00 +00:00
|
|
|
ShouldNotReachHere();
|
|
|
|
return NULL;
|
2010-08-11 05:51:21 -07:00
|
|
|
#endif // COMPILER2 || SHARK
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
2009-09-16 11:06:10 -07:00
|
|
|
// ciMethod::raw_liveness_at_bci
|
2007-12-01 00:00:00 +00:00
|
|
|
//
|
|
|
|
// Which local variables are live at a specific bci?
|
2009-09-16 11:06:10 -07:00
|
|
|
MethodLivenessResult ciMethod::raw_liveness_at_bci(int bci) {
|
2007-12-01 00:00:00 +00:00
|
|
|
check_is_loaded();
|
|
|
|
if (_liveness == NULL) {
|
|
|
|
// Create the liveness analyzer.
|
|
|
|
Arena* arena = CURRENT_ENV->arena();
|
|
|
|
_liveness = new (arena) MethodLiveness(arena, this);
|
|
|
|
_liveness->compute_liveness();
|
|
|
|
}
|
2009-09-16 11:06:10 -07:00
|
|
|
return _liveness->get_liveness_at(bci);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::liveness_at_bci
|
|
|
|
//
|
|
|
|
// Which local variables are live at a specific bci? When debugging
|
|
|
|
// will return true for all locals in some cases to improve debug
|
|
|
|
// information.
|
|
|
|
MethodLivenessResult ciMethod::liveness_at_bci(int bci) {
|
|
|
|
MethodLivenessResult result = raw_liveness_at_bci(bci);
|
2009-05-08 10:44:20 -07:00
|
|
|
if (CURRENT_ENV->jvmti_can_access_local_variables() || DeoptimizeALot || CompileTheWorld) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Keep all locals live for the user's edification and amusement.
|
|
|
|
result.at_put_range(0, result.size(), true);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ciMethod::live_local_oops_at_bci
|
|
|
|
//
|
|
|
|
// find all the live oops in the locals array for a particular bci
|
|
|
|
// Compute what the interpreter believes by using the interpreter
|
|
|
|
// oopmap generator. This is used as a double check during osr to
|
|
|
|
// guard against conservative result from MethodLiveness making us
|
|
|
|
// think a dead oop is live. MethodLiveness is conservative in the
|
|
|
|
// sense that it may consider locals to be live which cannot be live,
|
|
|
|
// like in the case where a local could contain an oop or a primitive
|
|
|
|
// along different paths. In that case the local must be dead when
|
|
|
|
// those paths merge. Since the interpreter's viewpoint is used when
|
|
|
|
// gc'ing an interpreter frame we need to use its viewpoint during
|
|
|
|
// OSR when loading the locals.
|
|
|
|
|
|
|
|
BitMap ciMethod::live_local_oops_at_bci(int bci) {
|
|
|
|
VM_ENTRY_MARK;
|
|
|
|
InterpreterOopMap mask;
|
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
|
|
|
OopMapCache::compute_one_oop_map(get_Method(), bci, &mask);
|
2007-12-01 00:00:00 +00:00
|
|
|
int mask_size = max_locals();
|
|
|
|
BitMap result(mask_size);
|
|
|
|
result.clear();
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < mask_size ; i++ ) {
|
|
|
|
if (mask.is_oop(i)) result.set_bit(i);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef COMPILER1
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::bci_block_start
|
|
|
|
//
|
|
|
|
// Marks all bcis where a new basic block starts
|
|
|
|
const BitMap ciMethod::bci_block_start() {
|
|
|
|
check_is_loaded();
|
|
|
|
if (_liveness == NULL) {
|
|
|
|
// Create the liveness analyzer.
|
|
|
|
Arena* arena = CURRENT_ENV->arena();
|
|
|
|
_liveness = new (arena) MethodLiveness(arena, this);
|
|
|
|
_liveness->compute_liveness();
|
|
|
|
}
|
|
|
|
|
|
|
|
return _liveness->get_bci_block_start();
|
|
|
|
}
|
|
|
|
#endif // COMPILER1
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::call_profile_at_bci
|
|
|
|
//
|
|
|
|
// Get the ciCallProfile for the invocation of this method.
|
|
|
|
// Also reports receiver types for non-call type checks (if TypeProfileCasts).
|
|
|
|
ciCallProfile ciMethod::call_profile_at_bci(int bci) {
|
|
|
|
ResourceMark rm;
|
|
|
|
ciCallProfile result;
|
|
|
|
if (method_data() != NULL && method_data()->is_mature()) {
|
|
|
|
ciProfileData* data = method_data()->bci_to_data(bci);
|
|
|
|
if (data != NULL && data->is_CounterData()) {
|
|
|
|
// Every profiled call site has a counter.
|
|
|
|
int count = data->as_CounterData()->count();
|
|
|
|
|
|
|
|
if (!data->is_ReceiverTypeData()) {
|
|
|
|
result._receiver_count[0] = 0; // that's a definite zero
|
|
|
|
} else { // ReceiverTypeData is a subclass of CounterData
|
|
|
|
ciReceiverTypeData* call = (ciReceiverTypeData*)data->as_ReceiverTypeData();
|
|
|
|
// In addition, virtual call sites have receiver type information
|
|
|
|
int receivers_count_total = 0;
|
|
|
|
int morphism = 0;
|
2010-09-03 17:51:07 -07:00
|
|
|
// Precompute morphism for the possible fixup
|
2007-12-01 00:00:00 +00:00
|
|
|
for (uint i = 0; i < call->row_limit(); i++) {
|
|
|
|
ciKlass* receiver = call->receiver(i);
|
|
|
|
if (receiver == NULL) continue;
|
2010-09-03 17:51:07 -07:00
|
|
|
morphism++;
|
|
|
|
}
|
|
|
|
int epsilon = 0;
|
|
|
|
if (TieredCompilation && ProfileInterpreter) {
|
|
|
|
// Interpreter and C1 treat final and special invokes differently.
|
|
|
|
// C1 will record a type, whereas the interpreter will just
|
|
|
|
// increment the count. Detect this case.
|
|
|
|
if (morphism == 1 && count > 0) {
|
|
|
|
epsilon = count;
|
|
|
|
count = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (uint i = 0; i < call->row_limit(); i++) {
|
|
|
|
ciKlass* receiver = call->receiver(i);
|
|
|
|
if (receiver == NULL) continue;
|
|
|
|
int rcount = call->receiver_count(i) + epsilon;
|
2007-12-01 00:00:00 +00:00
|
|
|
if (rcount == 0) rcount = 1; // Should be valid value
|
|
|
|
receivers_count_total += rcount;
|
|
|
|
// Add the receiver to result data.
|
|
|
|
result.add_receiver(receiver, rcount);
|
|
|
|
// If we extend profiling to record methods,
|
|
|
|
// we will set result._method also.
|
|
|
|
}
|
|
|
|
// Determine call site's morphism.
|
2010-02-01 16:49:49 -08:00
|
|
|
// The call site count is 0 with known morphism (onlt 1 or 2 receivers)
|
|
|
|
// or < 0 in the case of a type check failured for checkcast, aastore, instanceof.
|
|
|
|
// The call site count is > 0 in the case of a polymorphic virtual call.
|
|
|
|
if (morphism > 0 && morphism == result._limit) {
|
|
|
|
// The morphism <= MorphismLimit.
|
|
|
|
if ((morphism < ciCallProfile::MorphismLimit) ||
|
|
|
|
(morphism == ciCallProfile::MorphismLimit && count == 0)) {
|
|
|
|
#ifdef ASSERT
|
|
|
|
if (count > 0) {
|
2010-02-07 12:15:06 -08:00
|
|
|
this->print_short_name(tty);
|
|
|
|
tty->print_cr(" @ bci:%d", bci);
|
2010-02-01 16:49:49 -08:00
|
|
|
this->print_codes();
|
|
|
|
assert(false, "this call site should not be polymorphic");
|
|
|
|
}
|
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
result._morphism = morphism;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Make the count consistent if this is a call profile. If count is
|
|
|
|
// zero or less, presume that this is a typecheck profile and
|
|
|
|
// do nothing. Otherwise, increase count to be the sum of all
|
|
|
|
// receiver's counts.
|
2010-02-01 16:49:49 -08:00
|
|
|
if (count >= 0) {
|
|
|
|
count += receivers_count_total;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
result._count = count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// Add new receiver and sort data by receiver's profile count.
|
|
|
|
void ciCallProfile::add_receiver(ciKlass* receiver, int receiver_count) {
|
|
|
|
// Add new receiver and sort data by receiver's counts when we have space
|
|
|
|
// for it otherwise replace the less called receiver (less called receiver
|
|
|
|
// is placed to the last array element which is not used).
|
|
|
|
// First array's element contains most called receiver.
|
|
|
|
int i = _limit;
|
|
|
|
for (; i > 0 && receiver_count > _receiver_count[i-1]; i--) {
|
|
|
|
_receiver[i] = _receiver[i-1];
|
|
|
|
_receiver_count[i] = _receiver_count[i-1];
|
|
|
|
}
|
|
|
|
_receiver[i] = receiver;
|
|
|
|
_receiver_count[i] = receiver_count;
|
|
|
|
if (_limit < MorphismLimit) _limit++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::find_monomorphic_target
|
|
|
|
//
|
|
|
|
// Given a certain calling environment, find the monomorphic target
|
|
|
|
// for the call. Return NULL if the call is not monomorphic in
|
|
|
|
// its calling environment, or if there are only abstract methods.
|
|
|
|
// The returned method is never abstract.
|
|
|
|
// Note: If caller uses a non-null result, it must inform dependencies
|
|
|
|
// via assert_unique_concrete_method or assert_leaf_type.
|
|
|
|
ciMethod* ciMethod::find_monomorphic_target(ciInstanceKlass* caller,
|
|
|
|
ciInstanceKlass* callee_holder,
|
|
|
|
ciInstanceKlass* actual_recv) {
|
|
|
|
check_is_loaded();
|
|
|
|
|
|
|
|
if (actual_recv->is_interface()) {
|
|
|
|
// %%% We cannot trust interface types, yet. See bug 6312651.
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ciMethod* root_m = resolve_invoke(caller, actual_recv);
|
|
|
|
if (root_m == NULL) {
|
|
|
|
// Something went wrong looking up the actual receiver method.
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
assert(!root_m->is_abstract(), "resolve_invoke promise");
|
|
|
|
|
|
|
|
// Make certain quick checks even if UseCHA is false.
|
|
|
|
|
|
|
|
// Is it private or final?
|
|
|
|
if (root_m->can_be_statically_bound()) {
|
|
|
|
return root_m;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (actual_recv->is_leaf_type() && actual_recv == root_m->holder()) {
|
|
|
|
// Easy case. There is no other place to put a method, so don't bother
|
|
|
|
// to go through the VM_ENTRY_MARK and all the rest.
|
|
|
|
return root_m;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Array methods (clone, hashCode, etc.) are always statically bound.
|
|
|
|
// If we were to see an array type here, we'd return root_m.
|
|
|
|
// However, this method processes only ciInstanceKlasses. (See 4962591.)
|
|
|
|
// The inline_native_clone intrinsic narrows Object to T[] properly,
|
|
|
|
// so there is no need to do the same job here.
|
|
|
|
|
|
|
|
if (!UseCHA) return NULL;
|
|
|
|
|
|
|
|
VM_ENTRY_MARK;
|
|
|
|
|
|
|
|
methodHandle target;
|
|
|
|
{
|
|
|
|
MutexLocker locker(Compile_lock);
|
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* context = actual_recv->get_Klass();
|
2007-12-01 00:00:00 +00:00
|
|
|
target = Dependencies::find_unique_concrete_method(context,
|
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
|
|
|
root_m->get_Method());
|
2007-12-01 00:00:00 +00:00
|
|
|
// %%% Should upgrade this ciMethod API to look for 1 or 2 concrete methods.
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef 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
|
|
|
if (TraceDependencies && target() != NULL && target() != root_m->get_Method()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
tty->print("found a non-root unique target 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
|
|
|
tty->print_cr(" context = %s", InstanceKlass::cast(actual_recv->get_Klass())->external_name());
|
2007-12-01 00:00:00 +00:00
|
|
|
tty->print(" method = ");
|
|
|
|
target->print_short_name(tty);
|
|
|
|
tty->cr();
|
|
|
|
}
|
|
|
|
#endif //PRODUCT
|
|
|
|
|
|
|
|
if (target() == NULL) {
|
|
|
|
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
|
|
|
if (target() == root_m->get_Method()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return root_m;
|
|
|
|
}
|
|
|
|
if (!root_m->is_public() &&
|
|
|
|
!root_m->is_protected()) {
|
|
|
|
// If we are going to reason about inheritance, it's easiest
|
|
|
|
// if the method in question is public, protected, or private.
|
|
|
|
// If the answer is not root_m, it is conservatively correct
|
|
|
|
// to return NULL, even if the CHA encountered irrelevant
|
|
|
|
// methods in other packages.
|
|
|
|
// %%% TO DO: Work out logic for package-private methods
|
|
|
|
// with the same name but different vtable indexes.
|
|
|
|
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
|
|
|
return CURRENT_THREAD_ENV->get_method(target());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::resolve_invoke
|
|
|
|
//
|
|
|
|
// Given a known receiver klass, find the target for the call.
|
|
|
|
// Return NULL if the call has no target or the target is abstract.
|
|
|
|
ciMethod* ciMethod::resolve_invoke(ciKlass* caller, ciKlass* exact_receiver) {
|
|
|
|
check_is_loaded();
|
|
|
|
VM_ENTRY_MARK;
|
|
|
|
|
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
|
|
|
KlassHandle caller_klass (THREAD, caller->get_Klass());
|
|
|
|
KlassHandle h_recv (THREAD, exact_receiver->get_Klass());
|
|
|
|
KlassHandle h_resolved (THREAD, holder()->get_Klass());
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* h_name = name()->get_symbol();
|
|
|
|
Symbol* h_signature = signature()->get_symbol();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
methodHandle m;
|
|
|
|
// Only do exact lookup if receiver klass has been linked. Otherwise,
|
|
|
|
// the vtable has not been setup, and the LinkResolver will fail.
|
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 (h_recv->oop_is_array()
|
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
|
|
|
InstanceKlass::cast(h_recv())->is_linked() && !exact_receiver->is_interface()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (holder()->is_interface()) {
|
|
|
|
m = LinkResolver::resolve_interface_call_or_null(h_recv, h_resolved, h_name, h_signature, caller_klass);
|
|
|
|
} else {
|
|
|
|
m = LinkResolver::resolve_virtual_call_or_null(h_recv, h_resolved, h_name, h_signature, caller_klass);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m.is_null()) {
|
|
|
|
// Return NULL only if there was a problem with lookup (uninitialized class, etc.)
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ciMethod* result = 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
|
|
|
if (m() != get_Method()) {
|
|
|
|
result = CURRENT_THREAD_ENV->get_method(m());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Don't return abstract methods because they aren't
|
|
|
|
// optimizable or interesting.
|
|
|
|
if (result->is_abstract()) {
|
|
|
|
return NULL;
|
|
|
|
} else {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::resolve_vtable_index
|
|
|
|
//
|
|
|
|
// Given a known receiver klass, find the vtable index for the call.
|
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 Method::invalid_vtable_index if the vtable_index is unknown.
|
2007-12-01 00:00:00 +00:00
|
|
|
int ciMethod::resolve_vtable_index(ciKlass* caller, ciKlass* receiver) {
|
|
|
|
check_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
|
|
|
int vtable_index = Method::invalid_vtable_index;
|
2007-12-01 00:00:00 +00:00
|
|
|
// Only do lookup if receiver klass has been linked. Otherwise,
|
|
|
|
// the vtable has not been setup, and the LinkResolver will fail.
|
|
|
|
if (!receiver->is_interface()
|
|
|
|
&& (!receiver->is_instance_klass() ||
|
|
|
|
receiver->as_instance_klass()->is_linked())) {
|
|
|
|
VM_ENTRY_MARK;
|
|
|
|
|
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
|
|
|
KlassHandle caller_klass (THREAD, caller->get_Klass());
|
|
|
|
KlassHandle h_recv (THREAD, receiver->get_Klass());
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* h_name = name()->get_symbol();
|
|
|
|
Symbol* h_signature = signature()->get_symbol();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
vtable_index = LinkResolver::resolve_virtual_vtable_index(h_recv, h_recv, h_name, h_signature, caller_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
|
|
|
if (vtable_index == Method::nonvirtual_vtable_index) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// A statically bound method. Return "no such 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
|
|
|
vtable_index = Method::invalid_vtable_index;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return vtable_index;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::interpreter_call_site_count
|
|
|
|
int ciMethod::interpreter_call_site_count(int bci) {
|
|
|
|
if (method_data() != NULL) {
|
|
|
|
ResourceMark rm;
|
|
|
|
ciProfileData* data = method_data()->bci_to_data(bci);
|
|
|
|
if (data != NULL && data->is_CounterData()) {
|
|
|
|
return scale_count(data->as_CounterData()->count());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1; // unknown
|
|
|
|
}
|
|
|
|
|
2012-11-26 17:25:11 -08:00
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::get_field_at_bci
|
|
|
|
ciField* ciMethod::get_field_at_bci(int bci, bool &will_link) {
|
|
|
|
ciBytecodeStream iter(this);
|
|
|
|
iter.reset_to_bci(bci);
|
|
|
|
iter.next();
|
|
|
|
return iter.get_field(will_link);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::get_method_at_bci
|
|
|
|
ciMethod* ciMethod::get_method_at_bci(int bci, bool &will_link, ciSignature* *declared_signature) {
|
|
|
|
ciBytecodeStream iter(this);
|
|
|
|
iter.reset_to_bci(bci);
|
|
|
|
iter.next();
|
|
|
|
return iter.get_method(will_link, declared_signature);
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// Adjust a CounterData count to be commensurate with
|
|
|
|
// interpreter_invocation_count. If the MDO exists for
|
|
|
|
// only 25% of the time the method exists, then the
|
|
|
|
// counts in the MDO should be scaled by 4X, so that
|
|
|
|
// they can be usefully and stably compared against the
|
|
|
|
// invocation counts in methods.
|
|
|
|
int ciMethod::scale_count(int count, float prof_factor) {
|
|
|
|
if (count > 0 && method_data() != NULL) {
|
2010-09-03 17:51:07 -07:00
|
|
|
int counter_life;
|
2007-12-01 00:00:00 +00:00
|
|
|
int method_life = interpreter_invocation_count();
|
2010-09-03 17:51:07 -07:00
|
|
|
if (TieredCompilation) {
|
|
|
|
// In tiered the MDO's life is measured directly, so just use the snapshotted counters
|
|
|
|
counter_life = MAX2(method_data()->invocation_count(), method_data()->backedge_count());
|
|
|
|
} else {
|
|
|
|
int current_mileage = method_data()->current_mileage();
|
|
|
|
int creation_mileage = method_data()->creation_mileage();
|
|
|
|
counter_life = current_mileage - creation_mileage;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// counter_life due to backedge_counter could be > method_life
|
|
|
|
if (counter_life > method_life)
|
|
|
|
counter_life = method_life;
|
|
|
|
if (0 < counter_life && counter_life <= method_life) {
|
|
|
|
count = (int)((double)count * prof_factor * method_life / counter_life + 0.5);
|
|
|
|
count = (count > 0) ? count : 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2013-03-25 17:13:26 -07:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::is_special_get_caller_class_method
|
|
|
|
//
|
|
|
|
bool ciMethod::is_ignored_by_security_stack_walk() const {
|
|
|
|
check_is_loaded();
|
|
|
|
VM_ENTRY_MARK;
|
|
|
|
return get_Method()->is_ignored_by_security_stack_walk();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-08 10:56:49 -07:00
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// invokedynamic support
|
2010-05-21 02:59:24 -07:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
2012-07-24 10:51:00 -07:00
|
|
|
// ciMethod::is_method_handle_intrinsic
|
2009-04-08 10:56:49 -07:00
|
|
|
//
|
2012-07-24 10:51:00 -07:00
|
|
|
// Return true if the method is an instance of the JVM-generated
|
|
|
|
// signature-polymorphic MethodHandle methods, _invokeBasic, _linkToVirtual, etc.
|
|
|
|
bool ciMethod::is_method_handle_intrinsic() const {
|
|
|
|
vmIntrinsics::ID iid = _intrinsic_id; // do not check if loaded
|
|
|
|
return (MethodHandles::is_signature_polymorphic(iid) &&
|
|
|
|
MethodHandles::is_signature_polymorphic_intrinsic(iid));
|
2009-04-08 10:56:49 -07:00
|
|
|
}
|
|
|
|
|
2010-05-21 02:59:24 -07:00
|
|
|
// ------------------------------------------------------------------
|
2012-07-24 10:51:00 -07:00
|
|
|
// ciMethod::is_compiled_lambda_form
|
2010-05-21 02:59:24 -07:00
|
|
|
//
|
|
|
|
// Return true if the method is a generated MethodHandle adapter.
|
2012-07-24 10:51:00 -07:00
|
|
|
// These are built by Java code.
|
|
|
|
bool ciMethod::is_compiled_lambda_form() const {
|
|
|
|
vmIntrinsics::ID iid = _intrinsic_id; // do not check if loaded
|
|
|
|
return iid == vmIntrinsics::_compiledLambdaForm;
|
2010-01-08 11:09:46 +01:00
|
|
|
}
|
|
|
|
|
2012-07-24 10:51:00 -07:00
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::has_member_arg
|
|
|
|
//
|
|
|
|
// Return true if the method is a linker intrinsic like _linkToVirtual.
|
|
|
|
// These are built by the JVM.
|
|
|
|
bool ciMethod::has_member_arg() const {
|
|
|
|
vmIntrinsics::ID iid = _intrinsic_id; // do not check if loaded
|
|
|
|
return (MethodHandles::is_signature_polymorphic(iid) &&
|
|
|
|
MethodHandles::has_member_arg(iid));
|
2009-04-08 10:56:49 -07:00
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// ------------------------------------------------------------------
|
2010-12-02 17:21:12 -08:00
|
|
|
// ciMethod::ensure_method_data
|
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
|
|
|
// Generate new MethodData* objects at compile time.
|
2010-12-02 17:21:12 -08:00
|
|
|
// Return true if allocation was successful or no MDO is required.
|
|
|
|
bool ciMethod::ensure_method_data(methodHandle h_m) {
|
2007-12-01 00:00:00 +00:00
|
|
|
EXCEPTION_CONTEXT;
|
2010-12-02 17:21:12 -08:00
|
|
|
if (is_native() || is_abstract() || h_m()->is_accessor()) return true;
|
2007-12-01 00:00:00 +00:00
|
|
|
if (h_m()->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
|
|
|
Method::build_interpreter_method_data(h_m, THREAD);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (HAS_PENDING_EXCEPTION) {
|
|
|
|
CLEAR_PENDING_EXCEPTION;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (h_m()->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
|
|
|
_method_data = CURRENT_ENV->get_method_data(h_m()->method_data());
|
2007-12-01 00:00:00 +00:00
|
|
|
_method_data->load_data();
|
2010-12-02 17:21:12 -08:00
|
|
|
return true;
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
|
|
|
_method_data = CURRENT_ENV->get_empty_methodData();
|
2010-12-02 17:21:12 -08:00
|
|
|
return false;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// public, retroactive version
|
2010-12-02 17:21:12 -08:00
|
|
|
bool ciMethod::ensure_method_data() {
|
|
|
|
bool result = true;
|
2007-12-01 00:00:00 +00:00
|
|
|
if (_method_data == NULL || _method_data->is_empty()) {
|
|
|
|
GUARDED_VM_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
|
|
|
result = ensure_method_data(get_Method());
|
2007-12-01 00:00:00 +00:00
|
|
|
});
|
|
|
|
}
|
2010-12-02 17:21:12 -08:00
|
|
|
return result;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::method_data
|
|
|
|
//
|
|
|
|
ciMethodData* ciMethod::method_data() {
|
|
|
|
if (_method_data != NULL) {
|
|
|
|
return _method_data;
|
|
|
|
}
|
|
|
|
VM_ENTRY_MARK;
|
|
|
|
ciEnv* env = CURRENT_ENV;
|
|
|
|
Thread* my_thread = JavaThread::current();
|
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 h_m(my_thread, get_Method());
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (h_m()->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
|
|
|
_method_data = CURRENT_ENV->get_method_data(h_m()->method_data());
|
2007-12-01 00:00:00 +00:00
|
|
|
_method_data->load_data();
|
|
|
|
} else {
|
|
|
|
_method_data = CURRENT_ENV->get_empty_methodData();
|
|
|
|
}
|
|
|
|
return _method_data;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-12-02 17:21:12 -08:00
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::method_data_or_null
|
|
|
|
// Returns a pointer to ciMethodData if MDO exists on the VM side,
|
|
|
|
// NULL otherwise.
|
|
|
|
ciMethodData* ciMethod::method_data_or_null() {
|
|
|
|
ciMethodData *md = method_data();
|
|
|
|
if (md->is_empty()) return NULL;
|
|
|
|
return md;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2013-04-09 17:17:41 -04:00
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::ensure_method_counters
|
|
|
|
//
|
|
|
|
address ciMethod::ensure_method_counters() {
|
|
|
|
check_is_loaded();
|
|
|
|
VM_ENTRY_MARK;
|
|
|
|
methodHandle mh(THREAD, get_Method());
|
|
|
|
MethodCounters *counter = mh->method_counters();
|
|
|
|
if (counter == NULL) {
|
|
|
|
counter = Method::build_method_counters(mh(), CHECK_AND_CLEAR_NULL);
|
|
|
|
}
|
|
|
|
return (address)counter;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::should_exclude
|
|
|
|
//
|
|
|
|
// Should this method be excluded from compilation?
|
|
|
|
bool ciMethod::should_exclude() {
|
|
|
|
check_is_loaded();
|
|
|
|
VM_ENTRY_MARK;
|
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, get_Method());
|
2007-12-01 00:00:00 +00:00
|
|
|
bool ignore;
|
|
|
|
return CompilerOracle::should_exclude(mh, ignore);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::should_inline
|
|
|
|
//
|
|
|
|
// Should this method be inlined during compilation?
|
|
|
|
bool ciMethod::should_inline() {
|
|
|
|
check_is_loaded();
|
|
|
|
VM_ENTRY_MARK;
|
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, get_Method());
|
2007-12-01 00:00:00 +00:00
|
|
|
return CompilerOracle::should_inline(mh);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::should_not_inline
|
|
|
|
//
|
|
|
|
// Should this method be disallowed from inlining during compilation?
|
|
|
|
bool ciMethod::should_not_inline() {
|
|
|
|
check_is_loaded();
|
|
|
|
VM_ENTRY_MARK;
|
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, get_Method());
|
2007-12-01 00:00:00 +00:00
|
|
|
return CompilerOracle::should_not_inline(mh);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::should_print_assembly
|
|
|
|
//
|
|
|
|
// Should the compiler print the generated code for this method?
|
|
|
|
bool ciMethod::should_print_assembly() {
|
|
|
|
check_is_loaded();
|
|
|
|
VM_ENTRY_MARK;
|
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, get_Method());
|
2007-12-01 00:00:00 +00:00
|
|
|
return CompilerOracle::should_print(mh);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::break_at_execute
|
|
|
|
//
|
|
|
|
// Should the compiler insert a breakpoint into the generated code
|
|
|
|
// method?
|
|
|
|
bool ciMethod::break_at_execute() {
|
|
|
|
check_is_loaded();
|
|
|
|
VM_ENTRY_MARK;
|
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, get_Method());
|
2007-12-01 00:00:00 +00:00
|
|
|
return CompilerOracle::should_break_at(mh);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::has_option
|
|
|
|
//
|
|
|
|
bool ciMethod::has_option(const char* option) {
|
|
|
|
check_is_loaded();
|
|
|
|
VM_ENTRY_MARK;
|
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, get_Method());
|
2007-12-01 00:00:00 +00:00
|
|
|
return CompilerOracle::has_option_string(mh, option);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::can_be_compiled
|
|
|
|
//
|
|
|
|
// Have previous compilations of this method succeeded?
|
|
|
|
bool ciMethod::can_be_compiled() {
|
|
|
|
check_is_loaded();
|
2010-09-03 17:51:07 -07:00
|
|
|
ciEnv* env = CURRENT_ENV;
|
|
|
|
if (is_c1_compile(env->comp_level())) {
|
|
|
|
return _is_c1_compilable;
|
|
|
|
}
|
|
|
|
return _is_c2_compilable;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::set_not_compilable
|
|
|
|
//
|
|
|
|
// Tell the VM that this method cannot be compiled at all.
|
2013-02-05 08:25:51 -08:00
|
|
|
void ciMethod::set_not_compilable(const char* reason) {
|
2007-12-01 00:00:00 +00:00
|
|
|
check_is_loaded();
|
|
|
|
VM_ENTRY_MARK;
|
2010-09-03 17:51:07 -07:00
|
|
|
ciEnv* env = CURRENT_ENV;
|
|
|
|
if (is_c1_compile(env->comp_level())) {
|
|
|
|
_is_c1_compilable = false;
|
|
|
|
} else {
|
|
|
|
_is_c2_compilable = false;
|
|
|
|
}
|
2013-02-05 08:25:51 -08:00
|
|
|
get_Method()->set_not_compilable(env->comp_level(), true, reason);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::can_be_osr_compiled
|
|
|
|
//
|
|
|
|
// Have previous compilations of this method succeeded?
|
|
|
|
//
|
|
|
|
// Implementation note: the VM does not currently keep track
|
|
|
|
// of failed OSR compilations per bci. The entry_bci parameter
|
|
|
|
// is currently unused.
|
|
|
|
bool ciMethod::can_be_osr_compiled(int entry_bci) {
|
|
|
|
check_is_loaded();
|
|
|
|
VM_ENTRY_MARK;
|
2010-09-03 17:51:07 -07:00
|
|
|
ciEnv* env = CURRENT_ENV;
|
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 !get_Method()->is_not_osr_compilable(env->comp_level());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::has_compiled_code
|
|
|
|
bool ciMethod::has_compiled_code() {
|
2012-11-12 14:03:53 -08:00
|
|
|
return instructions_size() > 0;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2010-09-03 17:51:07 -07:00
|
|
|
int ciMethod::comp_level() {
|
|
|
|
check_is_loaded();
|
|
|
|
VM_ENTRY_MARK;
|
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
|
|
|
nmethod* nm = get_Method()->code();
|
2010-09-03 17:51:07 -07:00
|
|
|
if (nm != NULL) return nm->comp_level();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-07-01 10:37:37 -07:00
|
|
|
int ciMethod::highest_osr_comp_level() {
|
|
|
|
check_is_loaded();
|
|
|
|
VM_ENTRY_MARK;
|
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 get_Method()->highest_osr_comp_level();
|
2011-07-01 10:37:37 -07:00
|
|
|
}
|
|
|
|
|
2011-08-31 01:40:45 -07:00
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::code_size_for_inlining
|
|
|
|
//
|
2012-07-24 10:51:00 -07:00
|
|
|
// Code size for inlining decisions. This method returns a code
|
|
|
|
// size of 1 for methods which has the ForceInline annotation.
|
2011-08-31 01:40:45 -07:00
|
|
|
int ciMethod::code_size_for_inlining() {
|
|
|
|
check_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
|
|
|
if (get_Method()->force_inline()) {
|
2012-07-24 10:51:00 -07:00
|
|
|
return 1;
|
2011-08-31 01:40:45 -07:00
|
|
|
}
|
|
|
|
return code_size();
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::instructions_size
|
2010-08-25 05:27:54 -07:00
|
|
|
//
|
|
|
|
// This is a rough metric for "fat" methods, compared before inlining
|
|
|
|
// with InlineSmallCode. The CodeBlob::code_size accessor includes
|
|
|
|
// junk like exception handler, stubs, and constant table, which are
|
|
|
|
// not highly relevant to an inlined method. So we use the more
|
|
|
|
// specific accessor nmethod::insts_size.
|
2012-11-12 14:03:53 -08:00
|
|
|
int ciMethod::instructions_size() {
|
|
|
|
if (_instructions_size == -1) {
|
|
|
|
GUARDED_VM_ENTRY(
|
|
|
|
nmethod* code = get_Method()->code();
|
|
|
|
if (code != NULL && (code->comp_level() == CompLevel_full_optimization)) {
|
|
|
|
_instructions_size = code->insts_end() - code->verified_entry_point();
|
|
|
|
} else {
|
|
|
|
_instructions_size = 0;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return _instructions_size;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::log_nmethod_identity
|
|
|
|
void ciMethod::log_nmethod_identity(xmlStream* log) {
|
|
|
|
GUARDED_VM_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
|
|
|
nmethod* code = get_Method()->code();
|
2007-12-01 00:00:00 +00:00
|
|
|
if (code != NULL) {
|
|
|
|
code->log_identity(log);
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::is_not_reached
|
|
|
|
bool ciMethod::is_not_reached(int bci) {
|
|
|
|
check_is_loaded();
|
|
|
|
VM_ENTRY_MARK;
|
|
|
|
return Interpreter::is_not_reached(
|
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(THREAD, get_Method()), bci);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::was_never_executed
|
|
|
|
bool ciMethod::was_executed_more_than(int times) {
|
|
|
|
VM_ENTRY_MARK;
|
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 get_Method()->was_executed_more_than(times);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::has_unloaded_classes_in_signature
|
|
|
|
bool ciMethod::has_unloaded_classes_in_signature() {
|
|
|
|
VM_ENTRY_MARK;
|
|
|
|
{
|
|
|
|
EXCEPTION_MARK;
|
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 m(THREAD, get_Method());
|
|
|
|
bool has_unloaded = Method::has_unloaded_classes_in_signature(m, (JavaThread *)THREAD);
|
2007-12-01 00:00:00 +00:00
|
|
|
if( HAS_PENDING_EXCEPTION ) {
|
|
|
|
CLEAR_PENDING_EXCEPTION;
|
|
|
|
return true; // Declare that we may have unloaded classes
|
|
|
|
}
|
|
|
|
return has_unloaded;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::is_klass_loaded
|
|
|
|
bool ciMethod::is_klass_loaded(int refinfo_index, bool must_be_resolved) const {
|
|
|
|
VM_ENTRY_MARK;
|
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 get_Method()->is_klass_loaded(refinfo_index, must_be_resolved);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::check_call
|
|
|
|
bool ciMethod::check_call(int refinfo_index, bool is_static) const {
|
|
|
|
VM_ENTRY_MARK;
|
|
|
|
{
|
|
|
|
EXCEPTION_MARK;
|
|
|
|
HandleMark hm(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
|
|
|
constantPoolHandle pool (THREAD, get_Method()->constants());
|
2007-12-01 00:00:00 +00:00
|
|
|
methodHandle spec_method;
|
|
|
|
KlassHandle spec_klass;
|
2012-07-24 10:51:00 -07:00
|
|
|
Bytecodes::Code code = (is_static ? Bytecodes::_invokestatic : Bytecodes::_invokevirtual);
|
|
|
|
LinkResolver::resolve_method_statically(spec_method, spec_klass, code, pool, refinfo_index, THREAD);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (HAS_PENDING_EXCEPTION) {
|
|
|
|
CLEAR_PENDING_EXCEPTION;
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return (spec_method->is_static() == is_static);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::print_codes
|
|
|
|
//
|
|
|
|
// Print the bytecodes for this method.
|
|
|
|
void ciMethod::print_codes_on(outputStream* st) {
|
|
|
|
check_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
|
|
|
GUARDED_VM_ENTRY(get_Method()->print_codes_on(st);)
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define FETCH_FLAG_FROM_VM(flag_accessor) { \
|
|
|
|
check_is_loaded(); \
|
|
|
|
VM_ENTRY_MARK; \
|
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 get_Method()->flag_accessor(); \
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ciMethod::is_empty_method() const { FETCH_FLAG_FROM_VM(is_empty_method); }
|
|
|
|
bool ciMethod::is_vanilla_constructor() const { FETCH_FLAG_FROM_VM(is_vanilla_constructor); }
|
|
|
|
bool ciMethod::has_loops () const { FETCH_FLAG_FROM_VM(has_loops); }
|
|
|
|
bool ciMethod::has_jsrs () const { FETCH_FLAG_FROM_VM(has_jsrs); }
|
|
|
|
bool ciMethod::is_accessor () const { FETCH_FLAG_FROM_VM(is_accessor); }
|
|
|
|
bool ciMethod::is_initializer () const { FETCH_FLAG_FROM_VM(is_initializer); }
|
|
|
|
|
|
|
|
BCEscapeAnalyzer *ciMethod::get_bcea() {
|
2010-07-14 14:47:34 -07:00
|
|
|
#ifdef COMPILER2
|
2007-12-01 00:00:00 +00:00
|
|
|
if (_bcea == NULL) {
|
|
|
|
_bcea = new (CURRENT_ENV->arena()) BCEscapeAnalyzer(this, NULL);
|
|
|
|
}
|
|
|
|
return _bcea;
|
2010-07-14 14:47:34 -07:00
|
|
|
#else // COMPILER2
|
|
|
|
ShouldNotReachHere();
|
|
|
|
return NULL;
|
|
|
|
#endif // COMPILER2
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ciMethodBlocks *ciMethod::get_method_blocks() {
|
|
|
|
Arena *arena = CURRENT_ENV->arena();
|
|
|
|
if (_method_blocks == NULL) {
|
|
|
|
_method_blocks = new (arena) ciMethodBlocks(arena, this);
|
|
|
|
}
|
|
|
|
return _method_blocks;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef FETCH_FLAG_FROM_VM
|
|
|
|
|
2012-11-12 14:03:53 -08:00
|
|
|
void ciMethod::dump_replay_data(outputStream* st) {
|
|
|
|
ASSERT_IN_VM;
|
2013-02-01 02:50:23 -08:00
|
|
|
ResourceMark rm;
|
2012-11-12 14:03:53 -08:00
|
|
|
Method* method = get_Method();
|
2013-04-09 17:17:41 -04:00
|
|
|
MethodCounters* mcs = method->method_counters();
|
2012-11-12 14:03:53 -08:00
|
|
|
Klass* holder = method->method_holder();
|
|
|
|
st->print_cr("ciMethod %s %s %s %d %d %d %d %d",
|
|
|
|
holder->name()->as_quoted_ascii(),
|
|
|
|
method->name()->as_quoted_ascii(),
|
|
|
|
method->signature()->as_quoted_ascii(),
|
2013-04-09 17:17:41 -04:00
|
|
|
mcs == NULL ? 0 : mcs->invocation_counter()->raw_counter(),
|
|
|
|
mcs == NULL ? 0 : mcs->backedge_counter()->raw_counter(),
|
2012-11-12 14:03:53 -08:00
|
|
|
interpreter_invocation_count(),
|
|
|
|
interpreter_throwout_count(),
|
|
|
|
_instructions_size);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::print_codes
|
|
|
|
//
|
|
|
|
// Print a range of the bytecodes for this method.
|
|
|
|
void ciMethod::print_codes_on(int from, int to, outputStream* st) {
|
|
|
|
check_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
|
|
|
GUARDED_VM_ENTRY(get_Method()->print_codes_on(from, to, st);)
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::print_name
|
|
|
|
//
|
|
|
|
// Print the name of this method, including signature and some flags.
|
|
|
|
void ciMethod::print_name(outputStream* st) {
|
|
|
|
check_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
|
|
|
GUARDED_VM_ENTRY(get_Method()->print_name(st);)
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::print_short_name
|
|
|
|
//
|
|
|
|
// Print the name of this method, without signature.
|
|
|
|
void ciMethod::print_short_name(outputStream* st) {
|
2012-07-24 10:51:00 -07:00
|
|
|
if (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
|
|
|
GUARDED_VM_ENTRY(get_Method()->print_short_name(st););
|
2012-07-24 10:51:00 -07:00
|
|
|
} else {
|
|
|
|
// Fall back if method is not loaded.
|
|
|
|
holder()->print_name_on(st);
|
|
|
|
st->print("::");
|
|
|
|
name()->print_symbol_on(st);
|
|
|
|
if (WizardMode)
|
|
|
|
signature()->as_symbol()->print_symbol_on(st);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciMethod::print_impl
|
|
|
|
//
|
|
|
|
// Implementation of the print method.
|
|
|
|
void ciMethod::print_impl(outputStream* 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
|
|
|
ciMetadata::print_impl(st);
|
2007-12-01 00:00:00 +00:00
|
|
|
st->print(" name=");
|
|
|
|
name()->print_symbol_on(st);
|
|
|
|
st->print(" holder=");
|
|
|
|
holder()->print_name_on(st);
|
|
|
|
st->print(" signature=");
|
|
|
|
signature()->as_symbol()->print_symbol_on(st);
|
|
|
|
if (is_loaded()) {
|
2012-08-28 15:24:39 -07:00
|
|
|
st->print(" loaded=true");
|
|
|
|
st->print(" arg_size=%d", arg_size());
|
|
|
|
st->print(" flags=");
|
2007-12-01 00:00:00 +00:00
|
|
|
flags().print_member_flags(st);
|
|
|
|
} else {
|
|
|
|
st->print(" loaded=false");
|
|
|
|
}
|
|
|
|
}
|