Update Poisoned pointers to take a Poison class instead of a uintptr_t&.
authormark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Jan 2018 17:43:16 +0000 (17:43 +0000)
committermark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Jan 2018 17:43:16 +0000 (17:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182017
<rdar://problem/36795513>

Reviewed by Filip Pizlo and JF Bastien.

Source/JavaScriptCore:

Removed the POISON() macro.  Now that we have Poison types, we can just use the
the Poison type instead and make the code a bit nicer to read.

* API/JSAPIWrapperObject.h:
* API/JSCallbackFunction.h:
* API/JSCallbackObject.h:
* b3/B3LowerMacros.cpp:
* b3/testb3.cpp:
(JSC::B3::testInterpreter):
* bytecode/CodeBlock.h:
(JSC::CodeBlock::instructions):
(JSC::CodeBlock::instructions const):
* dfg/DFGOSRExitCompilerCommon.h:
(JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileCheckSubClass):
(JSC::DFG::SpeculativeJIT::emitSwitchIntJump):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileCheckSubClass):
* jit/JIT.h:
* jit/ThunkGenerators.cpp:
(JSC::virtualThunkFor):
(JSC::nativeForGenerator):
(JSC::boundThisNoArgsFunctionCallGenerator):
* parser/UnlinkedSourceCode.h:
* runtime/ArrayPrototype.h:
* runtime/CustomGetterSetter.h:
* runtime/DateInstance.h:
* runtime/InternalFunction.h:
* runtime/JSArrayBuffer.h:
* runtime/JSCPoison.cpp:
(JSC::initializePoison):
* runtime/JSCPoison.h:
* runtime/JSGlobalObject.h:
* runtime/JSScriptFetchParameters.h:
* runtime/JSScriptFetcher.h:
* runtime/NativeExecutable.h:
* runtime/StructureTransitionTable.h:
* runtime/WriteBarrier.h:
(JSC::WriteBarrier::poison): Deleted.
* wasm/js/JSToWasm.cpp:
(JSC::Wasm::createJSToWasmWrapper):
* wasm/js/JSWebAssemblyCodeBlock.cpp:
(JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock):
* wasm/js/JSWebAssemblyCodeBlock.h:
* wasm/js/JSWebAssemblyInstance.h:
(JSC::JSWebAssemblyInstance::poison):
* wasm/js/JSWebAssemblyMemory.h:
* wasm/js/JSWebAssemblyModule.h:
* wasm/js/JSWebAssemblyTable.h:
* wasm/js/WasmToJS.cpp:
(JSC::Wasm::handleBadI64Use):
(JSC::Wasm::wasmToJS):
* wasm/js/WebAssemblyFunctionBase.h:
* wasm/js/WebAssemblyModuleRecord.h:
* wasm/js/WebAssemblyToJSCallee.h:
* wasm/js/WebAssemblyWrapperFunction.h:

Source/WTF:

This paves the way for custom poison values which we'll need for use in
TypedArrays later.

* wtf/Bag.h:
* wtf/DumbPtrTraits.h:
(WTF::DumbPtrTraits::poison): Deleted.
* wtf/DumbValueTraits.h:
(WTF::DumbValueTraits::poison): Deleted.
* wtf/Poisoned.h:
(WTF::Poison::key):
(WTF::Poisoned::swap):
(WTF::Poisoned::poison const):
(WTF::Poisoned::unpoison const):
(WTF::Poisoned::poison):
(WTF::Poisoned::unpoison):
(WTF::PoisonedPtrTraits::swap):
(WTF::PoisonedValueTraits::swap):
(WTF::PoisonedPtrTraits::poison): Deleted.
(WTF::PoisonedValueTraits::poison): Deleted.
* wtf/PoisonedUniquePtr.h:
* wtf/Ref.h:
* wtf/RefCountedArray.h:
* wtf/RefPtr.h:
* wtf/WTFAssertions.cpp:

Tools:

* TestWebKitAPI/Tests/WTF/Poisoned.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WTF/PoisonedRef.cpp:
(TestWebKitAPI::TEST):
(TestWebKitAPI::passWithRef):
* TestWebKitAPI/Tests/WTF/PoisonedRefPtr.cpp:
(TestWebKitAPI::TEST):
(TestWebKitAPI::f1):
* TestWebKitAPI/Tests/WTF/PoisonedUniquePtr.cpp:
(TestWebKitAPI::TEST):
(TestWebKitAPI::poisonedPtrFoo):
* TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForNonTriviallyDestructibleArrays.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForTriviallyDestructibleArrays.cpp:
(TestWebKitAPI::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227527 268f45cc-cd09-0410-ab3c-d52691b4dbfc

55 files changed:
Source/JavaScriptCore/API/JSAPIWrapperObject.h
Source/JavaScriptCore/API/JSCallbackFunction.h
Source/JavaScriptCore/API/JSCallbackObject.h
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/b3/B3LowerMacros.cpp
Source/JavaScriptCore/b3/testb3.cpp
Source/JavaScriptCore/bytecode/CodeBlock.h
Source/JavaScriptCore/dfg/DFGOSRExitCompilerCommon.h
Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
Source/JavaScriptCore/jit/JIT.h
Source/JavaScriptCore/jit/ThunkGenerators.cpp
Source/JavaScriptCore/parser/UnlinkedSourceCode.h
Source/JavaScriptCore/runtime/ArrayPrototype.h
Source/JavaScriptCore/runtime/CustomGetterSetter.h
Source/JavaScriptCore/runtime/DateInstance.h
Source/JavaScriptCore/runtime/InternalFunction.h
Source/JavaScriptCore/runtime/JSArrayBuffer.h
Source/JavaScriptCore/runtime/JSCPoison.cpp
Source/JavaScriptCore/runtime/JSCPoison.h
Source/JavaScriptCore/runtime/JSGlobalObject.h
Source/JavaScriptCore/runtime/JSScriptFetchParameters.h
Source/JavaScriptCore/runtime/JSScriptFetcher.h
Source/JavaScriptCore/runtime/NativeExecutable.h
Source/JavaScriptCore/runtime/StructureTransitionTable.h
Source/JavaScriptCore/runtime/WriteBarrier.h
Source/JavaScriptCore/wasm/js/JSToWasm.cpp
Source/JavaScriptCore/wasm/js/JSWebAssemblyCodeBlock.cpp
Source/JavaScriptCore/wasm/js/JSWebAssemblyCodeBlock.h
Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h
Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.h
Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.h
Source/JavaScriptCore/wasm/js/JSWebAssemblyTable.h
Source/JavaScriptCore/wasm/js/WasmToJS.cpp
Source/JavaScriptCore/wasm/js/WebAssemblyFunctionBase.h
Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.h
Source/JavaScriptCore/wasm/js/WebAssemblyToJSCallee.h
Source/JavaScriptCore/wasm/js/WebAssemblyWrapperFunction.h
Source/WTF/ChangeLog
Source/WTF/wtf/Bag.h
Source/WTF/wtf/DumbPtrTraits.h
Source/WTF/wtf/DumbValueTraits.h
Source/WTF/wtf/Poisoned.h
Source/WTF/wtf/PoisonedUniquePtr.h
Source/WTF/wtf/Ref.h
Source/WTF/wtf/RefCountedArray.h
Source/WTF/wtf/RefPtr.h
Source/WTF/wtf/WTFAssertions.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/Poisoned.cpp
Tools/TestWebKitAPI/Tests/WTF/PoisonedRef.cpp
Tools/TestWebKitAPI/Tests/WTF/PoisonedRefPtr.cpp
Tools/TestWebKitAPI/Tests/WTF/PoisonedUniquePtr.cpp
Tools/TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForNonTriviallyDestructibleArrays.cpp
Tools/TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForTriviallyDestructibleArrays.cpp

index d15a89e..3958cf4 100644 (file)
@@ -50,7 +50,7 @@ protected:
     JSAPIWrapperObject(VM&, Structure*);
 
 private:
-    Poisoned<POISON(JSAPIWrapperObject), void*> m_wrappedObject;
+    Poisoned<JSAPIWrapperObjectPoison, void*> m_wrappedObject;
 };
 
 } // namespace JSC
index 9a1900b..47d8711 100644 (file)
@@ -54,7 +54,7 @@ private:
 
     JSObjectCallAsFunctionCallback functionCallback() { return m_callback.unpoisoned(); }
 
-    Poisoned<POISON(NativeCode), JSObjectCallAsFunctionCallback> m_callback;
+    Poisoned<NativeCodePoison, JSObjectCallAsFunctionCallback> m_callback;
 };
 
 } // namespace JSC
index ce12fca..98332fe 100644 (file)
@@ -234,7 +234,7 @@ private:
     static EncodedJSValue staticFunctionGetter(ExecState*, EncodedJSValue, PropertyName);
     static EncodedJSValue callbackGetter(ExecState*, EncodedJSValue, PropertyName);
 
-    WTF::PoisonedUniquePtr<POISON(JSCallbackObject), JSCallbackObjectData> m_callbackObjectData;
+    WTF::PoisonedUniquePtr<JSCallbackObjectPoison, JSCallbackObjectData> m_callbackObjectData;
     PoisonedClassInfoPtr m_classInfo;
 };
 
index c760b02..40c6a7f 100644 (file)
@@ -1,3 +1,69 @@
+2018-01-23  Mark Lam  <mark.lam@apple.com>
+
+        Update Poisoned pointers to take a Poison class instead of a uintptr_t&.
+        https://bugs.webkit.org/show_bug.cgi?id=182017
+        <rdar://problem/36795513>
+
+        Reviewed by Filip Pizlo and JF Bastien.
+
+        Removed the POISON() macro.  Now that we have Poison types, we can just use the
+        the Poison type instead and make the code a bit nicer to read.
+
+        * API/JSAPIWrapperObject.h:
+        * API/JSCallbackFunction.h:
+        * API/JSCallbackObject.h:
+        * b3/B3LowerMacros.cpp:
+        * b3/testb3.cpp:
+        (JSC::B3::testInterpreter):
+        * bytecode/CodeBlock.h:
+        (JSC::CodeBlock::instructions):
+        (JSC::CodeBlock::instructions const):
+        * dfg/DFGOSRExitCompilerCommon.h:
+        (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk):
+        * dfg/DFGSpeculativeJIT.cpp:
+        (JSC::DFG::SpeculativeJIT::compileCheckSubClass):
+        (JSC::DFG::SpeculativeJIT::emitSwitchIntJump):
+        * ftl/FTLLowerDFGToB3.cpp:
+        (JSC::FTL::DFG::LowerDFGToB3::compileCheckSubClass):
+        * jit/JIT.h:
+        * jit/ThunkGenerators.cpp:
+        (JSC::virtualThunkFor):
+        (JSC::nativeForGenerator):
+        (JSC::boundThisNoArgsFunctionCallGenerator):
+        * parser/UnlinkedSourceCode.h:
+        * runtime/ArrayPrototype.h:
+        * runtime/CustomGetterSetter.h:
+        * runtime/DateInstance.h:
+        * runtime/InternalFunction.h:
+        * runtime/JSArrayBuffer.h:
+        * runtime/JSCPoison.cpp:
+        (JSC::initializePoison):
+        * runtime/JSCPoison.h:
+        * runtime/JSGlobalObject.h:
+        * runtime/JSScriptFetchParameters.h:
+        * runtime/JSScriptFetcher.h:
+        * runtime/NativeExecutable.h:
+        * runtime/StructureTransitionTable.h:
+        * runtime/WriteBarrier.h:
+        (JSC::WriteBarrier::poison): Deleted.
+        * wasm/js/JSToWasm.cpp:
+        (JSC::Wasm::createJSToWasmWrapper):
+        * wasm/js/JSWebAssemblyCodeBlock.cpp:
+        (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock):
+        * wasm/js/JSWebAssemblyCodeBlock.h:
+        * wasm/js/JSWebAssemblyInstance.h:
+        (JSC::JSWebAssemblyInstance::poison):
+        * wasm/js/JSWebAssemblyMemory.h:
+        * wasm/js/JSWebAssemblyModule.h:
+        * wasm/js/JSWebAssemblyTable.h:
+        * wasm/js/WasmToJS.cpp:
+        (JSC::Wasm::handleBadI64Use):
+        (JSC::Wasm::wasmToJS):
+        * wasm/js/WebAssemblyFunctionBase.h:
+        * wasm/js/WebAssemblyModuleRecord.h:
+        * wasm/js/WebAssemblyToJSCallee.h:
+        * wasm/js/WebAssemblyWrapperFunction.h:
+
 2018-01-23  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         Unreviewed, suppress GCC warnings
index 31732f8..6159467 100644 (file)
@@ -507,7 +507,7 @@ private:
                         GPRReg scratch = params.gpScratch(0);
                         GPRReg poisonScratch = params.gpScratch(1);
 
-                        jit.move(CCallHelpers::TrustedImm64(POISON(JITCode)), poisonScratch);
+                        jit.move(CCallHelpers::TrustedImm64(JITCodePoison::key()), poisonScratch);
                         jit.move(CCallHelpers::TrustedImmPtr(jumpTable), scratch);
                         jit.load64(CCallHelpers::BaseIndex(scratch, index, CCallHelpers::timesPtr()), scratch);
                         jit.xor64(poisonScratch, scratch);
index f997bdd..0df3ca1 100644 (file)
@@ -13033,7 +13033,7 @@ void testInterpreter()
             GPRReg poisonScratch = params.gpScratch(1);
 
             jit.move(CCallHelpers::TrustedImmPtr(jumpTable), scratch);
-            jit.move(CCallHelpers::TrustedImm64(POISON(JITCode)), poisonScratch);
+            jit.move(CCallHelpers::TrustedImm64(JITCodePoison::key()), poisonScratch);
             jit.load64(CCallHelpers::BaseIndex(scratch, params[0].gpr(), CCallHelpers::timesPtr()), scratch);
             jit.xor64(poisonScratch, scratch);
             jit.jump(scratch);
index a1ff6da..dcd9d22 100644 (file)
@@ -319,11 +319,11 @@ public:
     }
 
     typedef JSC::Instruction Instruction;
-    typedef PoisonedRefCountedArray<POISON(CodeBlock), Instruction>& UnpackedInstructions;
+    typedef PoisonedRefCountedArray<CodeBlockPoison, Instruction>& UnpackedInstructions;
 
     unsigned numberOfInstructions() const { return m_instructions.size(); }
-    PoisonedRefCountedArray<POISON(CodeBlock), Instruction>& instructions() { return m_instructions; }
-    const PoisonedRefCountedArray<POISON(CodeBlock), Instruction>& instructions() const { return m_instructions; }
+    PoisonedRefCountedArray<CodeBlockPoison, Instruction>& instructions() { return m_instructions; }
+    const PoisonedRefCountedArray<CodeBlockPoison, Instruction>& instructions() const { return m_instructions; }
 
     size_t predictedMachineCodeSize();
 
@@ -959,30 +959,30 @@ private:
     };
     WriteBarrier<ExecutableBase> m_ownerExecutable;
     WriteBarrier<ExecutableToCodeBlockEdge> m_ownerEdge;
-    Poisoned<POISON(CodeBlock), VM*> m_poisonedVM;
+    Poisoned<CodeBlockPoison, VM*> m_poisonedVM;
 
-    PoisonedRefCountedArray<POISON(CodeBlock), Instruction> m_instructions;
+    PoisonedRefCountedArray<CodeBlockPoison, Instruction> m_instructions;
     VirtualRegister m_thisRegister;
     VirtualRegister m_scopeRegister;
     mutable CodeBlockHash m_hash;
 
-    PoisonedRefPtr<POISON(CodeBlock), SourceProvider> m_source;
+    PoisonedRefPtr<CodeBlockPoison, SourceProvider> m_source;
     unsigned m_sourceOffset;
     unsigned m_firstLineColumnOffset;
 
     RefCountedArray<LLIntCallLinkInfo> m_llintCallLinkInfos;
     SentinelLinkedList<LLIntCallLinkInfo, BasicRawSentinelNode<LLIntCallLinkInfo>> m_incomingLLIntCalls;
     StructureWatchpointMap m_llintGetByIdWatchpointMap;
-    PoisonedRefPtr<POISON(CodeBlock), JITCode> m_jitCode;
+    PoisonedRefPtr<CodeBlockPoison, JITCode> m_jitCode;
 #if ENABLE(JIT)
     std::unique_ptr<RegisterAtOffsetList> m_calleeSaveRegisters;
-    PoisonedBag<POISON(CodeBlock), StructureStubInfo> m_stubInfos;
-    PoisonedBag<POISON(CodeBlock), JITAddIC> m_addICs;
-    PoisonedBag<POISON(CodeBlock), JITMulIC> m_mulICs;
-    PoisonedBag<POISON(CodeBlock), JITNegIC> m_negICs;
-    PoisonedBag<POISON(CodeBlock), JITSubIC> m_subICs;
-    PoisonedBag<POISON(CodeBlock), ByValInfo> m_byValInfos;
-    PoisonedBag<POISON(CodeBlock), CallLinkInfo> m_callLinkInfos;
+    PoisonedBag<CodeBlockPoison, StructureStubInfo> m_stubInfos;
+    PoisonedBag<CodeBlockPoison, JITAddIC> m_addICs;
+    PoisonedBag<CodeBlockPoison, JITMulIC> m_mulICs;
+    PoisonedBag<CodeBlockPoison, JITNegIC> m_negICs;
+    PoisonedBag<CodeBlockPoison, JITSubIC> m_subICs;
+    PoisonedBag<CodeBlockPoison, ByValInfo> m_byValInfos;
+    PoisonedBag<CodeBlockPoison, CallLinkInfo> m_callLinkInfos;
     SentinelLinkedList<CallLinkInfo, BasicRawSentinelNode<CallLinkInfo>> m_incomingCalls;
     SentinelLinkedList<PolymorphicCallNode, BasicRawSentinelNode<PolymorphicCallNode>> m_incomingPolymorphicCalls;
     std::unique_ptr<PCToCodeOriginMap> m_pcToCodeOriginMap;
