Tue, 08 Aug 2017 15:57:29 +0800
merge
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc. |
aoqi@0 | 4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 5 | * |
aoqi@0 | 6 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 7 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 8 | * published by the Free Software Foundation. |
aoqi@0 | 9 | * |
aoqi@0 | 10 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 13 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 14 | * accompanied this code). |
aoqi@0 | 15 | * |
aoqi@0 | 16 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 17 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 18 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 19 | * |
aoqi@0 | 20 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 21 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 22 | * questions. |
aoqi@0 | 23 | * |
aoqi@0 | 24 | */ |
aoqi@0 | 25 | |
aoqi@0 | 26 | // no precompiled headers |
aoqi@0 | 27 | #include "assembler_zero.inline.hpp" |
aoqi@0 | 28 | #include "classfile/classLoader.hpp" |
aoqi@0 | 29 | #include "classfile/systemDictionary.hpp" |
aoqi@0 | 30 | #include "classfile/vmSymbols.hpp" |
aoqi@0 | 31 | #include "code/icBuffer.hpp" |
aoqi@0 | 32 | #include "code/vtableStubs.hpp" |
aoqi@0 | 33 | #include "interpreter/interpreter.hpp" |
aoqi@0 | 34 | #include "jvm_linux.h" |
aoqi@0 | 35 | #include "memory/allocation.inline.hpp" |
aoqi@0 | 36 | #include "mutex_linux.inline.hpp" |
aoqi@0 | 37 | #include "nativeInst_zero.hpp" |
aoqi@0 | 38 | #include "os_share_linux.hpp" |
aoqi@0 | 39 | #include "prims/jniFastGetField.hpp" |
aoqi@0 | 40 | #include "prims/jvm.h" |
aoqi@0 | 41 | #include "prims/jvm_misc.hpp" |
aoqi@0 | 42 | #include "runtime/arguments.hpp" |
aoqi@0 | 43 | #include "runtime/extendedPC.hpp" |
aoqi@0 | 44 | #include "runtime/frame.inline.hpp" |
aoqi@0 | 45 | #include "runtime/interfaceSupport.hpp" |
aoqi@0 | 46 | #include "runtime/java.hpp" |
aoqi@0 | 47 | #include "runtime/javaCalls.hpp" |
aoqi@0 | 48 | #include "runtime/mutexLocker.hpp" |
aoqi@0 | 49 | #include "runtime/osThread.hpp" |
aoqi@0 | 50 | #include "runtime/sharedRuntime.hpp" |
aoqi@0 | 51 | #include "runtime/stubRoutines.hpp" |
aoqi@0 | 52 | #include "runtime/thread.inline.hpp" |
aoqi@0 | 53 | #include "runtime/timer.hpp" |
aoqi@0 | 54 | #include "utilities/events.hpp" |
aoqi@0 | 55 | #include "utilities/vmError.hpp" |
aoqi@0 | 56 | |
aoqi@0 | 57 | address os::current_stack_pointer() { |
aoqi@0 | 58 | address dummy = (address) &dummy; |
aoqi@0 | 59 | return dummy; |
aoqi@0 | 60 | } |
aoqi@0 | 61 | |
aoqi@0 | 62 | frame os::get_sender_for_C_frame(frame* fr) { |
aoqi@0 | 63 | ShouldNotCallThis(); |
aoqi@0 | 64 | } |
aoqi@0 | 65 | |
aoqi@0 | 66 | frame os::current_frame() { |
aoqi@0 | 67 | // The only thing that calls this is the stack printing code in |
aoqi@0 | 68 | // VMError::report: |
aoqi@0 | 69 | // - Step 110 (printing stack bounds) uses the sp in the frame |
aoqi@0 | 70 | // to determine the amount of free space on the stack. We |
aoqi@0 | 71 | // set the sp to a close approximation of the real value in |
aoqi@0 | 72 | // order to allow this step to complete. |
aoqi@0 | 73 | // - Step 120 (printing native stack) tries to walk the stack. |
aoqi@0 | 74 | // The frame we create has a NULL pc, which is ignored as an |
aoqi@0 | 75 | // invalid frame. |
aoqi@0 | 76 | frame dummy = frame(); |
aoqi@0 | 77 | dummy.set_sp((intptr_t *) current_stack_pointer()); |
aoqi@0 | 78 | return dummy; |
aoqi@0 | 79 | } |
aoqi@0 | 80 | |
aoqi@0 | 81 | char* os::non_memory_address_word() { |
aoqi@0 | 82 | // Must never look like an address returned by reserve_memory, |
aoqi@0 | 83 | // even in its subfields (as defined by the CPU immediate fields, |
aoqi@0 | 84 | // if the CPU splits constants across multiple instructions). |
aoqi@0 | 85 | #ifdef SPARC |
aoqi@0 | 86 | // On SPARC, 0 != %hi(any real address), because there is no |
aoqi@0 | 87 | // allocation in the first 1Kb of the virtual address space. |
aoqi@0 | 88 | return (char *) 0; |
aoqi@0 | 89 | #else |
aoqi@0 | 90 | // This is the value for x86; works pretty well for PPC too. |
aoqi@0 | 91 | return (char *) -1; |
aoqi@0 | 92 | #endif // SPARC |
aoqi@0 | 93 | } |
aoqi@0 | 94 | |
aoqi@0 | 95 | void os::initialize_thread(Thread * thr){ |
aoqi@0 | 96 | // Nothing to do. |
aoqi@0 | 97 | } |
aoqi@0 | 98 | |
aoqi@0 | 99 | address os::Linux::ucontext_get_pc(ucontext_t* uc) { |
aoqi@0 | 100 | ShouldNotCallThis(); |
aoqi@0 | 101 | } |
aoqi@0 | 102 | |
aoqi@0 | 103 | ExtendedPC os::fetch_frame_from_context(void* ucVoid, |
aoqi@0 | 104 | intptr_t** ret_sp, |
aoqi@0 | 105 | intptr_t** ret_fp) { |
aoqi@0 | 106 | ShouldNotCallThis(); |
aoqi@0 | 107 | } |
aoqi@0 | 108 | |
aoqi@0 | 109 | frame os::fetch_frame_from_context(void* ucVoid) { |
aoqi@0 | 110 | ShouldNotCallThis(); |
aoqi@0 | 111 | } |
aoqi@0 | 112 | |
aoqi@0 | 113 | extern "C" JNIEXPORT int |
aoqi@0 | 114 | JVM_handle_linux_signal(int sig, |
aoqi@0 | 115 | siginfo_t* info, |
aoqi@0 | 116 | void* ucVoid, |
aoqi@0 | 117 | int abort_if_unrecognized) { |
aoqi@0 | 118 | ucontext_t* uc = (ucontext_t*) ucVoid; |
aoqi@0 | 119 | |
aoqi@0 | 120 | Thread* t = ThreadLocalStorage::get_thread_slow(); |
aoqi@0 | 121 | |
aoqi@0 | 122 | SignalHandlerMark shm(t); |
aoqi@0 | 123 | |
aoqi@0 | 124 | // Note: it's not uncommon that JNI code uses signal/sigset to |
aoqi@0 | 125 | // install then restore certain signal handler (e.g. to temporarily |
aoqi@0 | 126 | // block SIGPIPE, or have a SIGILL handler when detecting CPU |
aoqi@0 | 127 | // type). When that happens, JVM_handle_linux_signal() might be |
aoqi@0 | 128 | // invoked with junk info/ucVoid. To avoid unnecessary crash when |
aoqi@0 | 129 | // libjsig is not preloaded, try handle signals that do not require |
aoqi@0 | 130 | // siginfo/ucontext first. |
aoqi@0 | 131 | |
aoqi@0 | 132 | if (sig == SIGPIPE || sig == SIGXFSZ) { |
aoqi@0 | 133 | // allow chained handler to go first |
aoqi@0 | 134 | if (os::Linux::chained_handler(sig, info, ucVoid)) { |
aoqi@0 | 135 | return true; |
aoqi@0 | 136 | } else { |
aoqi@0 | 137 | if (PrintMiscellaneous && (WizardMode || Verbose)) { |
aoqi@0 | 138 | char buf[64]; |
aoqi@0 | 139 | warning("Ignoring %s - see bugs 4229104 or 646499219", |
aoqi@0 | 140 | os::exception_name(sig, buf, sizeof(buf))); |
aoqi@0 | 141 | } |
aoqi@0 | 142 | return true; |
aoqi@0 | 143 | } |
aoqi@0 | 144 | } |
aoqi@0 | 145 | |
aoqi@0 | 146 | JavaThread* thread = NULL; |
aoqi@0 | 147 | VMThread* vmthread = NULL; |
aoqi@0 | 148 | if (os::Linux::signal_handlers_are_installed) { |
aoqi@0 | 149 | if (t != NULL ){ |
aoqi@0 | 150 | if(t->is_Java_thread()) { |
aoqi@0 | 151 | thread = (JavaThread*)t; |
aoqi@0 | 152 | } |
aoqi@0 | 153 | else if(t->is_VM_thread()){ |
aoqi@0 | 154 | vmthread = (VMThread *)t; |
aoqi@0 | 155 | } |
aoqi@0 | 156 | } |
aoqi@0 | 157 | } |
aoqi@0 | 158 | |
aoqi@0 | 159 | if (info != NULL && thread != NULL) { |
aoqi@0 | 160 | // Handle ALL stack overflow variations here |
aoqi@0 | 161 | if (sig == SIGSEGV) { |
aoqi@0 | 162 | address addr = (address) info->si_addr; |
aoqi@0 | 163 | |
aoqi@0 | 164 | // check if fault address is within thread stack |
aoqi@0 | 165 | if (addr < thread->stack_base() && |
aoqi@0 | 166 | addr >= thread->stack_base() - thread->stack_size()) { |
aoqi@0 | 167 | // stack overflow |
aoqi@0 | 168 | if (thread->in_stack_yellow_zone(addr)) { |
aoqi@0 | 169 | thread->disable_stack_yellow_zone(); |
aoqi@0 | 170 | ShouldNotCallThis(); |
aoqi@0 | 171 | } |
aoqi@0 | 172 | else if (thread->in_stack_red_zone(addr)) { |
aoqi@0 | 173 | thread->disable_stack_red_zone(); |
aoqi@0 | 174 | ShouldNotCallThis(); |
aoqi@0 | 175 | } |
aoqi@0 | 176 | else { |
aoqi@0 | 177 | // Accessing stack address below sp may cause SEGV if |
aoqi@0 | 178 | // current thread has MAP_GROWSDOWN stack. This should |
aoqi@0 | 179 | // only happen when current thread was created by user |
aoqi@0 | 180 | // code with MAP_GROWSDOWN flag and then attached to VM. |
aoqi@0 | 181 | // See notes in os_linux.cpp. |
aoqi@0 | 182 | if (thread->osthread()->expanding_stack() == 0) { |
aoqi@0 | 183 | thread->osthread()->set_expanding_stack(); |
aoqi@0 | 184 | if (os::Linux::manually_expand_stack(thread, addr)) { |
aoqi@0 | 185 | thread->osthread()->clear_expanding_stack(); |
aoqi@0 | 186 | return true; |
aoqi@0 | 187 | } |
aoqi@0 | 188 | thread->osthread()->clear_expanding_stack(); |
aoqi@0 | 189 | } |
aoqi@0 | 190 | else { |
aoqi@0 | 191 | fatal("recursive segv. expanding stack."); |
aoqi@0 | 192 | } |
aoqi@0 | 193 | } |
aoqi@0 | 194 | } |
aoqi@0 | 195 | } |
aoqi@0 | 196 | |
aoqi@0 | 197 | /*if (thread->thread_state() == _thread_in_Java) { |
aoqi@0 | 198 | ShouldNotCallThis(); |
aoqi@0 | 199 | } |
aoqi@0 | 200 | else*/ if (thread->thread_state() == _thread_in_vm && |
aoqi@0 | 201 | sig == SIGBUS && thread->doing_unsafe_access()) { |
aoqi@0 | 202 | ShouldNotCallThis(); |
aoqi@0 | 203 | } |
aoqi@0 | 204 | |
aoqi@0 | 205 | // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC |
aoqi@0 | 206 | // kicks in and the heap gets shrunk before the field access. |
aoqi@0 | 207 | /*if (sig == SIGSEGV || sig == SIGBUS) { |
aoqi@0 | 208 | address addr = JNI_FastGetField::find_slowcase_pc(pc); |
aoqi@0 | 209 | if (addr != (address)-1) { |
aoqi@0 | 210 | stub = addr; |
aoqi@0 | 211 | } |
aoqi@0 | 212 | }*/ |
aoqi@0 | 213 | |
aoqi@0 | 214 | // Check to see if we caught the safepoint code in the process |
aoqi@0 | 215 | // of write protecting the memory serialization page. It write |
aoqi@0 | 216 | // enables the page immediately after protecting it so we can |
aoqi@0 | 217 | // just return to retry the write. |
aoqi@0 | 218 | if (sig == SIGSEGV && |
aoqi@0 | 219 | os::is_memory_serialize_page(thread, (address) info->si_addr)) { |
aoqi@0 | 220 | // Block current thread until permission is restored. |
aoqi@0 | 221 | os::block_on_serialize_page_trap(); |
aoqi@0 | 222 | return true; |
aoqi@0 | 223 | } |
aoqi@0 | 224 | } |
aoqi@0 | 225 | |
aoqi@0 | 226 | // signal-chaining |
aoqi@0 | 227 | if (os::Linux::chained_handler(sig, info, ucVoid)) { |
aoqi@0 | 228 | return true; |
aoqi@0 | 229 | } |
aoqi@0 | 230 | |
aoqi@0 | 231 | if (!abort_if_unrecognized) { |
aoqi@0 | 232 | // caller wants another chance, so give it to him |
aoqi@0 | 233 | return false; |
aoqi@0 | 234 | } |
aoqi@0 | 235 | |
aoqi@0 | 236 | #ifndef PRODUCT |
aoqi@0 | 237 | if (sig == SIGSEGV) { |
aoqi@0 | 238 | fatal("\n#" |
aoqi@0 | 239 | "\n# /--------------------\\" |
aoqi@0 | 240 | "\n# | segmentation fault |" |
aoqi@0 | 241 | "\n# \\---\\ /--------------/" |
aoqi@0 | 242 | "\n# /" |
aoqi@0 | 243 | "\n# [-] |\\_/| " |
aoqi@0 | 244 | "\n# (+)=C |o o|__ " |
aoqi@0 | 245 | "\n# | | =-*-=__\\ " |
aoqi@0 | 246 | "\n# OOO c_c_(___)"); |
aoqi@0 | 247 | } |
aoqi@0 | 248 | #endif // !PRODUCT |
aoqi@0 | 249 | |
aoqi@0 | 250 | const char *fmt = "caught unhandled signal %d"; |
aoqi@0 | 251 | char buf[64]; |
aoqi@0 | 252 | |
aoqi@0 | 253 | sprintf(buf, fmt, sig); |
aoqi@0 | 254 | fatal(buf); |
aoqi@0 | 255 | } |
aoqi@0 | 256 | |
aoqi@0 | 257 | void os::Linux::init_thread_fpu_state(void) { |
aoqi@0 | 258 | // Nothing to do |
aoqi@0 | 259 | } |
aoqi@0 | 260 | |
aoqi@0 | 261 | int os::Linux::get_fpu_control_word() { |
aoqi@0 | 262 | ShouldNotCallThis(); |
aoqi@0 | 263 | } |
aoqi@0 | 264 | |
aoqi@0 | 265 | void os::Linux::set_fpu_control_word(int fpu) { |
aoqi@0 | 266 | ShouldNotCallThis(); |
aoqi@0 | 267 | } |
aoqi@0 | 268 | |
aoqi@0 | 269 | bool os::is_allocatable(size_t bytes) { |
aoqi@0 | 270 | #ifdef _LP64 |
aoqi@0 | 271 | return true; |
aoqi@0 | 272 | #else |
aoqi@0 | 273 | if (bytes < 2 * G) { |
aoqi@0 | 274 | return true; |
aoqi@0 | 275 | } |
aoqi@0 | 276 | |
aoqi@0 | 277 | char* addr = reserve_memory(bytes, NULL); |
aoqi@0 | 278 | |
aoqi@0 | 279 | if (addr != NULL) { |
aoqi@0 | 280 | release_memory(addr, bytes); |
aoqi@0 | 281 | } |
aoqi@0 | 282 | |
aoqi@0 | 283 | return addr != NULL; |
aoqi@0 | 284 | #endif // _LP64 |
aoqi@0 | 285 | } |
aoqi@0 | 286 | |
aoqi@0 | 287 | /////////////////////////////////////////////////////////////////////////////// |
aoqi@0 | 288 | // thread stack |
aoqi@0 | 289 | |
aoqi@0 | 290 | size_t os::Linux::min_stack_allowed = 64 * K; |
aoqi@0 | 291 | |
aoqi@0 | 292 | bool os::Linux::supports_variable_stack_size() { |
aoqi@0 | 293 | return true; |
aoqi@0 | 294 | } |
aoqi@0 | 295 | |
aoqi@0 | 296 | size_t os::Linux::default_stack_size(os::ThreadType thr_type) { |
aoqi@0 | 297 | #ifdef _LP64 |
aoqi@0 | 298 | size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M); |
aoqi@0 | 299 | #else |
aoqi@0 | 300 | size_t s = (thr_type == os::compiler_thread ? 2 * M : 512 * K); |
aoqi@0 | 301 | #endif // _LP64 |
aoqi@0 | 302 | return s; |
aoqi@0 | 303 | } |
aoqi@0 | 304 | |
aoqi@0 | 305 | size_t os::Linux::default_guard_size(os::ThreadType thr_type) { |
aoqi@0 | 306 | // Only enable glibc guard pages for non-Java threads |
aoqi@0 | 307 | // (Java threads have HotSpot guard pages) |
aoqi@0 | 308 | return (thr_type == java_thread ? 0 : page_size()); |
aoqi@0 | 309 | } |
aoqi@0 | 310 | |
aoqi@0 | 311 | static void current_stack_region(address *bottom, size_t *size) { |
aoqi@0 | 312 | pthread_attr_t attr; |
aoqi@0 | 313 | int res = pthread_getattr_np(pthread_self(), &attr); |
aoqi@0 | 314 | if (res != 0) { |
aoqi@0 | 315 | if (res == ENOMEM) { |
aoqi@0 | 316 | vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "pthread_getattr_np"); |
aoqi@0 | 317 | } |
aoqi@0 | 318 | else { |
aoqi@0 | 319 | fatal(err_msg("pthread_getattr_np failed with errno = %d", res)); |
aoqi@0 | 320 | } |
aoqi@0 | 321 | } |
aoqi@0 | 322 | |
aoqi@0 | 323 | address stack_bottom; |
aoqi@0 | 324 | size_t stack_bytes; |
aoqi@0 | 325 | res = pthread_attr_getstack(&attr, (void **) &stack_bottom, &stack_bytes); |
aoqi@0 | 326 | if (res != 0) { |
aoqi@0 | 327 | fatal(err_msg("pthread_attr_getstack failed with errno = %d", res)); |
aoqi@0 | 328 | } |
aoqi@0 | 329 | address stack_top = stack_bottom + stack_bytes; |
aoqi@0 | 330 | |
aoqi@0 | 331 | // The block of memory returned by pthread_attr_getstack() includes |
aoqi@0 | 332 | // guard pages where present. We need to trim these off. |
aoqi@0 | 333 | size_t page_bytes = os::Linux::page_size(); |
aoqi@0 | 334 | assert(((intptr_t) stack_bottom & (page_bytes - 1)) == 0, "unaligned stack"); |
aoqi@0 | 335 | |
aoqi@0 | 336 | size_t guard_bytes; |
aoqi@0 | 337 | res = pthread_attr_getguardsize(&attr, &guard_bytes); |
aoqi@0 | 338 | if (res != 0) { |
aoqi@0 | 339 | fatal(err_msg("pthread_attr_getguardsize failed with errno = %d", res)); |
aoqi@0 | 340 | } |
aoqi@0 | 341 | int guard_pages = align_size_up(guard_bytes, page_bytes) / page_bytes; |
aoqi@0 | 342 | assert(guard_bytes == guard_pages * page_bytes, "unaligned guard"); |
aoqi@0 | 343 | |
aoqi@0 | 344 | #ifdef IA64 |
aoqi@0 | 345 | // IA64 has two stacks sharing the same area of memory, a normal |
aoqi@0 | 346 | // stack growing downwards and a register stack growing upwards. |
aoqi@0 | 347 | // Guard pages, if present, are in the centre. This code splits |
aoqi@0 | 348 | // the stack in two even without guard pages, though in theory |
aoqi@0 | 349 | // there's nothing to stop us allocating more to the normal stack |
aoqi@0 | 350 | // or more to the register stack if one or the other were found |
aoqi@0 | 351 | // to grow faster. |
aoqi@0 | 352 | int total_pages = align_size_down(stack_bytes, page_bytes) / page_bytes; |
aoqi@0 | 353 | stack_bottom += (total_pages - guard_pages) / 2 * page_bytes; |
aoqi@0 | 354 | #endif // IA64 |
aoqi@0 | 355 | |
aoqi@0 | 356 | stack_bottom += guard_bytes; |
aoqi@0 | 357 | |
aoqi@0 | 358 | pthread_attr_destroy(&attr); |
aoqi@0 | 359 | |
aoqi@0 | 360 | // The initial thread has a growable stack, and the size reported |
aoqi@0 | 361 | // by pthread_attr_getstack is the maximum size it could possibly |
aoqi@0 | 362 | // be given what currently mapped. This can be huge, so we cap it. |
aoqi@0 | 363 | if (os::Linux::is_initial_thread()) { |
aoqi@0 | 364 | stack_bytes = stack_top - stack_bottom; |
aoqi@0 | 365 | |
aoqi@0 | 366 | if (stack_bytes > JavaThread::stack_size_at_create()) |
aoqi@0 | 367 | stack_bytes = JavaThread::stack_size_at_create(); |
aoqi@0 | 368 | |
aoqi@0 | 369 | stack_bottom = stack_top - stack_bytes; |
aoqi@0 | 370 | } |
aoqi@0 | 371 | |
aoqi@0 | 372 | assert(os::current_stack_pointer() >= stack_bottom, "should do"); |
aoqi@0 | 373 | assert(os::current_stack_pointer() < stack_top, "should do"); |
aoqi@0 | 374 | |
aoqi@0 | 375 | *bottom = stack_bottom; |
aoqi@0 | 376 | *size = stack_top - stack_bottom; |
aoqi@0 | 377 | } |
aoqi@0 | 378 | |
aoqi@0 | 379 | address os::current_stack_base() { |
aoqi@0 | 380 | address bottom; |
aoqi@0 | 381 | size_t size; |
aoqi@0 | 382 | current_stack_region(&bottom, &size); |
aoqi@0 | 383 | return bottom + size; |
aoqi@0 | 384 | } |
aoqi@0 | 385 | |
aoqi@0 | 386 | size_t os::current_stack_size() { |
aoqi@0 | 387 | // stack size includes normal stack and HotSpot guard pages |
aoqi@0 | 388 | address bottom; |
aoqi@0 | 389 | size_t size; |
aoqi@0 | 390 | current_stack_region(&bottom, &size); |
aoqi@0 | 391 | return size; |
aoqi@0 | 392 | } |
aoqi@0 | 393 | |
aoqi@0 | 394 | ///////////////////////////////////////////////////////////////////////////// |
aoqi@0 | 395 | // helper functions for fatal error handler |
aoqi@0 | 396 | |
aoqi@0 | 397 | void os::print_context(outputStream* st, void* context) { |
aoqi@0 | 398 | ShouldNotCallThis(); |
aoqi@0 | 399 | } |
aoqi@0 | 400 | |
aoqi@0 | 401 | void os::print_register_info(outputStream *st, void *context) { |
aoqi@0 | 402 | ShouldNotCallThis(); |
aoqi@0 | 403 | } |
aoqi@0 | 404 | |
aoqi@0 | 405 | ///////////////////////////////////////////////////////////////////////////// |
aoqi@0 | 406 | // Stubs for things that would be in linux_zero.s if it existed. |
aoqi@0 | 407 | // You probably want to disassemble these monkeys to check they're ok. |
aoqi@0 | 408 | |
aoqi@0 | 409 | extern "C" { |
aoqi@0 | 410 | int SpinPause() { |
aoqi@0 | 411 | } |
aoqi@0 | 412 | |
aoqi@0 | 413 | |
aoqi@0 | 414 | void _Copy_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) { |
aoqi@0 | 415 | if (from > to) { |
aoqi@0 | 416 | jshort *end = from + count; |
aoqi@0 | 417 | while (from < end) |
aoqi@0 | 418 | *(to++) = *(from++); |
aoqi@0 | 419 | } |
aoqi@0 | 420 | else if (from < to) { |
aoqi@0 | 421 | jshort *end = from; |
aoqi@0 | 422 | from += count - 1; |
aoqi@0 | 423 | to += count - 1; |
aoqi@0 | 424 | while (from >= end) |
aoqi@0 | 425 | *(to--) = *(from--); |
aoqi@0 | 426 | } |
aoqi@0 | 427 | } |
aoqi@0 | 428 | void _Copy_conjoint_jints_atomic(jint* from, jint* to, size_t count) { |
aoqi@0 | 429 | if (from > to) { |
aoqi@0 | 430 | jint *end = from + count; |
aoqi@0 | 431 | while (from < end) |
aoqi@0 | 432 | *(to++) = *(from++); |
aoqi@0 | 433 | } |
aoqi@0 | 434 | else if (from < to) { |
aoqi@0 | 435 | jint *end = from; |
aoqi@0 | 436 | from += count - 1; |
aoqi@0 | 437 | to += count - 1; |
aoqi@0 | 438 | while (from >= end) |
aoqi@0 | 439 | *(to--) = *(from--); |
aoqi@0 | 440 | } |
aoqi@0 | 441 | } |
aoqi@0 | 442 | void _Copy_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) { |
aoqi@0 | 443 | if (from > to) { |
aoqi@0 | 444 | jlong *end = from + count; |
aoqi@0 | 445 | while (from < end) |
aoqi@0 | 446 | os::atomic_copy64(from++, to++); |
aoqi@0 | 447 | } |
aoqi@0 | 448 | else if (from < to) { |
aoqi@0 | 449 | jlong *end = from; |
aoqi@0 | 450 | from += count - 1; |
aoqi@0 | 451 | to += count - 1; |
aoqi@0 | 452 | while (from >= end) |
aoqi@0 | 453 | os::atomic_copy64(from--, to--); |
aoqi@0 | 454 | } |
aoqi@0 | 455 | } |
aoqi@0 | 456 | |
aoqi@0 | 457 | void _Copy_arrayof_conjoint_bytes(HeapWord* from, |
aoqi@0 | 458 | HeapWord* to, |
aoqi@0 | 459 | size_t count) { |
aoqi@0 | 460 | memmove(to, from, count); |
aoqi@0 | 461 | } |
aoqi@0 | 462 | void _Copy_arrayof_conjoint_jshorts(HeapWord* from, |
aoqi@0 | 463 | HeapWord* to, |
aoqi@0 | 464 | size_t count) { |
aoqi@0 | 465 | memmove(to, from, count * 2); |
aoqi@0 | 466 | } |
aoqi@0 | 467 | void _Copy_arrayof_conjoint_jints(HeapWord* from, |
aoqi@0 | 468 | HeapWord* to, |
aoqi@0 | 469 | size_t count) { |
aoqi@0 | 470 | memmove(to, from, count * 4); |
aoqi@0 | 471 | } |
aoqi@0 | 472 | void _Copy_arrayof_conjoint_jlongs(HeapWord* from, |
aoqi@0 | 473 | HeapWord* to, |
aoqi@0 | 474 | size_t count) { |
aoqi@0 | 475 | memmove(to, from, count * 8); |
aoqi@0 | 476 | } |
aoqi@0 | 477 | }; |
aoqi@0 | 478 | |
aoqi@0 | 479 | ///////////////////////////////////////////////////////////////////////////// |
aoqi@0 | 480 | // Implementations of atomic operations not supported by processors. |
aoqi@0 | 481 | // -- http://gcc.gnu.org/onlinedocs/gcc-4.2.1/gcc/Atomic-Builtins.html |
aoqi@0 | 482 | |
aoqi@0 | 483 | #ifndef _LP64 |
aoqi@0 | 484 | extern "C" { |
aoqi@0 | 485 | long long unsigned int __sync_val_compare_and_swap_8( |
aoqi@0 | 486 | volatile void *ptr, |
aoqi@0 | 487 | long long unsigned int oldval, |
aoqi@0 | 488 | long long unsigned int newval) { |
aoqi@0 | 489 | ShouldNotCallThis(); |
aoqi@0 | 490 | } |
aoqi@0 | 491 | }; |
aoqi@0 | 492 | #endif // !_LP64 |
aoqi@0 | 493 | |
aoqi@0 | 494 | #ifndef PRODUCT |
aoqi@0 | 495 | void os::verify_stack_alignment() { |
aoqi@0 | 496 | } |
aoqi@0 | 497 | #endif |