src/share/vm/ci/ciType.cpp

Wed, 12 Oct 2011 21:00:13 -0700

author
twisti
date
Wed, 12 Oct 2011 21:00:13 -0700
changeset 3197
5eb9169b1a14
parent 2314
f95d63e2154a
child 4037
da91efe96a93
permissions
-rw-r--r--

7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
Reviewed-by: jrose, never

     1 /*
     2  * Copyright (c) 2000, 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #include "precompiled.hpp"
    26 #include "ci/ciType.hpp"
    27 #include "ci/ciUtilities.hpp"
    28 #include "classfile/systemDictionary.hpp"
    29 #include "oops/oop.inline.hpp"
    31 ciType* ciType::_basic_types[T_CONFLICT+1];
    33 // ciType
    34 //
    35 // This class represents either a class (T_OBJECT), array (T_ARRAY),
    36 // or one of the primitive types such as T_INT.
    38 // ------------------------------------------------------------------
    39 // ciType::ciType
    40 //
    41 ciType::ciType(BasicType basic_type) : ciObject() {
    42   assert(basic_type >= T_BOOLEAN && basic_type <= T_CONFLICT, "range check");
    43   assert(basic_type != T_OBJECT && basic_type != T_ARRAY, "not a reference type");
    44   _basic_type = basic_type;
    45 }
    47 ciType::ciType(KlassHandle k) : ciObject(k) {
    48   _basic_type = Klass::cast(k())->oop_is_array() ? T_ARRAY : T_OBJECT;
    49 }
    51 ciType::ciType(ciKlass* klass) : ciObject(klass) {
    52   _basic_type = klass->is_array_klass_klass() ? T_ARRAY : T_OBJECT;
    53 }
    56 // ------------------------------------------------------------------
    57 // ciType::is_subtype_of
    58 //
    59 bool ciType::is_subtype_of(ciType* type) {
    60   if (this == type)  return true;
    61   if (is_klass() && type->is_klass())
    62     return this->as_klass()->is_subtype_of(type->as_klass());
    63   return false;
    64 }
    66 // ------------------------------------------------------------------
    67 // ciType::print_impl
    68 //
    69 // Implementation of the print method.
    70 void ciType::print_impl(outputStream* st) {
    71   st->print(" type=");
    72   print_name_on(st);
    73 }
    75 // ------------------------------------------------------------------
    76 // ciType::print_name
    77 //
    78 // Print the name of this type
    79 void ciType::print_name_on(outputStream* st) {
    80   st->print(type2name(basic_type()));
    81 }
    85 // ------------------------------------------------------------------
    86 // ciType::java_mirror
    87 //
    88 ciInstance* ciType::java_mirror() {
    89   VM_ENTRY_MARK;
    90   return CURRENT_THREAD_ENV->get_object(Universe::java_mirror(basic_type()))->as_instance();
    91 }
    93 // ------------------------------------------------------------------
    94 // ciType::box_klass
    95 //
    96 ciKlass* ciType::box_klass() {
    97   if (!is_primitive_type())  return this->as_klass();  // reference types are "self boxing"
    99   // Void is "boxed" with a null.
   100   if (basic_type() == T_VOID)  return NULL;
   102   VM_ENTRY_MARK;
   103   return CURRENT_THREAD_ENV->get_object(SystemDictionary::box_klass(basic_type()))->as_instance_klass();
   104 }
   107 // ------------------------------------------------------------------
   108 // ciType::make
   109 //
   110 // Produce the ciType for a given primitive BasicType.
   111 // As a bonus, produce the right reference type for T_OBJECT.
   112 // Does not work on T_ARRAY.
   113 ciType* ciType::make(BasicType t) {
   114   // short, etc.
   115   // Note: Bare T_ADDRESS means a raw pointer type, not a return_address.
   116   assert((uint)t < T_CONFLICT+1, "range check");
   117   if (t == T_OBJECT)  return ciEnv::_Object_klass;  // java/lang/Object
   118   assert(_basic_types[t] != NULL, "domain check");
   119   return _basic_types[t];
   120 }
   122 // ciReturnAddress
   123 //
   124 // This class represents the type of a specific return address in the
   125 // bytecodes.
   127 // ------------------------------------------------------------------
   128 // ciReturnAddress::ciReturnAddress
   129 //
   130 ciReturnAddress::ciReturnAddress(int bci) : ciType(T_ADDRESS) {
   131   assert(0 <= bci, "bci cannot be negative");
   132   _bci = bci;
   133 }
   135 // ------------------------------------------------------------------
   136 // ciReturnAddress::print_impl
   137 //
   138 // Implementation of the print method.
   139 void ciReturnAddress::print_impl(outputStream* st) {
   140   st->print(" bci=%d", _bci);
   141 }
   143 // ------------------------------------------------------------------
   144 // ciReturnAddress::make
   145 ciReturnAddress* ciReturnAddress::make(int bci) {
   146   GUARDED_VM_ENTRY(return CURRENT_ENV->get_return_address(bci);)
   147 }

mercurial