Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 576922 | Differences between
and this patch

Collapse All | Expand All

(-)file_not_specified_in_diff (-3 / +245 lines)
Line  Link Here
0
-- a/js/src/jit/AtomicOperations.h
0
++ b/js/src/jit/AtomicOperations.h
Lines 337-343 AtomicOperations::isLockfree(int32_t size) Link Here
337
  // C++ realizations of atomics.  These operations cannot be written
337
  // C++ realizations of atomics.  These operations cannot be written
338
  // in portable C++, hence the default here is to crash.  See the
338
  // in portable C++, hence the default here is to crash.  See the
339
  // top of the file for more guidance.
339
  // top of the file for more guidance.
340
# if defined(__ppc64__) || defined(__PPC64__) || defined(__ppc64le__) || defined(__PPC64LE__)
340
# if defined(__ia64__)
341
#  include "jit/none/AtomicOperations-ia64.h"
342
# elif defined(__ppc64__) || defined(__PPC64__) || defined(__ppc64le__) || defined(__PPC64LE__)
341
#  include "jit/none/AtomicOperations-ppc.h"
343
#  include "jit/none/AtomicOperations-ppc.h"
342
# elif defined(__aarch64__)
344
# elif defined(__aarch64__)
343
#  include "jit/arm64/AtomicOperations-arm64.h"
345
#  include "jit/arm64/AtomicOperations-arm64.h"
344
-- /dev/null
346
++ b/js/src/jit/none/AtomicOperations-ia64.h
Line 0 Link Here
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2
 * vim: set ts=8 sts=4 et sw=4 tw=99:
3
 * This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
