key.cpp

Go to the documentation of this file.
00001 /* Copyright 1994, 1995 LongView Technologies L.L.C. $Revision: 1.30 $ */
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/_key.cpp.incl"
00026 
00027 int LookupKey::hash() const {
00028   return klass()->identity_hash() ^ selector_or_method()->identity_hash();
00029 }
00030 
00031 void LookupKey::relocate() {
00032   RELOCATE_TEMPLATE(&_klass);
00033   RELOCATE_TEMPLATE(&_selector_or_method);
00034 }
00035 
00036 symbolOop LookupKey::selector() const {
00037   if (is_normal_type()) {
00038     return symbolOop(selector_or_method());
00039   } else {
00040     return method()->selector();
00041   }
00042 }
00043 
00044 bool LookupKey::verify() const {
00045   bool flag = true;
00046   if (!klass()->is_klass()) {
00047     error("klass %#lx isn't a klass", klass());
00048     flag = false;
00049   }
00050   if (!selector_or_method()->is_symbol() && !selector_or_method()->is_method()) {
00051     lprintf("\tin selector_or_method of LookupKey %#lx\n", this);
00052     flag = false;
00053   }
00054   return flag;
00055 }
00056 
00057 
00058 void LookupKey::switch_pointers(oop from, oop to) {
00059   SWITCH_POINTERS_TEMPLATE(&_klass);
00060   SWITCH_POINTERS_TEMPLATE(&_selector_or_method);
00061 }
00062 
00063 void LookupKey::oops_do(void f(oop*)) {
00064   f((oop*) &_klass);
00065   f((oop*) &_selector_or_method);
00066 }
00067 
00068 void LookupKey::print_on(outputStream* st) const {
00069   print_inlining_database_on(st);
00070 }
00071 
00072 void LookupKey::print_inlining_database_on(outputStream* st) const {
00073   if (klass()) {
00074     klass()->klass_part()->print_name_on(st);
00075   } else {
00076     st->print("NULL");
00077   }
00078   if (is_normal_type()) {
00079     st->print("::");
00080     selector()->print_symbol_on(st);
00081   } else if (is_super_type()) {
00082     st->print("^^");
00083     method()->selector()->print_symbol_on(st);
00084   } else if (is_block_type()) {
00085     st->print("->");
00086     method()->print_inlining_database_on(st);
00087   } else {
00088     ShouldNotReachHere();
00089   }
00090 }
00091 
00092 void LookupKey::print() const {
00093   print_on(std);
00094 }
00095 
00096 char* LookupKey::print_string() const {
00097   stringStream* st = new stringStream(50);
00098   print_on(st);
00099   return st->as_string();
00100 }
00101 
00102 LookupKey* LookupKey::allocate(klassOop klass, oop selector_or_method) {
00103   LookupKey* result = NEW_RESOURCE_OBJ(LookupKey);
00104   result->initialize(klass, selector_or_method);
00105   return result;
00106 }
00107 

Generated on Mon Oct 9 13:37:12 2006 for Strongtalk VM by  doxygen 1.4.7