Line data Source code
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 : #ifndef jit_AtomicOp_h
8 : #define jit_AtomicOp_h
9 :
10 : namespace js {
11 : namespace jit {
12 :
13 : // Types of atomic operation, shared by MIR and LIR.
14 :
15 : enum AtomicOp {
16 : AtomicFetchAddOp,
17 : AtomicFetchSubOp,
18 : AtomicFetchAndOp,
19 : AtomicFetchOrOp,
20 : AtomicFetchXorOp
21 : };
22 :
23 : // Memory barrier types, shared by MIR and LIR.
24 : //
25 : // MembarSynchronizing is here because some platforms can make the
26 : // distinction (DSB vs DMB on ARM, SYNC vs parameterized SYNC on MIPS)
27 : // but there's been no reason to use it yet.
28 :
29 : enum MemoryBarrierBits {
30 : MembarLoadLoad = 1,
31 : MembarLoadStore = 2,
32 : MembarStoreStore = 4,
33 : MembarStoreLoad = 8,
34 :
35 : MembarSynchronizing = 16,
36 :
37 : // For validity testing
38 : MembarNobits = 0,
39 : MembarAllbits = 31,
40 : };
41 :
42 : static inline constexpr MemoryBarrierBits
43 0 : operator|(MemoryBarrierBits a, MemoryBarrierBits b)
44 : {
45 0 : return MemoryBarrierBits(int(a) | int(b));
46 : }
47 :
48 : static inline constexpr MemoryBarrierBits
49 0 : operator&(MemoryBarrierBits a, MemoryBarrierBits b)
50 : {
51 0 : return MemoryBarrierBits(int(a) & int(b));
52 : }
53 :
54 : static inline constexpr MemoryBarrierBits
55 0 : operator~(MemoryBarrierBits a)
56 : {
57 0 : return MemoryBarrierBits(~int(a));
58 : }
59 :
60 : // Standard barrier bits for a full barrier.
61 : static constexpr MemoryBarrierBits MembarFull = MembarLoadLoad|MembarLoadStore|MembarStoreLoad|MembarStoreStore;
62 :
63 : // Standard sets of barrier bits for atomic loads and stores.
64 : // See http://gee.cs.oswego.edu/dl/jmm/cookbook.html for more.
65 : static constexpr MemoryBarrierBits MembarBeforeLoad = MembarNobits;
66 : static constexpr MemoryBarrierBits MembarAfterLoad = MembarLoadLoad|MembarLoadStore;
67 : static constexpr MemoryBarrierBits MembarBeforeStore = MembarStoreStore;
68 : static constexpr MemoryBarrierBits MembarAfterStore = MembarStoreLoad;
69 :
70 : } // namespace jit
71 : } // namespace js
72 :
73 : #endif /* jit_AtomicOp_h */
|