ciObjectFactory.cpp revision 1138
3879N/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. 1472N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1472N/A * CA 95054 USA or visit www.sun.com if you need additional information or 1879N/A#
include "incls/_precompiled.incl" 1879N/A// This class handles requests for the creation of new instances 1879N/A// of ciObject and its subclasses. It contains a caching mechanism 0N/A// which ensures that for each oop, at most one ciObject is created. 0N/A// This invariant allows more efficient implementation of ciObject. 0N/A// Implementation note: the oop->ciObject mapping is represented as 0N/A// a table stored in an array. Even though objects are moved 0N/A// by the garbage collector, the compactor preserves their relative 0N/A// order; address comparison of oops (in perm space) is safe so long 0N/A// as we prohibit GC during our comparisons. We currently use binary 0N/A// search to find the oop in the table, and inserting a new oop 0N/A// into the table may be costly. If this cost ends up being 518N/A// problematic the underlying data structure can be switched to some 518N/A// sort of balanced binary tree. 518N/A// ------------------------------------------------------------------ 518N/A// ciObjectFactory::ciObjectFactory 0N/A // If the shared ci objects exist append them to this factory's objects 0N/A// ------------------------------------------------------------------ 0N/A// ciObjectFactory::ciObjectFactory 0N/A // This Arena is long lived and exists in the resource mark of the 0N/A // compiler thread that initializes the initial ciObjectFactory which 0N/A // creates the shared ciObjects that all later ciObjectFactories use. // Create the shared symbols, but not in _shared_ci_objects. // Create dummy instanceKlass and objArrayKlass object and assign them idents // The shared_ident_limit is the first ident number that will // be used for non-shared objects. That is, numbers less than // this limit are permanently assigned to shared CI objects, // while the higher numbers are recycled afresh by each new ciEnv. // ------------------------------------------------------------------ // Get the ciObject corresponding to some oop. If the ciObject has // already been created, it is returned. Otherwise, a new ciObject // Check in the non-perm area before putting it in the list. // Check in the shared symbol area before putting it in the list. // do not pollute the main cache with it // The ciObject does not yet exist. Create it and insert it // Not a perm-space object. // creating the new object has recursively entered new objects // into the table. We need to recompute our index. // ------------------------------------------------------------------ // ciObjectFactory::create_new_object // Create a new ciObject from an oop. // Implementation note: this functionality could be virtual behavior // of the oop itself. For now, we explicitly marshal the object. // The oop is of some type not supported by the compiler interface. //------------------------------------------------------------------ // ciObjectFactory::get_unloaded_method // Implementation note: unloaded methods are currently stored in // an unordered array, requiring a linear-time lookup for each // unloaded method. This may need to change. // This is a new unloaded method. Create it and stick it in //------------------------------------------------------------------ // ciObjectFactory::get_unloaded_klass // Get a ciKlass representing an unloaded klass. // Implementation note: unloaded klasses are currently stored in // an unordered array, requiring a linear-time lookup for each // unloaded klass. This may need to change. // This is a new unloaded klass. Create it and stick it in // Two cases: this is an unloaded objArrayKlass or an // unloaded instanceKlass. Deal with both. // The type array itself takes care of one of the dimensions. // The element klass is a typeArrayKlass. //------------------------------------------------------------------ // ciObjectFactory::get_empty_methodData // Get the ciMethodData representing the methodData for a method with //------------------------------------------------------------------ // ciObjectFactory::get_return_address // Get a ciReturnAddress for a specified bci. // ------------------------------------------------------------------ // ciObjectFactory::init_ident_of // ------------------------------------------------------------------ // Use binary search to find the position of this oop in the cache. // If there is no entry in the cache corresponding to this oop, return // the position at which the oop should be inserted. // ------------------------------------------------------------------ // ciObjectFactory::is_found_at // Verify that the binary seach found the given key. // ------------------------------------------------------------------ // ciObjectFactory::insert // Insert a ciObject into the table at some index. // ------------------------------------------------------------------ // ciObjectFactory::find_non_perm // Use a small hash table, hashed on the klass of the key. // If there is no entry in the cache corresponding to this oop, return // the null tail of the bucket into which the oop should be inserted. // Be careful: is_perm might change from false to true. // Thus, there might be a matching perm object in the table. // If there is, this probe must find it. // class mirror instances are always perm // not an array or instance // ------------------------------------------------------------------ // Code for for NonPermObject // ------------------------------------------------------------------ // ciObjectFactory::insert_non_perm // Insert a ciObject into the non-perm table. // ------------------------------------------------------------------ // ciObjectFactory::vm_symbol_at // Get the ciSymbol corresponding to some index in vmSymbols. // ------------------------------------------------------------------ // ciObjectFactory::print_contents_impl for (
int i=0; i<
len; i++) {
// ------------------------------------------------------------------ // ciObjectFactory::print_contents // ------------------------------------------------------------------ // ciObjectFactory::print // Print debugging information about the object factory tty->
print(
"<ciObjectFactory oops=%d unloaded_methods=%d unloaded_klasses=%d>",