index c6f6523..52a1f3b 100644 (file)
@@ -87,7 +87,7 @@ void adjustFrameAndStackInOSRExitCompilerThunk(MacroAssembler& jit, VM* vm, JITC
     // We need to make sure SP is correct in case of an exception.
     jit.loadPtr(MacroAssembler::Address(GPRInfo::callFrameRegister, CallFrameSlot::codeBlock * static_cast<int>(sizeof(Register))), GPRInfo::regT0);
     jit.loadPtr(MacroAssembler::Address(GPRInfo::regT0, CodeBlock::jitCodeOffset()), GPRInfo::regT0);
-    jit.xorPtr(MacroAssembler::TrustedImmPtr(POISON(CodeBlock)), GPRInfo::regT0);
+    jit.xorPtr(MacroAssembler::TrustedImmPtr(CodeBlockPoison::key()), GPRInfo::regT0);
     jit.addPtr(MacroAssembler::TrustedImm32(JITCodeType::commonDataOffset()), GPRInfo::regT0);
     jit.load32(MacroAssembler::Address(GPRInfo::regT0, CommonData::frameRegisterCountOffset()), GPRInfo::regT0);
     // This does virtualRegisterForLocal(frameRegisterCount - 1)*sizeof(Register) where:
index 54a9c4b..841532f 100644 (file)
@@ -8663,7 +8663,7 @@ void SpeculativeJIT::compileCheckSubClass(Node* node)
         m_jit.emitLoadStructure(*m_jit.vm(), baseGPR, otherGPR, specifiedGPR);
         m_jit.loadPtr(CCallHelpers::Address(otherGPR, Structure::classInfoOffset()), otherGPR);
 #if USE(JSVALUE64)
-        m_jit.move(CCallHelpers::TrustedImm64(POISON(GlobalData)), specifiedGPR);
+        m_jit.move(CCallHelpers::TrustedImm64(GlobalDataPoison::key()), specifiedGPR);
         m_jit.xor64(specifiedGPR, otherGPR);
 #endif
         m_jit.move(CCallHelpers::TrustedImmPtr(node->classInfo()), specifiedGPR);
@@ -9781,7 +9781,7 @@ void SpeculativeJIT::emitSwitchIntJump(
         data->fallThrough.block);
     UNUSED_PARAM(poisonScratch); // Placate the 32-bit build.
 #if USE(JSVALUE64)
-    m_jit.move(TrustedImm64(POISON(JITCode)), poisonScratch);
+    m_jit.move(TrustedImm64(JITCodePoison::key()), poisonScratch);
 #endif
     m_jit.move(TrustedImmPtr(table.ctiOffsets.begin()), scratch);
     m_jit.loadPtr(JITCompiler::BaseIndex(scratch, value, JITCompiler::timesPtr()), scratch);
index d3242de..dedd61c 100644 (file)
@@ -11443,7 +11443,7 @@ private:
 
             LValue structure = loadStructure(cell);
             LValue poisonedClassInfo = m_out.loadPtr(structure, m_heaps.Structure_classInfo);
-            LValue classInfo = m_out.bitXor(poisonedClassInfo, m_out.constInt64(POISON(GlobalData)));
+            LValue classInfo = m_out.bitXor(poisonedClassInfo, m_out.constInt64(GlobalDataPoison::key()));
             ValueFromBlock otherAtStart = m_out.anchor(classInfo);
             m_out.jump(loop);
 
index 985bc0f..b61874e 100644 (file)
@@ -904,7 +904,7 @@ namespace JSC {
 
         Interpreter* m_interpreter;
 
-        PoisonedRefCountedArray<POISON(CodeBlock), Instruction> m_instructions;
+        PoisonedRefCountedArray<CodeBlockPoison, Instruction> m_instructions;
 
         Vector<CallRecord> m_calls;
         Vector<Label> m_labels;
index 83bd8c4..4cc9c90 100644 (file)
@@ -214,7 +214,7 @@ MacroAssemblerCodeRef virtualThunkFor(VM* vm, CallLinkInfo& callLinkInfo)
     // Now we know that we have a CodeBlock, and we're committed to making a fast
     // call.
 #if USE(JSVALUE64)
-    jit.move(CCallHelpers::TrustedImm64(POISON(JITCode)), GPRInfo::regT1);
+    jit.move(CCallHelpers::TrustedImm64(JITCodePoison::key()), GPRInfo::regT1);
     jit.xor64(GPRInfo::regT1, GPRInfo::regT4);
 #endif
 
@@ -310,7 +310,7 @@ static MacroAssemblerCodeRef nativeForGenerator(VM* vm, ThunkFunctionType thunkF
         jit.loadPtr(JSInterfaceJIT::Address(X86Registers::r9, executableOffsetToFunction), X86Registers::r9);
     } else
         jit.loadPtr(JSInterfaceJIT::Address(X86Registers::esi, InternalFunction::offsetOfNativeFunctionFor(kind)), X86Registers::r9);
-    jit.move(JSInterfaceJIT::TrustedImm64(POISON(NativeCode)), X86Registers::esi);
+    jit.move(JSInterfaceJIT::TrustedImm64(NativeCodePoison::key()), X86Registers::esi);
     jit.xor64(X86Registers::esi, X86Registers::r9);
     jit.call(X86Registers::r9);
 
@@ -347,7 +347,7 @@ static MacroAssemblerCodeRef nativeForGenerator(VM* vm, ThunkFunctionType thunkF
         jit.loadPtr(JSInterfaceJIT::Address(ARM64Registers::x2, executableOffsetToFunction), ARM64Registers::x2);
     } else
         jit.loadPtr(JSInterfaceJIT::Address(ARM64Registers::x1, InternalFunction::offsetOfNativeFunctionFor(kind)), ARM64Registers::x2);
-    jit.move(JSInterfaceJIT::TrustedImm64(POISON(NativeCode)), ARM64Registers::x1);
+    jit.move(JSInterfaceJIT::TrustedImm64(NativeCodePoison::key()), ARM64Registers::x1);
     jit.xor64(ARM64Registers::x1, ARM64Registers::x2);
     jit.call(ARM64Registers::x2);
 
@@ -1171,7 +1171,7 @@ MacroAssemblerCodeRef boundThisNoArgsFunctionCallGenerator(VM* vm)
     CCallHelpers::Jump noCode = jit.branchTestPtr(CCallHelpers::Zero, GPRInfo::regT0);
     
 #if USE(JSVALUE64)
-    jit.move(CCallHelpers::TrustedImm64(POISON(JITCode)), GPRInfo::regT1);
+    jit.move(CCallHelpers::TrustedImm64(JITCodePoison::key()), GPRInfo::regT1);
     jit.xor64(GPRInfo::regT1, GPRInfo::regT0);
 #endif
     emitPointerValidation(jit, GPRInfo::regT0);
index 8df4311..6ec590b 100644 (file)
@@ -101,7 +101,7 @@ namespace JSC {
     protected:
         // FIXME: Make it PoisonedRef<SourceProvidier>.
         // https://bugs.webkit.org/show_bug.cgi?id=168325
-        PoisonedRefPtr<POISON(UnlinkedSourceCode), SourceProvider> m_provider;
+        PoisonedRefPtr<UnlinkedSourceCodePoison, SourceProvider> m_provider;
         int m_startOffset;
         int m_endOffset;
     };
index 193819f..25587d8 100644 (file)
@@ -62,8 +62,8 @@ protected:
 private:
     // This bit is set if any user modifies the constructor property Array.prototype. This is used to optimize species creation for JSArrays.
     friend ArrayPrototypeAdaptiveInferredPropertyWatchpoint;
-    PoisonedUniquePtr<POISON(ArrayPrototype), ArrayPrototypeAdaptiveInferredPropertyWatchpoint> m_constructorWatchpoint;
-    PoisonedUniquePtr<POISON(ArrayPrototype), ArrayPrototypeAdaptiveInferredPropertyWatchpoint> m_constructorSpeciesWatchpoint;
+    PoisonedUniquePtr<ArrayPrototypePoison, ArrayPrototypeAdaptiveInferredPropertyWatchpoint> m_constructorWatchpoint;
+    PoisonedUniquePtr<ArrayPrototypePoison, ArrayPrototypeAdaptiveInferredPropertyWatchpoint> m_constructorSpeciesWatchpoint;
 };
 
 EncodedJSValue JSC_HOST_CALL arrayProtoFuncToString(ExecState*);
index ade8419..d3b62fe 100644 (file)
@@ -68,7 +68,7 @@ protected:
 
 private:
     template<typename T>
-    using PoisonedAccessor = Poisoned<POISON(NativeCode), T>;
+    using PoisonedAccessor = Poisoned<NativeCodePoison, T>;
 
     PoisonedAccessor<CustomGetter> m_getter;
     PoisonedAccessor<CustomSetter> m_setter;
index 06ae84e..3f11ae3 100644 (file)
@@ -77,7 +77,7 @@ private:
     JS_EXPORT_PRIVATE const GregorianDateTime* calculateGregorianDateTime(ExecState*) const;
     JS_EXPORT_PRIVATE const GregorianDateTime* calculateGregorianDateTimeUTC(ExecState*) const;
 
-    mutable PoisonedRefPtr<POISON(DateInstance), DateInstanceData> m_data;
+    mutable PoisonedRefPtr<DateInstancePoison, DateInstanceData> m_data;
 };
 
 DateInstance* asDateInstance(JSValue);
index 900b4d1..2d9bb50 100644 (file)
@@ -70,7 +70,7 @@ public:
     }
 
 protected:
-    using PoisonedNativeFunction = Poisoned<POISON(NativeCode), NativeFunction>;
+    using PoisonedNativeFunction = Poisoned<NativeCodePoison, NativeFunction>;
 
     JS_EXPORT_PRIVATE InternalFunction(VM&, Structure*, NativeFunction functionForCall, NativeFunction functionForConstruct);
 
index 95d5b95..2f5a5f9 100644 (file)
@@ -61,7 +61,7 @@ protected:
     static size_t estimatedSize(JSCell*);
 
 private:
-    Poisoned<POISON(JSArrayBuffer), ArrayBuffer*> m_impl;
+    Poisoned<JSArrayBufferPoison, ArrayBuffer*> m_impl;
 };
 
 inline ArrayBuffer* toPossiblySharedArrayBuffer(VM& vm, JSValue value)
index 708a349..7d85643 100644 (file)
@@ -33,7 +33,7 @@
 namespace JSC {
 
 #define DEFINE_POISON(poisonID) \
-    uintptr_t POISON(poisonID);
+    uintptr_t POISON_KEY_NAME(poisonID);
 FOR_EACH_JSC_POISON(DEFINE_POISON)
 
 void initializePoison()
@@ -44,7 +44,7 @@ void initializePoison()
             return;
 
 #define INITIALIZE_POISON(poisonID) \
-    POISON(poisonID) = makePoison();
+    POISON_KEY_NAME(poisonID) = makePoison();
 
         FOR_EACH_JSC_POISON(INITIALIZE_POISON)
     });
index 5ed49bb..5ba4c0a 100644 (file)
@@ -55,18 +55,19 @@ namespace JSC {
     v(WebAssemblyToJSCallee) \
     v(WebAssemblyWrapperFunction) \
 
-#define POISON(_poisonID_) g_##_poisonID_##Poison
+#define POISON_KEY_NAME(_poisonID_) g_##_poisonID_##Poison
 
 #define DECLARE_POISON(_poisonID_) \
-    extern "C" JS_EXPORTDATA uintptr_t POISON(_poisonID_);
+    extern "C" JS_EXPORTDATA uintptr_t POISON_KEY_NAME(_poisonID_); \
+    using _poisonID_ ## Poison = Poison<POISON_KEY_NAME(_poisonID_)>;
 
 FOR_EACH_JSC_POISON(DECLARE_POISON)
 #undef DECLARE_POISON
 
 struct ClassInfo;
 
-using PoisonedClassInfoPtr = Poisoned<POISON(GlobalData), const ClassInfo*>;
-using PoisonedMasmPtr = Poisoned<POISON(JITCode), void*>;
+using PoisonedClassInfoPtr = Poisoned<GlobalDataPoison, const ClassInfo*>;
+using PoisonedMasmPtr = Poisoned<JITCodePoison, void*>;
 
 void initializePoison();
 
index 8f2e4fd..8ddce14 100644 (file)
@@ -401,7 +401,7 @@ public:
 
     VM& m_vm;
 
-    template<typename T> using PoisonedUniquePtr = WTF::PoisonedUniquePtr<POISON(JSGlobalObject), T>;
+    template<typename T> using PoisonedUniquePtr = WTF::PoisonedUniquePtr<JSGlobalObjectPoison, T>;
 
 #if ENABLE(REMOTE_INSPECTOR)
     PoisonedUniquePtr<Inspector::JSGlobalObjectInspectorController> m_inspectorController;
index 56b5e11..33ea6a6 100644 (file)
@@ -74,7 +74,7 @@ private:
     {
     }
 
-    PoisonedRef<POISON(JSScriptFetchParameters), ScriptFetchParameters> m_parameters;
+    PoisonedRef<JSScriptFetchParametersPoison, ScriptFetchParameters> m_parameters;
 };
 
 } // namespace JSC
index 923ab43..0eb3ed0 100644 (file)
@@ -74,7 +74,7 @@ private:
     {
     }
 
-    PoisonedRefPtr<POISON(JSScriptFetcher), ScriptFetcher> m_fetcher;
+    PoisonedRefPtr<JSScriptFetcherPoison, ScriptFetcher> m_fetcher;
 };
 
 } // namespace JSC
index 9670cb7..3ac8612 100644 (file)
@@ -90,7 +90,7 @@ protected:
 
 private:
     friend class ExecutableBase;
-    using PoisonedNativeFunction = Poisoned<POISON(NativeCode), NativeFunction>;
+    using PoisonedNativeFunction = Poisoned<NativeCodePoison, NativeFunction>;
 
     NativeExecutable(VM&, NativeFunction function, NativeFunction constructor, Intrinsic, const DOMJIT::Signature*);
 
index f6bcb94..68a4689 100644 (file)
@@ -187,8 +187,8 @@ public:
 
 private:
     friend class SingleSlotTransitionWeakOwner;
-    using PoisonedTransitionMapPtr = Poisoned<POISON(StructureTransitionTable), TransitionMap*>;
-    using PoisonedWeakImplPtr = Poisoned<POISON(StructureTransitionTable), WeakImpl*>;
+    using PoisonedTransitionMapPtr = Poisoned<StructureTransitionTablePoison, TransitionMap*>;
+    using PoisonedWeakImplPtr = Poisoned<StructureTransitionTablePoison, WeakImpl*>;
 
     bool isUsingSingleSlot() const
     {
index 5836fa5..e2bc7c5 100644 (file)
@@ -195,8 +195,6 @@ template <typename T, typename Traits = WriteBarrierTraitsSelect<T>>
 class WriteBarrier : public WriteBarrierBase<T, Traits> {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    static auto poison() { return Traits::poison(); }
-
     WriteBarrier()
     {
         this->setWithoutWriteBarrier(0);
@@ -225,8 +223,6 @@ template <>
 class WriteBarrier<Unknown, DumbValueTraits<Unknown>> : public WriteBarrierBase<Unknown, DumbValueTraits<Unknown>> {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    static auto poison() { return DumbValueTraits<Unknown>::poison(); }
-
     WriteBarrier()
     {
         this->setWithoutWriteBarrier(JSValue());
@@ -254,12 +250,12 @@ inline bool operator==(const WriteBarrierBase<U, TraitsU>& lhs, const WriteBarri
     return lhs.get() == rhs.get();
 }
 
-template<uintptr_t& key, class T>
+template<typename Poison, class T>
 using PoisonedWriteBarrierTraitsSelect = typename std::conditional<std::is_same<T, Unknown>::value,
-    WTF::PoisonedValueTraits<key, T>, WTF::PoisonedPtrTraits<key, T>
+    WTF::PoisonedValueTraits<Poison, T>, WTF::PoisonedPtrTraits<Poison, T>
 >::type;
 
-template <uintptr_t& key, typename T>
-using PoisonedWriteBarrier = WriteBarrier<T, PoisonedWriteBarrierTraitsSelect<key, T>>;
+template <typename Poison, typename T>
+using PoisonedWriteBarrier = WriteBarrier<T, PoisonedWriteBarrierTraitsSelect<Poison, T>>;
 
 } // namespace JSC
index 208a376..c6d053b 100644 (file)
@@ -118,7 +118,7 @@ std::unique_ptr<InternalFunction> createJSToWasmWrapper(CompilationContext& comp
         if (!Context::useFastTLS()) {
             jit.loadPtr(CCallHelpers::Address(GPRInfo::callFrameRegister, jsOffset), wasmContextInstanceGPR);
             jit.loadPtr(CCallHelpers::Address(wasmContextInstanceGPR, JSWebAssemblyInstance::offsetOfPoisonedInstance()), wasmContextInstanceGPR);
-            jit.move(CCallHelpers::TrustedImm64(POISON(JSWebAssemblyInstance)), scratchReg);
+            jit.move(CCallHelpers::TrustedImm64(JSWebAssemblyInstancePoison::key()), scratchReg);
             jit.xor64(scratchReg, wasmContextInstanceGPR);
             jsOffset += sizeof(EncodedJSValue);
         }
index 39d901f..94e483b 100644 (file)
@@ -51,7 +51,7 @@ JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock(VM& vm, Ref<Wasm::CodeBlock>&& co
     : Base(vm, vm.webAssemblyCodeBlockStructure.get())
     , m_codeBlock(WTFMove(codeBlock))
 {
-    m_unconditionalFinalizer = PoisonedUniquePtr<POISON(JSWebAssemblyCodeBlock), UnconditionalFinalizer>::create(*this);
+    m_unconditionalFinalizer = PoisonedUniquePtr<JSWebAssemblyCodeBlockPoison, UnconditionalFinalizer>::create(*this);
 
     // FIXME: We should not need to do this synchronously.
     // https://bugs.webkit.org/show_bug.cgi?id=170567
index e26e4cf..e76a617 100644 (file)
@@ -97,9 +97,9 @@ private:
         JSWebAssemblyCodeBlock& codeBlock;
     };
 
-    PoisonedRef<POISON(JSWebAssemblyCodeBlock), Wasm::CodeBlock> m_codeBlock;
+    PoisonedRef<JSWebAssemblyCodeBlockPoison, Wasm::CodeBlock> m_codeBlock;
     Vector<MacroAssemblerCodeRef> m_wasmToJSExitStubs;
-    PoisonedUniquePtr<POISON(JSWebAssemblyCodeBlock), UnconditionalFinalizer> m_unconditionalFinalizer;
+    PoisonedUniquePtr<JSWebAssemblyCodeBlockPoison, UnconditionalFinalizer> m_unconditionalFinalizer;
     Bag<CallLinkInfo> m_callLinkInfos;
     String m_errorMessage;
 };
index 7f95100..1780af2 100644 (file)
@@ -80,7 +80,7 @@ public:
     static size_t offsetOfPoisonedCallee() { return OBJECT_OFFSETOF(JSWebAssemblyInstance, m_callee); }
 
     template<typename T>
-    using PoisonedBarrier = PoisonedWriteBarrier<POISON(JSWebAssemblyInstance), T>;
+    using PoisonedBarrier = PoisonedWriteBarrier<JSWebAssemblyInstancePoison, T>;
 
 protected:
     JSWebAssemblyInstance(VM&, Structure*, Ref<Wasm::Instance>&&);
@@ -91,7 +91,7 @@ protected:
 private:
     JSWebAssemblyModule* module() const { return m_module.get(); }
 
-    PoisonedRef<POISON(JSWebAssemblyInstance), Wasm::Instance> m_instance;
+    PoisonedRef<JSWebAssemblyInstancePoison, Wasm::Instance> m_instance;
 
     PoisonedBarrier<JSWebAssemblyModule> m_module;
     PoisonedBarrier<JSWebAssemblyCodeBlock> m_codeBlock;
index c0f84a1..86cff99 100644 (file)
@@ -67,9 +67,9 @@ private:
     static void destroy(JSCell*);
     static void visitChildren(JSCell*, SlotVisitor&);
 
-    PoisonedRef<POISON(JSWebAssemblyMemory), Wasm::Memory> m_memory;
-    PoisonedWriteBarrier<POISON(JSWebAssemblyMemory), JSArrayBuffer> m_bufferWrapper;
-    PoisonedRefPtr<POISON(JSWebAssemblyMemory), ArrayBuffer> m_buffer;
+    PoisonedRef<JSWebAssemblyMemoryPoison, Wasm::Memory> m_memory;
+    PoisonedWriteBarrier<JSWebAssemblyMemoryPoison, JSArrayBuffer> m_bufferWrapper;
+    PoisonedRefPtr<JSWebAssemblyMemoryPoison, ArrayBuffer> m_buffer;
 };
 
 } // namespace JSC
index 4bed210..089c2fd 100644 (file)
@@ -81,10 +81,10 @@ private:
     static void destroy(JSCell*);
     static void visitChildren(JSCell*, SlotVisitor&);
 
-    PoisonedRef<POISON(JSWebAssemblyModule), Wasm::Module> m_module;
+    PoisonedRef<JSWebAssemblyModulePoison, Wasm::Module> m_module;
 
     template<typename T>
-    using PoisonedBarrier = PoisonedWriteBarrier<POISON(JSWebAssemblyModule), T>;
+    using PoisonedBarrier = PoisonedWriteBarrier<JSWebAssemblyModulePoison, T>;
 
     PoisonedBarrier<SymbolTable> m_exportSymbolTable;
     PoisonedBarrier<JSWebAssemblyCodeBlock> m_codeBlocks[Wasm::NumberOfMemoryModes];
index 61036e6..c540e76 100644 (file)
@@ -66,10 +66,10 @@ private:
     static void destroy(JSCell*);
     static void visitChildren(JSCell*, SlotVisitor&);
 
-    PoisonedRef<POISON(JSWebAssemblyTable), Wasm::Table> m_table;
+    PoisonedRef<JSWebAssemblyTablePoison, Wasm::Table> m_table;
 
     template<typename T>
-    using PoisonedBarrier = PoisonedWriteBarrier<POISON(JSWebAssemblyTable), T>;
+    using PoisonedBarrier = PoisonedWriteBarrier<JSWebAssemblyTablePoison, T>;
 
     MallocPtr<PoisonedBarrier<JSObject>> m_jsFunctions;
 };
index 00acec4..89841da 100644 (file)
@@ -86,7 +86,7 @@ static Expected<MacroAssemblerCodeRef, BindingFailure> handleBadI64Use(VM* vm, J
         // Store Callee.
         jit.loadPtr(CCallHelpers::Address(GPRInfo::argumentGPR1, Instance::offsetOfOwner()), GPRInfo::argumentGPR1);
         jit.loadPtr(CCallHelpers::Address(GPRInfo::argumentGPR1, JSWebAssemblyInstance::offsetOfPoisonedCallee()), GPRInfo::argumentGPR2);
-        jit.move(CCallHelpers::TrustedImm64(JSWebAssemblyInstance::PoisonedBarrier<WebAssemblyToJSCallee>::poison()), GPRInfo::argumentGPR3);
+        jit.move(CCallHelpers::TrustedImm64(JSWebAssemblyInstancePoison::key()), GPRInfo::argumentGPR3);
         jit.xor64(GPRInfo::argumentGPR3, GPRInfo::argumentGPR2);
         jit.storePtr(GPRInfo::argumentGPR2, JIT::Address(GPRInfo::callFrameRegister, CallFrameSlot::callee * static_cast<int>(sizeof(Register))));
 
@@ -291,7 +291,7 @@ Expected<MacroAssemblerCodeRef, BindingFailure> wasmToJS(VM* vm, Bag<CallLinkInf
         jit.loadWasmContextInstance(GPRInfo::argumentGPR0);
         jit.loadPtr(CCallHelpers::Address(GPRInfo::argumentGPR0, Instance::offsetOfOwner()), GPRInfo::argumentGPR0);
         jit.loadPtr(CCallHelpers::Address(GPRInfo::argumentGPR0, JSWebAssemblyInstance::offsetOfPoisonedCallee()), GPRInfo::argumentGPR0);
-        jit.move(CCallHelpers::TrustedImm64(JSWebAssemblyInstance::PoisonedBarrier<WebAssemblyToJSCallee>::poison()), GPRInfo::argumentGPR3);
+        jit.move(CCallHelpers::TrustedImm64(JSWebAssemblyInstancePoison::key()), GPRInfo::argumentGPR3);
         jit.xor64(GPRInfo::argumentGPR3, GPRInfo::argumentGPR0);
         jit.storePtr(GPRInfo::argumentGPR0, JIT::Address(GPRInfo::callFrameRegister, CallFrameSlot::callee * static_cast<int>(sizeof(Register))));
         
@@ -483,7 +483,7 @@ Expected<MacroAssemblerCodeRef, BindingFailure> wasmToJS(VM* vm, Bag<CallLinkInf
     jit.loadWasmContextInstance(GPRInfo::argumentGPR0);
     jit.loadPtr(CCallHelpers::Address(GPRInfo::argumentGPR0, Instance::offsetOfOwner()), GPRInfo::argumentGPR0);
     jit.loadPtr(CCallHelpers::Address(GPRInfo::argumentGPR0, JSWebAssemblyInstance::offsetOfPoisonedCallee()), GPRInfo::argumentGPR0);
-    jit.move(CCallHelpers::TrustedImm64(JSWebAssemblyInstance::PoisonedBarrier<WebAssemblyToJSCallee>::poison()), poison);
+    jit.move(CCallHelpers::TrustedImm64(JSWebAssemblyInstancePoison::key()), poison);
     jit.xor64(poison, GPRInfo::argumentGPR0);
     jit.storePtr(GPRInfo::argumentGPR0, JIT::Address(GPRInfo::callFrameRegister, CallFrameSlot::callee * static_cast<int>(sizeof(Register))));
 
index a40c350..d1719a0 100644 (file)
@@ -50,7 +50,7 @@ protected:
     void finishCreation(VM&, NativeExecutable*, unsigned length, const String& name, JSWebAssemblyInstance*);
     WebAssemblyFunctionBase(VM&, JSGlobalObject*, Structure*);
 
-    PoisonedWriteBarrier<POISON(WebAssemblyFunctionBase), JSWebAssemblyInstance> m_instance;
+    PoisonedWriteBarrier<WebAssemblyFunctionBasePoison, JSWebAssemblyInstance> m_instance;
 };
 
 } // namespace JSC
index a6a4242..fc2addd 100644 (file)
@@ -60,7 +60,7 @@ private:
     static void visitChildren(JSCell*, SlotVisitor&);
 
     template<typename T>
-    using PoisonedBarrier = PoisonedWriteBarrier<POISON(WebAssemblyModuleRecord), T>;
+    using PoisonedBarrier = PoisonedWriteBarrier<WebAssemblyModuleRecordPoison, T>;
 
     PoisonedBarrier<JSWebAssemblyInstance> m_instance;
     PoisonedBarrier<JSObject> m_startFunction;
index 5bd56ff..c89a1af 100644 (file)
@@ -51,7 +51,7 @@ private:
     void finishCreation(VM&, JSWebAssemblyModule*);
     WebAssemblyToJSCallee(VM&, Structure*);
 
-    PoisonedWriteBarrier<POISON(WebAssemblyToJSCallee), JSWebAssemblyModule> m_module;
+    PoisonedWriteBarrier<WebAssemblyToJSCalleePoison, JSWebAssemblyModule> m_module;
 };
 
 } // namespace JSC
index 4a4d757..ca6c0ca 100644 (file)
@@ -56,7 +56,7 @@ protected:
 private:
     WebAssemblyWrapperFunction(VM&, JSGlobalObject*, Structure*, Wasm::CallableFunction);
 
-    PoisonedWriteBarrier<POISON(WebAssemblyWrapperFunction), JSObject> m_function;
+    PoisonedWriteBarrier<WebAssemblyWrapperFunctionPoison, JSObject> m_function;
     // It's safe to just hold the raw CallableFunction because we have a reference
     // to our Instance, which points to the CodeBlock, which points to the Module
     // that exported us, which ensures that the actual Signature/code doesn't get deallocated.
index fcd0b48..1e49b2b 100644 (file)
@@ -1,3 +1,36 @@
+2018-01-23  Mark Lam  <mark.lam@apple.com>
+
+        Update Poisoned pointers to take a Poison class instead of a uintptr_t&.
+        https://bugs.webkit.org/show_bug.cgi?id=182017
+        <rdar://problem/36795513>
+
+        Reviewed by Filip Pizlo and JF Bastien.
+
+        This paves the way for custom poison values which we'll need for use in
+        TypedArrays later.
+
+        * wtf/Bag.h:
+        * wtf/DumbPtrTraits.h:
+        (WTF::DumbPtrTraits::poison): Deleted.
+        * wtf/DumbValueTraits.h:
+        (WTF::DumbValueTraits::poison): Deleted.
+        * wtf/Poisoned.h:
+        (WTF::Poison::key):
+        (WTF::Poisoned::swap):
+        (WTF::Poisoned::poison const):
+        (WTF::Poisoned::unpoison const):
+        (WTF::Poisoned::poison):
+        (WTF::Poisoned::unpoison):
+        (WTF::PoisonedPtrTraits::swap):
+        (WTF::PoisonedValueTraits::swap):
+        (WTF::PoisonedPtrTraits::poison): Deleted.
+        (WTF::PoisonedValueTraits::poison): Deleted.
+        * wtf/PoisonedUniquePtr.h:
+        * wtf/Ref.h:
+        * wtf/RefCountedArray.h:
+        * wtf/RefPtr.h:
+        * wtf/WTFAssertions.cpp:
+
 2018-01-23  Alex Christensen  <achristensen@webkit.org>
 
         Remove pre-Sierra-OS-specific code in WTF and JavaScriptCore
index 0ebdd75..feafbaa 100644 (file)
@@ -149,10 +149,10 @@ private:
     typename PtrTraits::StorageType m_head { nullptr };
 };
 