/* For documentation, see jit/AtomicOperations.h */
8
9
#ifndef jit_ia64_AtomicOperations_ia64_h
10
#define jit_ia64_AtomicOperations_ia64_h
11
12
#include "mozilla/Assertions.h"
13
#include "mozilla/Types.h"
14
15
#if defined(__GNUC__)
16
17
// The default implementation tactic for gcc is to use the newer
18
// __atomic intrinsics added for use in C++11 <atomic>.  Where that
19
// isn't available, we use GCC's older __sync functions instead.
20
//
21
// ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS is kept as a backward
22
// compatible option for older compilers: enable this to use GCC's old
23
// __sync functions instead of the newer __atomic functions.  This
24
// will be required for GCC 4.6.x and earlier, should we need to use
25
// those versions.
26
27
//#define ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
28
29
inline bool
30
js::jit::AtomicOperations::isLockfree8()
31
{
32
# ifndef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
33
    MOZ_ASSERT(__atomic_always_lock_free(sizeof(int8_t), 0));
34
    MOZ_ASSERT(__atomic_always_lock_free(sizeof(int16_t), 0));
35
    MOZ_ASSERT(__atomic_always_lock_free(sizeof(int32_t), 0));
36
    MOZ_ASSERT(__atomic_always_lock_free(sizeof(int64_t), 0));
37
#  endif
38
    return true;
39
# else
40
    return false;
41
# endif
42
}
43
44
inline void
45
js::jit::AtomicOperations::fenceSeqCst()
46
{
47
# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
48
    __sync_synchronize();
49
# else
50
    __atomic_thread_fence(__ATOMIC_SEQ_CST);
51
# endif
52
}
53
54
template<typename T>
55
inline T
56
js::jit::AtomicOperations::loadSeqCst(T* addr)
57
{
58
    MOZ_ASSERT(sizeof(T) < 8 || isLockfree8());
59
# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
60
    __sync_synchronize();
61
    T v = *addr;
62
    __sync_synchronize();
63
# else
64
    T v;
65
    __atomic_load(addr, &v, __ATOMIC_SEQ_CST);
66
# endif
67
    return v;
68
}
69
70
template<typename T>
71
inline void
72
js::jit::AtomicOperations::storeSeqCst(T* addr, T val)
73
{
74
    MOZ_ASSERT(sizeof(T) < 8 || isLockfree8());
75
# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
76
    __sync_synchronize();
77
    *addr = val;
78
    __sync_synchronize();
79
# else
80
    __atomic_store(addr, &val, __ATOMIC_SEQ_CST);
81
# endif
82
}
83
84
template<typename T>
85
inline T
86
js::jit::AtomicOperations::compareExchangeSeqCst(T* addr, T oldval, T newval)
87
{
88
    MOZ_ASSERT(sizeof(T) < 8 || isLockfree8());
89
# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
90
    return __sync_val_compare_and_swap(addr, oldval, newval);
91
# else
92
    __atomic_compare_exchange(addr, &oldval, &newval, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
93
    return oldval;
94
# endif
95
}
96
97
template<typename T>
98
inline T
99
js::jit::AtomicOperations::fetchAddSeqCst(T* addr, T val)
100
{
101
    static_assert(sizeof(T) <= 4, "not available for 8-byte values yet");
102
# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
103
    return __sync_fetch_and_add(addr, val);
104
# else
105
    return __atomic_fetch_add(addr, val, __ATOMIC_SEQ_CST);
106
# endif
107
}
108
109
template<typename T>
110
inline T
111
js::jit::AtomicOperations::fetchSubSeqCst(T* addr, T val)
112
{
113
    static_assert(sizeof(T) <= 4, "not available for 8-byte values yet");
114
# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
115
    return __sync_fetch_and_sub(addr, val);
116
# else
117
    return __atomic_fetch_sub(addr, val, __ATOMIC_SEQ_CST);
118
# endif
119
}
120
121
template<typename T>
122
inline T
123
js::jit::AtomicOperations::fetchAndSeqCst(T* addr, T val)
124
{
125
    static_assert(sizeof(T) <= 4, "not available for 8-byte values yet");
126
# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
127
    return __sync_fetch_and_and(addr, val);
128
# else
129
    return __atomic_fetch_and(addr, val, __ATOMIC_SEQ_CST);
130
# endif
131
}
132
133
template<typename T>
134
inline T
135
js::jit::AtomicOperations::fetchOrSeqCst(T* addr, T val)
136
{
137
    static_assert(sizeof(T) <= 4, "not available for 8-byte values yet");
138
# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
139
    return __sync_fetch_and_or(addr, val);
140
# else
141
    return __atomic_fetch_or(addr, val, __ATOMIC_SEQ_CST);
142
# endif
143
}
144
145
template<typename T>
146
inline T
147
js::jit::AtomicOperations::fetchXorSeqCst(T* addr, T val)
148
{
149
    static_assert(sizeof(T) <= 4, "not available for 8-byte values yet");
150
# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
151
    return __sync_fetch_and_xor(addr, val);
152
# else
153
    return __atomic_fetch_xor(addr, val, __ATOMIC_SEQ_CST);
154
# endif
155
}
156
157
template<typename T>
158
inline T
159
js::jit::AtomicOperations::loadSafeWhenRacy(T* addr)
160
{
161
    return *addr;               // FIXME (1208663): not yet safe
162
}
163
164
template<typename T>
165
inline void
166
js::jit::AtomicOperations::storeSafeWhenRacy(T* addr, T val)
167
{
168
    *addr = val;                // FIXME (1208663): not yet safe
169
}
170
171
inline void
172
js::jit::AtomicOperations::memcpySafeWhenRacy(void* dest, const void* src, size_t nbytes)
173
{
174
    ::memcpy(dest, src, nbytes); // FIXME (1208663): not yet safe
175
}
176
177
inline void
178
js::jit::AtomicOperations::memmoveSafeWhenRacy(void* dest, const void* src, size_t nbytes)
179
{
180
    ::memmove(dest, src, nbytes); // FIXME (1208663): not yet safe
181
}
182
183
template<typename T>
184
inline T
185
js::jit::AtomicOperations::exchangeSeqCst(T* addr, T val)
186
{
187
    MOZ_ASSERT(sizeof(T) < 8 || isLockfree8());
188
# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
189
    T v;
190
    __sync_synchronize();
191
    do {
192
	v = *addr;
193
    } while (__sync_val_compare_and_swap(addr, v, val) != v);
194
    return v;
195
# else
196
    T v;
197
    __atomic_exchange(addr, &val, &v, __ATOMIC_SEQ_CST);
198
    return v;
199
# endif
200
}
201
202
template<size_t nbytes>
203
inline void
204
js::jit::RegionLock::acquire(void* addr)
205
{
206
# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
207
    while (!__sync_bool_compare_and_swap(&spinlock, 0, 1))
208
        ;
209
# else
210
    uint32_t zero = 0;
211
    uint32_t one = 1;
212
    while (!__atomic_compare_exchange(&spinlock, &zero, &one, false, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE)) {
213
        zero = 0;
214
        continue;
215
    }
216
# endif
217
}
218
219
template<size_t nbytes>
220
inline void
221
js::jit::RegionLock::release(void* addr)
222
{
223
    MOZ_ASSERT(AtomicOperations::loadSeqCst(&spinlock) == 1, "releasing unlocked region lock");
224
# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
225
    __sync_sub_and_fetch(&spinlock, 1);
226
# else
227
    uint32_t zero = 0;
228
    __atomic_store(&spinlock, &zero, __ATOMIC_SEQ_CST);
229
# endif
230
}
231
232
# undef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
233
234
#elif defined(ENABLE_SHARED_ARRAY_BUFFER)
235
236
# error "Either disable JS shared memory, use GCC, or add code here"
237
238
#endif
239
240
#endif // jit_ia64_AtomicOperations_ia64_h

Return to bug 576922