src/share/vm/memory/oopFactory.cpp

Mon, 04 Jun 2012 09:21:53 +0200

author
mgerdin
date
Mon, 04 Jun 2012 09:21:53 +0200
changeset 3822
a297b0e14605
parent 3741
8bafad97cd26
child 3917
8150fa46d2ed
permissions
-rw-r--r--

7172226: HotSpot fails to build with GCC 4.7 because of stricter c++ argument dependent lookup
Summary: Add "using" keyword to import base class functions from FreeList<T> to fix template name lookup in gcc 4.7
Reviewed-by: brutisso, iveresov

duke@435 1 /*
jiangli@3701 2 * Copyright (c) 1997, 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"
stefank@2314 26 #include "classfile/javaClasses.hpp"
stefank@2314 27 #include "classfile/symbolTable.hpp"
stefank@2314 28 #include "classfile/systemDictionary.hpp"
stefank@2314 29 #include "classfile/vmSymbols.hpp"
stefank@2314 30 #include "gc_interface/collectedHeap.inline.hpp"
stefank@2314 31 #include "memory/oopFactory.hpp"
stefank@2314 32 #include "memory/resourceArea.hpp"
stefank@2314 33 #include "memory/universe.inline.hpp"
stefank@2314 34 #include "oops/compiledICHolderKlass.hpp"
stefank@2314 35 #include "oops/constMethodKlass.hpp"
stefank@2314 36 #include "oops/constantPoolKlass.hpp"
stefank@2314 37 #include "oops/cpCacheKlass.hpp"
stefank@2314 38 #include "oops/instanceKlass.hpp"
stefank@2314 39 #include "oops/instanceKlassKlass.hpp"
stefank@2314 40 #include "oops/instanceOop.hpp"
stefank@2314 41 #include "oops/klassKlass.hpp"
stefank@2314 42 #include "oops/klassOop.hpp"
stefank@2314 43 #include "oops/methodDataKlass.hpp"
stefank@2314 44 #include "oops/methodKlass.hpp"
stefank@2314 45 #include "oops/objArrayOop.hpp"
stefank@2314 46 #include "oops/oop.inline.hpp"
duke@435 47
duke@435 48
duke@435 49 typeArrayOop oopFactory::new_charArray(const char* utf8_str, TRAPS) {
duke@435 50 int length = utf8_str == NULL ? 0 : UTF8::unicode_length(utf8_str);
duke@435 51 typeArrayOop result = new_charArray(length, CHECK_NULL);
duke@435 52 if (length > 0) {
duke@435 53 UTF8::convert_to_unicode(utf8_str, result->char_at_addr(0), length);
duke@435 54 }
duke@435 55 return result;
duke@435 56 }
duke@435 57
duke@435 58 typeArrayOop oopFactory::new_permanent_charArray(int length, TRAPS) {
duke@435 59 return typeArrayKlass::cast(Universe::charArrayKlassObj())->allocate_permanent(length, THREAD);
duke@435 60 }
duke@435 61
duke@435 62 typeArrayOop oopFactory::new_permanent_byteArray(int length, TRAPS) {
duke@435 63 return typeArrayKlass::cast(Universe::byteArrayKlassObj())->allocate_permanent(length, THREAD);
duke@435 64 }
duke@435 65
duke@435 66
duke@435 67 typeArrayOop oopFactory::new_permanent_shortArray(int length, TRAPS) {
duke@435 68 return typeArrayKlass::cast(Universe::shortArrayKlassObj())->allocate_permanent(length, THREAD);
duke@435 69 }
duke@435 70
duke@435 71
duke@435 72 typeArrayOop oopFactory::new_permanent_intArray(int length, TRAPS) {
duke@435 73 return typeArrayKlass::cast(Universe::intArrayKlassObj())->allocate_permanent(length, THREAD);
duke@435 74 }
duke@435 75
duke@435 76
duke@435 77 typeArrayOop oopFactory::new_typeArray(BasicType type, int length, TRAPS) {
duke@435 78 klassOop type_asKlassOop = Universe::typeArrayKlassObj(type);
duke@435 79 typeArrayKlass* type_asArrayKlass = typeArrayKlass::cast(type_asKlassOop);
kvn@3157 80 typeArrayOop result = type_asArrayKlass->allocate_common(length, true, THREAD);
kvn@3157 81 return result;
kvn@3157 82 }
kvn@3157 83
kvn@3157 84 typeArrayOop oopFactory::new_typeArray_nozero(BasicType type, int length, TRAPS) {
kvn@3157 85 klassOop type_asKlassOop = Universe::typeArrayKlassObj(type);
kvn@3157 86 typeArrayKlass* type_asArrayKlass = typeArrayKlass::cast(type_asKlassOop);
kvn@3157 87 typeArrayOop result = type_asArrayKlass->allocate_common(length, false, THREAD);
duke@435 88 return result;
duke@435 89 }
duke@435 90
duke@435 91
duke@435 92 objArrayOop oopFactory::new_objArray(klassOop klass, int length, TRAPS) {
duke@435 93 assert(klass->is_klass(), "must be instance class");
duke@435 94 if (klass->klass_part()->oop_is_array()) {
duke@435 95 return ((arrayKlass*)klass->klass_part())->allocate_arrayArray(1, length, THREAD);
duke@435 96 } else {
duke@435 97 assert (klass->klass_part()->oop_is_instance(), "new object array with klass not an instanceKlass");
duke@435 98 return ((instanceKlass*)klass->klass_part())->allocate_objArray(1, length, THREAD);
duke@435 99 }
duke@435 100 }
duke@435 101
stefank@2574 102 objArrayOop oopFactory::new_system_objArray(int length, TRAPS) {
duke@435 103 int size = objArrayOopDesc::object_size(length);
duke@435 104 KlassHandle klass (THREAD, Universe::systemObjArrayKlassObj());
stefank@2574 105 objArrayOop o = (objArrayOop)
stefank@2574 106 Universe::heap()->permanent_array_allocate(klass, size, length, CHECK_NULL);
duke@435 107 // initialization not needed, allocated cleared
duke@435 108 return o;
duke@435 109 }
duke@435 110
duke@435 111
jmasa@953 112 constantPoolOop oopFactory::new_constantPool(int length,
jmasa@953 113 bool is_conc_safe,
jmasa@953 114 TRAPS) {
duke@435 115 constantPoolKlass* ck = constantPoolKlass::cast(Universe::constantPoolKlassObj());
jmasa@953 116 return ck->allocate(length, is_conc_safe, CHECK_NULL);
duke@435 117 }
duke@435 118
duke@435 119
jmasa@977 120 constantPoolCacheOop oopFactory::new_constantPoolCache(int length,
jmasa@977 121 TRAPS) {
duke@435 122 constantPoolCacheKlass* ck = constantPoolCacheKlass::cast(Universe::constantPoolCacheKlassObj());
ysr@2533 123 return ck->allocate(length, CHECK_NULL);
duke@435 124 }
duke@435 125
duke@435 126
never@2658 127 klassOop oopFactory::new_instanceKlass(Symbol* name, int vtable_len, int itable_len,
jcoomes@1374 128 int static_field_size,
jcoomes@1374 129 unsigned int nonstatic_oop_map_count,
jiangli@3701 130 AccessFlags access_flags,
jiangli@3741 131 ReferenceType rt,
jiangli@3741 132 KlassHandle host_klass, TRAPS) {
duke@435 133 instanceKlassKlass* ikk = instanceKlassKlass::cast(Universe::instanceKlassKlassObj());
jiangli@3701 134 return ikk->allocate_instance_klass(name, vtable_len, itable_len,
jiangli@3701 135 static_field_size, nonstatic_oop_map_count,
jiangli@3741 136 access_flags, rt, host_klass, CHECK_NULL);
duke@435 137 }
duke@435 138
duke@435 139
duke@435 140 constMethodOop oopFactory::new_constMethod(int byte_code_size,
duke@435 141 int compressed_line_number_size,
duke@435 142 int localvariable_table_length,
duke@435 143 int checked_exceptions_length,
jmasa@953 144 bool is_conc_safe,
duke@435 145 TRAPS) {
duke@435 146 klassOop cmkObj = Universe::constMethodKlassObj();
duke@435 147 constMethodKlass* cmk = constMethodKlass::cast(cmkObj);
duke@435 148 return cmk->allocate(byte_code_size, compressed_line_number_size,
duke@435 149 localvariable_table_length, checked_exceptions_length,
jmasa@953 150 is_conc_safe,
duke@435 151 CHECK_NULL);
duke@435 152 }
duke@435 153
duke@435 154
duke@435 155 methodOop oopFactory::new_method(int byte_code_size, AccessFlags access_flags,
duke@435 156 int compressed_line_number_size,
duke@435 157 int localvariable_table_length,
jmasa@953 158 int checked_exceptions_length,
jmasa@953 159 bool is_conc_safe,
jmasa@953 160 TRAPS) {
duke@435 161 methodKlass* mk = methodKlass::cast(Universe::methodKlassObj());
duke@435 162 assert(!access_flags.is_native() || byte_code_size == 0,
duke@435 163 "native methods should not contain byte codes");
duke@435 164 constMethodOop cm = new_constMethod(byte_code_size,
duke@435 165 compressed_line_number_size,
duke@435 166 localvariable_table_length,
jmasa@953 167 checked_exceptions_length,
jmasa@953 168 is_conc_safe, CHECK_NULL);
duke@435 169 constMethodHandle rw(THREAD, cm);
duke@435 170 return mk->allocate(rw, access_flags, CHECK_NULL);
duke@435 171 }
duke@435 172
duke@435 173
duke@435 174 methodDataOop oopFactory::new_methodData(methodHandle method, TRAPS) {
duke@435 175 methodDataKlass* mdk = methodDataKlass::cast(Universe::methodDataKlassObj());
duke@435 176 return mdk->allocate(method, CHECK_NULL);
duke@435 177 }
duke@435 178
duke@435 179
duke@435 180 compiledICHolderOop oopFactory::new_compiledICHolder(methodHandle method, KlassHandle klass, TRAPS) {
duke@435 181 compiledICHolderKlass* ck = (compiledICHolderKlass*) Universe::compiledICHolderKlassObj()->klass_part();
duke@435 182 compiledICHolderOop c = ck->allocate(CHECK_NULL);
duke@435 183 c->set_holder_method(method());
duke@435 184 c->set_holder_klass(klass());
duke@435 185 return c;
duke@435 186 }

mercurial