32 #include "interpreter/interpreter.hpp"
33 #include "jvm.h"
34 #include "logging/log.hpp"
35 #include "memory/allocation.inline.hpp"
36 #include "os_bsd.hpp"
37 #include "os_posix.hpp"
38 #include "prims/jniFastGetField.hpp"
39 #include "prims/jvm_misc.hpp"
40 #include "runtime/arguments.hpp"
41 #include "runtime/frame.inline.hpp"
42 #include "runtime/interfaceSupport.inline.hpp"
43 #include "runtime/java.hpp"
44 #include "runtime/javaCalls.hpp"
45 #include "runtime/javaThread.hpp"
46 #include "runtime/mutexLocker.hpp"
47 #include "runtime/osThread.hpp"
48 #include "runtime/safepointMechanism.hpp"
49 #include "runtime/sharedRuntime.hpp"
50 #include "runtime/stubRoutines.hpp"
51 #include "runtime/timer.hpp"
52 #include "signals_posix.hpp"
53 #include "utilities/align.hpp"
54 #include "utilities/events.hpp"
55 #include "utilities/vmError.hpp"
56
57 // put OS-includes here
58 # include <sys/types.h>
59 # include <sys/mman.h>
60 # include <pthread.h>
61 # include <signal.h>
62 # include <errno.h>
63 # include <dlfcn.h>
64 # include <stdlib.h>
65 # include <stdio.h>
66 # include <unistd.h>
67 # include <sys/resource.h>
68 # include <sys/stat.h>
69 # include <sys/time.h>
70 # include <sys/utsname.h>
71 # include <sys/socket.h>
72 # include <sys/wait.h>
73 # include <pwd.h>
489 #ifndef PRODUCT
490 void os::verify_stack_alignment() {
491 assert(((intptr_t)os::current_stack_pointer() & (StackAlignmentInBytes-1)) == 0, "incorrect stack alignment");
492 }
493 #endif
494
495 int os::extra_bang_size_in_bytes() {
496 // AArch64 does not require the additional stack bang.
497 return 0;
498 }
499
500 void os::current_thread_enable_wx(WXMode mode) {
501 pthread_jit_write_protect_np(mode == WXExec);
502 }
503
504 static inline void atomic_copy64(const volatile void *src, volatile void *dst) {
505 *(jlong *) dst = *(const jlong *) src;
506 }
507
508 extern "C" {
509 // needs local assembler label '1:' to avoid trouble when using linktime optimization
510 int SpinPause() {
511 // We don't use StubRoutines::aarch64::spin_wait stub in order to
512 // avoid a costly call to os::current_thread_enable_wx() on MacOS.
513 // We should return 1 if SpinPause is implemented, and since there
514 // will be a sequence of 11 instructions for NONE and YIELD and 12
515 // instructions for NOP and ISB, SpinPause will always return 1.
516 uint64_t br_dst;
517 const int instructions_per_case = 2;
518 int64_t off = VM_Version::spin_wait_desc().inst() * instructions_per_case * Assembler::instruction_size;
519
520 assert(VM_Version::spin_wait_desc().inst() >= SpinWait::NONE &&
521 VM_Version::spin_wait_desc().inst() <= SpinWait::YIELD, "must be");
522 assert(-1 == SpinWait::NONE, "must be");
523 assert( 0 == SpinWait::NOP, "must be");
524 assert( 1 == SpinWait::ISB, "must be");
525 assert( 2 == SpinWait::YIELD, "must be");
526
527 asm volatile(
528 " adr %[d], 20 \n" // 20 == PC here + 5 instructions => address
529 // to entry for case SpinWait::NOP
530 " add %[d], %[d], %[o] \n"
531 " br %[d] \n"
532 " b 1f \n" // case SpinWait::NONE (-1)
533 " nop \n" // padding
534 " nop \n" // case SpinWait::NOP ( 0)
535 " b 1f \n"
536 " isb \n" // case SpinWait::ISB ( 1)
537 " b 1f \n"
538 " yield \n" // case SpinWait::YIELD ( 2)
539 "1: \n"
540 : [d]"=&r"(br_dst)
541 : [o]"r"(off)
542 : "memory");
543 return 1;
544 }
545
546 void _Copy_conjoint_jshorts_atomic(const jshort* from, jshort* to, size_t count) {
547 if (from > to) {
548 const jshort *end = from + count;
549 while (from < end)
550 *(to++) = *(from++);
551 }
552 else if (from < to) {
553 const jshort *end = from;
554 from += count - 1;
555 to += count - 1;
556 while (from >= end)
557 *(to--) = *(from--);
558 }
559 }
560 void _Copy_conjoint_jints_atomic(const jint* from, jint* to, size_t count) {
561 if (from > to) {
562 const jint *end = from + count;
|
32 #include "interpreter/interpreter.hpp"
33 #include "jvm.h"
34 #include "logging/log.hpp"
35 #include "memory/allocation.inline.hpp"
36 #include "os_bsd.hpp"
37 #include "os_posix.hpp"
38 #include "prims/jniFastGetField.hpp"
39 #include "prims/jvm_misc.hpp"
40 #include "runtime/arguments.hpp"
41 #include "runtime/frame.inline.hpp"
42 #include "runtime/interfaceSupport.inline.hpp"
43 #include "runtime/java.hpp"
44 #include "runtime/javaCalls.hpp"
45 #include "runtime/javaThread.hpp"
46 #include "runtime/mutexLocker.hpp"
47 #include "runtime/osThread.hpp"
48 #include "runtime/safepointMechanism.hpp"
49 #include "runtime/sharedRuntime.hpp"
50 #include "runtime/stubRoutines.hpp"
51 #include "runtime/timer.hpp"
52 #include "runtime/vm_version.hpp"
53 #include "signals_posix.hpp"
54 #include "utilities/align.hpp"
55 #include "utilities/debug.hpp"
56 #include "utilities/events.hpp"
57 #include "utilities/vmError.hpp"
58
59 // put OS-includes here
60 # include <sys/types.h>
61 # include <sys/mman.h>
62 # include <pthread.h>
63 # include <signal.h>
64 # include <errno.h>
65 # include <dlfcn.h>
66 # include <stdlib.h>
67 # include <stdio.h>
68 # include <unistd.h>
69 # include <sys/resource.h>
70 # include <sys/stat.h>
71 # include <sys/time.h>
72 # include <sys/utsname.h>
73 # include <sys/socket.h>
74 # include <sys/wait.h>
75 # include <pwd.h>
491 #ifndef PRODUCT
492 void os::verify_stack_alignment() {
493 assert(((intptr_t)os::current_stack_pointer() & (StackAlignmentInBytes-1)) == 0, "incorrect stack alignment");
494 }
495 #endif
496
497 int os::extra_bang_size_in_bytes() {
498 // AArch64 does not require the additional stack bang.
499 return 0;
500 }
501
502 void os::current_thread_enable_wx(WXMode mode) {
503 pthread_jit_write_protect_np(mode == WXExec);
504 }
505
506 static inline void atomic_copy64(const volatile void *src, volatile void *dst) {
507 *(jlong *) dst = *(const jlong *) src;
508 }
509
510 extern "C" {
511 int SpinPause() {
512 // We don't use StubRoutines::aarch64::spin_wait stub in order to
513 // avoid a costly call to os::current_thread_enable_wx() on MacOS.
514 // We should return 1 if SpinPause is implemented, and since there
515 // will be always a sequence of instructions, SpinPause will always return 1.
516 switch (VM_Version::spin_wait_desc().inst()) {
517 case SpinWait::NONE:
518 break;
519 case SpinWait::NOP:
520 asm volatile("nop" : : : "memory");
521 break;
522 case SpinWait::ISB:
523 asm volatile("isb" : : : "memory");
524 break;
525 case SpinWait::YIELD:
526 asm volatile("yield" : : : "memory");
527 break;
528 case SpinWait::SB:
529 assert(VM_Version::supports_sb(), "current CPU does not support SB instruction");
530 asm volatile(".inst 0xd50330ff" : : : "memory");
531 break;
532 #ifdef ASSERT
533 default:
534 ShouldNotReachHere();
535 #endif
536 }
537 return 1;
538 }
539
540 void _Copy_conjoint_jshorts_atomic(const jshort* from, jshort* to, size_t count) {
541 if (from > to) {
542 const jshort *end = from + count;
543 while (from < end)
544 *(to++) = *(from++);
545 }
546 else if (from < to) {
547 const jshort *end = from;
548 from += count - 1;
549 to += count - 1;
550 while (from >= end)
551 *(to--) = *(from--);
552 }
553 }
554 void _Copy_conjoint_jints_atomic(const jint* from, jint* to, size_t count) {
555 if (from > to) {
556 const jint *end = from + count;
|