ciEnv.cpp revision 1142
0N/A * Copyright 1999-2009 Sun Microsystems, Inc. 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. 0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * have any questions. 0N/A#
include "incls/_precompiled.incl" 0N/A// This class is the top level broker for requests from the compiler 0N/A// ------------------------------------------------------------------ 0N/A // Set up ciEnv::current immediately, for the sake of ciObjectFactory, etc. 0N/A#
endif /* !PRODUCT */ 0N/A // Temporary buffer for creating symbols and such. 0N/A // Preload commonly referenced system ciObjects. 0N/A // During VM initialization, these instances have not yet been created. // Assertions ensure that these instances are not accessed before assert(o !=
NULL,
"should have been initialized");
assert(o !=
NULL,
"should have been initialized");
// Set up ciEnv::current immediately, for the sake of ciObjectFactory, etc. // Temporary buffer for creating symbols and such. // Preload commonly referenced system ciObjects. // During VM initialization, these instances have not yet been created. // Assertions ensure that these instances are not accessed before assert(o !=
NULL,
"should have been initialized");
assert(o !=
NULL,
"should have been initialized");
// ------------------------------------------------------------------ // Get Jvmti capabilities under lock to get consistant values. // ------------------------------------------------------------------ // ------------------------------------------------------------------ // helper for lazy exception creation // Cf. universe.cpp, creation of Universe::_null_ptr_exception_instance. // ------------------------------------------------------------------ // ciEnv::ArrayIndexOutOfBoundsException_instance, etc. // ------------------------------------------------------------------ // ciEnv::get_method_from_handle // ------------------------------------------------------------------ for (
int i = 0; i <
length; i++) {
// ------------------------------------------------------------------ // ciEnv::array_element_offset_in_bytes for (
int i = 0; i <
length; i++) {
if (a->
obj_at(i) == o)
return i;
// ------------------------------------------------------------------ // ciEnv::check_klass_accessiblity // Note: the logic of this method should mirror the logic of // constantPoolOopDesc::verify_constant_pool_resolve. // Find the element klass, if this is an array. // ------------------------------------------------------------------ // ciEnv::get_klass_by_name_impl // Now we need to check the SystemDictionary // This is a name from a signature. Strip off the trimmings. // Check for prior unloaded klass. The SystemDictionary's answers // can vary over time but the compiler needs consistency. // setup up the proper type to return on OOM // Found it. Build a CI handle. // If we fail to find an array klass, look again for its element type. // The element type may be available either locally or via constraints. // In either case, if we can find the element type in the system dictionary, // we must build an array type around it. The CI requires array klasses // to be loaded if their element klasses are loaded, except when memory // We have an unloaded array. // Build it on the fly if the element class exists. // Get element ciKlass recursively. // Now make an array for it // Not yet loaded into the VM, or not governed by loader constraints. // Make a CI representative for it. // ------------------------------------------------------------------ // ciEnv::get_klass_by_name // ------------------------------------------------------------------ // ciEnv::get_klass_by_index_impl // Implementation of get_klass_by_index. // The klass has not been inserted into the constant pool. // Try to look it up by name. // We have to lock the cpool to keep the oop from being resolved // while we are accessing it. // The klass has been inserted into the constant pool // Not found in constant pool. Use the name to do the lookup. // Calculate accessibility the hard way. // Loaded only remotely. Not linked yet. // Check for prior unloaded klass. The SystemDictionary's answers // can vary over time but the compiler needs consistency. // It is known to be accessible, since it was found in the constant pool. // ------------------------------------------------------------------ // ciEnv::get_klass_by_index // Get a klass from the constant pool. // ------------------------------------------------------------------ // ciEnv::get_constant_by_index_impl // Implementation of get_constant_by_index(). // 4881222: allow ldc to take a class type "must be an instance or array klass ");
// ------------------------------------------------------------------ // ciEnv::is_unresolved_string_impl // Implementation of is_unresolved_string(). // ------------------------------------------------------------------ // ciEnv::is_unresolved_klass_impl // Implementation of is_unresolved_klass(). // ------------------------------------------------------------------ // ciEnv::get_constant_by_index // Pull a constant out of the constant pool. How appropriate. // Implementation note: this query is currently in no way cached. // ------------------------------------------------------------------ // ciEnv::is_unresolved_string // Implementation note: this query is currently in no way cached. // ------------------------------------------------------------------ // ciEnv::is_unresolved_klass // Implementation note: this query is currently in no way cached. // ------------------------------------------------------------------ // ciEnv::get_field_by_index_impl // Implementation of get_field_by_index. // Implementation note: the results of field lookups are cached // in the accessor klass. // ------------------------------------------------------------------ // ciEnv::get_field_by_index // Get a field by index from a klass's constant pool. // ------------------------------------------------------------------ // Perform an appropriate method lookup based on accessor, holder, // name, signature, and bytecode. // ------------------------------------------------------------------ // ciEnv::get_method_by_index_impl // Get the method's name and signature. // Either the declared holder was not loaded, or the method could // not be found. Create a dummy ciMethod to represent the failed // ------------------------------------------------------------------ // ciEnv::get_fake_invokedynamic_method_impl // Get the CallSite from the constant pool cache. // Call site might not be linked yet. // Get the methodOop from the CallSite. // ------------------------------------------------------------------ // ciEnv::get_instance_klass_for_declared_method_holder // For the case of <array>.clone(), the method holder can be a ciArrayKlass // instead of a ciInstanceKlass. For that case simply pretend that the // declared holder is Object.clone since that's where the call will bottom out. // A more correct fix would trickle out through many interfaces in CI, // requiring ciInstanceKlass* to become ciKlass* and many more places would // require checks to make sure the expected type was found. Given that this // only occurs for clone() the more extensive fix seems like overkill so // instead we simply smear the array type into Object. // ------------------------------------------------------------------ // ciEnv::get_method_by_index // ------------------------------------------------------------------ // ------------------------------------------------------------------ // ------------------------------------------------------------------ // ciEnv::check_for_system_dictionary_modification // Check for changes to the system dictionary during compilation // class loads, evolution, breakpoints if (
failing())
return;
// no need for further checks // Dependencies must be checked when the system dictionary changes. // If logging is enabled all violated dependences will be recorded in // the log. In debug mode check dependencies even if the system // dictionary hasn't changed to verify that no invalid dependencies // were inserted. Any violated dependences in this case are dumped to // If there's no log and we're not sanity-checking, we're done. // ------------------------------------------------------------------ // ciEnv::register_method // To prevent compile queue updates. // Prevent SystemDictionary::add_to_hierarchy from running // and invalidating our dependencies until we install this method. // Change in Jvmti state may invalidate compilation. // Change in DTrace flags may invalidate compilation. // Log the dependencies which this compilation declares. // Encode the dependencies now, so we can check them right away. // Check for {class loads, evolution, breakpoints} during compilation // While not a true deoptimization, it is a preemptive decompile. // All buffers in the CodeBuffer are allocated in the CodeCache. // If the code buffer is created on each compile attempt // as in C2, then it must be freed. // stress test 6243940 by immediately making the method // non-entrant behind the system's back. This has serious // side effects on the code cache and is not meant for // general stress testing // The CodeCache is full. Print out warning and disable compilation. warning(
"CodeCache is full. Compiler has been disabled");
// Record successful registration. // (Put nm into the task handle *before* publishing to the Java heap.) // If there is an old version we're done with it // Allow the code to be executed // JVMTI -- compiled method notification (must be done outside lock) // ------------------------------------------------------------------ // ciEnv::find_system_klass // ------------------------------------------------------------------ // ------------------------------------------------------------------ // ------------------------------------------------------------------ // ciEnv::notice_inlined_method() // ------------------------------------------------------------------ // ciEnv::num_inlined_bytecodes() // ------------------------------------------------------------------ // ciEnv::record_failure() // Record the first failure reason. // ------------------------------------------------------------------ // ciEnv::record_method_not_compilable() // Only note transitions to a worse state log()->
elem(
"method_not_compilable");
log()->
elem(
"method_not_compilable_at_tier");
// Reset failure reason; this one is more important. // ------------------------------------------------------------------ // ciEnv::record_out_of_memory_failure() // If memory is low, we stop compiling methods.