hotspot/src/share/vm/ci/ciSignature.cpp
author stefank
Tue, 23 Nov 2010 13:22:55 -0800
changeset 7397 5b173b4ca846
parent 5547 f4b087cbb361
child 8076 96d498ec7ae1
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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
     2
 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "ci/ciSignature.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "ci/ciUtilities.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "memory/allocation.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "runtime/signature.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// ciSignature
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// This class represents the signature of a method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// ciSignature::ciSignature
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
ciSignature::ciSignature(ciKlass* accessing_klass, ciSymbol* symbol) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  ASSERT_IN_VM;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  EXCEPTION_CONTEXT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  _accessing_klass = accessing_klass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  _symbol = symbol;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  ciEnv* env = CURRENT_ENV;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  Arena* arena = env->arena();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  _types = new (arena) GrowableArray<ciType*>(arena, 8, 0, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  int size = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  int count = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  symbolHandle sh (THREAD, symbol->get_symbolOop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  SignatureStream ss(sh);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  for (; ; ss.next()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    // Process one element of the signature
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
    ciType* type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    if (!ss.is_object()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
      type = ciType::make(ss.type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
      symbolOop name = ss.as_symbol(THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
      if (HAS_PENDING_EXCEPTION) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
        type = ss.is_array() ? (ciType*)ciEnv::unloaded_ciobjarrayklass()
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
          : (ciType*)ciEnv::unloaded_ciinstance_klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
        env->record_out_of_memory_failure();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
        CLEAR_PENDING_EXCEPTION;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
        ciSymbol* klass_name = env->get_object(name)->as_symbol();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
        type = env->get_klass_by_name_impl(_accessing_klass, klass_name, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    _types->append(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    if (ss.at_return_type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
      // Done processing the return type; do not add it into the count.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
    size += type->size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
    count++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  _size = size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  _count = count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
// ciSignature::return_ciType
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
// What is the return type of this signature?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
ciType* ciSignature::return_type() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  return _types->at(_count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
// ciSignature::ciType_at
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
// What is the type of the index'th element of this
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
// signature?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
ciType* ciSignature::type_at(int index) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  assert(index < _count, "out of bounds");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // The first _klasses element holds the return klass.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  return _types->at(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
// ciSignature::print_signature
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
void ciSignature::print_signature() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  _symbol->print_symbol();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
// ciSignature::print
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
void ciSignature::print() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  tty->print("<ciSignature symbol=");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  print_signature();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
 tty->print(" accessing_klass=");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  _accessing_klass->print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  tty->print(" address=0x%x>", (address)this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
}