-template<uintptr_t& key, typename T> struct PoisonedPtrTraits;
+template<typename Poison, typename T> struct PoisonedPtrTraits;
 
-template<uintptr_t& key, typename T>
-using PoisonedBag = Bag<T, PoisonedPtrTraits<key, Private::BagNode<T>>>;
+template<typename Poison, typename T>
+using PoisonedBag = Bag<T, PoisonedPtrTraits<Poison, Private::BagNode<T>>>;
 
 } // namespace WTF
 
index 5adeb39..982a368 100644 (file)
@@ -32,8 +32,6 @@ namespace WTF {
     
 template<typename T>
 struct DumbPtrTraits {
-    static uintptr_t poison() { return 0; }
-
     using StorageType = T*;
 
     template<typename U>
index c0d8551..fbc6322 100644 (file)
@@ -32,8 +32,6 @@ namespace WTF {
 
 template<typename T>
 struct DumbValueTraits {
-    static uintptr_t poison() { return 0; }
-
     using StorageType = T;
 
     template<typename U>
index e108e36..d0f99e4 100644 (file)
@@ -68,7 +68,14 @@ asReference(T ptr) { return *ptr; }
 
 enum AlreadyPoisonedTag { AlreadyPoisoned };
 
-template<uintptr_t& key, typename T, typename = std::enable_if_t<std::is_pointer<T>::value>>
+template<uintptr_t& poisonKey>
+class Poison {
+public:
+    template<typename PoisonedType = void>
+    static uintptr_t key(const PoisonedType* = nullptr) { return poisonKey; }
+};
+
+template<typename Poison, typename T, typename = std::enable_if_t<std::is_pointer<T>::value>>
 class Poisoned {
 public:
     static constexpr bool isPoisoned = true;
@@ -166,7 +173,7 @@ public:
         T t2 = other.unpoisoned();
         std::swap(t1, t2);
         m_poisonedBits = poison(t1);
-        other.m_poisonedBits = Other::poison(t2);
+        other.m_poisonedBits = other.poison(t2);
     }
 
     void swap(T& t2)
@@ -185,22 +192,27 @@ public:
     }
 
 private:
-    constexpr static PoisonedBits poison(std::nullptr_t) { return 0; }
+    template<typename U>
+    ALWAYS_INLINE PoisonedBits poison(U ptr) const { return poison<PoisonedBits>(this, bitwise_cast<uintptr_t>(ptr)); }
+    template<typename U = T>
+    ALWAYS_INLINE U unpoison(PoisonedBits poisonedBits) const { return unpoison<U>(this, poisonedBits); }
+
+    constexpr static PoisonedBits poison(const Poisoned*, std::nullptr_t) { return 0; }
 #if ENABLE(POISON)
     template<typename U>
-    ALWAYS_INLINE static PoisonedBits poison(U ptr) { return ptr ? bitwise_cast<PoisonedBits>(ptr) ^ key : 0; }
+    ALWAYS_INLINE static PoisonedBits poison(const Poisoned* thisPoisoned, U ptr) { return ptr ? bitwise_cast<PoisonedBits>(ptr) ^ Poison::key(thisPoisoned) : 0; }
     template<typename U = T>
-    ALWAYS_INLINE static U unpoison(PoisonedBits poisonedBits) { return poisonedBits ? bitwise_cast<U>(poisonedBits ^ key) : bitwise_cast<U>(0ll); }
+    ALWAYS_INLINE static U unpoison(const Poisoned* thisPoisoned, PoisonedBits poisonedBits) { return poisonedBits ? bitwise_cast<U>(poisonedBits ^ Poison::key(thisPoisoned)) : bitwise_cast<U>(0ll); }
 #else
     template<typename U>
-    ALWAYS_INLINE static PoisonedBits poison(U ptr) { return bitwise_cast<PoisonedBits>(ptr); }
+    ALWAYS_INLINE static PoisonedBits poison(const Poisoned*, U ptr) { return bitwise_cast<PoisonedBits>(ptr); }
     template<typename U = T>
-    ALWAYS_INLINE static U unpoison(PoisonedBits poisonedBits) { return bitwise_cast<U>(poisonedBits); }
+    ALWAYS_INLINE static U unpoison(const Poisoned*, PoisonedBits poisonedBits) { return bitwise_cast<U>(poisonedBits); }
 #endif
 
     PoisonedBits m_poisonedBits { 0 };
 
-    template<uintptr_t&, typename, typename> friend class Poisoned;
+    template<typename, typename, typename> friend class Poisoned;
 };
 
 template<typename T, typename U, typename = std::enable_if_t<T::isPoisoned && U::isPoisoned && !std::is_same<T, U>::value>>
@@ -229,30 +241,26 @@ inline void swap(T& a, U& b)
 
 WTF_EXPORT_PRIVATE uintptr_t makePoison();
 
-template<uintptr_t& key, typename T>
+template<typename Poison, typename T>
 struct PoisonedPtrTraits {
-    static auto poison() { return key; }
-
-    using StorageType = Poisoned<key, T*>;
+    using StorageType = Poisoned<Poison, T*>;
 
     template<class U> static ALWAYS_INLINE T* exchange(StorageType& ptr, U&& newValue) { return ptr.exchange(newValue); }
 
     template<typename Other>
-    static ALWAYS_INLINE void swap(Poisoned<key, T*>& a, Other& b) { a.swap(b); }
+    static ALWAYS_INLINE void swap(Poisoned<Poison, T*>& a, Other& b) { a.swap(b); }
 
     static ALWAYS_INLINE T* unwrap(const StorageType& ptr) { return ptr.unpoisoned(); }
 };
 
-template<uintptr_t& key, typename T>
+template<typename Poison, typename T>
 struct PoisonedValueTraits {
-    static auto poison() { return key; }
-
-    using StorageType = Poisoned<key, T>;
+    using StorageType = Poisoned<Poison, T>;
 
     template<class U> static ALWAYS_INLINE T exchange(StorageType& val, U&& newValue) { return val.exchange(newValue); }
 
     template<typename Other>
-    static ALWAYS_INLINE void swap(Poisoned<key, T>& a, Other& b) { a.swap(b); }
+    static ALWAYS_INLINE void swap(Poisoned<Poison, T>& a, Other& b) { a.swap(b); }
 
     static ALWAYS_INLINE T unwrap(const StorageType& val) { return val.unpoisoned(); }
 };
@@ -260,6 +268,9 @@ struct PoisonedValueTraits {
 } // namespace WTF
 
 using WTF::AlreadyPoisoned;
+using WTF::Poison;
 using WTF::Poisoned;
 using WTF::PoisonedBits;
+using WTF::PoisonedPtrTraits;
+using WTF::PoisonedValueTraits;
 using WTF::makePoison;
index a891e22..2683bc6 100644 (file)
 
 namespace WTF {
 
-template<uintptr_t& key, typename T, typename Enable = void>
-class PoisonedUniquePtr : public Poisoned<key, T*> {
+template<typename Poison, typename T, typename Enable = void>
+class PoisonedUniquePtr : public Poisoned<Poison, T*> {
     WTF_MAKE_FAST_ALLOCATED;
-    using Base = Poisoned<key, T*>;
+    using Base = Poisoned<Poison, T*>;
 public:
     static constexpr bool isPoisonedUniquePtr = true;
     using ValueType = T;
@@ -125,13 +125,13 @@ private:
 
     void clearWithoutDestroy() { Base::clear(); }
 
-    template<uintptr_t&, typename, typename> friend class PoisonedUniquePtr;
+    template<typename, typename, typename> friend class PoisonedUniquePtr;
 };
 
-template<uintptr_t& key, typename T>
-class PoisonedUniquePtr<key, T[]> : public Poisoned<key, T*> {
+template<typename Poison, typename T>
+class PoisonedUniquePtr<Poison, T[]> : public Poisoned<Poison, T*> {
     WTF_MAKE_FAST_ALLOCATED;
-    using Base = Poisoned<key, T*>;
+    using Base = Poisoned<Poison, T*>;
 public:
     static constexpr bool isPoisonedUniquePtr = true;
     using ValueType = T[];
@@ -211,7 +211,7 @@ private:
 
     void clearWithoutDestroy() { Base::clear(); }
 
-    template<uintptr_t&, typename, typename> friend class PoisonedUniquePtr;
+    template<typename, typename, typename> friend class PoisonedUniquePtr;
 };
 
 } // namespace WTF
index 96805d0..2ed4d28 100644 (file)
@@ -256,10 +256,10 @@ inline bool is(const Ref<ArgType, PtrTraits>& source)
     return is<ExpectedType>(source.get());
 }
 
-template<uintptr_t& key, typename T> struct PoisonedPtrTraits;
+template<typename Poison, typename T> struct PoisonedPtrTraits;
 
-template<uintptr_t& key, typename T>
-using PoisonedRef = Ref<T, PoisonedPtrTraits<key, T>>;
+template<typename Poison, typename T>
+using PoisonedRef = Ref<T, PoisonedPtrTraits<Poison, T>>;
 
 } // namespace WTF
 
index 22319e6..6132f53 100644 (file)
@@ -238,10 +238,10 @@ private:
     typename PtrTraits::StorageType m_data { nullptr };
 };
 
-template<uintptr_t& key, typename T> struct PoisonedPtrTraits;
+template<typename Poison, typename T> struct PoisonedPtrTraits;
 
-template<uintptr_t& key, typename T>
-using PoisonedRefCountedArray = RefCountedArray<T, PoisonedPtrTraits<key, T>>;
+template<typename Poison, typename T>
+using PoisonedRefCountedArray = RefCountedArray<T, PoisonedPtrTraits<Poison, T>>;
 
 } // namespace WTF
 
index 2095ab3..6365f64 100644 (file)
@@ -276,10 +276,10 @@ inline bool is(const RefPtr<ArgType, PtrTraits>& source)
     return is<ExpectedType>(source.get());
 }
 
-template<uintptr_t& key, typename T> struct PoisonedPtrTraits;
+template<typename Poison, typename T> struct PoisonedPtrTraits;
 
-template<uintptr_t& key, typename T>
-using PoisonedRefPtr = RefPtr<T, PoisonedPtrTraits<key, T>>;
+template<typename Poison, typename T>
+using PoisonedRefPtr = RefPtr<T, PoisonedPtrTraits<Poison, T>>;
 
 } // namespace WTF
 
index f6af471..9870764 100644 (file)
@@ -39,20 +39,20 @@ uintptr_t dummyPoison = 0;
 }
 
 static_assert(sizeof(Bag<DummyStruct>) == sizeof(void*), "");
-static_assert(sizeof(PoisonedBag<dummyPoison, DummyStruct>) == sizeof(void*), "");
+static_assert(sizeof(PoisonedBag<Poison<dummyPoison>, DummyStruct>) == sizeof(void*), "");
 
 static_assert(sizeof(Ref<DummyStruct>) == sizeof(DummyStruct*), "");
-static_assert(sizeof(PoisonedRef<dummyPoison, DummyStruct>) == sizeof(DummyStruct*), "");
+static_assert(sizeof(PoisonedRef<Poison<dummyPoison>, DummyStruct>) == sizeof(DummyStruct*), "");
 
 static_assert(sizeof(RefPtr<DummyStruct>) == sizeof(DummyStruct*), "");
-static_assert(sizeof(PoisonedRefPtr<dummyPoison, DummyStruct>) == sizeof(DummyStruct*), "");
+static_assert(sizeof(PoisonedRefPtr<Poison<dummyPoison>, DummyStruct>) == sizeof(DummyStruct*), "");
 
-static_assert(sizeof(PoisonedUniquePtr<dummyPoison, DummyStruct>) == sizeof(DummyStruct*), "");
-static_assert(sizeof(PoisonedUniquePtr<dummyPoison, int[]>) == sizeof(int*), "");
-static_assert(sizeof(PoisonedUniquePtr<dummyPoison, DummyStruct[]>) == sizeof(DummyStruct*), "");
+static_assert(sizeof(PoisonedUniquePtr<Poison<dummyPoison>, DummyStruct>) == sizeof(DummyStruct*), "");
+static_assert(sizeof(PoisonedUniquePtr<Poison<dummyPoison>, int[]>) == sizeof(int*), "");
+static_assert(sizeof(PoisonedUniquePtr<Poison<dummyPoison>, DummyStruct[]>) == sizeof(DummyStruct*), "");
 
 static_assert(sizeof(RefCountedArray<DummyStruct>) == sizeof(void*), "");
