1 /* |
1 /* |
2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
33 // Implementation of class atomic |
33 // Implementation of class atomic |
34 |
34 |
35 inline void Atomic::store (jbyte store_value, jbyte* dest) { *dest = store_value; } |
35 inline void Atomic::store (jbyte store_value, jbyte* dest) { *dest = store_value; } |
36 inline void Atomic::store (jshort store_value, jshort* dest) { *dest = store_value; } |
36 inline void Atomic::store (jshort store_value, jshort* dest) { *dest = store_value; } |
37 inline void Atomic::store (jint store_value, jint* dest) { *dest = store_value; } |
37 inline void Atomic::store (jint store_value, jint* dest) { *dest = store_value; } |
38 inline void Atomic::store (jlong store_value, jlong* dest) { *dest = store_value; } |
|
39 inline void Atomic::store_ptr(intptr_t store_value, intptr_t* dest) { *dest = store_value; } |
38 inline void Atomic::store_ptr(intptr_t store_value, intptr_t* dest) { *dest = store_value; } |
40 inline void Atomic::store_ptr(void* store_value, void* dest) { *(void**)dest = store_value; } |
39 inline void Atomic::store_ptr(void* store_value, void* dest) { *(void**)dest = store_value; } |
41 |
40 |
42 inline void Atomic::store (jbyte store_value, volatile jbyte* dest) { *dest = store_value; } |
41 inline void Atomic::store (jbyte store_value, volatile jbyte* dest) { *dest = store_value; } |
43 inline void Atomic::store (jshort store_value, volatile jshort* dest) { *dest = store_value; } |
42 inline void Atomic::store (jshort store_value, volatile jshort* dest) { *dest = store_value; } |
44 inline void Atomic::store (jint store_value, volatile jint* dest) { *dest = store_value; } |
43 inline void Atomic::store (jint store_value, volatile jint* dest) { *dest = store_value; } |
45 inline void Atomic::store (jlong store_value, volatile jlong* dest) { *dest = store_value; } |
|
46 inline void Atomic::store_ptr(intptr_t store_value, volatile intptr_t* dest) { *dest = store_value; } |
44 inline void Atomic::store_ptr(intptr_t store_value, volatile intptr_t* dest) { *dest = store_value; } |
47 inline void Atomic::store_ptr(void* store_value, volatile void* dest) { *(void* volatile *)dest = store_value; } |
45 inline void Atomic::store_ptr(void* store_value, volatile void* dest) { *(void* volatile *)dest = store_value; } |
48 |
46 |
49 inline void Atomic::inc (volatile jint* dest) { (void)add (1, dest); } |
47 inline void Atomic::inc (volatile jint* dest) { (void)add (1, dest); } |
50 inline void Atomic::inc_ptr(volatile intptr_t* dest) { (void)add_ptr(1, dest); } |
48 inline void Atomic::inc_ptr(volatile intptr_t* dest) { (void)add_ptr(1, dest); } |
52 |
50 |
53 inline void Atomic::dec (volatile jint* dest) { (void)add (-1, dest); } |
51 inline void Atomic::dec (volatile jint* dest) { (void)add (-1, dest); } |
54 inline void Atomic::dec_ptr(volatile intptr_t* dest) { (void)add_ptr(-1, dest); } |
52 inline void Atomic::dec_ptr(volatile intptr_t* dest) { (void)add_ptr(-1, dest); } |
55 inline void Atomic::dec_ptr(volatile void* dest) { (void)add_ptr(-1, dest); } |
53 inline void Atomic::dec_ptr(volatile void* dest) { (void)add_ptr(-1, dest); } |
56 |
54 |
|
55 |
|
56 #ifdef _LP64 |
|
57 |
|
58 inline void Atomic::store(jlong store_value, jlong* dest) { *dest = store_value; } |
|
59 inline void Atomic::store(jlong store_value, volatile jlong* dest) { *dest = store_value; } |
57 inline jlong Atomic::load(volatile jlong* src) { return *src; } |
60 inline jlong Atomic::load(volatile jlong* src) { return *src; } |
|
61 |
|
62 #else |
|
63 |
|
64 extern "C" void _Atomic_move_long_v8(volatile jlong* src, volatile jlong* dst); |
|
65 extern "C" void _Atomic_move_long_v9(volatile jlong* src, volatile jlong* dst); |
|
66 |
|
67 inline void Atomic_move_long(volatile jlong* src, volatile jlong* dst) { |
|
68 #ifdef COMPILER2 |
|
69 // Compiler2 does not support v8, it is used only for v9. |
|
70 assert (VM_Version::v9_instructions_work(), "only supported on v9"); |
|
71 _Atomic_move_long_v9(src, dst); |
|
72 #else |
|
73 // The branch is cheaper then emulated LDD. |
|
74 if (VM_Version::v9_instructions_work()) { |
|
75 _Atomic_move_long_v9(src, dst); |
|
76 } else { |
|
77 _Atomic_move_long_v8(src, dst); |
|
78 } |
|
79 #endif |
|
80 } |
|
81 |
|
82 inline jlong Atomic::load(volatile jlong* src) { |
|
83 volatile jlong dest; |
|
84 Atomic_move_long(src, &dest); |
|
85 return dest; |
|
86 } |
|
87 |
|
88 inline void Atomic::store(jlong store_value, jlong* dest) { |
|
89 Atomic_move_long((volatile jlong*)&store_value, (volatile jlong*)dest); |
|
90 } |
|
91 |
|
92 inline void Atomic::store(jlong store_value, volatile jlong* dest) { |
|
93 Atomic_move_long((volatile jlong*)&store_value, dest); |
|
94 } |
|
95 |
|
96 #endif |
58 |
97 |
59 #ifdef _GNU_SOURCE |
98 #ifdef _GNU_SOURCE |
60 |
99 |
61 inline jint Atomic::add (jint add_value, volatile jint* dest) { |
100 inline jint Atomic::add (jint add_value, volatile jint* dest) { |
62 intptr_t rv; |
101 intptr_t rv; |