src/share/vm/ci/ciSignature.cpp

Tue, 23 Nov 2010 13:22:55 -0800

author
stefank
date
Tue, 23 Nov 2010 13:22:55 -0800
changeset 2314
f95d63e2154a
parent 1907
c18cbe5936b8
child 2497
3582bf76420e
permissions
-rw-r--r--

6989984: Use standard include model for Hospot
Summary: Replaced MakeDeps and the includeDB files with more standardized solutions.
Reviewed-by: coleenp, kvn, kamg

duke@435 1 /*
stefank@2314 2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. 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 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "ci/ciSignature.hpp"
stefank@2314 27 #include "ci/ciUtilities.hpp"
stefank@2314 28 #include "memory/allocation.inline.hpp"
stefank@2314 29 #include "oops/oop.inline.hpp"
stefank@2314 30 #include "runtime/signature.hpp"
duke@435 31
duke@435 32 // ciSignature
duke@435 33 //
duke@435 34 // This class represents the signature of a method.
duke@435 35
duke@435 36 // ------------------------------------------------------------------
duke@435 37 // ciSignature::ciSignature
duke@435 38 ciSignature::ciSignature(ciKlass* accessing_klass, ciSymbol* symbol) {
duke@435 39 ASSERT_IN_VM;
duke@435 40 EXCEPTION_CONTEXT;
duke@435 41 _accessing_klass = accessing_klass;
duke@435 42 _symbol = symbol;
duke@435 43
duke@435 44 ciEnv* env = CURRENT_ENV;
duke@435 45 Arena* arena = env->arena();
duke@435 46 _types = new (arena) GrowableArray<ciType*>(arena, 8, 0, NULL);
duke@435 47
duke@435 48 int size = 0;
duke@435 49 int count = 0;
duke@435 50 symbolHandle sh (THREAD, symbol->get_symbolOop());
duke@435 51 SignatureStream ss(sh);
duke@435 52 for (; ; ss.next()) {
duke@435 53 // Process one element of the signature
duke@435 54 ciType* type;
duke@435 55 if (!ss.is_object()) {
duke@435 56 type = ciType::make(ss.type());
duke@435 57 } else {
duke@435 58 symbolOop name = ss.as_symbol(THREAD);
duke@435 59 if (HAS_PENDING_EXCEPTION) {
duke@435 60 type = ss.is_array() ? (ciType*)ciEnv::unloaded_ciobjarrayklass()
duke@435 61 : (ciType*)ciEnv::unloaded_ciinstance_klass();
duke@435 62 env->record_out_of_memory_failure();
duke@435 63 CLEAR_PENDING_EXCEPTION;
duke@435 64 } else {
duke@435 65 ciSymbol* klass_name = env->get_object(name)->as_symbol();
duke@435 66 type = env->get_klass_by_name_impl(_accessing_klass, klass_name, false);
duke@435 67 }
duke@435 68 }
duke@435 69 _types->append(type);
duke@435 70 if (ss.at_return_type()) {
duke@435 71 // Done processing the return type; do not add it into the count.
duke@435 72 break;
duke@435 73 }
duke@435 74 size += type->size();
duke@435 75 count++;
duke@435 76 }
duke@435 77 _size = size;
duke@435 78 _count = count;
duke@435 79 }
duke@435 80
duke@435 81 // ------------------------------------------------------------------
duke@435 82 // ciSignature::return_ciType
duke@435 83 //
duke@435 84 // What is the return type of this signature?
duke@435 85 ciType* ciSignature::return_type() const {
duke@435 86 return _types->at(_count);
duke@435 87 }
duke@435 88
duke@435 89 // ------------------------------------------------------------------
duke@435 90 // ciSignature::ciType_at
duke@435 91 //
duke@435 92 // What is the type of the index'th element of this
duke@435 93 // signature?
duke@435 94 ciType* ciSignature::type_at(int index) const {
duke@435 95 assert(index < _count, "out of bounds");
duke@435 96 // The first _klasses element holds the return klass.
duke@435 97 return _types->at(index);
duke@435 98 }
duke@435 99
duke@435 100 // ------------------------------------------------------------------
duke@435 101 // ciSignature::print_signature
duke@435 102 void ciSignature::print_signature() {
duke@435 103 _symbol->print_symbol();
duke@435 104 }
duke@435 105
duke@435 106 // ------------------------------------------------------------------
duke@435 107 // ciSignature::print
duke@435 108 void ciSignature::print() {
duke@435 109 tty->print("<ciSignature symbol=");
duke@435 110 print_signature();
duke@435 111 tty->print(" accessing_klass=");
duke@435 112 _accessing_klass->print();
duke@435 113 tty->print(" address=0x%x>", (address)this);
duke@435 114 }

mercurial