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