00001 /* Copyright 1994, 1995, LongView Technologies, L.L.C. $Revision: 1.8 $ */ 00002 /* Copyright (c) 2006, Sun Microsystems, Inc. 00003 All rights reserved. 00004 00005 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 00006 following conditions are met: 00007 00008 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 00009 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following 00010 disclaimer in the documentation and/or other materials provided with the distribution. 00011 * Neither the name of Sun Microsystems nor the names of its contributors may be used to endorse or promote products derived 00012 from this software without specific prior written permission. 00013 00014 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 00015 NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 00016 THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00017 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00018 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 00019 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 00020 00021 00022 */ 00023 00024 # include "incls/_precompiled.incl" 00025 # include "incls/_ic_iterator.cpp.incl" 00026 00027 // Implementation of IC 00028 00029 IC::IC(CompiledIC* ic) : _iter(new CompiledIC_Iterator(ic)) {} 00030 IC::IC(InterpretedIC* ic) : _iter(new InterpretedIC_Iterator(ic)) {} 00031 00032 GrowableArray<klassOop>* IC::receiver_klasses() const { 00033 GrowableArray<klassOop>* result = new GrowableArray<klassOop>(); 00034 IC_Iterator* it = iterator(); 00035 it->init_iteration(); 00036 while (!it->at_end()) { 00037 result->append(it->klass()); 00038 it->advance(); 00039 } 00040 return result; 00041 } 00042 00043 00044 void IC::replace(nmethod* nm) { 00045 Unimplemented(); 00046 IC_Iterator* it = iterator(); 00047 it->init_iteration(); 00048 while (!it->at_end()) { 00049 // replace if found 00050 it->advance(); 00051 } 00052 } 00053 00054 00055 void IC::print() { 00056 char* s; 00057 switch (shape()) { 00058 case anamorphic : s = "Anamorphic"; break; 00059 case monomorphic: s = "Monomorphic"; break; 00060 case polymorphic: s = "Polymorphic"; break; 00061 case megamorphic: s = "Megamorphic"; break; 00062 default : ShouldNotReachHere(); 00063 } 00064 std->print("%s IC: %d entries\n", s, number_of_targets()); 00065 00066 IC_Iterator* it = iterator(); 00067 it->init_iteration(); 00068 while (!it->at_end()) { 00069 lprintf("\t- klass: "); 00070 it->klass()->print_value(); 00071 if (it->is_interpreted()) { 00072 lprintf(";\tmethod %#x\n", it->interpreted_method()); 00073 } else { 00074 lprintf(";\tnmethod %#x\n", it->compiled_method()); 00075 } 00076 it->advance(); 00077 } 00078 } 00079 00080 void IC_Iterator::goto_elem(int n) { 00081 init_iteration(); 00082 for (int i = 0; i < n; i++) advance(); 00083 } 00084 00085 methodOop IC_Iterator::interpreted_method(int i) { 00086 goto_elem(i); 00087 return interpreted_method(); 00088 } 00089 00090 nmethod* IC_Iterator::compiled_method(int i) { 00091 goto_elem(i); 00092 return compiled_method(); 00093 } 00094 00095 klassOop IC_Iterator::klass(int i) { 00096 goto_elem(i); 00097 return klass(); 00098 } 00099