annotate src/share/vm/runtime/stubRoutines.hpp @ 2701:c565834fb592

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