ciMethod.cpp revision 1703
1472N/A * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A#
include "incls/_precompiled.incl" 0N/A// This class represents a methodOop in the HotSpot virtual 0N/A// ------------------------------------------------------------------ 0N/A// ciMethod::ciMethod 0N/A // These fields are always filled in in loaded methods. 0N/A // Easy to compute, so fill them in now. 0N/A // Lazy fields, filled in on demand. Require allocation. 0N/A#
endif // COMPILER2 || SHARK 0N/A // 6328518 check hotswap conditions under the right lock. 0N/A // Have to use a conservative value in this case. 0N/A // Adjust the definition of this condition to be more useful: 0N/A // %%% take these conditions into account in vtable generation 0N/A // generating _signature may allow GC and therefore move m. 0N/A // These fields are always filled in. 0N/A // Take a snapshot of these values, so they will be commensurate with the MDO. 0N/A // if the value overflowed report it as max int 0N/A// ------------------------------------------------------------------ 0N/A// ciMethod::ciMethod 0N/A // These fields are always filled in. 0N/A#
endif // COMPILER2 || SHARK 0N/A// ------------------------------------------------------------------ 0N/A// ciMethod::load_code 0N/A// Load the bytecodes and exception handler table for this method. 0N/A // Load the bytecodes. 0N/A // Revert any breakpoint bytecodes in ci's copy 0N/A // And load the exception table. 0N/A // Allocate one extra spot in our list of exceptions. This 0N/A // last entry will be used to represent the possibility that 0N/A // an exception escapes the method. See ciExceptionHandlerStream 0N/A // Put an entry at the end of our list to represent the possibility 0N/A // of exceptional exit. 0N/A// ------------------------------------------------------------------ 1410N/A// ciMethod::has_linenumber_table 1410N/A// length unknown until decompression // ------------------------------------------------------------------ // ciMethod::compressed_linenumber_table // ------------------------------------------------------------------ // ciMethod::line_number_from_bci // ------------------------------------------------------------------ // ciMethod::vtable_index // Get the position of this method's entry in the vtable, if any. // ------------------------------------------------------------------ // ciMethod::itable_index // Get the position of this method's entry in the itable, if any. // ------------------------------------------------------------------ // ciMethod::native_entry // Get the address of this method's native code, if any. // ------------------------------------------------------------------ // ciMethod::interpreter_entry // Get the entry point for running this method in the interpreter. // ------------------------------------------------------------------ // ciMethod::uses_balanced_monitors // Does this method use monitors in a strict stack-disciplined manner? // Analyze the method to see if monitors are used properly. // Check to see if a previous compilation computed the // monitor-matching analysis. // ------------------------------------------------------------------ // ciMethod::get_flow_analysis #
else // COMPILER2 || SHARK#
endif // COMPILER2 || SHARK// ------------------------------------------------------------------ // ciMethod::get_osr_flow_analysis // OSR entry points are always place after a call bytecode of some sort #
else // COMPILER2 || SHARK#
endif // COMPILER2 || SHARK// ------------------------------------------------------------------ // ciMethod::raw_liveness_at_bci // Which local variables are live at a specific bci? // Create the liveness analyzer. // ------------------------------------------------------------------ // 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 // Keep all locals live for the user's edification and amusement. // 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. // ------------------------------------------------------------------ // ciMethod::bci_block_start // Marks all bcis where a new basic block starts // Create the liveness analyzer. // ------------------------------------------------------------------ // 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). // Every profiled call site has a counter. }
else {
// ReceiverTypeData is a subclass of CounterData // In addition, virtual call sites have receiver type information // Precompute morphism for the possible fixup // 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. // Add the receiver to result data. // If we extend profiling to record methods, // we will set result._method also. // Determine call site's morphism. // 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. // The morphism <= MorphismLimit. assert(
false,
"this call site should not be polymorphic");
// 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 // ------------------------------------------------------------------ // Add new receiver and sort data by receiver's profile 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. // ------------------------------------------------------------------ // 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. // %%% We cannot trust interface types, yet. See bug 6312651. // Something went wrong looking up the actual receiver method. // Make certain quick checks even if UseCHA is false. // Is it private or final? // 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. // 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. // %%% Should upgrade this ciMethod API to look for 1 or 2 concrete methods. tty->
print(
"found a non-root unique target method");
// 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. // ------------------------------------------------------------------ // 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. // Only do exact lookup if receiver klass has been linked. Otherwise, // the vtable has not been setup, and the LinkResolver will fail. // Return NULL only if there was a problem with lookup (uninitialized class, etc.) // Don't return abstract methods because they aren't // optimizable or interesting. // ------------------------------------------------------------------ // ciMethod::resolve_vtable_index // Given a known receiver klass, find the vtable index for the call. // Return methodOopDesc::invalid_vtable_index if the vtable_index is unknown. // Only do lookup if receiver klass has been linked. Otherwise, // the vtable has not been setup, and the LinkResolver will fail. // A statically bound method. Return "no such index". // ------------------------------------------------------------------ // ciMethod::interpreter_call_site_count // ------------------------------------------------------------------ // 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. // In tiered the MDO's life is measured directly, so just use the snapshotted counters // counter_life due to backedge_counter could be > method_life // ------------------------------------------------------------------ // ------------------------------------------------------------------ // ciMethod::is_method_handle_invoke // Return true if the method is an instance of one of the two // signature-polymorphic MethodHandle methods, invokeExact or invokeGeneric. // ------------------------------------------------------------------ // ciMethod::is_method_handle_adapter // Return true if the method is a generated MethodHandle adapter. // These are built by MethodHandleCompiler. // ------------------------------------------------------------------ // ciMethod::build_method_data // Generate new methodDataOop objects at compile time. // public, retroactive version // ------------------------------------------------------------------ // Create an MDO for the inlinee // ------------------------------------------------------------------ // Will this method link in a specific calling context? // The link checks have been front-loaded into the get_method // call. This method (ciMethod::will_link()) will be removed // ------------------------------------------------------------------ // ciMethod::should_exclude // Should this method be excluded from compilation? // ------------------------------------------------------------------ // ciMethod::should_inline // Should this method be inlined during compilation? // ------------------------------------------------------------------ // ciMethod::should_not_inline // Should this method be disallowed from inlining during compilation? // ------------------------------------------------------------------ // ciMethod::should_print_assembly // Should the compiler print the generated code for this method? // ------------------------------------------------------------------ // ciMethod::break_at_execute // Should the compiler insert a breakpoint into the generated code // ------------------------------------------------------------------ // ------------------------------------------------------------------ // ciMethod::can_be_compiled // Have previous compilations of this method succeeded? // ------------------------------------------------------------------ // ciMethod::set_not_compilable // Tell the VM that this method cannot be compiled at all. // ------------------------------------------------------------------ // 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 // ------------------------------------------------------------------ // ciMethod::has_compiled_code // ------------------------------------------------------------------ // ciMethod::instructions_size // 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. // ------------------------------------------------------------------ // ciMethod::log_nmethod_identity // ------------------------------------------------------------------ // ciMethod::is_not_reached // ------------------------------------------------------------------ // ciMethod::was_never_executed // ------------------------------------------------------------------ // ciMethod::has_unloaded_classes_in_signature return true;
// Declare that we may have unloaded classes // ------------------------------------------------------------------ // ciMethod::is_klass_loaded // ------------------------------------------------------------------ // ------------------------------------------------------------------ // Print the bytecodes for this method. // ------------------------------------------------------------------ // Print a range of the bytecodes for this method. // ------------------------------------------------------------------ // Print the name of this method, including signature and some flags. // ------------------------------------------------------------------ // ciMethod::print_short_name // Print the name of this method, without signature. // ------------------------------------------------------------------ // Implementation of the print method.