-static_assert(sizeof(PoisonedRefCountedArray<dummyPoison, DummyStruct>) == sizeof(void*), "");
+static_assert(sizeof(PoisonedRefCountedArray<Poison<dummyPoison>, DummyStruct>) == sizeof(void*), "");
     
 } // namespace WTF
 
index 34a4156..aef625c 100644 (file)
@@ -1,3 +1,27 @@
+2018-01-23  Mark Lam  <mark.lam@apple.com>
+
+        Update Poisoned pointers to take a Poison class instead of a uintptr_t&.
+        https://bugs.webkit.org/show_bug.cgi?id=182017
+        <rdar://problem/36795513>
+
+        Reviewed by Filip Pizlo and JF Bastien.
+
+        * TestWebKitAPI/Tests/WTF/Poisoned.cpp:
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WTF/PoisonedRef.cpp:
+        (TestWebKitAPI::TEST):
+        (TestWebKitAPI::passWithRef):
+        * TestWebKitAPI/Tests/WTF/PoisonedRefPtr.cpp:
+        (TestWebKitAPI::TEST):
+        (TestWebKitAPI::f1):
+        * TestWebKitAPI/Tests/WTF/PoisonedUniquePtr.cpp:
+        (TestWebKitAPI::TEST):
+        (TestWebKitAPI::poisonedPtrFoo):
+        * TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForNonTriviallyDestructibleArrays.cpp:
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForTriviallyDestructibleArrays.cpp:
+        (TestWebKitAPI::TEST):
+
 2018-01-18  Sergio Villar Senin  <svillar@igalia.com>
 
         [WebVR] Add OpenVR to the tree and to the build
