src/share/vm/ci/ciSignature.cpp

Tue, 05 Apr 2011 14:12:31 -0700

author
trims
date
Tue, 05 Apr 2011 14:12:31 -0700
changeset 2708
1d1603768966
parent 2497
3582bf76420e
child 2982
ddd894528dbc
permissions
-rw-r--r--

7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
Summary: Update the copyright to be 2010 on all changed files in OpenJDK
Reviewed-by: ohair

duke@435 1 /*
trims@2708 2 * Copyright (c) 1999, 2011, 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;
coleenp@2497 50 ResourceMark rm(THREAD);
coleenp@2497 51 Symbol* sh = symbol->get_symbol();
duke@435 52 SignatureStream ss(sh);
duke@435 53 for (; ; ss.next()) {
duke@435 54 // Process one element of the signature
duke@435 55 ciType* type;
duke@435 56 if (!ss.is_object()) {
duke@435 57 type = ciType::make(ss.type());
duke@435 58 } else {
coleenp@2497 59 Symbol* name = ss.as_symbol(THREAD);
duke@435 60 if (HAS_PENDING_EXCEPTION) {
duke@435 61 type = ss.is_array() ? (ciType*)ciEnv::unloaded_ciobjarrayklass()
duke@435 62 : (ciType*)ciEnv::unloaded_ciinstance_klass();
duke@435 63 env->record_out_of_memory_failure();
duke@435 64 CLEAR_PENDING_EXCEPTION;
duke@435 65 } else {
coleenp@2497 66 ciSymbol* klass_name = env->get_symbol(name);
duke@435 67 type = env->get_klass_by_name_impl(_accessing_klass, klass_name, false);
duke@435 68 }
duke@435 69 }
duke@435 70 _types->append(type);
duke@435 71 if (ss.at_return_type()) {
duke@435 72 // Done processing the return type; do not add it into the count.
duke@435 73 break;
duke@435 74 }
duke@435 75 size += type->size();
duke@435 76 count++;
duke@435 77 }
duke@435 78 _size = size;
duke@435 79 _count = count;
duke@435 80 }
duke@435 81
duke@435 82 // ------------------------------------------------------------------
duke@435 83 // ciSignature::return_ciType
duke@435 84 //
duke@435 85 // What is the return type of this signature?
duke@435 86 ciType* ciSignature::return_type() const {
duke@435 87 return _types->at(_count);
duke@435 88 }
duke@435 89
duke@435 90 // ------------------------------------------------------------------
duke@435 91 // ciSignature::ciType_at
duke@435 92 //
duke@435 93 // What is the type of the index'th element of this
duke@435 94 // signature?
duke@435 95 ciType* ciSignature::type_at(int index) const {
duke@435 96 assert(index < _count, "out of bounds");
duke@435 97 // The first _klasses element holds the return klass.
duke@435 98 return _types->at(index);
duke@435 99 }
duke@435 100
duke@435 101 // ------------------------------------------------------------------
duke@435 102 // ciSignature::print_signature
duke@435 103 void ciSignature::print_signature() {
duke@435 104 _symbol->print_symbol();
duke@435 105 }
duke@435 106
duke@435 107 // ------------------------------------------------------------------
duke@435 108 // ciSignature::print
duke@435 109 void ciSignature::print() {
duke@435 110 tty->print("<ciSignature symbol=");
duke@435 111 print_signature();
duke@435 112 tty->print(" accessing_klass=");
duke@435 113 _accessing_klass->print();
duke@435 114 tty->print(" address=0x%x>", (address)this);
duke@435 115 }

mercurial