src/share/vm/ci/ciSignature.cpp

Sat, 01 Dec 2007 00:00:00 +0000

author
duke
date
Sat, 01 Dec 2007 00:00:00 +0000
changeset 435
a61af66fc99e
child 1907
c18cbe5936b8
permissions
-rw-r--r--

Initial load

duke@435 1 /*
duke@435 2 * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 #include "incls/_precompiled.incl"
duke@435 26 #include "incls/_ciSignature.cpp.incl"
duke@435 27
duke@435 28 // ciSignature
duke@435 29 //
duke@435 30 // This class represents the signature of a method.
duke@435 31
duke@435 32 // ------------------------------------------------------------------
duke@435 33 // ciSignature::ciSignature
duke@435 34 ciSignature::ciSignature(ciKlass* accessing_klass, ciSymbol* symbol) {
duke@435 35 ASSERT_IN_VM;
duke@435 36 EXCEPTION_CONTEXT;
duke@435 37 _accessing_klass = accessing_klass;
duke@435 38 _symbol = symbol;
duke@435 39
duke@435 40 ciEnv* env = CURRENT_ENV;
duke@435 41 Arena* arena = env->arena();
duke@435 42 _types = new (arena) GrowableArray<ciType*>(arena, 8, 0, NULL);
duke@435 43
duke@435 44 int size = 0;
duke@435 45 int count = 0;
duke@435 46 symbolHandle sh (THREAD, symbol->get_symbolOop());
duke@435 47 SignatureStream ss(sh);
duke@435 48 for (; ; ss.next()) {
duke@435 49 // Process one element of the signature
duke@435 50 ciType* type;
duke@435 51 if (!ss.is_object()) {
duke@435 52 type = ciType::make(ss.type());
duke@435 53 } else {
duke@435 54 symbolOop name = ss.as_symbol(THREAD);
duke@435 55 if (HAS_PENDING_EXCEPTION) {
duke@435 56 type = ss.is_array() ? (ciType*)ciEnv::unloaded_ciobjarrayklass()
duke@435 57 : (ciType*)ciEnv::unloaded_ciinstance_klass();
duke@435 58 env->record_out_of_memory_failure();
duke@435 59 CLEAR_PENDING_EXCEPTION;
duke@435 60 } else {
duke@435 61 ciSymbol* klass_name = env->get_object(name)->as_symbol();
duke@435 62 type = env->get_klass_by_name_impl(_accessing_klass, klass_name, false);
duke@435 63 }
duke@435 64 }
duke@435 65 _types->append(type);
duke@435 66 if (ss.at_return_type()) {
duke@435 67 // Done processing the return type; do not add it into the count.
duke@435 68 break;
duke@435 69 }
duke@435 70 size += type->size();
duke@435 71 count++;
duke@435 72 }
duke@435 73 _size = size;
duke@435 74 _count = count;
duke@435 75 }
duke@435 76
duke@435 77 // ------------------------------------------------------------------
duke@435 78 // ciSignature::return_ciType
duke@435 79 //
duke@435 80 // What is the return type of this signature?
duke@435 81 ciType* ciSignature::return_type() const {
duke@435 82 return _types->at(_count);
duke@435 83 }
duke@435 84
duke@435 85 // ------------------------------------------------------------------
duke@435 86 // ciSignature::ciType_at
duke@435 87 //
duke@435 88 // What is the type of the index'th element of this
duke@435 89 // signature?
duke@435 90 ciType* ciSignature::type_at(int index) const {
duke@435 91 assert(index < _count, "out of bounds");
duke@435 92 // The first _klasses element holds the return klass.
duke@435 93 return _types->at(index);
duke@435 94 }
duke@435 95
duke@435 96 // ------------------------------------------------------------------
duke@435 97 // ciSignature::print_signature
duke@435 98 void ciSignature::print_signature() {
duke@435 99 _symbol->print_symbol();
duke@435 100 }
duke@435 101
duke@435 102 // ------------------------------------------------------------------
duke@435 103 // ciSignature::print
duke@435 104 void ciSignature::print() {
duke@435 105 tty->print("<ciSignature symbol=");
duke@435 106 print_signature();
duke@435 107 tty->print(" accessing_klass=");
duke@435 108 _accessing_klass->print();
duke@435 109 tty->print(" address=0x%x>", (address)this);
duke@435 110 }

mercurial