ciObjectFactory.cpp revision 196
196N/A * Copyright 1999-2008 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 handles requests for the creation of new instances 0N/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 0N/A// problematic the underlying data structure can be switched to some 0N/A// sort of balanced binary tree. 0N/A// ------------------------------------------------------------------ 0N/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. 0N/A // Create the shared symbols, but not in _shared_ci_objects. 0N/A // Create dummy instanceKlass and objArrayKlass object and assign them idents 0N/A // The shared_ident_limit is the first ident number that will 0N/A // be used for non-shared objects. That is, numbers less than 0N/A // this limit are permanently assigned to shared CI objects, 0N/A // while the higher numbers are recycled afresh by each new ciEnv. 0N/A// ------------------------------------------------------------------ 0N/A// ciObjectFactory::get 0N/A// Get the ciObject corresponding to some oop. If the ciObject has 0N/A// already been created, it is returned. Otherwise, a new ciObject 0N/A // Check in the non-perm area before putting it in the list. 0N/A // Check in the shared symbol area before putting it in the list. 0N/A // do not pollute the main cache with it 0N/A // The ciObject does not yet exist. Create it and insert it 0N/A // Not a perm-space object. 0N/A // creating the new object has recursively entered new objects 0N/A // into the table. We need to recompute our index. 0N/A// ------------------------------------------------------------------ 0N/A// ciObjectFactory::create_new_object 0N/A// Create a new ciObject from an oop. 0N/A// Implementation note: this functionality could be virtual behavior 0N/A// of the oop itself. For now, we explicitly marshal the object. 0N/A // The oop is of some type not supported by the compiler interface. 0N/A//------------------------------------------------------------------ 0N/A// ciObjectFactory::get_unloaded_method 0N/A// Implementation note: unloaded methods are currently stored in 0N/A// an unordered array, requiring a linear-time lookup for each 0N/A// unloaded method. This may need to change. 0N/A // We've found a match. 0N/A // This is a new unloaded method. Create it and stick it in 0N/A//------------------------------------------------------------------ 0N/A// ciObjectFactory::get_unloaded_klass 0N/A// Get a ciKlass representing an unloaded klass. 0N/A// Implementation note: unloaded klasses are currently stored in 0N/A// an unordered array, requiring a linear-time lookup for each 0N/A// unloaded klass. This may need to change. 0N/A // We've found a match. 0N/A // This is a new unloaded klass. Create it and stick it in 0N/A // Two cases: this is an unloaded objArrayKlass or an 0N/A // unloaded instanceKlass. Deal with both. 0N/A // Decompose the name.' 0N/A // The type array itself takes care of one of the dimensions. 0N/A // The element klass is a typeArrayKlass. 0N/A//------------------------------------------------------------------ 0N/A// ciObjectFactory::get_empty_methodData 0N/A// Get the ciMethodData representing the methodData for a method with 0N/A//------------------------------------------------------------------ 0N/A// ciObjectFactory::get_return_address 0N/A// Get a ciReturnAddress for a specified bci. 0N/A // We've found a match. 0N/A// ------------------------------------------------------------------ 0N/A// ciObjectFactory::init_ident_of 0N/A// ------------------------------------------------------------------ 0N/A// ciObjectFactory::find 0N/A// Use binary search to find the position of this oop in the cache. 0N/A// If there is no entry in the cache corresponding to this oop, return 0N/A// the position at which the oop should be inserted. 0N/A // print_contents(); 0N/A// ------------------------------------------------------------------ 0N/A// ciObjectFactory::is_found_at 0N/A// Verify that the binary seach found the given key. 0N/A// ------------------------------------------------------------------ 0N/A// ciObjectFactory::insert 0N/A// Insert a ciObject into the table at some index. 0N/A// ------------------------------------------------------------------ 0N/A// ciObjectFactory::find_non_perm 0N/A// Use a small hash table, hashed on the klass of the key. 0N/A// If there is no entry in the cache corresponding to this oop, return 0N/A// the null tail of the bucket into which the oop should be inserted. 0N/A // Be careful: is_perm might change from false to true. 0N/A // Thus, there might be a matching perm object in the table. 0N/A // If there is, this probe must find it. 0N/A // class mirror instances are always perm 0N/A // fall through to probe 0N/A // fall through to probe 0N/A // not an array or instance 0N/A// ------------------------------------------------------------------ 0N/A// Code for for NonPermObject 0N/A// ------------------------------------------------------------------ 0N/A// ciObjectFactory::insert_non_perm 0N/A// Insert a ciObject into the non-perm table. 0N/A// ------------------------------------------------------------------ 0N/A// ciObjectFactory::vm_symbol_at 0N/A// Get the ciSymbol corresponding to some index in vmSymbols. 0N/A// ------------------------------------------------------------------ 0N/A// ciObjectFactory::print_contents_impl 0N/A// ------------------------------------------------------------------ 0N/A// ciObjectFactory::print_contents 0N/A// ------------------------------------------------------------------ 0N/A// ciObjectFactory::print 0N/A// Print debugging information about the object factory 0N/A tty->
print(
"<ciObjectFactory oops=%d unloaded_methods=%d unloaded_klasses=%d>",