src/share/vm/ci/ciSignature.cpp

Tue, 18 Jun 2013 12:31:07 -0700

author
johnc
date
Tue, 18 Jun 2013 12:31:07 -0700
changeset 5277
01522ca68fc7
parent 4133
f6b0eb4e44cf
child 6680
78bbf4d43a14
permissions
-rw-r--r--

8015237: Parallelize string table scanning during strong root processing
Summary: Parallelize the scanning of the intern string table by having each GC worker claim a given number of buckets. Changes were also reviewed by Per Liden <per.liden@oracle.com>.
Reviewed-by: tschatzl, stefank, twisti

duke@435 1 /*
trims@2708 2 * Copyright (c) 1999, 2011, 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"
twisti@4133 26 #include "ci/ciMethodType.hpp"
stefank@2314 27 #include "ci/ciSignature.hpp"
stefank@2314 28 #include "ci/ciUtilities.hpp"
stefank@2314 29 #include "memory/allocation.inline.hpp"
stefank@2314 30 #include "oops/oop.inline.hpp"
stefank@2314 31 #include "runtime/signature.hpp"
duke@435 32
duke@435 33 // ciSignature
duke@435 34 //
duke@435 35 // This class represents the signature of a method.
duke@435 36
duke@435 37 // ------------------------------------------------------------------
duke@435 38 // ciSignature::ciSignature
jrose@2982 39 ciSignature::ciSignature(ciKlass* accessing_klass, constantPoolHandle cpool, ciSymbol* symbol) {
duke@435 40 ASSERT_IN_VM;
duke@435 41 EXCEPTION_CONTEXT;
duke@435 42 _accessing_klass = accessing_klass;
duke@435 43 _symbol = symbol;
duke@435 44
duke@435 45 ciEnv* env = CURRENT_ENV;
duke@435 46 Arena* arena = env->arena();
duke@435 47 _types = new (arena) GrowableArray<ciType*>(arena, 8, 0, NULL);
duke@435 48
duke@435 49 int size = 0;
duke@435 50 int count = 0;
coleenp@2497 51 ResourceMark rm(THREAD);
coleenp@2497 52 Symbol* sh = symbol->get_symbol();
duke@435 53 SignatureStream ss(sh);
duke@435 54 for (; ; ss.next()) {
duke@435 55 // Process one element of the signature
duke@435 56 ciType* type;
duke@435 57 if (!ss.is_object()) {
duke@435 58 type = ciType::make(ss.type());
duke@435 59 } else {
coleenp@2497 60 Symbol* name = ss.as_symbol(THREAD);
duke@435 61 if (HAS_PENDING_EXCEPTION) {
duke@435 62 type = ss.is_array() ? (ciType*)ciEnv::unloaded_ciobjarrayklass()
duke@435 63 : (ciType*)ciEnv::unloaded_ciinstance_klass();
duke@435 64 env->record_out_of_memory_failure();
duke@435 65 CLEAR_PENDING_EXCEPTION;
duke@435 66 } else {
coleenp@2497 67 ciSymbol* klass_name = env->get_symbol(name);
jrose@2982 68 type = env->get_klass_by_name_impl(_accessing_klass, cpool, klass_name, false);
duke@435 69 }
duke@435 70 }
duke@435 71 _types->append(type);
duke@435 72 if (ss.at_return_type()) {
duke@435 73 // Done processing the return type; do not add it into the count.
duke@435 74 break;
duke@435 75 }
duke@435 76 size += type->size();
duke@435 77 count++;
duke@435 78 }
duke@435 79 _size = size;
duke@435 80 _count = count;
duke@435 81 }
duke@435 82
duke@435 83 // ------------------------------------------------------------------
twisti@4133 84 // ciSignature::ciSignature
twisti@4133 85 ciSignature::ciSignature(ciKlass* accessing_klass, ciSymbol* symbol, ciMethodType* method_type) :
twisti@4133 86 _symbol(symbol),
twisti@4133 87 _accessing_klass(accessing_klass),
twisti@4133 88 _size( method_type->ptype_slot_count()),
twisti@4133 89 _count(method_type->ptype_count())
twisti@4133 90 {
twisti@4133 91 ASSERT_IN_VM;
twisti@4133 92 EXCEPTION_CONTEXT;
twisti@4133 93 Arena* arena = CURRENT_ENV->arena();
twisti@4133 94 _types = new (arena) GrowableArray<ciType*>(arena, _count + 1, 0, NULL);
twisti@4133 95 for (int i = 0; i < _count; i++) {
twisti@4133 96 _types->append(method_type->ptype_at(i));
twisti@4133 97 }
twisti@4133 98 _types->append(method_type->rtype());
twisti@4133 99 }
twisti@4133 100
twisti@4133 101 // ------------------------------------------------------------------
twisti@3197 102 // ciSignature::return_type
duke@435 103 //
duke@435 104 // What is the return type of this signature?
duke@435 105 ciType* ciSignature::return_type() const {
duke@435 106 return _types->at(_count);
duke@435 107 }
duke@435 108
duke@435 109 // ------------------------------------------------------------------
twisti@3197 110 // ciSignature::type_at
duke@435 111 //
duke@435 112 // What is the type of the index'th element of this
duke@435 113 // signature?
duke@435 114 ciType* ciSignature::type_at(int index) const {
duke@435 115 assert(index < _count, "out of bounds");
duke@435 116 // The first _klasses element holds the return klass.
duke@435 117 return _types->at(index);
duke@435 118 }
duke@435 119
duke@435 120 // ------------------------------------------------------------------
twisti@3197 121 // ciSignature::equals
twisti@3197 122 //
twisti@3197 123 // Compare this signature to another one. Signatures with different
twisti@3197 124 // accessing classes but with signature-types resolved to the same
twisti@3197 125 // types are defined to be equal.
twisti@3197 126 bool ciSignature::equals(ciSignature* that) {
twisti@3197 127 // Compare signature
twisti@3197 128 if (!this->as_symbol()->equals(that->as_symbol())) return false;
twisti@3197 129 // Compare all types of the arguments
twisti@3197 130 for (int i = 0; i < _count; i++) {
twisti@3197 131 if (this->type_at(i) != that->type_at(i)) return false;
twisti@3197 132 }
twisti@3197 133 // Compare the return type
twisti@3197 134 if (this->return_type() != that->return_type()) return false;
twisti@3197 135 return true;
twisti@3197 136 }
twisti@3197 137
twisti@3197 138 // ------------------------------------------------------------------
duke@435 139 // ciSignature::print_signature
duke@435 140 void ciSignature::print_signature() {
duke@435 141 _symbol->print_symbol();
duke@435 142 }
duke@435 143
duke@435 144 // ------------------------------------------------------------------
duke@435 145 // ciSignature::print
duke@435 146 void ciSignature::print() {
duke@435 147 tty->print("<ciSignature symbol=");
duke@435 148 print_signature();
duke@435 149 tty->print(" accessing_klass=");
duke@435 150 _accessing_klass->print();
duke@435 151 tty->print(" address=0x%x>", (address)this);
duke@435 152 }

mercurial