src/share/vm/runtime/stubRoutines.hpp

Sat, 01 Sep 2012 13:25:18 -0400

author
coleenp
date
Sat, 01 Sep 2012 13:25:18 -0400
changeset 4037
da91efe96a93
parent 3969
1d7922586cf6
child 4205
a3ecd773a7b9
permissions
-rw-r--r--

6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>

duke@435 1 /*
coleenp@4037 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 #ifndef SHARE_VM_RUNTIME_STUBROUTINES_HPP
stefank@2314 26 #define SHARE_VM_RUNTIME_STUBROUTINES_HPP
stefank@2314 27
stefank@2314 28 #include "code/codeBlob.hpp"
stefank@2314 29 #include "memory/allocation.hpp"
stefank@2314 30 #include "runtime/frame.hpp"
stefank@2314 31 #include "runtime/mutexLocker.hpp"
stefank@2314 32 #include "runtime/stubCodeGenerator.hpp"
stefank@2314 33 #include "utilities/top.hpp"
stefank@2314 34 #ifdef TARGET_ARCH_x86
stefank@2314 35 # include "nativeInst_x86.hpp"
stefank@2314 36 #endif
stefank@2314 37 #ifdef TARGET_ARCH_sparc
stefank@2314 38 # include "nativeInst_sparc.hpp"
stefank@2314 39 #endif
stefank@2314 40 #ifdef TARGET_ARCH_zero
stefank@2314 41 # include "nativeInst_zero.hpp"
stefank@2314 42 #endif
bobv@2508 43 #ifdef TARGET_ARCH_arm
bobv@2508 44 # include "nativeInst_arm.hpp"
bobv@2508 45 #endif
bobv@2508 46 #ifdef TARGET_ARCH_ppc
bobv@2508 47 # include "nativeInst_ppc.hpp"
bobv@2508 48 #endif
stefank@2314 49
duke@435 50 // StubRoutines provides entry points to assembly routines used by
duke@435 51 // compiled code and the run-time system. Platform-specific entry
duke@435 52 // points are defined in the platform-specific inner class.
duke@435 53 //
duke@435 54 // Class scheme:
duke@435 55 //
duke@435 56 // platform-independent platform-dependent
duke@435 57 //
duke@435 58 // stubRoutines.hpp <-- included -- stubRoutines_<arch>.hpp
duke@435 59 // ^ ^
duke@435 60 // | |
duke@435 61 // implements implements
duke@435 62 // | |
duke@435 63 // | |
duke@435 64 // stubRoutines.cpp stubRoutines_<arch>.cpp
duke@435 65 // stubRoutines_<os_family>.cpp stubGenerator_<arch>.cpp
duke@435 66 // stubRoutines_<os_arch>.cpp
duke@435 67 //
duke@435 68 // Note 1: The important thing is a clean decoupling between stub
duke@435 69 // entry points (interfacing to the whole vm; i.e., 1-to-n
duke@435 70 // relationship) and stub generators (interfacing only to
duke@435 71 // the entry points implementation; i.e., 1-to-1 relationship).
duke@435 72 // This significantly simplifies changes in the generator
duke@435 73 // structure since the rest of the vm is not affected.
duke@435 74 //
duke@435 75 // Note 2: stubGenerator_<arch>.cpp contains a minimal portion of
duke@435 76 // machine-independent code; namely the generator calls of
duke@435 77 // the generator functions that are used platform-independently.
duke@435 78 // However, it comes with the advantage of having a 1-file
duke@435 79 // implementation of the generator. It should be fairly easy
duke@435 80 // to change, should it become a problem later.
duke@435 81 //
duke@435 82 // Scheme for adding a new entry point:
duke@435 83 //
duke@435 84 // 1. determine if it's a platform-dependent or independent entry point
duke@435 85 // a) if platform independent: make subsequent changes in the independent files
duke@435 86 // b) if platform dependent: make subsequent changes in the dependent files
duke@435 87 // 2. add a private instance variable holding the entry point address
duke@435 88 // 3. add a public accessor function to the instance variable
duke@435 89 // 4. implement the corresponding generator function in the platform-dependent
duke@435 90 // stubGenerator_<arch>.cpp file and call the function in generate_all() of that file
duke@435 91
duke@435 92
duke@435 93 class StubRoutines: AllStatic {
duke@435 94
duke@435 95 public:
duke@435 96 enum platform_independent_constants {
duke@435 97 max_size_of_parameters = 256 // max. parameter size supported by megamorphic lookups
duke@435 98 };
duke@435 99
duke@435 100 // Dependencies
duke@435 101 friend class StubGenerator;
stefank@2314 102 #ifdef TARGET_ARCH_MODEL_x86_32
stefank@2314 103 # include "stubRoutines_x86_32.hpp"
stefank@2314 104 #endif
stefank@2314 105 #ifdef TARGET_ARCH_MODEL_x86_64
stefank@2314 106 # include "stubRoutines_x86_64.hpp"
stefank@2314 107 #endif
stefank@2314 108 #ifdef TARGET_ARCH_MODEL_sparc
stefank@2314 109 # include "stubRoutines_sparc.hpp"
stefank@2314 110 #endif
stefank@2314 111 #ifdef TARGET_ARCH_MODEL_zero
stefank@2314 112 # include "stubRoutines_zero.hpp"
stefank@2314 113 #endif
bobv@2508 114 #ifdef TARGET_ARCH_MODEL_arm
bobv@2508 115 # include "stubRoutines_arm.hpp"
bobv@2508 116 #endif
bobv@2508 117 #ifdef TARGET_ARCH_MODEL_ppc
bobv@2508 118 # include "stubRoutines_ppc.hpp"
bobv@2508 119 #endif
stefank@2314 120
duke@435 121
duke@435 122 static jint _verify_oop_count;
duke@435 123 static address _verify_oop_subroutine_entry;
duke@435 124
duke@435 125 static address _call_stub_return_address; // the return PC, when returning to a call stub
duke@435 126 static address _call_stub_entry;
duke@435 127 static address _forward_exception_entry;
duke@435 128 static address _catch_exception_entry;
duke@435 129 static address _throw_AbstractMethodError_entry;
dcubed@451 130 static address _throw_IncompatibleClassChangeError_entry;
duke@435 131 static address _throw_NullPointerException_at_call_entry;
duke@435 132 static address _throw_StackOverflowError_entry;
duke@435 133 static address _handler_for_unsafe_access_entry;
duke@435 134
duke@435 135 static address _atomic_xchg_entry;
duke@435 136 static address _atomic_xchg_ptr_entry;
duke@435 137 static address _atomic_store_entry;
duke@435 138 static address _atomic_store_ptr_entry;
duke@435 139 static address _atomic_cmpxchg_entry;
duke@435 140 static address _atomic_cmpxchg_ptr_entry;
duke@435 141 static address _atomic_cmpxchg_long_entry;
duke@435 142 static address _atomic_add_entry;
duke@435 143 static address _atomic_add_ptr_entry;
duke@435 144 static address _fence_entry;
duke@435 145 static address _d2i_wrapper;
duke@435 146 static address _d2l_wrapper;
duke@435 147
duke@435 148 static jint _fpu_cntrl_wrd_std;
duke@435 149 static jint _fpu_cntrl_wrd_24;
duke@435 150 static jint _fpu_cntrl_wrd_64;
duke@435 151 static jint _fpu_cntrl_wrd_trunc;
duke@435 152 static jint _mxcsr_std;
duke@435 153 static jint _fpu_subnormal_bias1[3];
duke@435 154 static jint _fpu_subnormal_bias2[3];
duke@435 155
duke@435 156 static BufferBlob* _code1; // code buffer for initial routines
duke@435 157 static BufferBlob* _code2; // code buffer for all other routines
duke@435 158
duke@435 159 // Leaf routines which implement arraycopy and their addresses
duke@435 160 // arraycopy operands aligned on element type boundary
duke@435 161 static address _jbyte_arraycopy;
duke@435 162 static address _jshort_arraycopy;
duke@435 163 static address _jint_arraycopy;
duke@435 164 static address _jlong_arraycopy;
iveresov@2606 165 static address _oop_arraycopy, _oop_arraycopy_uninit;
duke@435 166 static address _jbyte_disjoint_arraycopy;
duke@435 167 static address _jshort_disjoint_arraycopy;
duke@435 168 static address _jint_disjoint_arraycopy;
duke@435 169 static address _jlong_disjoint_arraycopy;
iveresov@2606 170 static address _oop_disjoint_arraycopy, _oop_disjoint_arraycopy_uninit;
duke@435 171
duke@435 172 // arraycopy operands aligned on zero'th element boundary
duke@435 173 // These are identical to the ones aligned aligned on an
duke@435 174 // element type boundary, except that they assume that both
duke@435 175 // source and destination are HeapWord aligned.
duke@435 176 static address _arrayof_jbyte_arraycopy;
duke@435 177 static address _arrayof_jshort_arraycopy;
duke@435 178 static address _arrayof_jint_arraycopy;
duke@435 179 static address _arrayof_jlong_arraycopy;
iveresov@2606 180 static address _arrayof_oop_arraycopy, _arrayof_oop_arraycopy_uninit;
duke@435 181 static address _arrayof_jbyte_disjoint_arraycopy;
duke@435 182 static address _arrayof_jshort_disjoint_arraycopy;
duke@435 183 static address _arrayof_jint_disjoint_arraycopy;
duke@435 184 static address _arrayof_jlong_disjoint_arraycopy;
iveresov@2606 185 static address _arrayof_oop_disjoint_arraycopy, _arrayof_oop_disjoint_arraycopy_uninit;
duke@435 186
duke@435 187 // these are recommended but optional:
iveresov@2606 188 static address _checkcast_arraycopy, _checkcast_arraycopy_uninit;
duke@435 189 static address _unsafe_arraycopy;
duke@435 190 static address _generic_arraycopy;
duke@435 191
never@2118 192 static address _jbyte_fill;
never@2118 193 static address _jshort_fill;
never@2118 194 static address _jint_fill;
never@2118 195 static address _arrayof_jbyte_fill;
never@2118 196 static address _arrayof_jshort_fill;
never@2118 197 static address _arrayof_jint_fill;
never@2118 198
kvn@3092 199 // zero heap space aligned to jlong (8 bytes)
kvn@3092 200 static address _zero_aligned_words;
kvn@3092 201
never@1609 202 // These are versions of the java.lang.Math methods which perform
never@1609 203 // the same operations as the intrinsic version. They are used for
never@1609 204 // constant folding in the compiler to ensure equivalence. If the
never@1609 205 // intrinsic version returns the same result as the strict version
never@1609 206 // then they can be set to the appropriate function from
never@1609 207 // SharedRuntime.
never@1609 208 static double (*_intrinsic_log)(double);
never@1609 209 static double (*_intrinsic_log10)(double);
never@1609 210 static double (*_intrinsic_exp)(double);
never@1609 211 static double (*_intrinsic_pow)(double, double);
never@1609 212 static double (*_intrinsic_sin)(double);
never@1609 213 static double (*_intrinsic_cos)(double);
never@1609 214 static double (*_intrinsic_tan)(double);
never@1609 215
duke@435 216 public:
duke@435 217 // Initialization/Testing
duke@435 218 static void initialize1(); // must happen before universe::genesis
duke@435 219 static void initialize2(); // must happen after universe::genesis
duke@435 220
duke@435 221 static bool contains(address addr) {
duke@435 222 return
duke@435 223 (_code1 != NULL && _code1->blob_contains(addr)) ||
duke@435 224 (_code2 != NULL && _code2->blob_contains(addr)) ;
duke@435 225 }
duke@435 226
twisti@3969 227 static CodeBlob* code1() { return _code1; }
twisti@3969 228 static CodeBlob* code2() { return _code2; }
twisti@3969 229
duke@435 230 // Debugging
duke@435 231 static jint verify_oop_count() { return _verify_oop_count; }
duke@435 232 static jint* verify_oop_count_addr() { return &_verify_oop_count; }
duke@435 233 // a subroutine for debugging the GC
duke@435 234 static address verify_oop_subroutine_entry_address() { return (address)&_verify_oop_subroutine_entry; }
duke@435 235
duke@435 236 static address catch_exception_entry() { return _catch_exception_entry; }
duke@435 237
duke@435 238 // Calls to Java
duke@435 239 typedef void (*CallStub)(
duke@435 240 address link,
duke@435 241 intptr_t* result,
duke@435 242 BasicType result_type,
coleenp@4037 243 Method* method,
duke@435 244 address entry_point,
duke@435 245 intptr_t* parameters,
duke@435 246 int size_of_parameters,
duke@435 247 TRAPS
duke@435 248 );
duke@435 249
duke@435 250 static CallStub call_stub() { return CAST_TO_FN_PTR(CallStub, _call_stub_entry); }
duke@435 251
duke@435 252 // Exceptions
duke@435 253 static address forward_exception_entry() { return _forward_exception_entry; }
duke@435 254 // Implicit exceptions
duke@435 255 static address throw_AbstractMethodError_entry() { return _throw_AbstractMethodError_entry; }
dcubed@451 256 static address throw_IncompatibleClassChangeError_entry(){ return _throw_IncompatibleClassChangeError_entry; }
duke@435 257 static address throw_NullPointerException_at_call_entry(){ return _throw_NullPointerException_at_call_entry; }
duke@435 258 static address throw_StackOverflowError_entry() { return _throw_StackOverflowError_entry; }
duke@435 259
duke@435 260 // Exceptions during unsafe access - should throw Java exception rather
duke@435 261 // than crash.
duke@435 262 static address handler_for_unsafe_access() { return _handler_for_unsafe_access_entry; }
duke@435 263
duke@435 264 static address atomic_xchg_entry() { return _atomic_xchg_entry; }
duke@435 265 static address atomic_xchg_ptr_entry() { return _atomic_xchg_ptr_entry; }
duke@435 266 static address atomic_store_entry() { return _atomic_store_entry; }
duke@435 267 static address atomic_store_ptr_entry() { return _atomic_store_ptr_entry; }
duke@435 268 static address atomic_cmpxchg_entry() { return _atomic_cmpxchg_entry; }
duke@435 269 static address atomic_cmpxchg_ptr_entry() { return _atomic_cmpxchg_ptr_entry; }
duke@435 270 static address atomic_cmpxchg_long_entry() { return _atomic_cmpxchg_long_entry; }
duke@435 271 static address atomic_add_entry() { return _atomic_add_entry; }
duke@435 272 static address atomic_add_ptr_entry() { return _atomic_add_ptr_entry; }
duke@435 273 static address fence_entry() { return _fence_entry; }
duke@435 274
duke@435 275 static address d2i_wrapper() { return _d2i_wrapper; }
duke@435 276 static address d2l_wrapper() { return _d2l_wrapper; }
duke@435 277 static jint fpu_cntrl_wrd_std() { return _fpu_cntrl_wrd_std; }
duke@435 278 static address addr_fpu_cntrl_wrd_std() { return (address)&_fpu_cntrl_wrd_std; }
duke@435 279 static address addr_fpu_cntrl_wrd_24() { return (address)&_fpu_cntrl_wrd_24; }
duke@435 280 static address addr_fpu_cntrl_wrd_64() { return (address)&_fpu_cntrl_wrd_64; }
duke@435 281 static address addr_fpu_cntrl_wrd_trunc() { return (address)&_fpu_cntrl_wrd_trunc; }
duke@435 282 static address addr_mxcsr_std() { return (address)&_mxcsr_std; }
duke@435 283 static address addr_fpu_subnormal_bias1() { return (address)&_fpu_subnormal_bias1; }
duke@435 284 static address addr_fpu_subnormal_bias2() { return (address)&_fpu_subnormal_bias2; }
duke@435 285
duke@435 286
roland@2728 287 static address select_arraycopy_function(BasicType t, bool aligned, bool disjoint, const char* &name, bool dest_uninitialized);
roland@2728 288
duke@435 289 static address jbyte_arraycopy() { return _jbyte_arraycopy; }
duke@435 290 static address jshort_arraycopy() { return _jshort_arraycopy; }
duke@435 291 static address jint_arraycopy() { return _jint_arraycopy; }
duke@435 292 static address jlong_arraycopy() { return _jlong_arraycopy; }
iveresov@2606 293 static address oop_arraycopy(bool dest_uninitialized = false) {
iveresov@2606 294 return dest_uninitialized ? _oop_arraycopy_uninit : _oop_arraycopy;
iveresov@2606 295 }
duke@435 296 static address jbyte_disjoint_arraycopy() { return _jbyte_disjoint_arraycopy; }
duke@435 297 static address jshort_disjoint_arraycopy() { return _jshort_disjoint_arraycopy; }
duke@435 298 static address jint_disjoint_arraycopy() { return _jint_disjoint_arraycopy; }
duke@435 299 static address jlong_disjoint_arraycopy() { return _jlong_disjoint_arraycopy; }
iveresov@2606 300 static address oop_disjoint_arraycopy(bool dest_uninitialized = false) {
iveresov@2606 301 return dest_uninitialized ? _oop_disjoint_arraycopy_uninit : _oop_disjoint_arraycopy;
iveresov@2606 302 }
duke@435 303
duke@435 304 static address arrayof_jbyte_arraycopy() { return _arrayof_jbyte_arraycopy; }
duke@435 305 static address arrayof_jshort_arraycopy() { return _arrayof_jshort_arraycopy; }
duke@435 306 static address arrayof_jint_arraycopy() { return _arrayof_jint_arraycopy; }
duke@435 307 static address arrayof_jlong_arraycopy() { return _arrayof_jlong_arraycopy; }
iveresov@2606 308 static address arrayof_oop_arraycopy(bool dest_uninitialized = false) {
iveresov@2606 309 return dest_uninitialized ? _arrayof_oop_arraycopy_uninit : _arrayof_oop_arraycopy;
iveresov@2606 310 }
duke@435 311
duke@435 312 static address arrayof_jbyte_disjoint_arraycopy() { return _arrayof_jbyte_disjoint_arraycopy; }
duke@435 313 static address arrayof_jshort_disjoint_arraycopy() { return _arrayof_jshort_disjoint_arraycopy; }
duke@435 314 static address arrayof_jint_disjoint_arraycopy() { return _arrayof_jint_disjoint_arraycopy; }
duke@435 315 static address arrayof_jlong_disjoint_arraycopy() { return _arrayof_jlong_disjoint_arraycopy; }
iveresov@2606 316 static address arrayof_oop_disjoint_arraycopy(bool dest_uninitialized = false) {
iveresov@2606 317 return dest_uninitialized ? _arrayof_oop_disjoint_arraycopy_uninit : _arrayof_oop_disjoint_arraycopy;
iveresov@2606 318 }
duke@435 319
iveresov@2606 320 static address checkcast_arraycopy(bool dest_uninitialized = false) {
iveresov@2606 321 return dest_uninitialized ? _checkcast_arraycopy_uninit : _checkcast_arraycopy;
iveresov@2606 322 }
duke@435 323 static address unsafe_arraycopy() { return _unsafe_arraycopy; }
duke@435 324 static address generic_arraycopy() { return _generic_arraycopy; }
duke@435 325
never@2118 326 static address jbyte_fill() { return _jbyte_fill; }
never@2118 327 static address jshort_fill() { return _jshort_fill; }
never@2118 328 static address jint_fill() { return _jint_fill; }
never@2118 329 static address arrayof_jbyte_fill() { return _arrayof_jbyte_fill; }
never@2118 330 static address arrayof_jshort_fill() { return _arrayof_jshort_fill; }
never@2118 331 static address arrayof_jint_fill() { return _arrayof_jint_fill; }
never@2118 332
never@2118 333 static address select_fill_function(BasicType t, bool aligned, const char* &name);
never@2118 334
kvn@3092 335 static address zero_aligned_words() { return _zero_aligned_words; }
never@2118 336
never@1609 337 static double intrinsic_log(double d) {
never@1609 338 assert(_intrinsic_log != NULL, "must be defined");
never@1609 339 return _intrinsic_log(d);
never@1609 340 }
never@1609 341 static double intrinsic_log10(double d) {
never@1609 342 assert(_intrinsic_log != NULL, "must be defined");
never@1609 343 return _intrinsic_log10(d);
never@1609 344 }
never@1609 345 static double intrinsic_exp(double d) {
never@1609 346 assert(_intrinsic_exp != NULL, "must be defined");
never@1609 347 return _intrinsic_exp(d);
never@1609 348 }
never@1609 349 static double intrinsic_pow(double d, double d2) {
never@1609 350 assert(_intrinsic_pow != NULL, "must be defined");
never@1609 351 return _intrinsic_pow(d, d2);
never@1609 352 }
never@1609 353 static double intrinsic_sin(double d) {
never@1609 354 assert(_intrinsic_sin != NULL, "must be defined");
never@1609 355 return _intrinsic_sin(d);
never@1609 356 }
never@1609 357 static double intrinsic_cos(double d) {
never@1609 358 assert(_intrinsic_cos != NULL, "must be defined");
never@1609 359 return _intrinsic_cos(d);
never@1609 360 }
never@1609 361 static double intrinsic_tan(double d) {
never@1609 362 assert(_intrinsic_tan != NULL, "must be defined");
never@1609 363 return _intrinsic_tan(d);
never@1609 364 }
never@1609 365
duke@435 366 //
duke@435 367 // Default versions of the above arraycopy functions for platforms which do
duke@435 368 // not have specialized versions
duke@435 369 //
iveresov@2606 370 static void jbyte_copy (jbyte* src, jbyte* dest, size_t count);
iveresov@2606 371 static void jshort_copy (jshort* src, jshort* dest, size_t count);
iveresov@2606 372 static void jint_copy (jint* src, jint* dest, size_t count);
iveresov@2606 373 static void jlong_copy (jlong* src, jlong* dest, size_t count);
iveresov@2606 374 static void oop_copy (oop* src, oop* dest, size_t count);
iveresov@2606 375 static void oop_copy_uninit(oop* src, oop* dest, size_t count);
duke@435 376
iveresov@2606 377 static void arrayof_jbyte_copy (HeapWord* src, HeapWord* dest, size_t count);
iveresov@2606 378 static void arrayof_jshort_copy (HeapWord* src, HeapWord* dest, size_t count);
iveresov@2606 379 static void arrayof_jint_copy (HeapWord* src, HeapWord* dest, size_t count);
iveresov@2606 380 static void arrayof_jlong_copy (HeapWord* src, HeapWord* dest, size_t count);
iveresov@2606 381 static void arrayof_oop_copy (HeapWord* src, HeapWord* dest, size_t count);
iveresov@2606 382 static void arrayof_oop_copy_uninit(HeapWord* src, HeapWord* dest, size_t count);
duke@435 383 };
stefank@2314 384
stefank@2314 385 #endif // SHARE_VM_RUNTIME_STUBROUTINES_HPP

mercurial