src/share/vm/ci/ciType.cpp

Mon, 26 Apr 2010 23:59:45 -0700

author
never
date
Mon, 26 Apr 2010 23:59:45 -0700
changeset 1832
b4776199210f
parent 1577
4ce7240d622c
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6943485: JVMTI always on capabilities change code generation too much
Reviewed-by: twisti, dcubed

     1 /*
     2  * Copyright 2000-2002 Sun Microsystems, Inc.  All Rights Reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 #include "incls/_precompiled.incl"
    26 #include "incls/_ciType.cpp.incl"
    28 ciType* ciType::_basic_types[T_CONFLICT+1];
    30 // ciType
    31 //
    32 // This class represents either a class (T_OBJECT), array (T_ARRAY),
    33 // or one of the primitive types such as T_INT.
    35 // ------------------------------------------------------------------
    36 // ciType::ciType
    37 //
    38 ciType::ciType(BasicType basic_type) : ciObject() {
    39   assert(basic_type >= T_BOOLEAN && basic_type <= T_CONFLICT, "range check");
    40   assert(basic_type != T_OBJECT && basic_type != T_ARRAY, "not a reference type");
    41   _basic_type = basic_type;
    42 }
    44 ciType::ciType(KlassHandle k) : ciObject(k) {
    45   _basic_type = Klass::cast(k())->oop_is_array() ? T_ARRAY : T_OBJECT;
    46 }
    48 ciType::ciType(ciKlass* klass) : ciObject(klass) {
    49   _basic_type = klass->is_array_klass_klass() ? T_ARRAY : T_OBJECT;
    50 }
    53 // ------------------------------------------------------------------
    54 // ciType::is_subtype_of
    55 //
    56 bool ciType::is_subtype_of(ciType* type) {
    57   if (this == type)  return true;
    58   if (is_klass() && type->is_klass())
    59     return this->as_klass()->is_subtype_of(type->as_klass());
    60   return false;
    61 }
    63 // ------------------------------------------------------------------
    64 // ciType::print_impl
    65 //
    66 // Implementation of the print method.
    67 void ciType::print_impl(outputStream* st) {
    68   st->print(" type=");
    69   print_name_on(st);
    70 }
    72 // ------------------------------------------------------------------
    73 // ciType::print_name
    74 //
    75 // Print the name of this type
    76 void ciType::print_name_on(outputStream* st) {
    77   st->print(type2name(basic_type()));
    78 }
    82 // ------------------------------------------------------------------
    83 // ciType::java_mirror
    84 //
    85 ciInstance* ciType::java_mirror() {
    86   VM_ENTRY_MARK;
    87   return CURRENT_THREAD_ENV->get_object(Universe::java_mirror(basic_type()))->as_instance();
    88 }
    90 // ------------------------------------------------------------------
    91 // ciType::box_klass
    92 //
    93 ciKlass* ciType::box_klass() {
    94   if (!is_primitive_type())  return this->as_klass();  // reference types are "self boxing"
    96   // Void is "boxed" with a null.
    97   if (basic_type() == T_VOID)  return NULL;
    99   VM_ENTRY_MARK;
   100   return CURRENT_THREAD_ENV->get_object(SystemDictionary::box_klass(basic_type()))->as_instance_klass();
   101 }
   104 // ------------------------------------------------------------------
   105 // ciType::make
   106 //
   107 // Produce the ciType for a given primitive BasicType.
   108 // As a bonus, produce the right reference type for T_OBJECT.
   109 // Does not work on T_ARRAY.
   110 ciType* ciType::make(BasicType t) {
   111   // short, etc.
   112   // Note: Bare T_ADDRESS means a raw pointer type, not a return_address.
   113   assert((uint)t < T_CONFLICT+1, "range check");
   114   if (t == T_OBJECT)  return ciEnv::_Object_klass;  // java/lang/Object
   115   assert(_basic_types[t] != NULL, "domain check");
   116   return _basic_types[t];
   117 }
   119 // ciReturnAddress
   120 //
   121 // This class represents the type of a specific return address in the
   122 // bytecodes.
   124 // ------------------------------------------------------------------
   125 // ciReturnAddress::ciReturnAddress
   126 //
   127 ciReturnAddress::ciReturnAddress(int bci) : ciType(T_ADDRESS) {
   128   assert(0 <= bci, "bci cannot be negative");
   129   _bci = bci;
   130 }
   132 // ------------------------------------------------------------------
   133 // ciReturnAddress::print_impl
   134 //
   135 // Implementation of the print method.
   136 void ciReturnAddress::print_impl(outputStream* st) {
   137   st->print(" bci=%d", _bci);
   138 }
   140 // ------------------------------------------------------------------
   141 // ciReturnAddress::make
   142 ciReturnAddress* ciReturnAddress::make(int bci) {
   143   GUARDED_VM_ENTRY(return CURRENT_ENV->get_return_address(bci);)
   144 }

mercurial