From acb8760d78978845e09eb6c4aa0573d98d77196c Mon Sep 17 00:00:00 2001 From: Lars T Hansen Date: Thu, 20 Nov 2014 16:27:38 +0100 Subject: [PATCH] Bug 1073096 - Use MemoryBarrierBits type as container for bit sets. r=luke --- js/src/jit/AtomicOp.h | 29 +++++++++++++++++++++++----- js/src/jit/LIR-Common.h | 8 ++++---- js/src/jit/MIR.h | 10 +++++----- js/src/jit/arm/CodeGenerator-arm.cpp | 2 +- js/src/jit/arm/CodeGenerator-arm.h | 2 +- 5 files changed, 35 insertions(+), 16 deletions(-) diff --git a/js/src/jit/AtomicOp.h b/js/src/jit/AtomicOp.h index b017926f9566..4c84e02a97dd 100644 --- a/js/src/jit/AtomicOp.h +++ b/js/src/jit/AtomicOp.h @@ -35,18 +35,37 @@ enum MemoryBarrierBits { MembarSynchronizing = 16, // For validity testing + MembarNobits = 0, MembarAllbits = 31, }; +inline MemoryBarrierBits +operator|(MemoryBarrierBits a, MemoryBarrierBits b) +{ + return MemoryBarrierBits(int(a) | int(b)); +} + +inline MemoryBarrierBits +operator&(MemoryBarrierBits a, MemoryBarrierBits b) +{ + return MemoryBarrierBits(int(a) & int(b)); +} + +inline MemoryBarrierBits +operator~(MemoryBarrierBits a) +{ + return MemoryBarrierBits(~int(a)); +} + // Standard barrier bits for a full barrier. -static const int MembarFull = MembarLoadLoad|MembarLoadStore|MembarStoreLoad|MembarStoreStore; +static const MemoryBarrierBits MembarFull = MembarLoadLoad|MembarLoadStore|MembarStoreLoad|MembarStoreStore; // Standard sets of barrier bits for atomic loads and stores. // See http://gee.cs.oswego.edu/dl/jmm/cookbook.html for more. -static const int MembarBeforeLoad = 0; -static const int MembarAfterLoad = MembarLoadLoad|MembarLoadStore; -static const int MembarBeforeStore = MembarStoreStore; -static const int MembarAfterStore = MembarStoreLoad; +static const MemoryBarrierBits MembarBeforeLoad = MembarNobits; +static const MemoryBarrierBits MembarAfterLoad = MembarLoadLoad|MembarLoadStore; +static const MemoryBarrierBits MembarBeforeStore = MembarStoreStore; +static const MemoryBarrierBits MembarAfterStore = MembarStoreLoad; } // namespace jit } // namespace js diff --git a/js/src/jit/LIR-Common.h b/js/src/jit/LIR-Common.h index 1938b9a483f2..903d64d1b2c3 100644 --- a/js/src/jit/LIR-Common.h +++ b/js/src/jit/LIR-Common.h @@ -6874,19 +6874,19 @@ class LThrowUninitializedLexical : public LCallInstructionHelper<0, 0, 0> class LMemoryBarrier : public LInstructionHelper<0, 0, 0> { private: - const int type_; + const MemoryBarrierBits type_; public: LIR_HEADER(MemoryBarrier) // The parameter 'type' is a bitwise 'or' of the barrier types needed, // see AtomicOp.h. - explicit LMemoryBarrier(int type) : type_(type) + explicit LMemoryBarrier(MemoryBarrierBits type) : type_(type) { - MOZ_ASSERT((type_ & ~MembarAllbits) == 0); + MOZ_ASSERT((type_ & ~MembarAllbits) == MembarNobits); } - int type() const { + MemoryBarrierBits type() const { return type_; } diff --git a/js/src/jit/MIR.h b/js/src/jit/MIR.h index 5977b3aa496e..c97c7a12b632 100644 --- a/js/src/jit/MIR.h +++ b/js/src/jit/MIR.h @@ -11930,22 +11930,22 @@ class MMemoryBarrier : public MNullaryInstruction { // The type is a combination of the memory barrier types in AtomicOp.h. - const int type_; + const MemoryBarrierBits type_; - explicit MMemoryBarrier(int type) + explicit MMemoryBarrier(MemoryBarrierBits type) : type_(type) { - MOZ_ASSERT((type_ & ~MembarAllbits) == 0); + MOZ_ASSERT((type_ & ~MembarAllbits) == MembarNobits); setGuard(); // Not removable } public: INSTRUCTION_HEADER(MemoryBarrier); - static MMemoryBarrier *New(TempAllocator &alloc, int type=MembarFull) { + static MMemoryBarrier *New(TempAllocator &alloc, MemoryBarrierBits type = MembarFull) { return new(alloc) MMemoryBarrier(type); } - int type() const { + MemoryBarrierBits type() const { return type_; } diff --git a/js/src/jit/arm/CodeGenerator-arm.cpp b/js/src/jit/arm/CodeGenerator-arm.cpp index a57c927bac91..1344759122b4 100644 --- a/js/src/jit/arm/CodeGenerator-arm.cpp +++ b/js/src/jit/arm/CodeGenerator-arm.cpp @@ -2250,7 +2250,7 @@ JitRuntime::generateForkJoinGetSliceStub(JSContext *cx) } void -CodeGeneratorARM::memoryBarrier(int barrier) +CodeGeneratorARM::memoryBarrier(MemoryBarrierBits barrier) { // On ARMv6 the optional argument (BarrierST, etc) is ignored. if (barrier == (MembarStoreStore|MembarSynchronizing)) diff --git a/js/src/jit/arm/CodeGenerator-arm.h b/js/src/jit/arm/CodeGenerator-arm.h index 2d89d2db420d..8bd0032c1166 100644 --- a/js/src/jit/arm/CodeGenerator-arm.h +++ b/js/src/jit/arm/CodeGenerator-arm.h @@ -181,7 +181,7 @@ class CodeGeneratorARM : public CodeGeneratorShared bool modICommon(MMod *mir, Register lhs, Register rhs, Register output, LSnapshot *snapshot, Label &done); - void memoryBarrier(int barrier); + void memoryBarrier(MemoryBarrierBits barrier); public: CodeGeneratorARM(MIRGenerator *gen, LIRGraph *graph, MacroAssembler *masm);