Tue, 08 Aug 2017 15:57:29 +0800
merge
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
aoqi@0 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
aoqi@0 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | * |
aoqi@0 | 23 | */ |
aoqi@0 | 24 | |
aoqi@0 | 25 | #ifndef SHARE_VM_OOPS_TYPEARRAYKLASS_HPP |
aoqi@0 | 26 | #define SHARE_VM_OOPS_TYPEARRAYKLASS_HPP |
aoqi@0 | 27 | |
aoqi@0 | 28 | #include "classfile/classLoaderData.hpp" |
aoqi@0 | 29 | #include "oops/arrayKlass.hpp" |
aoqi@0 | 30 | |
aoqi@0 | 31 | // A TypeArrayKlass is the klass of a typeArray |
aoqi@0 | 32 | // It contains the type and size of the elements |
aoqi@0 | 33 | |
aoqi@0 | 34 | class TypeArrayKlass : public ArrayKlass { |
aoqi@0 | 35 | friend class VMStructs; |
aoqi@0 | 36 | private: |
aoqi@0 | 37 | jint _max_length; // maximum number of elements allowed in an array |
aoqi@0 | 38 | |
aoqi@0 | 39 | // Constructor |
aoqi@0 | 40 | TypeArrayKlass(BasicType type, Symbol* name); |
aoqi@0 | 41 | static TypeArrayKlass* allocate(ClassLoaderData* loader_data, BasicType type, Symbol* name, TRAPS); |
aoqi@0 | 42 | public: |
aoqi@0 | 43 | TypeArrayKlass() {} // For dummy objects. |
aoqi@0 | 44 | |
aoqi@0 | 45 | // instance variables |
aoqi@0 | 46 | jint max_length() { return _max_length; } |
aoqi@0 | 47 | void set_max_length(jint m) { _max_length = m; } |
aoqi@0 | 48 | |
aoqi@0 | 49 | // testers |
aoqi@0 | 50 | bool oop_is_typeArray_slow() const { return true; } |
aoqi@0 | 51 | |
aoqi@0 | 52 | // klass allocation |
aoqi@0 | 53 | static TypeArrayKlass* create_klass(BasicType type, const char* name_str, |
aoqi@0 | 54 | TRAPS); |
aoqi@0 | 55 | static inline Klass* create_klass(BasicType type, int scale, TRAPS) { |
aoqi@0 | 56 | TypeArrayKlass* tak = create_klass(type, external_name(type), CHECK_NULL); |
aoqi@0 | 57 | assert(scale == (1 << tak->log2_element_size()), "scale must check out"); |
aoqi@0 | 58 | return tak; |
aoqi@0 | 59 | } |
aoqi@0 | 60 | |
aoqi@0 | 61 | int oop_size(oop obj) const; |
aoqi@0 | 62 | |
aoqi@0 | 63 | bool compute_is_subtype_of(Klass* k); |
aoqi@0 | 64 | |
aoqi@0 | 65 | // Allocation |
aoqi@0 | 66 | typeArrayOop allocate_common(int length, bool do_zero, TRAPS); |
aoqi@0 | 67 | typeArrayOop allocate(int length, TRAPS) { return allocate_common(length, true, THREAD); } |
aoqi@0 | 68 | oop multi_allocate(int rank, jint* sizes, TRAPS); |
aoqi@0 | 69 | |
aoqi@0 | 70 | oop protection_domain() const { return NULL; } |
aoqi@0 | 71 | |
aoqi@0 | 72 | // Copying |
aoqi@0 | 73 | void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS); |
aoqi@0 | 74 | |
aoqi@0 | 75 | // Iteration |
aoqi@0 | 76 | int oop_oop_iterate(oop obj, ExtendedOopClosure* blk); |
aoqi@0 | 77 | int oop_oop_iterate_m(oop obj, ExtendedOopClosure* blk, MemRegion mr); |
aoqi@0 | 78 | |
aoqi@0 | 79 | // Garbage collection |
aoqi@0 | 80 | void oop_follow_contents(oop obj); |
aoqi@0 | 81 | int oop_adjust_pointers(oop obj); |
aoqi@0 | 82 | |
aoqi@0 | 83 | // Parallel Scavenge and Parallel Old |
aoqi@0 | 84 | PARALLEL_GC_DECLS |
aoqi@0 | 85 | |
aoqi@0 | 86 | protected: |
aoqi@0 | 87 | // Find n'th dimensional array |
aoqi@0 | 88 | virtual Klass* array_klass_impl(bool or_null, int n, TRAPS); |
aoqi@0 | 89 | |
aoqi@0 | 90 | // Returns the array class with this class as element type |
aoqi@0 | 91 | virtual Klass* array_klass_impl(bool or_null, TRAPS); |
aoqi@0 | 92 | |
aoqi@0 | 93 | public: |
aoqi@0 | 94 | // Casting from Klass* |
aoqi@0 | 95 | static TypeArrayKlass* cast(Klass* k) { |
aoqi@0 | 96 | assert(k->oop_is_typeArray(), "cast to TypeArrayKlass"); |
aoqi@0 | 97 | return (TypeArrayKlass*) k; |
aoqi@0 | 98 | } |
aoqi@0 | 99 | |
aoqi@0 | 100 | // Naming |
aoqi@0 | 101 | static const char* external_name(BasicType type); |
aoqi@0 | 102 | |
aoqi@0 | 103 | // Sizing |
aoqi@0 | 104 | static int header_size() { return sizeof(TypeArrayKlass)/HeapWordSize; } |
aoqi@0 | 105 | int size() const { return ArrayKlass::static_size(header_size()); } |
aoqi@0 | 106 | |
aoqi@0 | 107 | // Initialization (virtual from Klass) |
aoqi@0 | 108 | void initialize(TRAPS); |
aoqi@0 | 109 | |
aoqi@0 | 110 | public: |
aoqi@0 | 111 | // Printing |
aoqi@0 | 112 | #ifndef PRODUCT |
aoqi@0 | 113 | void oop_print_on(oop obj, outputStream* st); |
aoqi@0 | 114 | #endif |
aoqi@0 | 115 | |
aoqi@0 | 116 | void print_on(outputStream* st) const; |
aoqi@0 | 117 | void print_value_on(outputStream* st) const; |
aoqi@0 | 118 | |
aoqi@0 | 119 | public: |
aoqi@0 | 120 | const char* internal_name() const; |
aoqi@0 | 121 | }; |
aoqi@0 | 122 | |
aoqi@0 | 123 | #endif // SHARE_VM_OOPS_TYPEARRAYKLASS_HPP |