hotspot/src/share/vm/ci/ciType.cpp
author coleenp
Sat, 01 Sep 2012 13:25:18 -0400
changeset 13728 882756847a04
parent 7397 5b173b4ca846
child 14488 ab48109f7d1b
permissions -rw-r--r--
6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
     2
 * Copyright (c) 2000, 2012, 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: 4571
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4571
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: 4571
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"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
    26
#include "ci/ciEnv.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "ci/ciType.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "ci/ciUtilities.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "classfile/systemDictionary.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "oops/oop.inline.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
ciType* ciType::_basic_types[T_CONFLICT+1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// ciType
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// This class represents either a class (T_OBJECT), array (T_ARRAY),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// or one of the primitive types such as T_INT.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// ciType::ciType
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
//
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
    42
ciType::ciType(BasicType basic_type) : ciMetadata() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  assert(basic_type >= T_BOOLEAN && basic_type <= T_CONFLICT, "range check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  _basic_type = basic_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
    47
ciType::ciType(KlassHandle k) : ciMetadata(k()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  _basic_type = Klass::cast(k())->oop_is_array() ? T_ARRAY : T_OBJECT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
// ciType::is_subtype_of
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
bool ciType::is_subtype_of(ciType* type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  if (this == type)  return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  if (is_klass() && type->is_klass())
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    return this->as_klass()->is_subtype_of(type->as_klass());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
// ciType::print_impl
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
// Implementation of the print method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
void ciType::print_impl(outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  st->print(" type=");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  print_name_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
// ciType::print_name
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
// Print the name of this type
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
void ciType::print_name_on(outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  st->print(type2name(basic_type()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
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
// ciType::java_mirror
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
ciInstance* ciType::java_mirror() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  VM_ENTRY_MARK;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
    86
  return CURRENT_THREAD_ENV->get_instance(Universe::java_mirror(basic_type()));
1
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
// ciType::box_klass
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
ciKlass* ciType::box_klass() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  if (!is_primitive_type())  return this->as_klass();  // reference types are "self boxing"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // Void is "boxed" with a null.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  if (basic_type() == T_VOID)  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  VM_ENTRY_MARK;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
    99
  return CURRENT_THREAD_ENV->get_instance_klass(SystemDictionary::box_klass(basic_type()));
1
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
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
// ciType::make
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
// Produce the ciType for a given primitive BasicType.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
// As a bonus, produce the right reference type for T_OBJECT.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
// Does not work on T_ARRAY.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
ciType* ciType::make(BasicType t) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  // short, etc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  // Note: Bare T_ADDRESS means a raw pointer type, not a return_address.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  assert((uint)t < T_CONFLICT+1, "range check");
4571
80b553bddc26 6914300: ciEnv should export all well known classes
never
parents: 1
diff changeset
   113
  if (t == T_OBJECT)  return ciEnv::_Object_klass;  // java/lang/Object
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  assert(_basic_types[t] != NULL, "domain check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  return _basic_types[t];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
// ciReturnAddress
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
// This class represents the type of a specific return address in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
// bytecodes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
// ciReturnAddress::ciReturnAddress
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
ciReturnAddress::ciReturnAddress(int bci) : ciType(T_ADDRESS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  assert(0 <= bci, "bci cannot be negative");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  _bci = bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
// ciReturnAddress::print_impl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
// Implementation of the print method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
void ciReturnAddress::print_impl(outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  st->print(" bci=%d", _bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
// ciReturnAddress::make
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
ciReturnAddress* ciReturnAddress::make(int bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  GUARDED_VM_ENTRY(return CURRENT_ENV->get_return_address(bci);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
}