Tue, 15 Nov 2011 20:17:33 +0100
7110152: assert(size_in_words <= (julong)max_jint) failed: no overflow
Summary: Reduce what arrayOopDesc::max_array_length() returns to avoid int overflow
Reviewed-by: kvn, dholmes, tonyp
duke@435 | 1 | /* |
stefank@2314 | 2 | * Copyright (c) 1997, 2010, 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 | #ifndef SHARE_VM_OOPS_OBJARRAYKLASS_HPP |
stefank@2314 | 26 | #define SHARE_VM_OOPS_OBJARRAYKLASS_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "memory/specialized_oop_closures.hpp" |
stefank@2314 | 29 | #include "oops/arrayKlass.hpp" |
stefank@2314 | 30 | #include "oops/instanceKlass.hpp" |
stefank@2314 | 31 | |
duke@435 | 32 | // objArrayKlass is the klass for objArrays |
duke@435 | 33 | |
duke@435 | 34 | class objArrayKlass : public arrayKlass { |
duke@435 | 35 | friend class VMStructs; |
duke@435 | 36 | private: |
duke@435 | 37 | klassOop _element_klass; // The klass of the elements of this array type |
duke@435 | 38 | klassOop _bottom_klass; // The one-dimensional type (instanceKlass or typeArrayKlass) |
duke@435 | 39 | public: |
duke@435 | 40 | // Instance variables |
duke@435 | 41 | klassOop element_klass() const { return _element_klass; } |
duke@435 | 42 | void set_element_klass(klassOop k) { oop_store_without_check((oop*) &_element_klass, (oop) k); } |
duke@435 | 43 | oop* element_klass_addr() { return (oop*)&_element_klass; } |
duke@435 | 44 | |
duke@435 | 45 | klassOop bottom_klass() const { return _bottom_klass; } |
duke@435 | 46 | void set_bottom_klass(klassOop k) { oop_store_without_check((oop*) &_bottom_klass, (oop) k); } |
duke@435 | 47 | oop* bottom_klass_addr() { return (oop*)&_bottom_klass; } |
duke@435 | 48 | |
duke@435 | 49 | // Compiler/Interpreter offset |
duke@435 | 50 | static int element_klass_offset_in_bytes() { return offset_of(objArrayKlass, _element_klass); } |
duke@435 | 51 | |
duke@435 | 52 | // Dispatched operation |
duke@435 | 53 | bool can_be_primary_super_slow() const; |
duke@435 | 54 | objArrayOop compute_secondary_supers(int num_extra_slots, TRAPS); |
duke@435 | 55 | bool compute_is_subtype_of(klassOop k); |
duke@435 | 56 | bool oop_is_objArray_slow() const { return true; } |
duke@435 | 57 | int oop_size(oop obj) const; |
duke@435 | 58 | int klass_oop_size() const { return object_size(); } |
duke@435 | 59 | |
duke@435 | 60 | // Allocation |
duke@435 | 61 | DEFINE_ALLOCATE_PERMANENT(objArrayKlass); |
duke@435 | 62 | objArrayOop allocate(int length, TRAPS); |
duke@435 | 63 | oop multi_allocate(int rank, jint* sizes, TRAPS); |
duke@435 | 64 | |
duke@435 | 65 | // Copying |
duke@435 | 66 | void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS); |
duke@435 | 67 | |
duke@435 | 68 | // Compute protection domain |
duke@435 | 69 | oop protection_domain() { return Klass::cast(bottom_klass())->protection_domain(); } |
duke@435 | 70 | // Compute class loader |
duke@435 | 71 | oop class_loader() const { return Klass::cast(bottom_klass())->class_loader(); } |
duke@435 | 72 | |
coleenp@548 | 73 | private: |
coleenp@548 | 74 | // Either oop or narrowOop depending on UseCompressedOops. |
coleenp@548 | 75 | // must be called from within objArrayKlass.cpp |
coleenp@548 | 76 | template <class T> void do_copy(arrayOop s, T* src, arrayOop d, |
coleenp@548 | 77 | T* dst, int length, TRAPS); |
duke@435 | 78 | protected: |
duke@435 | 79 | // Returns the objArrayKlass for n'th dimension. |
duke@435 | 80 | virtual klassOop array_klass_impl(bool or_null, int n, TRAPS); |
duke@435 | 81 | |
duke@435 | 82 | // Returns the array class with this class as element type. |
duke@435 | 83 | virtual klassOop array_klass_impl(bool or_null, TRAPS); |
duke@435 | 84 | |
duke@435 | 85 | public: |
duke@435 | 86 | // Casting from klassOop |
duke@435 | 87 | static objArrayKlass* cast(klassOop k) { |
duke@435 | 88 | assert(k->klass_part()->oop_is_objArray_slow(), "cast to objArrayKlass"); |
duke@435 | 89 | return (objArrayKlass*) k->klass_part(); |
duke@435 | 90 | } |
duke@435 | 91 | |
duke@435 | 92 | // Sizing |
duke@435 | 93 | static int header_size() { return oopDesc::header_size() + sizeof(objArrayKlass)/HeapWordSize; } |
duke@435 | 94 | int object_size() const { return arrayKlass::object_size(header_size()); } |
duke@435 | 95 | |
duke@435 | 96 | // Initialization (virtual from Klass) |
duke@435 | 97 | void initialize(TRAPS); |
duke@435 | 98 | |
duke@435 | 99 | // Garbage collection |
duke@435 | 100 | void oop_follow_contents(oop obj); |
jcoomes@1746 | 101 | inline void oop_follow_contents(oop obj, int index); |
jcoomes@1746 | 102 | template <class T> inline void objarray_follow_contents(oop obj, int index); |
jcoomes@1746 | 103 | |
duke@435 | 104 | int oop_adjust_pointers(oop obj); |
duke@435 | 105 | |
duke@435 | 106 | // Parallel Scavenge and Parallel Old |
duke@435 | 107 | PARALLEL_GC_DECLS |
jcoomes@1746 | 108 | #ifndef SERIALGC |
jcoomes@1746 | 109 | inline void oop_follow_contents(ParCompactionManager* cm, oop obj, int index); |
jcoomes@1746 | 110 | template <class T> inline void |
jcoomes@1746 | 111 | objarray_follow_contents(ParCompactionManager* cm, oop obj, int index); |
jcoomes@1746 | 112 | #endif // !SERIALGC |
duke@435 | 113 | |
duke@435 | 114 | // Iterators |
duke@435 | 115 | int oop_oop_iterate(oop obj, OopClosure* blk) { |
duke@435 | 116 | return oop_oop_iterate_v(obj, blk); |
duke@435 | 117 | } |
duke@435 | 118 | int oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) { |
duke@435 | 119 | return oop_oop_iterate_v_m(obj, blk, mr); |
duke@435 | 120 | } |
duke@435 | 121 | #define ObjArrayKlass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix) \ |
duke@435 | 122 | int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk); \ |
duke@435 | 123 | int oop_oop_iterate##nv_suffix##_m(oop obj, OopClosureType* blk, \ |
coleenp@548 | 124 | MemRegion mr); \ |
coleenp@548 | 125 | int oop_oop_iterate_range##nv_suffix(oop obj, OopClosureType* blk, \ |
coleenp@548 | 126 | int start, int end); |
duke@435 | 127 | |
duke@435 | 128 | ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayKlass_OOP_OOP_ITERATE_DECL) |
ysr@777 | 129 | ALL_OOP_OOP_ITERATE_CLOSURES_2(ObjArrayKlass_OOP_OOP_ITERATE_DECL) |
duke@435 | 130 | |
duke@435 | 131 | // JVM support |
duke@435 | 132 | jint compute_modifier_flags(TRAPS) const; |
duke@435 | 133 | |
duke@435 | 134 | private: |
duke@435 | 135 | static klassOop array_klass_impl (objArrayKlassHandle this_oop, bool or_null, int n, TRAPS); |
duke@435 | 136 | |
duke@435 | 137 | public: |
duke@435 | 138 | // Printing |
jrose@1590 | 139 | void oop_print_value_on(oop obj, outputStream* st); |
jrose@1590 | 140 | #ifndef PRODUCT |
duke@435 | 141 | void oop_print_on (oop obj, outputStream* st); |
jrose@1590 | 142 | #endif //PRODUCT |
duke@435 | 143 | |
duke@435 | 144 | // Verification |
duke@435 | 145 | const char* internal_name() const; |
duke@435 | 146 | void oop_verify_on(oop obj, outputStream* st); |
duke@435 | 147 | void oop_verify_old_oop(oop obj, oop* p, bool allow_dirty); |
coleenp@548 | 148 | void oop_verify_old_oop(oop obj, narrowOop* p, bool allow_dirty); |
duke@435 | 149 | }; |
stefank@2314 | 150 | |
stefank@2314 | 151 | #endif // SHARE_VM_OOPS_OBJARRAYKLASS_HPP |