Thu, 27 May 2010 18:01:56 -0700
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
Summary: Added new product ObjectAlignmentInBytes flag to control object alignment.
Reviewed-by: twisti, ysr, iveresov
duke@435 | 1 | /* |
never@1609 | 2 | * Copyright 1997-2010 Sun Microsystems, Inc. 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 | * |
duke@435 | 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@435 | 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@435 | 21 | * have any questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
duke@435 | 25 | // StubRoutines provides entry points to assembly routines used by |
duke@435 | 26 | // compiled code and the run-time system. Platform-specific entry |
duke@435 | 27 | // points are defined in the platform-specific inner class. |
duke@435 | 28 | // |
duke@435 | 29 | // Class scheme: |
duke@435 | 30 | // |
duke@435 | 31 | // platform-independent platform-dependent |
duke@435 | 32 | // |
duke@435 | 33 | // stubRoutines.hpp <-- included -- stubRoutines_<arch>.hpp |
duke@435 | 34 | // ^ ^ |
duke@435 | 35 | // | | |
duke@435 | 36 | // implements implements |
duke@435 | 37 | // | | |
duke@435 | 38 | // | | |
duke@435 | 39 | // stubRoutines.cpp stubRoutines_<arch>.cpp |
duke@435 | 40 | // stubRoutines_<os_family>.cpp stubGenerator_<arch>.cpp |
duke@435 | 41 | // stubRoutines_<os_arch>.cpp |
duke@435 | 42 | // |
duke@435 | 43 | // Note 1: The important thing is a clean decoupling between stub |
duke@435 | 44 | // entry points (interfacing to the whole vm; i.e., 1-to-n |
duke@435 | 45 | // relationship) and stub generators (interfacing only to |
duke@435 | 46 | // the entry points implementation; i.e., 1-to-1 relationship). |
duke@435 | 47 | // This significantly simplifies changes in the generator |
duke@435 | 48 | // structure since the rest of the vm is not affected. |
duke@435 | 49 | // |
duke@435 | 50 | // Note 2: stubGenerator_<arch>.cpp contains a minimal portion of |
duke@435 | 51 | // machine-independent code; namely the generator calls of |
duke@435 | 52 | // the generator functions that are used platform-independently. |
duke@435 | 53 | // However, it comes with the advantage of having a 1-file |
duke@435 | 54 | // implementation of the generator. It should be fairly easy |
duke@435 | 55 | // to change, should it become a problem later. |
duke@435 | 56 | // |
duke@435 | 57 | // Scheme for adding a new entry point: |
duke@435 | 58 | // |
duke@435 | 59 | // 1. determine if it's a platform-dependent or independent entry point |
duke@435 | 60 | // a) if platform independent: make subsequent changes in the independent files |
duke@435 | 61 | // b) if platform dependent: make subsequent changes in the dependent files |
duke@435 | 62 | // 2. add a private instance variable holding the entry point address |
duke@435 | 63 | // 3. add a public accessor function to the instance variable |
duke@435 | 64 | // 4. implement the corresponding generator function in the platform-dependent |
duke@435 | 65 | // stubGenerator_<arch>.cpp file and call the function in generate_all() of that file |
duke@435 | 66 | |
duke@435 | 67 | |
duke@435 | 68 | class StubRoutines: AllStatic { |
duke@435 | 69 | |
duke@435 | 70 | public: |
duke@435 | 71 | enum platform_independent_constants { |
duke@435 | 72 | max_size_of_parameters = 256 // max. parameter size supported by megamorphic lookups |
duke@435 | 73 | }; |
duke@435 | 74 | |
duke@435 | 75 | // Dependencies |
duke@435 | 76 | friend class StubGenerator; |
duke@435 | 77 | #include "incls/_stubRoutines_pd.hpp.incl" // machine-specific parts |
duke@435 | 78 | |
duke@435 | 79 | static jint _verify_oop_count; |
duke@435 | 80 | static address _verify_oop_subroutine_entry; |
duke@435 | 81 | |
duke@435 | 82 | static address _call_stub_return_address; // the return PC, when returning to a call stub |
duke@435 | 83 | static address _call_stub_entry; |
duke@435 | 84 | static address _forward_exception_entry; |
duke@435 | 85 | static address _catch_exception_entry; |
duke@435 | 86 | static address _throw_AbstractMethodError_entry; |
dcubed@451 | 87 | static address _throw_IncompatibleClassChangeError_entry; |
duke@435 | 88 | static address _throw_ArithmeticException_entry; |
duke@435 | 89 | static address _throw_NullPointerException_entry; |
duke@435 | 90 | static address _throw_NullPointerException_at_call_entry; |
duke@435 | 91 | static address _throw_StackOverflowError_entry; |
duke@435 | 92 | static address _handler_for_unsafe_access_entry; |
duke@435 | 93 | |
duke@435 | 94 | static address _atomic_xchg_entry; |
duke@435 | 95 | static address _atomic_xchg_ptr_entry; |
duke@435 | 96 | static address _atomic_store_entry; |
duke@435 | 97 | static address _atomic_store_ptr_entry; |
duke@435 | 98 | static address _atomic_cmpxchg_entry; |
duke@435 | 99 | static address _atomic_cmpxchg_ptr_entry; |
duke@435 | 100 | static address _atomic_cmpxchg_long_entry; |
duke@435 | 101 | static address _atomic_add_entry; |
duke@435 | 102 | static address _atomic_add_ptr_entry; |
duke@435 | 103 | static address _fence_entry; |
duke@435 | 104 | static address _d2i_wrapper; |
duke@435 | 105 | static address _d2l_wrapper; |
duke@435 | 106 | |
duke@435 | 107 | static jint _fpu_cntrl_wrd_std; |
duke@435 | 108 | static jint _fpu_cntrl_wrd_24; |
duke@435 | 109 | static jint _fpu_cntrl_wrd_64; |
duke@435 | 110 | static jint _fpu_cntrl_wrd_trunc; |
duke@435 | 111 | static jint _mxcsr_std; |
duke@435 | 112 | static jint _fpu_subnormal_bias1[3]; |
duke@435 | 113 | static jint _fpu_subnormal_bias2[3]; |
duke@435 | 114 | |
duke@435 | 115 | static BufferBlob* _code1; // code buffer for initial routines |
duke@435 | 116 | static BufferBlob* _code2; // code buffer for all other routines |
duke@435 | 117 | |
duke@435 | 118 | // Leaf routines which implement arraycopy and their addresses |
duke@435 | 119 | // arraycopy operands aligned on element type boundary |
duke@435 | 120 | static address _jbyte_arraycopy; |
duke@435 | 121 | static address _jshort_arraycopy; |
duke@435 | 122 | static address _jint_arraycopy; |
duke@435 | 123 | static address _jlong_arraycopy; |
duke@435 | 124 | static address _oop_arraycopy; |
duke@435 | 125 | static address _jbyte_disjoint_arraycopy; |
duke@435 | 126 | static address _jshort_disjoint_arraycopy; |
duke@435 | 127 | static address _jint_disjoint_arraycopy; |
duke@435 | 128 | static address _jlong_disjoint_arraycopy; |
duke@435 | 129 | static address _oop_disjoint_arraycopy; |
duke@435 | 130 | |
duke@435 | 131 | // arraycopy operands aligned on zero'th element boundary |
duke@435 | 132 | // These are identical to the ones aligned aligned on an |
duke@435 | 133 | // element type boundary, except that they assume that both |
duke@435 | 134 | // source and destination are HeapWord aligned. |
duke@435 | 135 | static address _arrayof_jbyte_arraycopy; |
duke@435 | 136 | static address _arrayof_jshort_arraycopy; |
duke@435 | 137 | static address _arrayof_jint_arraycopy; |
duke@435 | 138 | static address _arrayof_jlong_arraycopy; |
duke@435 | 139 | static address _arrayof_oop_arraycopy; |
duke@435 | 140 | static address _arrayof_jbyte_disjoint_arraycopy; |
duke@435 | 141 | static address _arrayof_jshort_disjoint_arraycopy; |
duke@435 | 142 | static address _arrayof_jint_disjoint_arraycopy; |
duke@435 | 143 | static address _arrayof_jlong_disjoint_arraycopy; |
duke@435 | 144 | static address _arrayof_oop_disjoint_arraycopy; |
duke@435 | 145 | |
duke@435 | 146 | // these are recommended but optional: |
duke@435 | 147 | static address _checkcast_arraycopy; |
duke@435 | 148 | static address _unsafe_arraycopy; |
duke@435 | 149 | static address _generic_arraycopy; |
duke@435 | 150 | |
never@1609 | 151 | // These are versions of the java.lang.Math methods which perform |
never@1609 | 152 | // the same operations as the intrinsic version. They are used for |
never@1609 | 153 | // constant folding in the compiler to ensure equivalence. If the |
never@1609 | 154 | // intrinsic version returns the same result as the strict version |
never@1609 | 155 | // then they can be set to the appropriate function from |
never@1609 | 156 | // SharedRuntime. |
never@1609 | 157 | static double (*_intrinsic_log)(double); |
never@1609 | 158 | static double (*_intrinsic_log10)(double); |
never@1609 | 159 | static double (*_intrinsic_exp)(double); |
never@1609 | 160 | static double (*_intrinsic_pow)(double, double); |
never@1609 | 161 | static double (*_intrinsic_sin)(double); |
never@1609 | 162 | static double (*_intrinsic_cos)(double); |
never@1609 | 163 | static double (*_intrinsic_tan)(double); |
never@1609 | 164 | |
duke@435 | 165 | public: |
duke@435 | 166 | // Initialization/Testing |
duke@435 | 167 | static void initialize1(); // must happen before universe::genesis |
duke@435 | 168 | static void initialize2(); // must happen after universe::genesis |
duke@435 | 169 | |
duke@435 | 170 | static bool contains(address addr) { |
duke@435 | 171 | return |
duke@435 | 172 | (_code1 != NULL && _code1->blob_contains(addr)) || |
duke@435 | 173 | (_code2 != NULL && _code2->blob_contains(addr)) ; |
duke@435 | 174 | } |
duke@435 | 175 | |
duke@435 | 176 | // Debugging |
duke@435 | 177 | static jint verify_oop_count() { return _verify_oop_count; } |
duke@435 | 178 | static jint* verify_oop_count_addr() { return &_verify_oop_count; } |
duke@435 | 179 | // a subroutine for debugging the GC |
duke@435 | 180 | static address verify_oop_subroutine_entry_address() { return (address)&_verify_oop_subroutine_entry; } |
duke@435 | 181 | |
duke@435 | 182 | static address catch_exception_entry() { return _catch_exception_entry; } |
duke@435 | 183 | |
duke@435 | 184 | // Calls to Java |
duke@435 | 185 | typedef void (*CallStub)( |
duke@435 | 186 | address link, |
duke@435 | 187 | intptr_t* result, |
duke@435 | 188 | BasicType result_type, |
duke@435 | 189 | methodOopDesc* method, |
duke@435 | 190 | address entry_point, |
duke@435 | 191 | intptr_t* parameters, |
duke@435 | 192 | int size_of_parameters, |
duke@435 | 193 | TRAPS |
duke@435 | 194 | ); |
duke@435 | 195 | |
duke@435 | 196 | static CallStub call_stub() { return CAST_TO_FN_PTR(CallStub, _call_stub_entry); } |
duke@435 | 197 | |
duke@435 | 198 | // Exceptions |
duke@435 | 199 | static address forward_exception_entry() { return _forward_exception_entry; } |
duke@435 | 200 | // Implicit exceptions |
duke@435 | 201 | static address throw_AbstractMethodError_entry() { return _throw_AbstractMethodError_entry; } |
dcubed@451 | 202 | static address throw_IncompatibleClassChangeError_entry(){ return _throw_IncompatibleClassChangeError_entry; } |
duke@435 | 203 | static address throw_ArithmeticException_entry() { return _throw_ArithmeticException_entry; } |
duke@435 | 204 | static address throw_NullPointerException_entry() { return _throw_NullPointerException_entry; } |
duke@435 | 205 | static address throw_NullPointerException_at_call_entry(){ return _throw_NullPointerException_at_call_entry; } |
duke@435 | 206 | static address throw_StackOverflowError_entry() { return _throw_StackOverflowError_entry; } |
duke@435 | 207 | |
duke@435 | 208 | // Exceptions during unsafe access - should throw Java exception rather |
duke@435 | 209 | // than crash. |
duke@435 | 210 | static address handler_for_unsafe_access() { return _handler_for_unsafe_access_entry; } |
duke@435 | 211 | |
duke@435 | 212 | static address atomic_xchg_entry() { return _atomic_xchg_entry; } |
duke@435 | 213 | static address atomic_xchg_ptr_entry() { return _atomic_xchg_ptr_entry; } |
duke@435 | 214 | static address atomic_store_entry() { return _atomic_store_entry; } |
duke@435 | 215 | static address atomic_store_ptr_entry() { return _atomic_store_ptr_entry; } |
duke@435 | 216 | static address atomic_cmpxchg_entry() { return _atomic_cmpxchg_entry; } |
duke@435 | 217 | static address atomic_cmpxchg_ptr_entry() { return _atomic_cmpxchg_ptr_entry; } |
duke@435 | 218 | static address atomic_cmpxchg_long_entry() { return _atomic_cmpxchg_long_entry; } |
duke@435 | 219 | static address atomic_add_entry() { return _atomic_add_entry; } |
duke@435 | 220 | static address atomic_add_ptr_entry() { return _atomic_add_ptr_entry; } |
duke@435 | 221 | static address fence_entry() { return _fence_entry; } |
duke@435 | 222 | |
duke@435 | 223 | static address d2i_wrapper() { return _d2i_wrapper; } |
duke@435 | 224 | static address d2l_wrapper() { return _d2l_wrapper; } |
duke@435 | 225 | static jint fpu_cntrl_wrd_std() { return _fpu_cntrl_wrd_std; } |
duke@435 | 226 | static address addr_fpu_cntrl_wrd_std() { return (address)&_fpu_cntrl_wrd_std; } |
duke@435 | 227 | static address addr_fpu_cntrl_wrd_24() { return (address)&_fpu_cntrl_wrd_24; } |
duke@435 | 228 | static address addr_fpu_cntrl_wrd_64() { return (address)&_fpu_cntrl_wrd_64; } |
duke@435 | 229 | static address addr_fpu_cntrl_wrd_trunc() { return (address)&_fpu_cntrl_wrd_trunc; } |
duke@435 | 230 | static address addr_mxcsr_std() { return (address)&_mxcsr_std; } |
duke@435 | 231 | static address addr_fpu_subnormal_bias1() { return (address)&_fpu_subnormal_bias1; } |
duke@435 | 232 | static address addr_fpu_subnormal_bias2() { return (address)&_fpu_subnormal_bias2; } |
duke@435 | 233 | |
duke@435 | 234 | |
duke@435 | 235 | static address jbyte_arraycopy() { return _jbyte_arraycopy; } |
duke@435 | 236 | static address jshort_arraycopy() { return _jshort_arraycopy; } |
duke@435 | 237 | static address jint_arraycopy() { return _jint_arraycopy; } |
duke@435 | 238 | static address jlong_arraycopy() { return _jlong_arraycopy; } |
duke@435 | 239 | static address oop_arraycopy() { return _oop_arraycopy; } |
duke@435 | 240 | static address jbyte_disjoint_arraycopy() { return _jbyte_disjoint_arraycopy; } |
duke@435 | 241 | static address jshort_disjoint_arraycopy() { return _jshort_disjoint_arraycopy; } |
duke@435 | 242 | static address jint_disjoint_arraycopy() { return _jint_disjoint_arraycopy; } |
duke@435 | 243 | static address jlong_disjoint_arraycopy() { return _jlong_disjoint_arraycopy; } |
duke@435 | 244 | static address oop_disjoint_arraycopy() { return _oop_disjoint_arraycopy; } |
duke@435 | 245 | |
duke@435 | 246 | static address arrayof_jbyte_arraycopy() { return _arrayof_jbyte_arraycopy; } |
duke@435 | 247 | static address arrayof_jshort_arraycopy() { return _arrayof_jshort_arraycopy; } |
duke@435 | 248 | static address arrayof_jint_arraycopy() { return _arrayof_jint_arraycopy; } |
duke@435 | 249 | static address arrayof_jlong_arraycopy() { return _arrayof_jlong_arraycopy; } |
duke@435 | 250 | static address arrayof_oop_arraycopy() { return _arrayof_oop_arraycopy; } |
duke@435 | 251 | |
duke@435 | 252 | static address arrayof_jbyte_disjoint_arraycopy() { return _arrayof_jbyte_disjoint_arraycopy; } |
duke@435 | 253 | static address arrayof_jshort_disjoint_arraycopy() { return _arrayof_jshort_disjoint_arraycopy; } |
duke@435 | 254 | static address arrayof_jint_disjoint_arraycopy() { return _arrayof_jint_disjoint_arraycopy; } |
duke@435 | 255 | static address arrayof_jlong_disjoint_arraycopy() { return _arrayof_jlong_disjoint_arraycopy; } |
duke@435 | 256 | static address arrayof_oop_disjoint_arraycopy() { return _arrayof_oop_disjoint_arraycopy; } |
duke@435 | 257 | |
duke@435 | 258 | static address checkcast_arraycopy() { return _checkcast_arraycopy; } |
duke@435 | 259 | static address unsafe_arraycopy() { return _unsafe_arraycopy; } |
duke@435 | 260 | static address generic_arraycopy() { return _generic_arraycopy; } |
duke@435 | 261 | |
never@1609 | 262 | static double intrinsic_log(double d) { |
never@1609 | 263 | assert(_intrinsic_log != NULL, "must be defined"); |
never@1609 | 264 | return _intrinsic_log(d); |
never@1609 | 265 | } |
never@1609 | 266 | static double intrinsic_log10(double d) { |
never@1609 | 267 | assert(_intrinsic_log != NULL, "must be defined"); |
never@1609 | 268 | return _intrinsic_log10(d); |
never@1609 | 269 | } |
never@1609 | 270 | static double intrinsic_exp(double d) { |
never@1609 | 271 | assert(_intrinsic_exp != NULL, "must be defined"); |
never@1609 | 272 | return _intrinsic_exp(d); |
never@1609 | 273 | } |
never@1609 | 274 | static double intrinsic_pow(double d, double d2) { |
never@1609 | 275 | assert(_intrinsic_pow != NULL, "must be defined"); |
never@1609 | 276 | return _intrinsic_pow(d, d2); |
never@1609 | 277 | } |
never@1609 | 278 | static double intrinsic_sin(double d) { |
never@1609 | 279 | assert(_intrinsic_sin != NULL, "must be defined"); |
never@1609 | 280 | return _intrinsic_sin(d); |
never@1609 | 281 | } |
never@1609 | 282 | static double intrinsic_cos(double d) { |
never@1609 | 283 | assert(_intrinsic_cos != NULL, "must be defined"); |
never@1609 | 284 | return _intrinsic_cos(d); |
never@1609 | 285 | } |
never@1609 | 286 | static double intrinsic_tan(double d) { |
never@1609 | 287 | assert(_intrinsic_tan != NULL, "must be defined"); |
never@1609 | 288 | return _intrinsic_tan(d); |
never@1609 | 289 | } |
never@1609 | 290 | |
duke@435 | 291 | // |
duke@435 | 292 | // Default versions of the above arraycopy functions for platforms which do |
duke@435 | 293 | // not have specialized versions |
duke@435 | 294 | // |
duke@435 | 295 | static void jbyte_copy (jbyte* src, jbyte* dest, size_t count); |
duke@435 | 296 | static void jshort_copy(jshort* src, jshort* dest, size_t count); |
duke@435 | 297 | static void jint_copy (jint* src, jint* dest, size_t count); |
duke@435 | 298 | static void jlong_copy (jlong* src, jlong* dest, size_t count); |
duke@435 | 299 | static void oop_copy (oop* src, oop* dest, size_t count); |
duke@435 | 300 | |
duke@435 | 301 | static void arrayof_jbyte_copy (HeapWord* src, HeapWord* dest, size_t count); |
duke@435 | 302 | static void arrayof_jshort_copy(HeapWord* src, HeapWord* dest, size_t count); |
duke@435 | 303 | static void arrayof_jint_copy (HeapWord* src, HeapWord* dest, size_t count); |
duke@435 | 304 | static void arrayof_jlong_copy (HeapWord* src, HeapWord* dest, size_t count); |
duke@435 | 305 | static void arrayof_oop_copy (HeapWord* src, HeapWord* dest, size_t count); |
duke@435 | 306 | }; |