index 10b0898..ac8c72f 100644 (file)
@@ -36,6 +36,9 @@ namespace {
 uintptr_t g_testPoisonA;
 uintptr_t g_testPoisonB;
 
+using TestPoisonA = Poison<g_testPoisonA>;
+using TestPoisonB = Poison<g_testPoisonB>;
+
 static void initializeTestPoison()
 {
     static std::once_flag initializeOnceFlag;
@@ -58,17 +61,17 @@ TEST(WTF_Poisoned, Basic)
     DerivedRefLogger a("a");
 
     {
-        Poisoned<g_testPoisonA, RefLogger*> empty;
+        Poisoned<TestPoisonA, RefLogger*> empty;
         ASSERT_EQ(nullptr, empty.unpoisoned());
     }
 
     {
-        Poisoned<g_testPoisonA, RefLogger*> empty(nullptr);
+        Poisoned<TestPoisonA, RefLogger*> empty(nullptr);
         ASSERT_EQ(nullptr, empty.unpoisoned());
     }
 
     {
-        Poisoned<g_testPoisonA, RefLogger*> ptr(&a);
+        Poisoned<TestPoisonA, RefLogger*> ptr(&a);
         ASSERT_EQ(&a, ptr.unpoisoned());
         ASSERT_EQ(&a, &*ptr);
         ASSERT_EQ(&a.name, &ptr->name);
@@ -78,55 +81,55 @@ TEST(WTF_Poisoned, Basic)
         std::memcpy(&ptrBits, &ptr, sizeof(ptrBits));
         ASSERT_TRUE(ptrBits != bitwise_cast<uintptr_t>(&a));
 #if ENABLE(POISON_ASSERTS)
-        ASSERT_TRUE((Poisoned<g_testPoisonA, RefLogger*>::isPoisoned(ptrBits)));
+        ASSERT_TRUE((Poisoned<TestPoisonA, RefLogger*>::isPoisoned(ptrBits)));
 #endif
 #endif // ENABLE(POISON)
     }
 
     {
-        Poisoned<g_testPoisonA, RefLogger*> ptr = &a;
+        Poisoned<TestPoisonA, RefLogger*> ptr = &a;
         ASSERT_EQ(&a, ptr.unpoisoned());
     }
 
     {
-        Poisoned<g_testPoisonA, RefLogger*> p1 = &a;
-        Poisoned<g_testPoisonA, RefLogger*> p2(p1);
+        Poisoned<TestPoisonA, RefLogger*> p1 = &a;
+        Poisoned<TestPoisonA, RefLogger*> p2(p1);
 
         ASSERT_EQ(&a, p1.unpoisoned());
         ASSERT_EQ(&a, p2.unpoisoned());
         ASSERT_TRUE(p1 == p2);
         ASSERT_TRUE(p1.bits() == p2.bits());
 
-        Poisoned<g_testPoisonB, RefLogger*> p3(p1);
+        Poisoned<TestPoisonB, RefLogger*> p3(p1);
         ASSERT_EQ(&a, p3.unpoisoned());
         ASSERT_TRUE(p1 == p3);
         ASSERT_TRUE(p1.bits() != p3.bits());
     }
 
     {
-        Poisoned<g_testPoisonA, RefLogger*> p1 = &a;
-        Poisoned<g_testPoisonA, RefLogger*> p2 = p1;
+        Poisoned<TestPoisonA, RefLogger*> p1 = &a;
+        Poisoned<TestPoisonA, RefLogger*> p2 = p1;
         ASSERT_EQ(&a, p1.unpoisoned());
         ASSERT_EQ(&a, p2.unpoisoned());
         ASSERT_TRUE(p1 == p2);
         ASSERT_TRUE(p1.bits() == p2.bits());
 
-        Poisoned<g_testPoisonB, RefLogger*> p3 = p1;
+        Poisoned<TestPoisonB, RefLogger*> p3 = p1;
         ASSERT_EQ(&a, p3.unpoisoned());
         ASSERT_TRUE(p1 == p3);
         ASSERT_TRUE(p1.bits() != p3.bits());
     }
 
     {
-        Poisoned<g_testPoisonA, RefLogger*> p1 = &a;
-        Poisoned<g_testPoisonA, RefLogger*> p2 = WTFMove(p1);
+        Poisoned<TestPoisonA, RefLogger*> p1 = &a;
+        Poisoned<TestPoisonA, RefLogger*> p2 = WTFMove(p1);
         ASSERT_EQ(&a, p1.unpoisoned());
         ASSERT_EQ(&a, p2.unpoisoned());
         ASSERT_TRUE(p1 == p2);
         ASSERT_TRUE(p1.bits() == p2.bits());
 
-        Poisoned<g_testPoisonA, RefLogger*> p3 = &a;
-        Poisoned<g_testPoisonB, RefLogger*> p4 = WTFMove(p3);
+        Poisoned<TestPoisonA, RefLogger*> p3 = &a;
+        Poisoned<TestPoisonB, RefLogger*> p4 = WTFMove(p3);
         ASSERT_EQ(&a, p3.unpoisoned());
         ASSERT_EQ(&a, p4.unpoisoned());
         ASSERT_TRUE(p3 == p4);
@@ -134,15 +137,15 @@ TEST(WTF_Poisoned, Basic)
     }
 
     {
-        Poisoned<g_testPoisonA, RefLogger*> p1 = &a;
-        Poisoned<g_testPoisonA, RefLogger*> p2(WTFMove(p1));
+        Poisoned<TestPoisonA, RefLogger*> p1 = &a;
+        Poisoned<TestPoisonA, RefLogger*> p2(WTFMove(p1));
         ASSERT_EQ(&a, p1.unpoisoned());
         ASSERT_EQ(&a, p2.unpoisoned());
         ASSERT_TRUE(p1 == p2);
         ASSERT_TRUE(p1.bits() == p2.bits());
 
-        Poisoned<g_testPoisonA, RefLogger*> p3 = &a;
-        Poisoned<g_testPoisonB, RefLogger*> p4(WTFMove(p3));
+        Poisoned<TestPoisonA, RefLogger*> p3 = &a;
+        Poisoned<TestPoisonB, RefLogger*> p4(WTFMove(p3));
         ASSERT_EQ(&a, p3.unpoisoned());
         ASSERT_EQ(&a, p4.unpoisoned());
         ASSERT_TRUE(p3 == p4);
@@ -150,15 +153,15 @@ TEST(WTF_Poisoned, Basic)
     }
 
     {
-        Poisoned<g_testPoisonA, DerivedRefLogger*> p1 = &a;
-        Poisoned<g_testPoisonA, RefLogger*> p2 = p1;
+        Poisoned<TestPoisonA, DerivedRefLogger*> p1 = &a;
+        Poisoned<TestPoisonA, RefLogger*> p2 = p1;
         ASSERT_EQ(&a, p1.unpoisoned());
         ASSERT_EQ(&a, p2.unpoisoned());
         ASSERT_TRUE(p1 == p2);
         ASSERT_TRUE(p2 == p1);
         ASSERT_TRUE(p1.bits() == p2.bits());
 
-        Poisoned<g_testPoisonB, RefLogger*> p3 = p1;
+        Poisoned<TestPoisonB, RefLogger*> p3 = p1;
         ASSERT_EQ(&a, p3.unpoisoned());
         ASSERT_TRUE(p1 == p3);
         ASSERT_TRUE(p3 == p1);
@@ -166,16 +169,16 @@ TEST(WTF_Poisoned, Basic)
     }
 
     {
-        Poisoned<g_testPoisonA, DerivedRefLogger*> p1 = &a;
-        Poisoned<g_testPoisonA, RefLogger*> p2 = WTFMove(p1);
+        Poisoned<TestPoisonA, DerivedRefLogger*> p1 = &a;
+        Poisoned<TestPoisonA, RefLogger*> p2 = WTFMove(p1);
         ASSERT_EQ(&a, p1.unpoisoned());
         ASSERT_EQ(&a, p2.unpoisoned());
         ASSERT_TRUE(p1 == p2);
         ASSERT_TRUE(p2 == p1);
         ASSERT_TRUE(p1.bits() == p2.bits());
 
-        Poisoned<g_testPoisonA, DerivedRefLogger*> p3 = &a;
-        Poisoned<g_testPoisonB, RefLogger*> p4 = WTFMove(p3);
+        Poisoned<TestPoisonA, DerivedRefLogger*> p3 = &a;
+        Poisoned<TestPoisonB, RefLogger*> p4 = WTFMove(p3);
         ASSERT_EQ(&a, p3.unpoisoned());
         ASSERT_EQ(&a, p4.unpoisoned());
         ASSERT_TRUE(p3 == p4);
@@ -184,21 +187,21 @@ TEST(WTF_Poisoned, Basic)
     }
 
     {
-        Poisoned<g_testPoisonA, RefLogger*> ptr(&a);
+        Poisoned<TestPoisonA, RefLogger*> ptr(&a);
         ASSERT_EQ(&a, ptr.unpoisoned());
         ptr.clear();
         ASSERT_EQ(nullptr, ptr.unpoisoned());
     }
 
     {
-        Poisoned<g_testPoisonA, RefLogger*> pA1000a = reinterpret_cast<RefLogger*>(0x1000);
-        Poisoned<g_testPoisonB, RefLogger*> pB2000a = reinterpret_cast<RefLogger*>(0x2000);
+        Poisoned<TestPoisonA, RefLogger*> pA1000a = reinterpret_cast<RefLogger*>(0x1000);
+        Poisoned<TestPoisonB, RefLogger*> pB2000a = reinterpret_cast<RefLogger*>(0x2000);
 
-        Poisoned<g_testPoisonA, RefLogger*> pA1000b = reinterpret_cast<RefLogger*>(0x1000);
-        Poisoned<g_testPoisonA, RefLogger*> pA2000b = reinterpret_cast<RefLogger*>(0x2000);
+        Poisoned<TestPoisonA, RefLogger*> pA1000b = reinterpret_cast<RefLogger*>(0x1000);
+        Poisoned<TestPoisonA, RefLogger*> pA2000b = reinterpret_cast<RefLogger*>(0x2000);
 
-        Poisoned<g_testPoisonB, RefLogger*> pB1000c = reinterpret_cast<RefLogger*>(0x1000);
-        Poisoned<g_testPoisonB, RefLogger*> pB2000c = reinterpret_cast<RefLogger*>(0x2000);
+        Poisoned<TestPoisonB, RefLogger*> pB1000c = reinterpret_cast<RefLogger*>(0x1000);
+        Poisoned<TestPoisonB, RefLogger*> pB2000c = reinterpret_cast<RefLogger*>(0x2000);
 
 
         ASSERT_EQ(pA1000a == pA1000a, true);
@@ -263,15 +266,15 @@ TEST(WTF_Poisoned, Basic)
     }
 
     {
-        Poisoned<g_testPoisonA, RefLogger*> prA1000 = reinterpret_cast<DerivedRefLogger*>(0x1000);
-        Poisoned<g_testPoisonA, DerivedRefLogger*> pdA1000 = reinterpret_cast<DerivedRefLogger*>(0x1000);
-        Poisoned<g_testPoisonB, RefLogger*> prB1000 = reinterpret_cast<DerivedRefLogger*>(0x1000);
-        Poisoned<g_testPoisonB, DerivedRefLogger*> pdB1000 = reinterpret_cast<DerivedRefLogger*>(0x1000);
+        Poisoned<TestPoisonA, RefLogger*> prA1000 = reinterpret_cast<DerivedRefLogger*>(0x1000);
+        Poisoned<TestPoisonA, DerivedRefLogger*> pdA1000 = reinterpret_cast<DerivedRefLogger*>(0x1000);
+        Poisoned<TestPoisonB, RefLogger*> prB1000 = reinterpret_cast<DerivedRefLogger*>(0x1000);
+        Poisoned<TestPoisonB, DerivedRefLogger*> pdB1000 = reinterpret_cast<DerivedRefLogger*>(0x1000);
 
-        Poisoned<g_testPoisonA, RefLogger*> prA2000 = reinterpret_cast<DerivedRefLogger*>(0x2000);
-        Poisoned<g_testPoisonA, DerivedRefLogger*> pdA2000 = reinterpret_cast<DerivedRefLogger*>(0x2000);
-        Poisoned<g_testPoisonB, RefLogger*> prB2000 = reinterpret_cast<DerivedRefLogger*>(0x2000);
-        Poisoned<g_testPoisonB, DerivedRefLogger*> pdB2000 = reinterpret_cast<DerivedRefLogger*>(0x2000);
+        Poisoned<TestPoisonA, RefLogger*> prA2000 = reinterpret_cast<DerivedRefLogger*>(0x2000);
+        Poisoned<TestPoisonA, DerivedRefLogger*> pdA2000 = reinterpret_cast<DerivedRefLogger*>(0x2000);
+        Poisoned<TestPoisonB, RefLogger*> prB2000 = reinterpret_cast<DerivedRefLogger*>(0x2000);
+        Poisoned<TestPoisonB, DerivedRefLogger*> pdB2000 = reinterpret_cast<DerivedRefLogger*>(0x2000);
 
         ASSERT_EQ(prA1000 == pdA1000, true);
         ASSERT_EQ(prA1000 == pdB1000, true);
@@ -373,8 +376,8 @@ TEST(WTF_Poisoned, Assignment)
     DerivedRefLogger c("c");
 
     {
-        Poisoned<g_testPoisonA, RefLogger*> p1(&a);
-        Poisoned<g_testPoisonA, RefLogger*> p2(&b);
+        Poisoned<TestPoisonA, RefLogger*> p1(&a);
+        Poisoned<TestPoisonA, RefLogger*> p2(&b);
         ASSERT_EQ(&a, p1.unpoisoned());
         ASSERT_EQ(&b, p2.unpoisoned());
         p1 = p2;
@@ -382,8 +385,8 @@ TEST(WTF_Poisoned, Assignment)
         ASSERT_EQ(&b, p2.unpoisoned());
         ASSERT_TRUE(p1.bits() == p2.bits());
 
-        Poisoned<g_testPoisonA, RefLogger*> p3(&a);
-        Poisoned<g_testPoisonB, RefLogger*> p4(&b);
+        Poisoned<TestPoisonA, RefLogger*> p3(&a);
+        Poisoned<TestPoisonB, RefLogger*> p4(&b);
         ASSERT_EQ(&a, p3.unpoisoned());
         ASSERT_EQ(&b, p4.unpoisoned());
         p3 = p4;
@@ -393,22 +396,22 @@ TEST(WTF_Poisoned, Assignment)
     }
 
     {
-        Poisoned<g_testPoisonA, RefLogger*> ptr(&a);
+        Poisoned<TestPoisonA, RefLogger*> ptr(&a);
         ASSERT_EQ(&a, ptr.unpoisoned());
         ptr = &b;
         ASSERT_EQ(&b, ptr.unpoisoned());
     }
 
     {
-        Poisoned<g_testPoisonA, RefLogger*> ptr(&a);
+        Poisoned<TestPoisonA, RefLogger*> ptr(&a);
         ASSERT_EQ(&a, ptr.unpoisoned());
         ptr = nullptr;
         ASSERT_EQ(nullptr, ptr.unpoisoned());
     }
 
     {
-        Poisoned<g_testPoisonA, RefLogger*> p1(&a);
-        Poisoned<g_testPoisonA, RefLogger*> p2(&b);
+        Poisoned<TestPoisonA, RefLogger*> p1(&a);
+        Poisoned<TestPoisonA, RefLogger*> p2(&b);
         ASSERT_EQ(&a, p1.unpoisoned());
         ASSERT_EQ(&b, p2.unpoisoned());
         p1 = WTFMove(p2);
@@ -416,8 +419,8 @@ TEST(WTF_Poisoned, Assignment)
         ASSERT_EQ(&b, p2.unpoisoned());
         ASSERT_TRUE(p1.bits() == p2.bits());
 
-        Poisoned<g_testPoisonA, RefLogger*> p3(&a);
-        Poisoned<g_testPoisonB, RefLogger*> p4(&b);
+        Poisoned<TestPoisonA, RefLogger*> p3(&a);
+        Poisoned<TestPoisonB, RefLogger*> p4(&b);
         ASSERT_EQ(&a, p3.unpoisoned());
         ASSERT_EQ(&b, p4.unpoisoned());
         p3 = WTFMove(p4);
@@ -427,8 +430,8 @@ TEST(WTF_Poisoned, Assignment)
     }
 
     {
-        Poisoned<g_testPoisonA, RefLogger*> p1(&a);
-        Poisoned<g_testPoisonA, DerivedRefLogger*> p2(&c);
+        Poisoned<TestPoisonA, RefLogger*> p1(&a);
+        Poisoned<TestPoisonA, DerivedRefLogger*> p2(&c);
         ASSERT_EQ(&a, p1.unpoisoned());
         ASSERT_EQ(&c, p2.unpoisoned());
         p1 = p2;
@@ -436,8 +439,8 @@ TEST(WTF_Poisoned, Assignment)
         ASSERT_EQ(&c, p2.unpoisoned());
         ASSERT_TRUE(p1.bits() == p2.bits());
 
-        Poisoned<g_testPoisonA, RefLogger*> p3(&a);
-        Poisoned<g_testPoisonB, DerivedRefLogger*> p4(&c);
+        Poisoned<TestPoisonA, RefLogger*> p3(&a);
+        Poisoned<TestPoisonB, DerivedRefLogger*> p4(&c);
         ASSERT_EQ(&a, p3.unpoisoned());
         ASSERT_EQ(&c, p4.unpoisoned());
         p3 = p4;
@@ -447,15 +450,15 @@ TEST(WTF_Poisoned, Assignment)
     }
 
     {
-        Poisoned<g_testPoisonA, RefLogger*> ptr(&a);
+        Poisoned<TestPoisonA, RefLogger*> ptr(&a);
         ASSERT_EQ(&a, ptr.unpoisoned());
         ptr = &c;
         ASSERT_EQ(&c, ptr.unpoisoned());
     }
 
     {
-        Poisoned<g_testPoisonA, RefLogger*> p1(&a);
-        Poisoned<g_testPoisonA, DerivedRefLogger*> p2(&c);
+        Poisoned<TestPoisonA, RefLogger*> p1(&a);
+        Poisoned<TestPoisonA, DerivedRefLogger*> p2(&c);
         ASSERT_EQ(&a, p1.unpoisoned());
         ASSERT_EQ(&c, p2.unpoisoned());
         p1 = WTFMove(p2);
@@ -463,8 +466,8 @@ TEST(WTF_Poisoned, Assignment)
         ASSERT_EQ(&c, p2.unpoisoned());
         ASSERT_TRUE(p1.bits() == p2.bits());
 
-        Poisoned<g_testPoisonA, RefLogger*> p3(&a);
-        Poisoned<g_testPoisonB, DerivedRefLogger*> p4(&c);
+        Poisoned<TestPoisonA, RefLogger*> p3(&a);
+        Poisoned<TestPoisonB, DerivedRefLogger*> p4(&c);
         ASSERT_EQ(&a, p3.unpoisoned());
         ASSERT_EQ(&c, p4.unpoisoned());
         p3 = WTFMove(p4);
@@ -474,14 +477,14 @@ TEST(WTF_Poisoned, Assignment)
     }
 
     {
-        Poisoned<g_testPoisonA, RefLogger*> ptr(&a);
+        Poisoned<TestPoisonA, RefLogger*> ptr(&a);
         ASSERT_EQ(&a, ptr.unpoisoned());
         ptr = ptr;
         ASSERT_EQ(&a, ptr.unpoisoned());
     }
 
     {
-        Poisoned<g_testPoisonA, RefLogger*> ptr(&a);
+        Poisoned<TestPoisonA, RefLogger*> ptr(&a);
         ASSERT_EQ(&a, ptr.unpoisoned());
 #if COMPILER(CLANG)
 #pragma clang diagnostic push
@@ -503,8 +506,8 @@ TEST(WTF_Poisoned, Swap)
     RefLogger b("b");
 
     {
-        Poisoned<g_testPoisonA, RefLogger*> p1(&a);
-        Poisoned<g_testPoisonA, RefLogger*> p2(&b);
+        Poisoned<TestPoisonA, RefLogger*> p1(&a);
+        Poisoned<TestPoisonA, RefLogger*> p2(&b);
         ASSERT_EQ(&a, p1.unpoisoned());
         ASSERT_EQ(&b, p2.unpoisoned());
         p1.swap(p2);
@@ -513,8 +516,8 @@ TEST(WTF_Poisoned, Swap)
 
         ASSERT_TRUE(p1.bits() != p2.bits());
 
-        Poisoned<g_testPoisonA, RefLogger*> p3(&a);
-        Poisoned<g_testPoisonB, RefLogger*> p4(&b);
+        Poisoned<TestPoisonA, RefLogger*> p3(&a);
+        Poisoned<TestPoisonB, RefLogger*> p4(&b);
         ASSERT_EQ(&a, p3.unpoisoned());
         ASSERT_EQ(&b, p4.unpoisoned());
         p3.swap(p4);
@@ -527,8 +530,8 @@ TEST(WTF_Poisoned, Swap)
     }
 
     {
-        Poisoned<g_testPoisonA, RefLogger*> p1(&a);
-        Poisoned<g_testPoisonA, RefLogger*> p2(&b);
+        Poisoned<TestPoisonA, RefLogger*> p1(&a);
+        Poisoned<TestPoisonA, RefLogger*> p2(&b);
         ASSERT_EQ(&a, p1.unpoisoned());
         ASSERT_EQ(&b, p2.unpoisoned());
         swap(p1, p2);
@@ -537,8 +540,8 @@ TEST(WTF_Poisoned, Swap)
 
         ASSERT_TRUE(p1.bits() != p2.bits());
 
-        Poisoned<g_testPoisonA, RefLogger*> p3(&a);
-        Poisoned<g_testPoisonB, RefLogger*> p4(&b);
+        Poisoned<TestPoisonA, RefLogger*> p3(&a);
+        Poisoned<TestPoisonB, RefLogger*> p4(&b);
         ASSERT_EQ(&a, p3.unpoisoned());
         ASSERT_EQ(&b, p4.unpoisoned());
         swap(p3, p4);
@@ -551,7 +554,7 @@ TEST(WTF_Poisoned, Swap)
     }
 
     {
-        Poisoned<g_testPoisonA, RefLogger*> p1(&a);
+        Poisoned<TestPoisonA, RefLogger*> p1(&a);
         RefLogger* p2(&b);
         ASSERT_EQ(&a, p1.unpoisoned());
         ASSERT_EQ(&b, p2);
@@ -563,7 +566,7 @@ TEST(WTF_Poisoned, Swap)
     }
 
     {
-        Poisoned<g_testPoisonA, RefLogger*> p1(&a);
+        Poisoned<TestPoisonA, RefLogger*> p1(&a);
         RefLogger* p2(&b);
         ASSERT_EQ(&a, p1.unpoisoned());
         ASSERT_EQ(&b, p2);
@@ -575,9 +578,9 @@ TEST(WTF_Poisoned, Swap)
     }
 }
 
-static Poisoned<g_testPoisonA, RefLogger*> poisonedPtrFoo(RefLogger& logger)
+static Poisoned<TestPoisonA, RefLogger*> poisonedPtrFoo(RefLogger& logger)
 {
-    return Poisoned<g_testPoisonA, RefLogger*>(&logger);
+    return Poisoned<TestPoisonA, RefLogger*>(&logger);
 }
 
 TEST(WTF_Poisoned, ReturnValue)
index 1d66757..3be228f 100644 (file)
@@ -41,6 +41,13 @@ uintptr_t g_poisonD;
 uintptr_t g_poisonE;
 uintptr_t g_poisonF;
 
+using PoisonA = Poison<g_poisonA>;
+using PoisonB = Poison<g_poisonB>;
+using PoisonC = Poison<g_poisonC>;
+using PoisonD = Poison<g_poisonD>;
+using PoisonE = Poison<g_poisonE>;
+using PoisonF = Poison<g_poisonF>;
+
 static void initializePoisons()
 {
     static std::once_flag initializeOnceFlag;
@@ -63,7 +70,7 @@ TEST(WTF_PoisonedRef, Basic)
     DerivedRefLogger a("a");
 
     {
-        PoisonedRef<g_poisonA, RefLogger> ref(a);
+        PoisonedRef<PoisonA, RefLogger> ref(a);
         EXPECT_EQ(&a, ref.ptr());
         EXPECT_EQ(&a.name, &ref->name);
 
@@ -71,16 +78,16 @@ TEST(WTF_PoisonedRef, Basic)
         uintptr_t ptrBits;
         std::memcpy(&ptrBits, &ref, sizeof(ptrBits));
         ASSERT_TRUE(ptrBits != bitwise_cast<uintptr_t>(&a));
-        ASSERT_EQ(ptrBits, (Poisoned<g_poisonA, RefLogger*>(&a).bits()));
+        ASSERT_EQ(ptrBits, (Poisoned<PoisonA, RefLogger*>(&a).bits()));
 #if ENABLE(POISON_ASSERTS)
-        ASSERT_TRUE((Poisoned<g_poisonA, RefLogger*>::isPoisoned(ptrBits)));
+        ASSERT_TRUE((Poisoned<PoisonA, RefLogger*>::isPoisoned(ptrBits)));
 #endif
 #endif // ENABLE(POISON)
     }
     EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
 
     {
-        PoisonedRef<g_poisonB, RefLogger> ref(adoptRef(a));
+        PoisonedRef<PoisonB, RefLogger> ref(adoptRef(a));
         EXPECT_EQ(&a, ref.ptr());
         EXPECT_EQ(&a.name, &ref->name);
     }
@@ -96,7 +103,7 @@ TEST(WTF_PoisonedRef, Assignment)
     DerivedRefLogger c("c");
 
     {
-        PoisonedRef<g_poisonC, RefLogger> ref(a);
+        PoisonedRef<PoisonC, RefLogger> ref(a);
         EXPECT_EQ(&a, ref.ptr());
         log() << "| ";
         ref = b;
@@ -106,7 +113,7 @@ TEST(WTF_PoisonedRef, Assignment)
     EXPECT_STREQ("ref(a) | ref(b) deref(a) | deref(b) ", takeLogStr().c_str());
 
     {
-        PoisonedRef<g_poisonD, RefLogger> ref(a);
+        PoisonedRef<PoisonD, RefLogger> ref(a);
         EXPECT_EQ(&a, ref.ptr());
         log() << "| ";
         ref = c;
@@ -116,7 +123,7 @@ TEST(WTF_PoisonedRef, Assignment)
     EXPECT_STREQ("ref(a) | ref(c) deref(a) | deref(c) ", takeLogStr().c_str());
 
     {
-        PoisonedRef<g_poisonE, RefLogger> ref(a);
+        PoisonedRef<PoisonE, RefLogger> ref(a);
         EXPECT_EQ(&a, ref.ptr());
         log() << "| ";
         ref = adoptRef(b);
@@ -126,7 +133,7 @@ TEST(WTF_PoisonedRef, Assignment)
     EXPECT_STREQ("ref(a) | deref(a) | deref(b) ", takeLogStr().c_str());
 
     {
-        PoisonedRef<g_poisonF, RefLogger> ref(a);
+        PoisonedRef<PoisonF, RefLogger> ref(a);
         EXPECT_EQ(&a, ref.ptr());
         log() << "| ";
         ref = adoptRef(c);
@@ -136,7 +143,7 @@ TEST(WTF_PoisonedRef, Assignment)
     EXPECT_STREQ("ref(a) | deref(a) | deref(c) ", takeLogStr().c_str());
 }
 
-static PoisonedRef<g_poisonB, RefLogger> passWithRef(PoisonedRef<g_poisonC, RefLogger>&& reference)
+static PoisonedRef<PoisonB, RefLogger> passWithRef(PoisonedRef<PoisonC, RefLogger>&& reference)
 {
     return WTFMove(reference);
 }
@@ -150,13 +157,13 @@ TEST(WTF_PoisonedRef, ReturnValue)
     DerivedRefLogger c("c");
 
     {
-        PoisonedRef<g_poisonB, RefLogger> ref(passWithRef(PoisonedRef<g_poisonC, RefLogger>(a)));
+        PoisonedRef<PoisonB, RefLogger> ref(passWithRef(PoisonedRef<PoisonC, RefLogger>(a)));
         EXPECT_EQ(&a, ref.ptr());
     }
     EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
 
     {
-        PoisonedRef<g_poisonD, RefLogger> ref(a);
+        PoisonedRef<PoisonD, RefLogger> ref(a);
         EXPECT_EQ(&a, ref.ptr());
         log() << "| ";
         ref = passWithRef(b);
@@ -166,22 +173,22 @@ TEST(WTF_PoisonedRef, ReturnValue)
     EXPECT_STREQ("ref(a) | ref(b) deref(a) | deref(b) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonE, RefLogger> ptr(passWithRef(a));
+        PoisonedRefPtr<PoisonE, RefLogger> ptr(passWithRef(a));
         EXPECT_EQ(&a, ptr.get());
     }
     EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonF, DerivedRefLogger> ptr(&a);
-        PoisonedRefPtr<g_poisonA, RefLogger> ptr2(WTFMove(ptr));
+        PoisonedRefPtr<PoisonF, DerivedRefLogger> ptr(&a);
+        PoisonedRefPtr<PoisonA, RefLogger> ptr2(WTFMove(ptr));
         EXPECT_EQ(nullptr, ptr.get());
         EXPECT_EQ(&a, ptr2.get());
     }
     EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
 
     {
-        PoisonedRef<g_poisonB, DerivedRefLogger> derivedReference(a);
-        PoisonedRef<g_poisonC, RefLogger> baseReference(passWithRef(derivedReference.copyRef()));
+        PoisonedRef<PoisonB, DerivedRefLogger> derivedReference(a);
+        PoisonedRef<PoisonC, RefLogger> baseReference(passWithRef(derivedReference.copyRef()));
         EXPECT_EQ(&a, derivedReference.ptr());
         EXPECT_EQ(&a, baseReference.ptr());
     }
@@ -196,8 +203,8 @@ TEST(WTF_PoisonedRef, Swap)
     RefLogger b("b");
 
     {
-        PoisonedRef<g_poisonD, RefLogger> p1(a);
-        PoisonedRef<g_poisonE, RefLogger> p2(b);
+        PoisonedRef<PoisonD, RefLogger> p1(a);
+        PoisonedRef<PoisonE, RefLogger> p2(b);
         log() << "| ";
         EXPECT_EQ(&a, p1.ptr());
         EXPECT_EQ(&b, p2.ptr());
@@ -209,8 +216,8 @@ TEST(WTF_PoisonedRef, Swap)
     EXPECT_STREQ("ref(a) ref(b) | | deref(a) deref(b) ", takeLogStr().c_str());
 
     {
-        PoisonedRef<g_poisonF, RefLogger> p1(a);
-        PoisonedRef<g_poisonA, RefLogger> p2(b);
+        PoisonedRef<PoisonF, RefLogger> p1(a);
+        PoisonedRef<PoisonA, RefLogger> p2(b);
         log() << "| ";
         EXPECT_EQ(&a, p1.ptr());
         EXPECT_EQ(&b, p2.ptr());
@@ -222,7 +229,7 @@ TEST(WTF_PoisonedRef, Swap)
     EXPECT_STREQ("ref(a) ref(b) | | deref(a) deref(b) ", takeLogStr().c_str());
 
     {
-        PoisonedRef<g_poisonF, RefLogger> p1(a);
+        PoisonedRef<PoisonF, RefLogger> p1(a);
         Ref<RefLogger> p2(b);
         log() << "| ";
         EXPECT_EQ(&a, p1.ptr());
@@ -235,7 +242,7 @@ TEST(WTF_PoisonedRef, Swap)
     EXPECT_STREQ("ref(a) ref(b) | | deref(a) deref(b) ", takeLogStr().c_str());
 
     {
-        PoisonedRef<g_poisonF, RefLogger> p1(a);
+        PoisonedRef<PoisonF, RefLogger> p1(a);
         Ref<RefLogger> p2(b);
         log() << "| ";
         EXPECT_EQ(&a, p1.ptr());
@@ -249,7 +256,7 @@ TEST(WTF_PoisonedRef, Swap)
 }
 
 struct PoisonedRefCheckingRefLogger : RefLogger {
-    using Ref = PoisonedRef<g_poisonB, PoisonedRefCheckingRefLogger>;
+    using Ref = PoisonedRef<PoisonB, PoisonedRefCheckingRefLogger>;
 
     PoisonedRefCheckingRefLogger(const char* name);
     void ref();
index 11952db..cee4c67 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -43,6 +43,13 @@ uintptr_t g_poisonD;
 uintptr_t g_poisonE;
 uintptr_t g_poisonF;
 
+using PoisonA = Poison<g_poisonA>;
+using PoisonB = Poison<g_poisonB>;
+using PoisonC = Poison<g_poisonC>;
+using PoisonD = Poison<g_poisonD>;
+using PoisonE = Poison<g_poisonE>;
+using PoisonF = Poison<g_poisonF>;
+
 static void initializePoisons()
 {
     static std::once_flag initializeOnceFlag;
@@ -64,11 +71,11 @@ TEST(WTF_PoisonedRefPtr, Basic)
 
     DerivedRefLogger a("a");
 
-    PoisonedRefPtr<g_poisonA, RefLogger> empty;
+    PoisonedRefPtr<PoisonA, RefLogger> empty;
     EXPECT_EQ(nullptr, empty.get());
 
     {
-        PoisonedRefPtr<g_poisonB, RefLogger> ptr(&a);
+        PoisonedRefPtr<PoisonB, RefLogger> ptr(&a);
         EXPECT_EQ(&a, ptr.get());
         EXPECT_EQ(&a, &*ptr);
         EXPECT_EQ(&a.name, &ptr->name);
@@ -77,70 +84,70 @@ TEST(WTF_PoisonedRefPtr, Basic)
         uintptr_t ptrBits;
         std::memcpy(&ptrBits, &ptr, sizeof(ptrBits));
         ASSERT_TRUE(ptrBits != bitwise_cast<uintptr_t>(&a));
-        ASSERT_EQ(ptrBits, (Poisoned<g_poisonB, RefLogger*>(&a).bits()));
+        ASSERT_EQ(ptrBits, (Poisoned<PoisonB, RefLogger*>(&a).bits()));
 #if ENABLE(POISON_ASSERTS)
-        ASSERT_TRUE((Poisoned<g_poisonB, RefLogger*>::isPoisoned(ptrBits)));
+        ASSERT_TRUE((Poisoned<PoisonB, RefLogger*>::isPoisoned(ptrBits)));
 #endif
 #endif // ENABLE(POISON)
     }
     EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonC, RefLogger> ptr = &a;
+        PoisonedRefPtr<PoisonC, RefLogger> ptr = &a;
         EXPECT_EQ(&a, ptr.get());
     }
     EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonD, RefLogger> p1 = &a;
-        PoisonedRefPtr<g_poisonE, RefLogger> p2(p1);
+        PoisonedRefPtr<PoisonD, RefLogger> p1 = &a;
+        PoisonedRefPtr<PoisonE, RefLogger> p2(p1);
         EXPECT_EQ(&a, p1.get());
         EXPECT_EQ(&a, p2.get());
     }
     EXPECT_STREQ("ref(a) ref(a) deref(a) deref(a) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonF, RefLogger> p1 = &a;
-        PoisonedRefPtr<g_poisonB, RefLogger> p2 = p1;
+        PoisonedRefPtr<PoisonF, RefLogger> p1 = &a;
+        PoisonedRefPtr<PoisonB, RefLogger> p2 = p1;
         EXPECT_EQ(&a, p1.get());
         EXPECT_EQ(&a, p2.get());
     }
     EXPECT_STREQ("ref(a) ref(a) deref(a) deref(a) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonC, RefLogger> p1 = &a;
-        PoisonedRefPtr<g_poisonD, RefLogger> p2 = WTFMove(p1);
+        PoisonedRefPtr<PoisonC, RefLogger> p1 = &a;
+        PoisonedRefPtr<PoisonD, RefLogger> p2 = WTFMove(p1);
         EXPECT_EQ(nullptr, p1.get());
         EXPECT_EQ(&a, p2.get());
     }
     EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonE, RefLogger> p1 = &a;
-        PoisonedRefPtr<g_poisonF, RefLogger> p2(WTFMove(p1));
+        PoisonedRefPtr<PoisonE, RefLogger> p1 = &a;
+        PoisonedRefPtr<PoisonF, RefLogger> p2(WTFMove(p1));
         EXPECT_EQ(nullptr, p1.get());
         EXPECT_EQ(&a, p2.get());
     }
     EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonB, DerivedRefLogger> p1 = &a;
-        PoisonedRefPtr<g_poisonC, RefLogger> p2 = p1;
+        PoisonedRefPtr<PoisonB, DerivedRefLogger> p1 = &a;
+        PoisonedRefPtr<PoisonC, RefLogger> p2 = p1;
         EXPECT_EQ(&a, p1.get());
         EXPECT_EQ(&a, p2.get());
     }
     EXPECT_STREQ("ref(a) ref(a) deref(a) deref(a) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonD, DerivedRefLogger> p1 = &a;
-        PoisonedRefPtr<g_poisonE, RefLogger> p2 = WTFMove(p1);
+        PoisonedRefPtr<PoisonD, DerivedRefLogger> p1 = &a;
+        PoisonedRefPtr<PoisonE, RefLogger> p2 = WTFMove(p1);
         EXPECT_EQ(nullptr, p1.get());
         EXPECT_EQ(&a, p2.get());
     }
     EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonF, RefLogger> ptr(&a);
+        PoisonedRefPtr<PoisonF, RefLogger> ptr(&a);
         EXPECT_EQ(&a, ptr.get());
         ptr = nullptr;
         EXPECT_EQ(nullptr, ptr.get());
@@ -155,7 +162,7 @@ TEST(WTF_PoisonedRefPtr, AssignPassRefToPoisonedRefPtr)
     DerivedRefLogger a("a");
     {
         Ref<RefLogger> passRef(a);
-        PoisonedRefPtr<g_poisonB, RefLogger> ptr = WTFMove(passRef);
+        PoisonedRefPtr<PoisonB, RefLogger> ptr = WTFMove(passRef);
         EXPECT_EQ(&a, ptr.get());
     }
     EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
@@ -167,11 +174,11 @@ TEST(WTF_PoisonedRefPtr, Adopt)
 
     DerivedRefLogger a("a");
 
-    PoisonedRefPtr<g_poisonC, RefLogger> empty;
+    PoisonedRefPtr<PoisonC, RefLogger> empty;
     EXPECT_EQ(nullptr, empty.get());
 
     {
-        PoisonedRefPtr<g_poisonD, RefLogger> ptr(adoptRef(&a));
+        PoisonedRefPtr<PoisonD, RefLogger> ptr(adoptRef(&a));
         EXPECT_EQ(&a, ptr.get());
         EXPECT_EQ(&a, &*ptr);
         EXPECT_EQ(&a.name, &ptr->name);
@@ -179,7 +186,7 @@ TEST(WTF_PoisonedRefPtr, Adopt)
     EXPECT_STREQ("deref(a) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonE, RefLogger> ptr = adoptRef(&a);
+        PoisonedRefPtr<PoisonE, RefLogger> ptr = adoptRef(&a);
         EXPECT_EQ(&a, ptr.get());
     }
     EXPECT_STREQ("deref(a) ", takeLogStr().c_str());
@@ -194,8 +201,8 @@ TEST(WTF_PoisonedRefPtr, Assignment)
     DerivedRefLogger c("c");
 
     {
-        PoisonedRefPtr<g_poisonF, RefLogger> p1(&a);
-        PoisonedRefPtr<g_poisonB, RefLogger> p2(&b);
+        PoisonedRefPtr<PoisonF, RefLogger> p1(&a);
+        PoisonedRefPtr<PoisonB, RefLogger> p2(&b);
         EXPECT_EQ(&a, p1.get());
         EXPECT_EQ(&b, p2.get());
         log() << "| ";
@@ -207,7 +214,7 @@ TEST(WTF_PoisonedRefPtr, Assignment)
     EXPECT_STREQ("ref(a) ref(b) | ref(b) deref(a) | deref(b) deref(b) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonC, RefLogger> ptr(&a);
+        PoisonedRefPtr<PoisonC, RefLogger> ptr(&a);
         EXPECT_EQ(&a, ptr.get());
         log() << "| ";
         ptr = &b;
@@ -217,7 +224,7 @@ TEST(WTF_PoisonedRefPtr, Assignment)
     EXPECT_STREQ("ref(a) | ref(b) deref(a) | deref(b) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonD, RefLogger> ptr(&a);
+        PoisonedRefPtr<PoisonD, RefLogger> ptr(&a);
         EXPECT_EQ(&a, ptr.get());
         log() << "| ";
         ptr = adoptRef(&b);
@@ -227,7 +234,7 @@ TEST(WTF_PoisonedRefPtr, Assignment)
     EXPECT_STREQ("ref(a) | deref(a) | deref(b) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonE, RefLogger> ptr(&a);
+        PoisonedRefPtr<PoisonE, RefLogger> ptr(&a);
         EXPECT_EQ(&a, ptr.get());
         ptr = nullptr;
         EXPECT_EQ(nullptr, ptr.get());
@@ -235,8 +242,8 @@ TEST(WTF_PoisonedRefPtr, Assignment)
     EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonB, RefLogger> p1(&a);
-        PoisonedRefPtr<g_poisonC, RefLogger> p2(&b);
+        PoisonedRefPtr<PoisonB, RefLogger> p1(&a);
+        PoisonedRefPtr<PoisonC, RefLogger> p2(&b);
         EXPECT_EQ(&a, p1.get());
         EXPECT_EQ(&b, p2.get());
         log() << "| ";
@@ -248,8 +255,8 @@ TEST(WTF_PoisonedRefPtr, Assignment)
     EXPECT_STREQ("ref(a) ref(b) | deref(a) | deref(b) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonD, RefLogger> p1(&a);
-        PoisonedRefPtr<g_poisonE, DerivedRefLogger> p2(&c);
+        PoisonedRefPtr<PoisonD, RefLogger> p1(&a);
+        PoisonedRefPtr<PoisonE, DerivedRefLogger> p2(&c);
         EXPECT_EQ(&a, p1.get());
         EXPECT_EQ(&c, p2.get());
         log() << "| ";
@@ -261,7 +268,7 @@ TEST(WTF_PoisonedRefPtr, Assignment)
     EXPECT_STREQ("ref(a) ref(c) | ref(c) deref(a) | deref(c) deref(c) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonF, RefLogger> ptr(&a);
+        PoisonedRefPtr<PoisonF, RefLogger> ptr(&a);
         EXPECT_EQ(&a, ptr.get());
         log() << "| ";
         ptr = &c;
@@ -271,7 +278,7 @@ TEST(WTF_PoisonedRefPtr, Assignment)
     EXPECT_STREQ("ref(a) | ref(c) deref(a) | deref(c) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonB, RefLogger> ptr(&a);
+        PoisonedRefPtr<PoisonB, RefLogger> ptr(&a);
         EXPECT_EQ(&a, ptr.get());
         log() << "| ";
         ptr = adoptRef(&c);
@@ -281,8 +288,8 @@ TEST(WTF_PoisonedRefPtr, Assignment)
     EXPECT_STREQ("ref(a) | deref(a) | deref(c) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonC, RefLogger> p1(&a);
-        PoisonedRefPtr<g_poisonD, DerivedRefLogger> p2(&c);
+        PoisonedRefPtr<PoisonC, RefLogger> p1(&a);
+        PoisonedRefPtr<PoisonD, DerivedRefLogger> p2(&c);
         EXPECT_EQ(&a, p1.get());
         EXPECT_EQ(&c, p2.get());
         log() << "| ";
@@ -294,7 +301,7 @@ TEST(WTF_PoisonedRefPtr, Assignment)
     EXPECT_STREQ("ref(a) ref(c) | deref(a) | deref(c) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonE, RefLogger> ptr(&a);
+        PoisonedRefPtr<PoisonE, RefLogger> ptr(&a);
         EXPECT_EQ(&a, ptr.get());
         log() << "| ";
         ptr = ptr;
@@ -304,7 +311,7 @@ TEST(WTF_PoisonedRefPtr, Assignment)
     EXPECT_STREQ("ref(a) | ref(a) deref(a) | deref(a) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonF, RefLogger> ptr(&a);
+        PoisonedRefPtr<PoisonF, RefLogger> ptr(&a);
         EXPECT_EQ(&a, ptr.get());
 #if COMPILER(CLANG)
 #pragma clang diagnostic push
@@ -328,8 +335,8 @@ TEST(WTF_PoisonedRefPtr, Swap)
     RefLogger b("b");
 
     {
-        PoisonedRefPtr<g_poisonB, RefLogger> p1(&a);
-        PoisonedRefPtr<g_poisonC, RefLogger> p2(&b);
+        PoisonedRefPtr<PoisonB, RefLogger> p1(&a);
+        PoisonedRefPtr<PoisonC, RefLogger> p2(&b);
         log() << "| ";
         EXPECT_EQ(&a, p1.get());
         EXPECT_EQ(&b, p2.get());
@@ -341,8 +348,8 @@ TEST(WTF_PoisonedRefPtr, Swap)
     EXPECT_STREQ("ref(a) ref(b) | | deref(a) deref(b) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonD, RefLogger> p1(&a);
-        PoisonedRefPtr<g_poisonE, RefLogger> p2(&b);
+        PoisonedRefPtr<PoisonD, RefLogger> p1(&a);
+        PoisonedRefPtr<PoisonE, RefLogger> p2(&b);
         log() << "| ";
         EXPECT_EQ(&a, p1.get());
         EXPECT_EQ(&b, p2.get());
@@ -361,8 +368,8 @@ TEST(WTF_PoisonedRefPtr, ReleaseNonNull)
     RefLogger a("a");
 
     {
-        PoisonedRefPtr<g_poisonF, RefLogger> refPtr = &a;
-        PoisonedRefPtr<g_poisonB, RefLogger> ref = refPtr.releaseNonNull();
+        PoisonedRefPtr<PoisonF, RefLogger> refPtr = &a;
+        PoisonedRefPtr<PoisonB, RefLogger> ref = refPtr.releaseNonNull();
     }
 
     EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
@@ -377,32 +384,32 @@ TEST(WTF_PoisonedRefPtr, Release)
     DerivedRefLogger c("c");
 
     {
-        PoisonedRefPtr<g_poisonC, RefLogger> p1 = &a;
-        PoisonedRefPtr<g_poisonD, RefLogger> p2 = WTFMove(p1);
+        PoisonedRefPtr<PoisonC, RefLogger> p1 = &a;
+        PoisonedRefPtr<PoisonD, RefLogger> p2 = WTFMove(p1);
         EXPECT_EQ(nullptr, p1.get());
         EXPECT_EQ(&a, p2.get());
     }
     EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonE, RefLogger> p1 = &a;
-        PoisonedRefPtr<g_poisonF, RefLogger> p2(WTFMove(p1));
+        PoisonedRefPtr<PoisonE, RefLogger> p1 = &a;
+        PoisonedRefPtr<PoisonF, RefLogger> p2(WTFMove(p1));
         EXPECT_EQ(nullptr, p1.get());
         EXPECT_EQ(&a, p2.get());
     }
     EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonB, DerivedRefLogger> p1 = &a;
-        PoisonedRefPtr<g_poisonC, RefLogger> p2 = WTFMove(p1);
+        PoisonedRefPtr<PoisonB, DerivedRefLogger> p1 = &a;
+        PoisonedRefPtr<PoisonC, RefLogger> p2 = WTFMove(p1);
         EXPECT_EQ(nullptr, p1.get());
         EXPECT_EQ(&a, p2.get());
     }
     EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonD, RefLogger> p1(&a);
-        PoisonedRefPtr<g_poisonE, RefLogger> p2(&b);
+        PoisonedRefPtr<PoisonD, RefLogger> p1(&a);
+        PoisonedRefPtr<PoisonE, RefLogger> p2(&b);
         EXPECT_EQ(&a, p1.get());
         EXPECT_EQ(&b, p2.get());
         log() << "| ";
@@ -414,8 +421,8 @@ TEST(WTF_PoisonedRefPtr, Release)
     EXPECT_STREQ("ref(a) ref(b) | deref(a) | deref(b) ", takeLogStr().c_str());
 
     {
-        PoisonedRefPtr<g_poisonF, RefLogger> p1(&a);
-        PoisonedRefPtr<g_poisonB, DerivedRefLogger> p2(&c);
+        PoisonedRefPtr<PoisonF, RefLogger> p1(&a);
+        PoisonedRefPtr<PoisonB, DerivedRefLogger> p2(&c);
         EXPECT_EQ(&a, p1.get());
         EXPECT_EQ(&c, p2.get());
         log() << "| ";
@@ -427,9 +434,9 @@ TEST(WTF_PoisonedRefPtr, Release)
     EXPECT_STREQ("ref(a) ref(c) | deref(a) | deref(c) ", takeLogStr().c_str());
 }
 
-static PoisonedRefPtr<g_poisonC, RefLogger> f1(RefLogger& logger)
+static PoisonedRefPtr<PoisonC, RefLogger> f1(RefLogger& logger)
 {
-    return PoisonedRefPtr<g_poisonC, RefLogger>(&logger);
+    return PoisonedRefPtr<PoisonC, RefLogger>(&logger);
 }
 
 TEST(WTF_PoisonedRefPtr, ReturnValue)
@@ -471,17 +478,17 @@ TEST(WTF_PoisonedRefPtr, Const)
     // This test passes if it compiles without an error.
     auto a = ConstRefCounted::create();
     Ref<const ConstRefCounted> b = WTFMove(a);
-    PoisonedRefPtr<g_poisonD, const ConstRefCounted> c = b.ptr();
+    PoisonedRefPtr<PoisonD, const ConstRefCounted> c = b.ptr();
     Ref<const ConstRefCounted> d = returnConstRefCountedRef();
-    PoisonedRefPtr<g_poisonE, const ConstRefCounted> e = &returnConstRefCountedRef();
-    PoisonedRefPtr<g_poisonF, ConstRefCounted> f = ConstRefCounted::create();
-    PoisonedRefPtr<g_poisonB, const ConstRefCounted> g = f;
-    PoisonedRefPtr<g_poisonC, const ConstRefCounted> h(f);
+    PoisonedRefPtr<PoisonE, const ConstRefCounted> e = &returnConstRefCountedRef();
+    PoisonedRefPtr<PoisonF, ConstRefCounted> f = ConstRefCounted::create();
+    PoisonedRefPtr<PoisonB, const ConstRefCounted> g = f;
+    PoisonedRefPtr<PoisonC, const ConstRefCounted> h(f);
     Ref<const ConstRefCounted> i(returnRefCountedRef());
 }
 
 struct PoisonedRefPtrCheckingRefLogger : RefLogger {
-    using Ref = PoisonedRefPtr<g_poisonD, PoisonedRefPtrCheckingRefLogger>;
+    using Ref = PoisonedRefPtr<PoisonD, PoisonedRefPtrCheckingRefLogger>;
 
     PoisonedRefPtrCheckingRefLogger(const char* name);
     void ref();
index fa81d91..81a4968 100644 (file)
@@ -35,6 +35,9 @@ namespace {
 uintptr_t g_poisonA;
 uintptr_t g_poisonB;
 
+using PoisonA = Poison<g_poisonA>;
+using PoisonB = Poison<g_poisonB>;
+
 static void initializePoisons()
 {
     static std::once_flag initializeOnceFlag;
@@ -76,12 +79,12 @@ TEST(WTF_PoisonedUniquePtr, Basic)
     initializePoisons();
 
     {
-        PoisonedUniquePtr<g_poisonA, Logger> empty;
+        PoisonedUniquePtr<PoisonA, Logger> empty;
         ASSERT_EQ(nullptr, empty.unpoisoned());
         ASSERT_EQ(0u, empty.bits());
     }
     {
-        PoisonedUniquePtr<g_poisonA, Logger> empty(nullptr);
+        PoisonedUniquePtr<PoisonA, Logger> empty(nullptr);
         ASSERT_EQ(nullptr, empty.unpoisoned());
         ASSERT_EQ(0u, empty.bits());
     }
@@ -90,7 +93,7 @@ TEST(WTF_PoisonedUniquePtr, Basic)
         int aDestructCount = 0;
         Logger* a = new Logger("a", aDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger> ptr(a);
+            PoisonedUniquePtr<PoisonA, Logger> ptr(a);
             ASSERT_EQ(0, aDestructCount);
             ASSERT_EQ(a, ptr.unpoisoned());
             ASSERT_EQ(a, &*ptr);
@@ -101,7 +104,7 @@ TEST(WTF_PoisonedUniquePtr, Basic)
             std::memcpy(&ptrBits, &ptr, sizeof(ptrBits));
             ASSERT_TRUE(ptrBits != bitwise_cast<uintptr_t>(a));
 #if ENABLE(POISON_ASSERTS)
-            ASSERT_TRUE((PoisonedUniquePtr<g_poisonA, Logger>::isPoisoned(ptrBits)));
+            ASSERT_TRUE((PoisonedUniquePtr<PoisonA, Logger>::isPoisoned(ptrBits)));
 #endif
 #endif // ENABLE(POISON)
         }
@@ -110,7 +113,7 @@ TEST(WTF_PoisonedUniquePtr, Basic)
         int bDestructCount = 0;
         DerivedLogger* b = new DerivedLogger("b", bDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger> ptr(b);
+            PoisonedUniquePtr<PoisonA, Logger> ptr(b);
             ASSERT_EQ(0, bDestructCount);
             ASSERT_EQ(b, ptr.unpoisoned());
             ASSERT_EQ(b, &*ptr);
@@ -123,7 +126,7 @@ TEST(WTF_PoisonedUniquePtr, Basic)
         int aDestructCount = 0;
         Logger* a = new Logger("a", aDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger> ptr = a;
+            PoisonedUniquePtr<PoisonA, Logger> ptr = a;
             ASSERT_EQ(0, aDestructCount);
             ASSERT_EQ(a, ptr.unpoisoned());
         }
@@ -132,7 +135,7 @@ TEST(WTF_PoisonedUniquePtr, Basic)
         int bDestructCount = 0;
         DerivedLogger* b = new DerivedLogger("b", bDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger> ptr = b;
+            PoisonedUniquePtr<PoisonA, Logger> ptr = b;
             ASSERT_EQ(0, bDestructCount);
             ASSERT_EQ(b, ptr.unpoisoned());
         }
@@ -143,7 +146,7 @@ TEST(WTF_PoisonedUniquePtr, Basic)
         int aDestructCount = 0;
         const char* aName = "a";
         {
-            PoisonedUniquePtr<g_poisonA, Logger> ptr = PoisonedUniquePtr<g_poisonA, Logger>::create(aName, aDestructCount);
+            PoisonedUniquePtr<PoisonA, Logger> ptr = PoisonedUniquePtr<PoisonA, Logger>::create(aName, aDestructCount);
             ASSERT_EQ(0, aDestructCount);
             ASSERT_TRUE(nullptr != ptr.unpoisoned());
             ASSERT_EQ(aName, &ptr->name);
@@ -153,7 +156,7 @@ TEST(WTF_PoisonedUniquePtr, Basic)
         int bDestructCount = 0;
         const char* bName = "b";
         {
-            PoisonedUniquePtr<g_poisonA, Logger> ptr = PoisonedUniquePtr<g_poisonA, DerivedLogger>::create(bName, bDestructCount);
+            PoisonedUniquePtr<PoisonA, Logger> ptr = PoisonedUniquePtr<PoisonA, DerivedLogger>::create(bName, bDestructCount);
             ASSERT_EQ(0, bDestructCount);
             ASSERT_TRUE(nullptr != ptr.unpoisoned());
             ASSERT_EQ(bName, &ptr->name);
@@ -165,7 +168,7 @@ TEST(WTF_PoisonedUniquePtr, Basic)
         int aDestructCount = 0;
         const char* aName = "a";
         {
-            PoisonedUniquePtr<g_poisonA, Logger> ptr = std::make_unique<Logger>(aName, aDestructCount);
+            PoisonedUniquePtr<PoisonA, Logger> ptr = std::make_unique<Logger>(aName, aDestructCount);
             ASSERT_EQ(0, aDestructCount);
             ASSERT_TRUE(nullptr != ptr.unpoisoned());
             ASSERT_EQ(aName, &ptr->name);
@@ -175,7 +178,7 @@ TEST(WTF_PoisonedUniquePtr, Basic)
         int bDestructCount = 0;
         const char* bName = "b";
         {
-            PoisonedUniquePtr<g_poisonA, Logger> ptr = std::make_unique<DerivedLogger>(bName, bDestructCount);
+            PoisonedUniquePtr<PoisonA, Logger> ptr = std::make_unique<DerivedLogger>(bName, bDestructCount);
             ASSERT_EQ(0, bDestructCount);
             ASSERT_TRUE(nullptr != ptr.unpoisoned());
             ASSERT_EQ(bName, &ptr->name);
@@ -185,7 +188,7 @@ TEST(WTF_PoisonedUniquePtr, Basic)
         int uniqueDestructCount = 0;
         const char* uniqueName = "unique";
         {
-            PoisonedUniquePtr<g_poisonA, DerivedLogger> ptr = std::make_unique<DerivedLogger>(uniqueName, uniqueDestructCount);
+            PoisonedUniquePtr<PoisonA, DerivedLogger> ptr = std::make_unique<DerivedLogger>(uniqueName, uniqueDestructCount);
             ASSERT_EQ(0, uniqueDestructCount);
             ASSERT_TRUE(nullptr != ptr.unpoisoned());
             ASSERT_EQ(uniqueName, &ptr->name);
@@ -195,7 +198,7 @@ TEST(WTF_PoisonedUniquePtr, Basic)
         int uniqueDerivedDestructCount = 0;
         const char* uniqueDerivedName = "unique derived";
         {
-            PoisonedUniquePtr<g_poisonA, Logger> ptr = std::make_unique<DerivedLogger>(uniqueDerivedName, uniqueDerivedDestructCount);
+            PoisonedUniquePtr<PoisonA, Logger> ptr = std::make_unique<DerivedLogger>(uniqueDerivedName, uniqueDerivedDestructCount);
             ASSERT_EQ(0, uniqueDerivedDestructCount);
             ASSERT_TRUE(nullptr != ptr.unpoisoned());
             ASSERT_EQ(uniqueDerivedName, &ptr->name);
@@ -209,15 +212,15 @@ TEST(WTF_PoisonedUniquePtr, Basic)
         Logger* a = new Logger("a", aDestructCount);
         Logger* b = new Logger("b", bDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger> p1 = a;
-            PoisonedUniquePtr<g_poisonA, Logger> p2 = WTFMove(p1);
+            PoisonedUniquePtr<PoisonA, Logger> p1 = a;
+            PoisonedUniquePtr<PoisonA, Logger> p2 = WTFMove(p1);
             ASSERT_EQ(aDestructCount, 0);
             ASSERT_EQ(nullptr, p1.unpoisoned());
             ASSERT_EQ(0u, p1.bits());
             ASSERT_EQ(a, p2.unpoisoned());
 
-            PoisonedUniquePtr<g_poisonA, Logger> p3 = b;
-            PoisonedUniquePtr<g_poisonB, Logger> p4 = WTFMove(p3);
+            PoisonedUniquePtr<PoisonA, Logger> p3 = b;
+            PoisonedUniquePtr<PoisonB, Logger> p4 = WTFMove(p3);
             ASSERT_EQ(0, bDestructCount);
             ASSERT_EQ(nullptr, p3.unpoisoned());
             ASSERT_EQ(0u, p3.bits());
@@ -233,15 +236,15 @@ TEST(WTF_PoisonedUniquePtr, Basic)
         Logger* a = new Logger("a", aDestructCount);
         Logger* b = new Logger("b", bDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger> p1 = a;
-            PoisonedUniquePtr<g_poisonA, Logger> p2(WTFMove(p1));
+            PoisonedUniquePtr<PoisonA, Logger> p1 = a;
+            PoisonedUniquePtr<PoisonA, Logger> p2(WTFMove(p1));
             ASSERT_EQ(0, aDestructCount);
             ASSERT_EQ(nullptr, p1.unpoisoned());
             ASSERT_EQ(0u, p1.bits());
             ASSERT_EQ(a, p2.unpoisoned());
 
-            PoisonedUniquePtr<g_poisonA, Logger> p3 = b;
-            PoisonedUniquePtr<g_poisonB, Logger> p4(WTFMove(p3));
+            PoisonedUniquePtr<PoisonA, Logger> p3 = b;
+            PoisonedUniquePtr<PoisonB, Logger> p4(WTFMove(p3));
             ASSERT_EQ(0, bDestructCount);
             ASSERT_EQ(nullptr, p3.unpoisoned());
             ASSERT_EQ(0u, p3.bits());
@@ -257,15 +260,15 @@ TEST(WTF_PoisonedUniquePtr, Basic)
         DerivedLogger* a = new DerivedLogger("a", aDestructCount);
         DerivedLogger* b = new DerivedLogger("b", bDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger> p1 = a;
-            PoisonedUniquePtr<g_poisonA, Logger> p2 = WTFMove(p1);
+            PoisonedUniquePtr<PoisonA, Logger> p1 = a;
+            PoisonedUniquePtr<PoisonA, Logger> p2 = WTFMove(p1);
             ASSERT_EQ(aDestructCount, 0);
             ASSERT_TRUE(!p1.unpoisoned());
             ASSERT_TRUE(!p1.bits());
             ASSERT_EQ(a, p2.unpoisoned());
 
-            PoisonedUniquePtr<g_poisonA, Logger> p3 = b;
-            PoisonedUniquePtr<g_poisonB, Logger> p4 = WTFMove(p3);
+            PoisonedUniquePtr<PoisonA, Logger> p3 = b;
+            PoisonedUniquePtr<PoisonB, Logger> p4 = WTFMove(p3);
             ASSERT_EQ(bDestructCount, 0);
             ASSERT_TRUE(!p3.unpoisoned());
             ASSERT_TRUE(!p3.bits());
@@ -281,15 +284,15 @@ TEST(WTF_PoisonedUniquePtr, Basic)
         DerivedLogger* a = new DerivedLogger("a", aDestructCount);
         DerivedLogger* b = new DerivedLogger("b", bDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger> p1 = a;
-            PoisonedUniquePtr<g_poisonA, Logger> p2(WTFMove(p1));
+            PoisonedUniquePtr<PoisonA, Logger> p1 = a;
+            PoisonedUniquePtr<PoisonA, Logger> p2(WTFMove(p1));
             ASSERT_EQ(aDestructCount, 0);
             ASSERT_TRUE(!p1.unpoisoned());
             ASSERT_TRUE(!p1.bits());
             ASSERT_EQ(a, p2.unpoisoned());
 
-            PoisonedUniquePtr<g_poisonA, Logger> p3 = b;
-            PoisonedUniquePtr<g_poisonB, Logger> p4(WTFMove(p3));
+            PoisonedUniquePtr<PoisonA, Logger> p3 = b;
+            PoisonedUniquePtr<PoisonB, Logger> p4(WTFMove(p3));
             ASSERT_EQ(bDestructCount, 0);
             ASSERT_TRUE(!p3.unpoisoned());
             ASSERT_TRUE(!p3.bits());
@@ -303,7 +306,7 @@ TEST(WTF_PoisonedUniquePtr, Basic)
         int aDestructCount = 0;
         Logger* a = new Logger("a", aDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger> ptr(a);
+            PoisonedUniquePtr<PoisonA, Logger> ptr(a);
             ASSERT_EQ(a, ptr.unpoisoned());
             ptr.clear();
             ASSERT_TRUE(!ptr.unpoisoned());
@@ -324,7 +327,7 @@ TEST(WTF_PoisonedUniquePtr, Assignment)
         Logger* a = new Logger("a", aDestructCount);
         Logger* b = new Logger("b", bDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger> ptr(a);
+            PoisonedUniquePtr<PoisonA, Logger> ptr(a);
             ASSERT_EQ(0, aDestructCount);
             ASSERT_EQ(0, bDestructCount);
             ASSERT_EQ(a, ptr.unpoisoned());
@@ -341,7 +344,7 @@ TEST(WTF_PoisonedUniquePtr, Assignment)
         int aDestructCount = 0;
         Logger* a = new Logger("a", aDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger> ptr(a);
+            PoisonedUniquePtr<PoisonA, Logger> ptr(a);
             ASSERT_EQ(0, aDestructCount);
             ASSERT_EQ(a, ptr.unpoisoned());
             ptr = nullptr;
@@ -361,8 +364,8 @@ TEST(WTF_PoisonedUniquePtr, Assignment)
         Logger* c = new Logger("c", cDestructCount);
         Logger* d = new Logger("d", dDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger> p1(a);
-            PoisonedUniquePtr<g_poisonA, Logger> p2(b);
+            PoisonedUniquePtr<PoisonA, Logger> p1(a);
+            PoisonedUniquePtr<PoisonA, Logger> p2(b);
             ASSERT_EQ(0, aDestructCount);
             ASSERT_EQ(0, bDestructCount);
             ASSERT_EQ(a, p1.unpoisoned());
@@ -373,8 +376,8 @@ TEST(WTF_PoisonedUniquePtr, Assignment)
             ASSERT_EQ(b, p1.unpoisoned());
             ASSERT_EQ(nullptr, p2.unpoisoned());
 
-            PoisonedUniquePtr<g_poisonA, Logger> p3(c);
-            PoisonedUniquePtr<g_poisonB, Logger> p4(d);
+            PoisonedUniquePtr<PoisonA, Logger> p3(c);
+            PoisonedUniquePtr<PoisonB, Logger> p4(d);
             ASSERT_EQ(0, cDestructCount);
             ASSERT_EQ(0, dDestructCount);
             ASSERT_EQ(c, p3.unpoisoned());
@@ -397,7 +400,7 @@ TEST(WTF_PoisonedUniquePtr, Assignment)
         DerivedLogger* a = new DerivedLogger("a", aDestructCount);
         DerivedLogger* b = new DerivedLogger("b", bDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger> ptr(a);
+            PoisonedUniquePtr<PoisonA, Logger> ptr(a);
             ASSERT_EQ(0, aDestructCount);
             ASSERT_EQ(0, bDestructCount);
             ASSERT_EQ(a, ptr.unpoisoned());
@@ -420,8 +423,8 @@ TEST(WTF_PoisonedUniquePtr, Assignment)
         DerivedLogger* c = new DerivedLogger("c", cDestructCount);
         DerivedLogger* d = new DerivedLogger("d", dDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger> p1(a);
-            PoisonedUniquePtr<g_poisonA, DerivedLogger> p2(b);
+            PoisonedUniquePtr<PoisonA, Logger> p1(a);
+            PoisonedUniquePtr<PoisonA, DerivedLogger> p2(b);
             ASSERT_EQ(0, aDestructCount);
             ASSERT_EQ(0, bDestructCount);
             ASSERT_EQ(a, p1.unpoisoned());
@@ -432,8 +435,8 @@ TEST(WTF_PoisonedUniquePtr, Assignment)
             ASSERT_EQ(b, p1.unpoisoned());
             ASSERT_EQ(nullptr, p2.unpoisoned());
 
-            PoisonedUniquePtr<g_poisonA, Logger> p3(c);
-            PoisonedUniquePtr<g_poisonB, DerivedLogger> p4(d);
+            PoisonedUniquePtr<PoisonA, Logger> p3(c);
+            PoisonedUniquePtr<PoisonB, DerivedLogger> p4(d);
             ASSERT_EQ(0, cDestructCount);
             ASSERT_EQ(0, dDestructCount);
             ASSERT_EQ(c, p3.unpoisoned());
@@ -454,7 +457,7 @@ TEST(WTF_PoisonedUniquePtr, Assignment)
         int aDestructCount = 0;
         Logger* a = new Logger("a", aDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger> ptr(a);
+            PoisonedUniquePtr<PoisonA, Logger> ptr(a);
             ASSERT_EQ(0, aDestructCount);
             ASSERT_EQ(a, ptr.unpoisoned());
             ptr = a;
@@ -468,7 +471,7 @@ TEST(WTF_PoisonedUniquePtr, Assignment)
         int aDestructCount = 0;
         Logger* a = new Logger("a", aDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger> ptr(a);
+            PoisonedUniquePtr<PoisonA, Logger> ptr(a);
             ASSERT_EQ(0, aDestructCount);
             ASSERT_EQ(a, ptr.unpoisoned());
 #if COMPILER(CLANG)
@@ -497,8 +500,8 @@ TEST(WTF_PoisonedUniquePtr, Swap)
         Logger* a = new Logger("a", aDestructCount);
         Logger* b = new Logger("b", bDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger> p1 = a;
-            PoisonedUniquePtr<g_poisonA, Logger> p2;
+            PoisonedUniquePtr<PoisonA, Logger> p1 = a;
+            PoisonedUniquePtr<PoisonA, Logger> p2;
             ASSERT_EQ(a, p1.unpoisoned());
             ASSERT_TRUE(!p2.bits());
             ASSERT_TRUE(!p2.unpoisoned());
@@ -508,8 +511,8 @@ TEST(WTF_PoisonedUniquePtr, Swap)
             ASSERT_TRUE(!p1.unpoisoned());
             ASSERT_EQ(a, p2.unpoisoned());
 
-            PoisonedUniquePtr<g_poisonA, Logger> p3 = b;
-            PoisonedUniquePtr<g_poisonB, Logger> p4;
+            PoisonedUniquePtr<PoisonA, Logger> p3 = b;
+            PoisonedUniquePtr<PoisonB, Logger> p4;
             ASSERT_EQ(b, p3.unpoisoned());
             ASSERT_TRUE(!p4.bits());
             ASSERT_TRUE(!p4.unpoisoned());
@@ -529,8 +532,8 @@ TEST(WTF_PoisonedUniquePtr, Swap)
         Logger* a = new Logger("a", aDestructCount);
         Logger* b = new Logger("b", bDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger> p1 = a;
-            PoisonedUniquePtr<g_poisonA, Logger> p2;
+            PoisonedUniquePtr<PoisonA, Logger> p1 = a;
+            PoisonedUniquePtr<PoisonA, Logger> p2;
             ASSERT_EQ(a, p1.unpoisoned());
             ASSERT_TRUE(!p2.bits());
             ASSERT_TRUE(!p2.unpoisoned());
@@ -540,8 +543,8 @@ TEST(WTF_PoisonedUniquePtr, Swap)
             ASSERT_TRUE(!p1.unpoisoned());
             ASSERT_EQ(a, p2.unpoisoned());
 
-            PoisonedUniquePtr<g_poisonA, Logger> p3 = b;
-            PoisonedUniquePtr<g_poisonB, Logger> p4;
+            PoisonedUniquePtr<PoisonA, Logger> p3 = b;
+            PoisonedUniquePtr<PoisonB, Logger> p4;
             ASSERT_EQ(b, p3.unpoisoned());
             ASSERT_TRUE(!p4.bits());
             ASSERT_TRUE(!p4.unpoisoned());
@@ -556,9 +559,9 @@ TEST(WTF_PoisonedUniquePtr, Swap)
     }
 }
 
-static PoisonedUniquePtr<g_poisonA, Logger> poisonedPtrFoo(Logger* logger)
+static PoisonedUniquePtr<PoisonA, Logger> poisonedPtrFoo(Logger* logger)
 {
-    return PoisonedUniquePtr<g_poisonA, Logger>(logger);
+    return PoisonedUniquePtr<PoisonA, Logger>(logger);
 }
 
 TEST(WTF_PoisonedUniquePtr, ReturnValue)
index 0fbedc4..11f79ed 100644 (file)
@@ -35,6 +35,9 @@ namespace {
 uintptr_t g_poisonA;
 uintptr_t g_poisonB;
 
+using PoisonA = Poison<g_poisonA>;
+using PoisonB = Poison<g_poisonB>;
+
 static void initializePoisons()
 {
     static std::once_flag initializeOnceFlag;
@@ -77,7 +80,7 @@ TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, Basic)
     initializePoisons();
 
     {
-        PoisonedUniquePtr<g_poisonA, Logger[]> empty;
+        PoisonedUniquePtr<PoisonA, Logger[]> empty;
         ASSERT_EQ(nullptr, empty.unpoisoned());
         ASSERT_EQ(0u, empty.bits());
     }
@@ -86,7 +89,7 @@ TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, Basic)
         int aDestructCount = 0;
         Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger[]> ptr(a);
+            PoisonedUniquePtr<PoisonA, Logger[]> ptr(a);
             ASSERT_EQ(0, aDestructCount);
             ASSERT_EQ(a, ptr.unpoisoned());
             ASSERT_EQ(a, &*ptr);
@@ -98,7 +101,7 @@ TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, Basic)
             std::memcpy(&ptrBits, &ptr, sizeof(ptrBits));
             ASSERT_TRUE(ptrBits != bitwise_cast<uintptr_t>(a));
 #if ENABLE(POISON_ASSERTS)
-            ASSERT_TRUE((PoisonedUniquePtr<g_poisonA, Logger[]>::isPoisoned(ptrBits)));
+            ASSERT_TRUE((PoisonedUniquePtr<PoisonA, Logger[]>::isPoisoned(ptrBits)));
 #endif
 #endif // ENABLE(POISON)
         }
@@ -109,7 +112,7 @@ TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, Basic)
         int aDestructCount = 0;
         Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger[]> ptr = a;
+            PoisonedUniquePtr<PoisonA, Logger[]> ptr = a;
             ASSERT_EQ(0, aDestructCount);
             ASSERT_EQ(a, ptr.unpoisoned());
             for (auto i = 0; i < arraySize; ++i)
@@ -122,7 +125,7 @@ TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, Basic)
         int aDestructCount = 0;
         const char* aName = "a";
         {
-            PoisonedUniquePtr<g_poisonA, Logger[]> ptr = PoisonedUniquePtr<g_poisonA, Logger[]>::create(arraySize, aName, aDestructCount);
+            PoisonedUniquePtr<PoisonA, Logger[]> ptr = PoisonedUniquePtr<PoisonA, Logger[]>::create(arraySize, aName, aDestructCount);
             ASSERT_EQ(0, aDestructCount);
             ASSERT_TRUE(nullptr != ptr.unpoisoned());
             for (auto i = 0; i < arraySize; ++i)
@@ -137,15 +140,15 @@ TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, Basic)
         Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
         Logger* b = makeArray<Logger>(arraySize, "b", bDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger[]> p1 = a;
-            PoisonedUniquePtr<g_poisonA, Logger[]> p2 = WTFMove(p1);
+            PoisonedUniquePtr<PoisonA, Logger[]> p1 = a;
+            PoisonedUniquePtr<PoisonA, Logger[]> p2 = WTFMove(p1);
             ASSERT_EQ(aDestructCount, 0);
             ASSERT_EQ(nullptr, p1.unpoisoned());
             ASSERT_EQ(0u, p1.bits());
             ASSERT_EQ(a, p2.unpoisoned());
 
-            PoisonedUniquePtr<g_poisonA, Logger[]> p3 = b;
-            PoisonedUniquePtr<g_poisonB, Logger[]> p4 = WTFMove(p3);
+            PoisonedUniquePtr<PoisonA, Logger[]> p3 = b;
+            PoisonedUniquePtr<PoisonB, Logger[]> p4 = WTFMove(p3);
             ASSERT_EQ(0, bDestructCount);
             ASSERT_EQ(nullptr, p3.unpoisoned());
             ASSERT_EQ(0u, p3.bits());
@@ -161,15 +164,15 @@ TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, Basic)
         Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
         Logger* b = makeArray<Logger>(arraySize, "b", bDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger[]> p1 = a;
-            PoisonedUniquePtr<g_poisonA, Logger[]> p2(WTFMove(p1));
+            PoisonedUniquePtr<PoisonA, Logger[]> p1 = a;
+            PoisonedUniquePtr<PoisonA, Logger[]> p2(WTFMove(p1));
             ASSERT_EQ(0, aDestructCount);
             ASSERT_EQ(nullptr, p1.unpoisoned());
             ASSERT_EQ(0u, p1.bits());
             ASSERT_EQ(a, p2.unpoisoned());
 
-            PoisonedUniquePtr<g_poisonA, Logger[]> p3 = b;
-            PoisonedUniquePtr<g_poisonB, Logger[]> p4(WTFMove(p3));
+            PoisonedUniquePtr<PoisonA, Logger[]> p3 = b;
+            PoisonedUniquePtr<PoisonB, Logger[]> p4(WTFMove(p3));
             ASSERT_EQ(0, bDestructCount);
             ASSERT_EQ(nullptr, p3.unpoisoned());
             ASSERT_EQ(0u, p3.bits());
@@ -185,15 +188,15 @@ TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, Basic)
         Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
         Logger* b = makeArray<Logger>(arraySize, "b", bDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger[]> p1 = a;
-            PoisonedUniquePtr<g_poisonA, Logger[]> p2 = WTFMove(p1);
+            PoisonedUniquePtr<PoisonA, Logger[]> p1 = a;
+            PoisonedUniquePtr<PoisonA, Logger[]> p2 = WTFMove(p1);
             ASSERT_EQ(aDestructCount, 0);
             ASSERT_TRUE(!p1.unpoisoned());
             ASSERT_TRUE(!p1.bits());
             ASSERT_EQ(a, p2.unpoisoned());
 
-            PoisonedUniquePtr<g_poisonA, Logger[]> p3 = b;
-            PoisonedUniquePtr<g_poisonB, Logger[]> p4 = WTFMove(p3);
+            PoisonedUniquePtr<PoisonA, Logger[]> p3 = b;
+            PoisonedUniquePtr<PoisonB, Logger[]> p4 = WTFMove(p3);
             ASSERT_EQ(bDestructCount, 0);
             ASSERT_TRUE(!p3.unpoisoned());
             ASSERT_TRUE(!p3.bits());
@@ -209,15 +212,15 @@ TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, Basic)
         Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
         Logger* b = makeArray<Logger>(arraySize, "b", bDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger[]> p1 = a;
-            PoisonedUniquePtr<g_poisonA, Logger[]> p2(WTFMove(p1));
+            PoisonedUniquePtr<PoisonA, Logger[]> p1 = a;
+            PoisonedUniquePtr<PoisonA, Logger[]> p2(WTFMove(p1));
             ASSERT_EQ(aDestructCount, 0);
             ASSERT_TRUE(!p1.unpoisoned());
             ASSERT_TRUE(!p1.bits());
             ASSERT_EQ(a, p2.unpoisoned());
 
-            PoisonedUniquePtr<g_poisonA, Logger[]> p3 = b;
-            PoisonedUniquePtr<g_poisonB, Logger[]> p4(WTFMove(p3));
+            PoisonedUniquePtr<PoisonA, Logger[]> p3 = b;
+            PoisonedUniquePtr<PoisonB, Logger[]> p4(WTFMove(p3));
             ASSERT_EQ(bDestructCount, 0);
             ASSERT_TRUE(!p3.unpoisoned());
             ASSERT_TRUE(!p3.bits());
@@ -231,7 +234,7 @@ TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, Basic)
         int aDestructCount = 0;
         Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger[]> ptr(a);
+            PoisonedUniquePtr<PoisonA, Logger[]> ptr(a);
             ASSERT_EQ(a, ptr.unpoisoned());
             ptr.clear();
             ASSERT_TRUE(!ptr.unpoisoned());
@@ -252,7 +255,7 @@ TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, Assignment)
         Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
         Logger* b = makeArray<Logger>(arraySize, "b", bDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger[]> ptr(a);
+            PoisonedUniquePtr<PoisonA, Logger[]> ptr(a);
             ASSERT_EQ(0, aDestructCount);
             ASSERT_EQ(0, bDestructCount);
             ASSERT_EQ(a, ptr.unpoisoned());
@@ -269,7 +272,7 @@ TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, Assignment)
         int aDestructCount = 0;
         Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger[]> ptr(a);
+            PoisonedUniquePtr<PoisonA, Logger[]> ptr(a);
             ASSERT_EQ(0, aDestructCount);
             ASSERT_EQ(a, ptr.unpoisoned());
             ptr = nullptr;
@@ -289,8 +292,8 @@ TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, Assignment)
         Logger* c = makeArray<Logger>(arraySize, "c", cDestructCount);
         Logger* d = makeArray<Logger>(arraySize, "d", dDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger[]> p1(a);
-            PoisonedUniquePtr<g_poisonA, Logger[]> p2(b);
+            PoisonedUniquePtr<PoisonA, Logger[]> p1(a);
+            PoisonedUniquePtr<PoisonA, Logger[]> p2(b);
             ASSERT_EQ(0, aDestructCount);
             ASSERT_EQ(0, bDestructCount);
             ASSERT_EQ(a, p1.unpoisoned());
@@ -301,8 +304,8 @@ TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, Assignment)
             ASSERT_EQ(b, p1.unpoisoned());
             ASSERT_EQ(nullptr, p2.unpoisoned());
 
-            PoisonedUniquePtr<g_poisonA, Logger[]> p3(c);
-            PoisonedUniquePtr<g_poisonB, Logger[]> p4(d);
+            PoisonedUniquePtr<PoisonA, Logger[]> p3(c);
+            PoisonedUniquePtr<PoisonB, Logger[]> p4(d);
             ASSERT_EQ(0, cDestructCount);
             ASSERT_EQ(0, dDestructCount);
             ASSERT_EQ(c, p3.unpoisoned());
@@ -323,7 +326,7 @@ TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, Assignment)
         int aDestructCount = 0;
         Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger[]> ptr(a);
+            PoisonedUniquePtr<PoisonA, Logger[]> ptr(a);
             ASSERT_EQ(0, aDestructCount);
             ASSERT_EQ(a, ptr.unpoisoned());
             ptr = a;
@@ -337,7 +340,7 @@ TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, Assignment)
         int aDestructCount = 0;
         Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger[]> ptr(a);
+            PoisonedUniquePtr<PoisonA, Logger[]> ptr(a);
             ASSERT_EQ(0, aDestructCount);
             ASSERT_EQ(a, ptr.unpoisoned());
 #if COMPILER(CLANG)
@@ -366,8 +369,8 @@ TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, Swap)
         Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
         Logger* b = makeArray<Logger>(arraySize, "b", bDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger[]> p1 = a;
-            PoisonedUniquePtr<g_poisonA, Logger[]> p2;
+            PoisonedUniquePtr<PoisonA, Logger[]> p1 = a;
+            PoisonedUniquePtr<PoisonA, Logger[]> p2;
             ASSERT_EQ(a, p1.unpoisoned());
             ASSERT_TRUE(!p2.bits());
             ASSERT_TRUE(!p2.unpoisoned());
@@ -377,8 +380,8 @@ TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, Swap)
             ASSERT_TRUE(!p1.unpoisoned());
             ASSERT_EQ(a, p2.unpoisoned());
 
-            PoisonedUniquePtr<g_poisonA, Logger[]> p3 = b;
-            PoisonedUniquePtr<g_poisonB, Logger[]> p4;
+            PoisonedUniquePtr<PoisonA, Logger[]> p3 = b;
+            PoisonedUniquePtr<PoisonB, Logger[]> p4;
             ASSERT_EQ(b, p3.unpoisoned());
             ASSERT_TRUE(!p4.bits());
             ASSERT_TRUE(!p4.unpoisoned());
@@ -398,8 +401,8 @@ TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, Swap)
         Logger* a = makeArray<Logger>(arraySize, "a", aDestructCount);
         Logger* b = makeArray<Logger>(arraySize, "b", bDestructCount);
         {
-            PoisonedUniquePtr<g_poisonA, Logger[]> p1 = a;
-            PoisonedUniquePtr<g_poisonA, Logger[]> p2;
+            PoisonedUniquePtr<PoisonA, Logger[]> p1 = a;
+            PoisonedUniquePtr<PoisonA, Logger[]> p2;
             ASSERT_EQ(a, p1.unpoisoned());
             ASSERT_TRUE(!p2.bits());
             ASSERT_TRUE(!p2.unpoisoned());
@@ -409,8 +412,8 @@ TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, Swap)
             ASSERT_TRUE(!p1.unpoisoned());
             ASSERT_EQ(a, p2.unpoisoned());
 
-            PoisonedUniquePtr<g_poisonA, Logger[]> p3 = b;
-            PoisonedUniquePtr<g_poisonB, Logger[]> p4;
+            PoisonedUniquePtr<PoisonA, Logger[]> p3 = b;
+            PoisonedUniquePtr<PoisonB, Logger[]> p4;
             ASSERT_EQ(b, p3.unpoisoned());
             ASSERT_TRUE(!p4.bits());
             ASSERT_TRUE(!p4.unpoisoned());
@@ -425,9 +428,9 @@ TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, Swap)
     }
 }
 
-static PoisonedUniquePtr<g_poisonA, Logger[]> poisonedPtrFoo(Logger* array)
+static PoisonedUniquePtr<PoisonA, Logger[]> poisonedPtrFoo(Logger* array)
 {
-    return PoisonedUniquePtr<g_poisonA, Logger[]>(array);
+    return PoisonedUniquePtr<PoisonA, Logger[]>(array);
 }
 
 TEST(WTF_PoisonedUniquePtrForNonTriviallyDestructibleArrays, ReturnValue)
index a24e09e..d084f92 100644 (file)
@@ -36,6 +36,9 @@ namespace {
 uintptr_t g_poisonA;
 uintptr_t g_poisonB;
 
+using PoisonA = Poison<g_poisonA>;
+using PoisonB = Poison<g_poisonB>;
+
 static void initializePoisons()
 {
     static std::once_flag initializeOnceFlag;
@@ -63,12 +66,12 @@ TEST(WTF_PoisonedUniquePtrForTriviallyDestructibleArrays, Basic)
     initializePoisons();
 
     {
-        PoisonedUniquePtr<g_poisonA, int[]> empty;
+        PoisonedUniquePtr<PoisonA, int[]> empty;
         ASSERT_EQ(nullptr, empty.unpoisoned());
         ASSERT_EQ(0u, empty.bits());
     }
     {
-        PoisonedUniquePtr<g_poisonA, int[]> empty(nullptr);
+        PoisonedUniquePtr<PoisonA, int[]> empty(nullptr);
         ASSERT_EQ(nullptr, empty.unpoisoned());
         ASSERT_EQ(0u, empty.bits());
     }
@@ -77,7 +80,7 @@ TEST(WTF_PoisonedUniquePtrForTriviallyDestructibleArrays, Basic)
         auto* a = new int[arraySize];
         fillArray(a, arraySize);
         {
-            PoisonedUniquePtr<g_poisonA, int[]> ptr(a);
+            PoisonedUniquePtr<PoisonA, int[]> ptr(a);
             ASSERT_EQ(a, ptr.unpoisoned());
             ASSERT_EQ(a, &*ptr);
             for (auto i = 0; i < arraySize; ++i)
@@ -88,7 +91,7 @@ TEST(WTF_PoisonedUniquePtrForTriviallyDestructibleArrays, Basic)
             std::memcpy(&ptrBits, &ptr, sizeof(ptrBits));
             ASSERT_TRUE(ptrBits != bitwise_cast<uintptr_t>(a));
 #if ENABLE(POISON_ASSERTS)
-            ASSERT_TRUE((PoisonedUniquePtr<g_poisonA, int[]>::isPoisoned(ptrBits)));
+            ASSERT_TRUE((PoisonedUniquePtr<PoisonA, int[]>::isPoisoned(ptrBits)));
 #endif
 #endif // ENABLE(POISON)
         }
@@ -98,7 +101,7 @@ TEST(WTF_PoisonedUniquePtrForTriviallyDestructibleArrays, Basic)
         auto* a = new int[arraySize];
         fillArray(a, arraySize);
 
-        PoisonedUniquePtr<g_poisonA, int[]> ptr = a;
+        PoisonedUniquePtr<PoisonA, int[]> ptr = a;
         ASSERT_EQ(a, ptr.unpoisoned());
         ASSERT_EQ(a, &*ptr);
         for (auto i = 0; i < arraySize; ++i)
@@ -106,7 +109,7 @@ TEST(WTF_PoisonedUniquePtrForTriviallyDestructibleArrays, Basic)
     }
 
     {
-        PoisonedUniquePtr<g_poisonA, int[]> ptr = PoisonedUniquePtr<g_poisonA, int[]>::create(arraySize);
+        PoisonedUniquePtr<PoisonA, int[]> ptr = PoisonedUniquePtr<PoisonA, int[]>::create(arraySize);
         ASSERT_TRUE(nullptr != ptr.unpoisoned());
         fillArray(ptr, arraySize);
         for (auto i = 0; i < arraySize; ++i)
@@ -119,16 +122,16 @@ TEST(WTF_PoisonedUniquePtrForTriviallyDestructibleArrays, Basic)
         auto* b = new int[arraySize];
         fillArray(b, arraySize);
 
-        PoisonedUniquePtr<g_poisonA, int[]> p1 = a;
-        PoisonedUniquePtr<g_poisonA, int[]> p2 = WTFMove(p1);
+        PoisonedUniquePtr<PoisonA, int[]> p1 = a;
+        PoisonedUniquePtr<PoisonA, int[]> p2 = WTFMove(p1);
         ASSERT_EQ(nullptr, p1.unpoisoned());
         ASSERT_EQ(0u, p1.bits());
         ASSERT_EQ(a, p2.unpoisoned());
         for (auto i = 0; i < arraySize; ++i)
             ASSERT_EQ(a[i], p2[i]);
 
-        PoisonedUniquePtr<g_poisonA, int[]> p3 = b;
-        PoisonedUniquePtr<g_poisonB, int[]> p4 = WTFMove(p3);
+        PoisonedUniquePtr<PoisonA, int[]> p3 = b;
+        PoisonedUniquePtr<PoisonB, int[]> p4 = WTFMove(p3);
         ASSERT_EQ(nullptr, p3.unpoisoned());
         ASSERT_EQ(0u, p3.bits());
         ASSERT_EQ(b, p4.unpoisoned());
@@ -142,16 +145,16 @@ TEST(WTF_PoisonedUniquePtrForTriviallyDestructibleArrays, Basic)
         auto* b = new int[arraySize];
         fillArray(b, arraySize);
 
-        PoisonedUniquePtr<g_poisonA, int[]> p1 = a;
-        PoisonedUniquePtr<g_poisonA, int[]> p2(WTFMove(p1));
+        PoisonedUniquePtr<PoisonA, int[]> p1 = a;
+        PoisonedUniquePtr<PoisonA, int[]> p2(WTFMove(p1));
         ASSERT_EQ(nullptr, p1.unpoisoned());
         ASSERT_EQ(0u, p1.bits());
         ASSERT_EQ(a, p2.unpoisoned());
         for (auto i = 0; i < arraySize; ++i)
             ASSERT_EQ(a[i], p2[i]);
 
-        PoisonedUniquePtr<g_poisonA, int[]> p3 = b;
-        PoisonedUniquePtr<g_poisonB, int[]> p4(WTFMove(p3));
+        PoisonedUniquePtr<PoisonA, int[]> p3 = b;
+        PoisonedUniquePtr<PoisonB, int[]> p4(WTFMove(p3));
         ASSERT_EQ(nullptr, p3.unpoisoned());
         ASSERT_EQ(0u, p3.bits());
         ASSERT_EQ(b, p4.unpoisoned());
@@ -163,7 +166,7 @@ TEST(WTF_PoisonedUniquePtrForTriviallyDestructibleArrays, Basic)
         auto* a = new int[arraySize];
         fillArray(a, arraySize);
 
-        PoisonedUniquePtr<g_poisonA, int[]> ptr(a);
+        PoisonedUniquePtr<PoisonA, int[]> ptr(a);
         ASSERT_EQ(a, ptr.unpoisoned());
         ptr.clear();
         ASSERT_TRUE(!ptr.unpoisoned());
@@ -181,7 +184,7 @@ TEST(WTF_PoisonedUniquePtrForTriviallyDestructibleArrays, Assignment)
         fillArray(a, arraySize);
         fillArray(b, arraySize);
 
-        PoisonedUniquePtr<g_poisonA, int[]> ptr(a);
+        PoisonedUniquePtr<PoisonA, int[]> ptr(a);
         ASSERT_EQ(a, ptr.unpoisoned());
         ptr = b;
         ASSERT_EQ(b, ptr.unpoisoned());
@@ -191,7 +194,7 @@ TEST(WTF_PoisonedUniquePtrForTriviallyDestructibleArrays, Assignment)
         auto* a = new int[arraySize];
         fillArray(a, arraySize);
 
-        PoisonedUniquePtr<g_poisonA, int[]> ptr(a);
+        PoisonedUniquePtr<PoisonA, int[]> ptr(a);
         ASSERT_EQ(a, ptr.unpoisoned());
         ptr = nullptr;
         ASSERT_EQ(nullptr, ptr.unpoisoned());
@@ -207,16 +210,16 @@ TEST(WTF_PoisonedUniquePtrForTriviallyDestructibleArrays, Assignment)
         fillArray(c, arraySize);
         fillArray(d, arraySize);
 
-        PoisonedUniquePtr<g_poisonA, int[]> p1(a);
-        PoisonedUniquePtr<g_poisonA, int[]> p2(b);
+        PoisonedUniquePtr<PoisonA, int[]> p1(a);
+        PoisonedUniquePtr<PoisonA, int[]> p2(b);
         ASSERT_EQ(a, p1.unpoisoned());
         ASSERT_EQ(b, p2.unpoisoned());
         p1 = WTFMove(p2);
         ASSERT_EQ(b, p1.unpoisoned());
         ASSERT_EQ(nullptr, p2.unpoisoned());
 
-        PoisonedUniquePtr<g_poisonA, int[]> p3(c);
-        PoisonedUniquePtr<g_poisonB, int[]> p4(d);
+        PoisonedUniquePtr<PoisonA, int[]> p3(c);
+        PoisonedUniquePtr<PoisonB, int[]> p4(d);
         ASSERT_EQ(c, p3.unpoisoned());
         ASSERT_EQ(d, p4.unpoisoned());
         p3 = WTFMove(p4);
@@ -228,7 +231,7 @@ TEST(WTF_PoisonedUniquePtrForTriviallyDestructibleArrays, Assignment)
         auto* a = new int[arraySize];
         fillArray(a, arraySize);
 
-        PoisonedUniquePtr<g_poisonA, int[]> ptr(a);
+        PoisonedUniquePtr<PoisonA, int[]> ptr(a);
         ASSERT_EQ(a, ptr.unpoisoned());
         ptr = a;
         ASSERT_EQ(a, ptr.unpoisoned());
@@ -238,7 +241,7 @@ TEST(WTF_PoisonedUniquePtrForTriviallyDestructibleArrays, Assignment)
         auto* a = new int[arraySize];
         fillArray(a, arraySize);
 
-        PoisonedUniquePtr<g_poisonA, int[]> ptr(a);
+        PoisonedUniquePtr<PoisonA, int[]> ptr(a);
         ASSERT_EQ(a, ptr.unpoisoned());
 #if COMPILER(CLANG)
 #pragma clang diagnostic push
@@ -263,8 +266,8 @@ TEST(WTF_PoisonedUniquePtrForTriviallyDestructibleArrays, Swap)
         fillArray(a, arraySize);
         fillArray(b, arraySize);
 
-        PoisonedUniquePtr<g_poisonA, int[]> p1 = a;
-        PoisonedUniquePtr<g_poisonA, int[]> p2;
+        PoisonedUniquePtr<PoisonA, int[]> p1 = a;
+        PoisonedUniquePtr<PoisonA, int[]> p2;
         ASSERT_EQ(p1.unpoisoned(), a);
         ASSERT_TRUE(!p2.bits());
         ASSERT_TRUE(!p2.unpoisoned());
@@ -273,8 +276,8 @@ TEST(WTF_PoisonedUniquePtrForTriviallyDestructibleArrays, Swap)
         ASSERT_TRUE(!p1.unpoisoned());
         ASSERT_EQ(p2.unpoisoned(), a);
 
-        PoisonedUniquePtr<g_poisonA, int[]> p3 = b;
-        PoisonedUniquePtr<g_poisonB, int[]> p4;
+        PoisonedUniquePtr<PoisonA, int[]> p3 = b;
+        PoisonedUniquePtr<PoisonB, int[]> p4;
         ASSERT_EQ(p3.unpoisoned(), b);
         ASSERT_TRUE(!p4.bits());
         ASSERT_TRUE(!p4.unpoisoned());
@@ -290,8 +293,8 @@ TEST(WTF_PoisonedUniquePtrForTriviallyDestructibleArrays, Swap)
         fillArray(a, arraySize);
         fillArray(b, arraySize);
 
-        PoisonedUniquePtr<g_poisonA, int[]> p1 = a;
-        PoisonedUniquePtr<g_poisonA, int[]> p2;
+        PoisonedUniquePtr<PoisonA, int[]> p1 = a;
+        PoisonedUniquePtr<PoisonA, int[]> p2;
         ASSERT_EQ(p1.unpoisoned(), a);
         ASSERT_TRUE(!p2.bits());
         ASSERT_TRUE(!p2.unpoisoned());
@@ -300,8 +303,8 @@ TEST(WTF_PoisonedUniquePtrForTriviallyDestructibleArrays, Swap)
         ASSERT_TRUE(!p1.unpoisoned());
         ASSERT_EQ(p2.unpoisoned(), a);
 
-        PoisonedUniquePtr<g_poisonA, int[]> p3 = b;
-        PoisonedUniquePtr<g_poisonB, int[]> p4;
+        PoisonedUniquePtr<PoisonA, int[]> p3 = b;
+        PoisonedUniquePtr<PoisonB, int[]> p4;
         ASSERT_EQ(p3.unpoisoned(), b);
         ASSERT_TRUE(!p4.bits());
         ASSERT_TRUE(!p4.unpoisoned());
@@ -312,9 +315,9 @@ TEST(WTF_PoisonedUniquePtrForTriviallyDestructibleArrays, Swap)
     }
 }
 
-static PoisonedUniquePtr<g_poisonA, int[]> poisonedPtrFoo(int* ptr)
+static PoisonedUniquePtr<PoisonA, int[]> poisonedPtrFoo(int* ptr)
 {
-    return PoisonedUniquePtr<g_poisonA, int[]>(ptr);
+    return PoisonedUniquePtr<PoisonA, int[]>(ptr);
 }
 
 TEST(WTF_PoisonedUniquePtrForTriviallyDestructibleArrays, ReturnValue)