src/share/vm/ci/ciSignature.cpp

changeset 435
a61af66fc99e
child 1907
c18cbe5936b8
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/ci/ciSignature.cpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,110 @@
     1.4 +/*
     1.5 + * Copyright 1999-2007 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#include "incls/_precompiled.incl"
    1.29 +#include "incls/_ciSignature.cpp.incl"
    1.30 +
    1.31 +// ciSignature
    1.32 +//
    1.33 +// This class represents the signature of a method.
    1.34 +
    1.35 +// ------------------------------------------------------------------
    1.36 +// ciSignature::ciSignature
    1.37 +ciSignature::ciSignature(ciKlass* accessing_klass, ciSymbol* symbol) {
    1.38 +  ASSERT_IN_VM;
    1.39 +  EXCEPTION_CONTEXT;
    1.40 +  _accessing_klass = accessing_klass;
    1.41 +  _symbol = symbol;
    1.42 +
    1.43 +  ciEnv* env = CURRENT_ENV;
    1.44 +  Arena* arena = env->arena();
    1.45 +  _types = new (arena) GrowableArray<ciType*>(arena, 8, 0, NULL);
    1.46 +
    1.47 +  int size = 0;
    1.48 +  int count = 0;
    1.49 +  symbolHandle sh (THREAD, symbol->get_symbolOop());
    1.50 +  SignatureStream ss(sh);
    1.51 +  for (; ; ss.next()) {
    1.52 +    // Process one element of the signature
    1.53 +    ciType* type;
    1.54 +    if (!ss.is_object()) {
    1.55 +      type = ciType::make(ss.type());
    1.56 +    } else {
    1.57 +      symbolOop name = ss.as_symbol(THREAD);
    1.58 +      if (HAS_PENDING_EXCEPTION) {
    1.59 +        type = ss.is_array() ? (ciType*)ciEnv::unloaded_ciobjarrayklass()
    1.60 +          : (ciType*)ciEnv::unloaded_ciinstance_klass();
    1.61 +        env->record_out_of_memory_failure();
    1.62 +        CLEAR_PENDING_EXCEPTION;
    1.63 +      } else {
    1.64 +        ciSymbol* klass_name = env->get_object(name)->as_symbol();
    1.65 +        type = env->get_klass_by_name_impl(_accessing_klass, klass_name, false);
    1.66 +      }
    1.67 +    }
    1.68 +    _types->append(type);
    1.69 +    if (ss.at_return_type()) {
    1.70 +      // Done processing the return type; do not add it into the count.
    1.71 +      break;
    1.72 +    }
    1.73 +    size += type->size();
    1.74 +    count++;
    1.75 +  }
    1.76 +  _size = size;
    1.77 +  _count = count;
    1.78 +}
    1.79 +
    1.80 +// ------------------------------------------------------------------
    1.81 +// ciSignature::return_ciType
    1.82 +//
    1.83 +// What is the return type of this signature?
    1.84 +ciType* ciSignature::return_type() const {
    1.85 +  return _types->at(_count);
    1.86 +}
    1.87 +
    1.88 +// ------------------------------------------------------------------
    1.89 +// ciSignature::ciType_at
    1.90 +//
    1.91 +// What is the type of the index'th element of this
    1.92 +// signature?
    1.93 +ciType* ciSignature::type_at(int index) const {
    1.94 +  assert(index < _count, "out of bounds");
    1.95 +  // The first _klasses element holds the return klass.
    1.96 +  return _types->at(index);
    1.97 +}
    1.98 +
    1.99 +// ------------------------------------------------------------------
   1.100 +// ciSignature::print_signature
   1.101 +void ciSignature::print_signature() {
   1.102 +  _symbol->print_symbol();
   1.103 +}
   1.104 +
   1.105 +// ------------------------------------------------------------------
   1.106 +// ciSignature::print
   1.107 +void ciSignature::print() {
   1.108 +  tty->print("<ciSignature symbol=");
   1.109 +  print_signature();
   1.110 + tty->print(" accessing_klass=");
   1.111 +  _accessing_klass->print();
   1.112 +  tty->print(" address=0x%x>", (address)this);
   1.113 +}

mercurial