888
889
890 #ifdef AMD64
891 void os::Solaris::init_thread_fpu_state(void) {
892 // Nothing to do
893 }
894 #else
895 // From solaris_i486.s
896 extern "C" void fixcw();
897
898 void os::Solaris::init_thread_fpu_state(void) {
899 // Set fpu to 53 bit precision. This happens too early to use a stub.
900 fixcw();
901 }
902
903 // These routines are the initial value of atomic_xchg_entry(),
904 // atomic_cmpxchg_entry(), atomic_inc_entry() and fence_entry()
905 // until initialization is complete.
906 // TODO - replace with .il implementation when compiler supports it.
907
908 typedef jint xchg_func_t (jint, volatile jint*);
909 typedef jint cmpxchg_func_t (jint, volatile jint*, jint);
910 typedef jlong cmpxchg_long_func_t(jlong, volatile jlong*, jlong);
911 typedef jint add_func_t (jint, volatile jint*);
912
913 jint os::atomic_xchg_bootstrap(jint exchange_value, volatile jint* dest) {
914 // try to use the stub:
915 xchg_func_t* func = CAST_TO_FN_PTR(xchg_func_t*, StubRoutines::atomic_xchg_entry());
916
917 if (func != NULL) {
918 os::atomic_xchg_func = func;
919 return (*func)(exchange_value, dest);
920 }
921 assert(Threads::number_of_threads() == 0, "for bootstrap only");
922
923 jint old_value = *dest;
924 *dest = exchange_value;
925 return old_value;
926 }
927
928 jint os::atomic_cmpxchg_bootstrap(jint exchange_value, volatile jint* dest, jint compare_value) {
929 // try to use the stub:
930 cmpxchg_func_t* func = CAST_TO_FN_PTR(cmpxchg_func_t*, StubRoutines::atomic_cmpxchg_entry());
931
932 if (func != NULL) {
933 os::atomic_cmpxchg_func = func;
934 return (*func)(exchange_value, dest, compare_value);
935 }
936 assert(Threads::number_of_threads() == 0, "for bootstrap only");
937
938 jint old_value = *dest;
939 if (old_value == compare_value)
940 *dest = exchange_value;
941 return old_value;
942 }
943
944 jlong os::atomic_cmpxchg_long_bootstrap(jlong exchange_value, volatile jlong* dest, jlong compare_value) {
945 // try to use the stub:
946 cmpxchg_long_func_t* func = CAST_TO_FN_PTR(cmpxchg_long_func_t*, StubRoutines::atomic_cmpxchg_long_entry());
947
948 if (func != NULL) {
949 os::atomic_cmpxchg_long_func = func;
950 return (*func)(exchange_value, dest, compare_value);
951 }
952 assert(Threads::number_of_threads() == 0, "for bootstrap only");
953
954 jlong old_value = *dest;
955 if (old_value == compare_value)
956 *dest = exchange_value;
957 return old_value;
958 }
959
960 jint os::atomic_add_bootstrap(jint add_value, volatile jint* dest) {
961 // try to use the stub:
962 add_func_t* func = CAST_TO_FN_PTR(add_func_t*, StubRoutines::atomic_add_entry());
963
964 if (func != NULL) {
965 os::atomic_add_func = func;
966 return (*func)(add_value, dest);
967 }
968 assert(Threads::number_of_threads() == 0, "for bootstrap only");
969
970 return (*dest) += add_value;
971 }
972
973 xchg_func_t* os::atomic_xchg_func = os::atomic_xchg_bootstrap;
974 cmpxchg_func_t* os::atomic_cmpxchg_func = os::atomic_cmpxchg_bootstrap;
975 cmpxchg_long_func_t* os::atomic_cmpxchg_long_func = os::atomic_cmpxchg_long_bootstrap;
976 add_func_t* os::atomic_add_func = os::atomic_add_bootstrap;
977
978 extern "C" void _solaris_raw_setup_fpu(address ptr);
979 void os::setup_fpu() {
980 address fpu_cntrl = StubRoutines::addr_fpu_cntrl_wrd_std();
|
888
889
890 #ifdef AMD64
891 void os::Solaris::init_thread_fpu_state(void) {
892 // Nothing to do
893 }
894 #else
895 // From solaris_i486.s
896 extern "C" void fixcw();
897
898 void os::Solaris::init_thread_fpu_state(void) {
899 // Set fpu to 53 bit precision. This happens too early to use a stub.
900 fixcw();
901 }
902
903 // These routines are the initial value of atomic_xchg_entry(),
904 // atomic_cmpxchg_entry(), atomic_inc_entry() and fence_entry()
905 // until initialization is complete.
906 // TODO - replace with .il implementation when compiler supports it.
907
908 typedef int32_t xchg_func_t (int32_t, volatile int32_t*);
909 typedef int32_t cmpxchg_func_t (int32_t, volatile int32_t*, int32_t);
910 typedef int64_t cmpxchg_long_func_t(int64_t, volatile int64_t*, int64_t);
911 typedef int32_t add_func_t (int32_t, volatile int32_t*);
912
913 int32_t os::atomic_xchg_bootstrap(int32_t exchange_value, volatile int32_t* dest) {
914 // try to use the stub:
915 xchg_func_t* func = CAST_TO_FN_PTR(xchg_func_t*, StubRoutines::atomic_xchg_entry());
916
917 if (func != NULL) {
918 os::atomic_xchg_func = func;
919 return (*func)(exchange_value, dest);
920 }
921 assert(Threads::number_of_threads() == 0, "for bootstrap only");
922
923 int32_t old_value = *dest;
924 *dest = exchange_value;
925 return old_value;
926 }
927
928 int32_t os::atomic_cmpxchg_bootstrap(int32_t exchange_value, volatile int32_t* dest, int32_t compare_value) {
929 // try to use the stub:
930 cmpxchg_func_t* func = CAST_TO_FN_PTR(cmpxchg_func_t*, StubRoutines::atomic_cmpxchg_entry());
931
932 if (func != NULL) {
933 os::atomic_cmpxchg_func = func;
934 return (*func)(exchange_value, dest, compare_value);
935 }
936 assert(Threads::number_of_threads() == 0, "for bootstrap only");
937
938 int32_t old_value = *dest;
939 if (old_value == compare_value)
940 *dest = exchange_value;
941 return old_value;
942 }
943
944 int64_t os::atomic_cmpxchg_long_bootstrap(int64_t exchange_value, volatile int64_t* dest, int64_t compare_value) {
945 // try to use the stub:
946 cmpxchg_long_func_t* func = CAST_TO_FN_PTR(cmpxchg_long_func_t*, StubRoutines::atomic_cmpxchg_long_entry());
947
948 if (func != NULL) {
949 os::atomic_cmpxchg_long_func = func;
950 return (*func)(exchange_value, dest, compare_value);
951 }
952 assert(Threads::number_of_threads() == 0, "for bootstrap only");
953
954 int64_t old_value = *dest;
955 if (old_value == compare_value)
956 *dest = exchange_value;
957 return old_value;
958 }
959
960 int32_t os::atomic_add_bootstrap(int32_t add_value, volatile int32_t* dest) {
961 // try to use the stub:
962 add_func_t* func = CAST_TO_FN_PTR(add_func_t*, StubRoutines::atomic_add_entry());
963
964 if (func != NULL) {
965 os::atomic_add_func = func;
966 return (*func)(add_value, dest);
967 }
968 assert(Threads::number_of_threads() == 0, "for bootstrap only");
969
970 return (*dest) += add_value;
971 }
972
973 xchg_func_t* os::atomic_xchg_func = os::atomic_xchg_bootstrap;
974 cmpxchg_func_t* os::atomic_cmpxchg_func = os::atomic_cmpxchg_bootstrap;
975 cmpxchg_long_func_t* os::atomic_cmpxchg_long_func = os::atomic_cmpxchg_long_bootstrap;
976 add_func_t* os::atomic_add_func = os::atomic_add_bootstrap;
977
978 extern "C" void _solaris_raw_setup_fpu(address ptr);
979 void os::setup_fpu() {
980 address fpu_cntrl = StubRoutines::addr_fpu_cntrl_wrd_std();
|