src/share/vm/ci/ciType.cpp

Wed, 23 Oct 2013 12:40:23 +0200

author
roland
date
Wed, 23 Oct 2013 12:40:23 +0200
changeset 5991
b2ee5dc63353
parent 4447
f1de9dbc914e
child 6198
55fb97c4c58d
permissions
-rw-r--r--

8024070: C2 needs some form of type speculation
Summary: record unused type profile information with type system, propagate and use it.
Reviewed-by: kvn, twisti

duke@435 1 /*
coleenp@4037 2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
coleenp@4037 26 #include "ci/ciEnv.hpp"
stefank@2314 27 #include "ci/ciType.hpp"
stefank@2314 28 #include "ci/ciUtilities.hpp"
stefank@2314 29 #include "classfile/systemDictionary.hpp"
stefank@2314 30 #include "oops/oop.inline.hpp"
duke@435 31
duke@435 32 ciType* ciType::_basic_types[T_CONFLICT+1];
duke@435 33
duke@435 34 // ciType
duke@435 35 //
duke@435 36 // This class represents either a class (T_OBJECT), array (T_ARRAY),
duke@435 37 // or one of the primitive types such as T_INT.
duke@435 38
duke@435 39 // ------------------------------------------------------------------
duke@435 40 // ciType::ciType
duke@435 41 //
coleenp@4037 42 ciType::ciType(BasicType basic_type) : ciMetadata() {
duke@435 43 assert(basic_type >= T_BOOLEAN && basic_type <= T_CONFLICT, "range check");
duke@435 44 _basic_type = basic_type;
duke@435 45 }
duke@435 46
coleenp@4037 47 ciType::ciType(KlassHandle k) : ciMetadata(k()) {
hseigel@4278 48 _basic_type = k()->oop_is_array() ? T_ARRAY : T_OBJECT;
duke@435 49 }
duke@435 50
duke@435 51
duke@435 52 // ------------------------------------------------------------------
duke@435 53 // ciType::is_subtype_of
duke@435 54 //
duke@435 55 bool ciType::is_subtype_of(ciType* type) {
duke@435 56 if (this == type) return true;
duke@435 57 if (is_klass() && type->is_klass())
duke@435 58 return this->as_klass()->is_subtype_of(type->as_klass());
duke@435 59 return false;
duke@435 60 }
duke@435 61
duke@435 62 // ------------------------------------------------------------------
twisti@4447 63 // ciType::name
twisti@4447 64 //
twisti@4447 65 // Return the name of this type
twisti@4447 66 const char* ciType::name() {
twisti@4447 67 if (is_primitive_type()) {
twisti@4447 68 return type2name(basic_type());
twisti@4447 69 } else {
twisti@4447 70 assert(is_klass(), "must be");
twisti@4447 71 return as_klass()->name()->as_utf8();
twisti@4447 72 }
twisti@4447 73 }
twisti@4447 74
twisti@4447 75 // ------------------------------------------------------------------
duke@435 76 // ciType::print_impl
duke@435 77 //
duke@435 78 // Implementation of the print method.
duke@435 79 void ciType::print_impl(outputStream* st) {
duke@435 80 st->print(" type=");
duke@435 81 print_name_on(st);
duke@435 82 }
duke@435 83
duke@435 84 // ------------------------------------------------------------------
duke@435 85 // ciType::print_name
duke@435 86 //
duke@435 87 // Print the name of this type
duke@435 88 void ciType::print_name_on(outputStream* st) {
twisti@4447 89 ResourceMark rm;
twisti@4447 90 st->print(name());
duke@435 91 }
duke@435 92
duke@435 93
duke@435 94
duke@435 95 // ------------------------------------------------------------------
duke@435 96 // ciType::java_mirror
duke@435 97 //
duke@435 98 ciInstance* ciType::java_mirror() {
duke@435 99 VM_ENTRY_MARK;
coleenp@4037 100 return CURRENT_THREAD_ENV->get_instance(Universe::java_mirror(basic_type()));
duke@435 101 }
duke@435 102
duke@435 103 // ------------------------------------------------------------------
duke@435 104 // ciType::box_klass
duke@435 105 //
duke@435 106 ciKlass* ciType::box_klass() {
duke@435 107 if (!is_primitive_type()) return this->as_klass(); // reference types are "self boxing"
duke@435 108
duke@435 109 // Void is "boxed" with a null.
duke@435 110 if (basic_type() == T_VOID) return NULL;
duke@435 111
duke@435 112 VM_ENTRY_MARK;
coleenp@4037 113 return CURRENT_THREAD_ENV->get_instance_klass(SystemDictionary::box_klass(basic_type()));
duke@435 114 }
duke@435 115
duke@435 116
duke@435 117 // ------------------------------------------------------------------
duke@435 118 // ciType::make
duke@435 119 //
duke@435 120 // Produce the ciType for a given primitive BasicType.
duke@435 121 // As a bonus, produce the right reference type for T_OBJECT.
duke@435 122 // Does not work on T_ARRAY.
duke@435 123 ciType* ciType::make(BasicType t) {
duke@435 124 // short, etc.
duke@435 125 // Note: Bare T_ADDRESS means a raw pointer type, not a return_address.
duke@435 126 assert((uint)t < T_CONFLICT+1, "range check");
never@1577 127 if (t == T_OBJECT) return ciEnv::_Object_klass; // java/lang/Object
duke@435 128 assert(_basic_types[t] != NULL, "domain check");
duke@435 129 return _basic_types[t];
duke@435 130 }
duke@435 131
duke@435 132 // ciReturnAddress
duke@435 133 //
duke@435 134 // This class represents the type of a specific return address in the
duke@435 135 // bytecodes.
duke@435 136
duke@435 137 // ------------------------------------------------------------------
duke@435 138 // ciReturnAddress::ciReturnAddress
duke@435 139 //
duke@435 140 ciReturnAddress::ciReturnAddress(int bci) : ciType(T_ADDRESS) {
duke@435 141 assert(0 <= bci, "bci cannot be negative");
duke@435 142 _bci = bci;
duke@435 143 }
duke@435 144
duke@435 145 // ------------------------------------------------------------------
duke@435 146 // ciReturnAddress::print_impl
duke@435 147 //
duke@435 148 // Implementation of the print method.
duke@435 149 void ciReturnAddress::print_impl(outputStream* st) {
duke@435 150 st->print(" bci=%d", _bci);
duke@435 151 }
duke@435 152
duke@435 153 // ------------------------------------------------------------------
duke@435 154 // ciReturnAddress::make
duke@435 155 ciReturnAddress* ciReturnAddress::make(int bci) {
duke@435 156 GUARDED_VM_ENTRY(return CURRENT_ENV->get_return_address(bci);)
duke@435 157 }

mercurial