src/share/vm/memory/oopFactory.cpp

Tue, 24 Feb 2015 15:04:52 -0500

author
dlong
date
Tue, 24 Feb 2015 15:04:52 -0500
changeset 7598
ddce0b7cee93
parent 4142
d8ce2825b193
child 6876
710a3c8b516e
permissions
-rw-r--r--

8072383: resolve conflicts between open and closed ports
Summary: refactor close to remove references to closed ports
Reviewed-by: kvn, simonis, sgehwolf, dholmes

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/instanceKlass.hpp"
stefank@2314 35 #include "oops/instanceOop.hpp"
stefank@2314 36 #include "oops/objArrayOop.hpp"
stefank@2314 37 #include "oops/oop.inline.hpp"
duke@435 38
duke@435 39
duke@435 40 typeArrayOop oopFactory::new_charArray(const char* utf8_str, TRAPS) {
duke@435 41 int length = utf8_str == NULL ? 0 : UTF8::unicode_length(utf8_str);
duke@435 42 typeArrayOop result = new_charArray(length, CHECK_NULL);
duke@435 43 if (length > 0) {
duke@435 44 UTF8::convert_to_unicode(utf8_str, result->char_at_addr(0), length);
duke@435 45 }
duke@435 46 return result;
duke@435 47 }
duke@435 48
coleenp@4037 49 typeArrayOop oopFactory::new_tenured_charArray(int length, TRAPS) {
coleenp@4142 50 return TypeArrayKlass::cast(Universe::charArrayKlassObj())->allocate(length, THREAD);
duke@435 51 }
duke@435 52
coleenp@4037 53 typeArrayOop oopFactory::new_typeArray(BasicType type, int length, TRAPS) {
coleenp@4037 54 Klass* type_asKlassOop = Universe::typeArrayKlassObj(type);
coleenp@4142 55 TypeArrayKlass* type_asArrayKlass = TypeArrayKlass::cast(type_asKlassOop);
coleenp@4037 56 typeArrayOop result = type_asArrayKlass->allocate(length, THREAD);
coleenp@4037 57 return result;
duke@435 58 }
duke@435 59
coleenp@4037 60 // Create a Java array that points to metadata.
coleenp@4037 61 // As far as Java code is concerned, a metaData array is either an array of
coleenp@4037 62 // int or long depending on pointer size. Only a few things use this, like
coleenp@4037 63 // stack trace elements in Throwable. They cast Method* into this type.
coleenp@4037 64 // Note:can't point to symbols because there's no way to unreference count
coleenp@4037 65 // them when this object goes away.
coleenp@4037 66 typeArrayOop oopFactory::new_metaDataArray(int length, TRAPS) {
coleenp@4037 67 BasicType type = LP64_ONLY(T_LONG) NOT_LP64(T_INT);
coleenp@4037 68 Klass* type_asKlassOop = Universe::typeArrayKlassObj(type);
coleenp@4142 69 TypeArrayKlass* type_asArrayKlass = TypeArrayKlass::cast(type_asKlassOop);
kvn@3157 70 typeArrayOop result = type_asArrayKlass->allocate_common(length, true, THREAD);
kvn@3157 71 return result;
kvn@3157 72 }
kvn@3157 73
kvn@3157 74 typeArrayOop oopFactory::new_typeArray_nozero(BasicType type, int length, TRAPS) {
coleenp@4037 75 Klass* type_asKlassOop = Universe::typeArrayKlassObj(type);
coleenp@4142 76 TypeArrayKlass* type_asArrayKlass = TypeArrayKlass::cast(type_asKlassOop);
kvn@3157 77 typeArrayOop result = type_asArrayKlass->allocate_common(length, false, THREAD);
duke@435 78 return result;
duke@435 79 }
duke@435 80
duke@435 81
coleenp@4037 82 objArrayOop oopFactory::new_objArray(Klass* klass, int length, TRAPS) {
duke@435 83 assert(klass->is_klass(), "must be instance class");
coleenp@4037 84 if (klass->oop_is_array()) {
coleenp@4142 85 return ((ArrayKlass*)klass)->allocate_arrayArray(1, length, THREAD);
duke@435 86 } else {
coleenp@4037 87 assert (klass->oop_is_instance(), "new object array with klass not an InstanceKlass");
coleenp@4037 88 return ((InstanceKlass*)klass)->allocate_objArray(1, length, THREAD);
duke@435 89 }
duke@435 90 }

mercurial