hotspot/src/share/vm/ci/ciSignature.cpp
author never
Wed, 17 Sep 2008 12:59:52 -0700
changeset 1399 9648dfd4ce09
parent 1 489c9b5090e2
child 5547 f4b087cbb361
permissions -rw-r--r--
6384206: Phis which are later unneeded are impairing our ability to inline based on static types Reviewed-by: rasbold, jrose
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1999-2007 Sun Microsystems, Inc.  All Rights Reserved.
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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
#include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
#include "incls/_ciSignature.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// ciSignature
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
// This class represents the signature of a method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// ciSignature::ciSignature
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
ciSignature::ciSignature(ciKlass* accessing_klass, ciSymbol* symbol) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  ASSERT_IN_VM;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  EXCEPTION_CONTEXT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  _accessing_klass = accessing_klass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  _symbol = symbol;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  ciEnv* env = CURRENT_ENV;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  Arena* arena = env->arena();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  _types = new (arena) GrowableArray<ciType*>(arena, 8, 0, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  int size = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  int count = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  symbolHandle sh (THREAD, symbol->get_symbolOop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  SignatureStream ss(sh);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  for (; ; ss.next()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    // Process one element of the signature
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    ciType* type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
    if (!ss.is_object()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
      type = ciType::make(ss.type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
      symbolOop name = ss.as_symbol(THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
      if (HAS_PENDING_EXCEPTION) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
        type = ss.is_array() ? (ciType*)ciEnv::unloaded_ciobjarrayklass()
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
          : (ciType*)ciEnv::unloaded_ciinstance_klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
        env->record_out_of_memory_failure();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
        CLEAR_PENDING_EXCEPTION;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
        ciSymbol* klass_name = env->get_object(name)->as_symbol();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
        type = env->get_klass_by_name_impl(_accessing_klass, klass_name, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
    _types->append(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
    if (ss.at_return_type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
      // Done processing the return type; do not add it into the count.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    size += type->size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    count++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  _size = size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  _count = count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
// ciSignature::return_ciType
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
// What is the return type of this signature?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
ciType* ciSignature::return_type() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  return _types->at(_count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
// ciSignature::ciType_at
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
// What is the type of the index'th element of this
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
// signature?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
ciType* ciSignature::type_at(int index) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  assert(index < _count, "out of bounds");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  // The first _klasses element holds the return klass.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  return _types->at(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
// ciSignature::print_signature
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
void ciSignature::print_signature() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  _symbol->print_symbol();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
// ciSignature::print
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
void ciSignature::print() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  tty->print("<ciSignature symbol=");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  print_signature();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
 tty->print(" accessing_klass=");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  _accessing_klass->print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  tty->print(" address=0x%x>", (address)this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
}