Push the definition of PtrTag down to the WTF layer.
authormark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Apr 2018 22:31:13 +0000 (22:31 +0000)
committermark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Apr 2018 22:31:13 +0000 (22:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184976
<rdar://problem/39723901>

Reviewed by Saam Barati.

Source/JavaScriptCore:

* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* assembler/ARM64Assembler.h:
* assembler/AbstractMacroAssembler.h:
* assembler/MacroAssemblerCodeRef.cpp:
* assembler/MacroAssemblerCodeRef.h:
* b3/B3MathExtras.cpp:
* bytecode/LLIntCallLinkInfo.h:
* disassembler/Disassembler.h:
* ftl/FTLJITCode.cpp:
* interpreter/InterpreterInlines.h:
* jit/ExecutableAllocator.h:
* jit/JITOperations.cpp:
* jit/ThunkGenerator.h:
* jit/ThunkGenerators.h:
* llint/LLIntOffsetsExtractor.cpp:
* llint/LLIntPCRanges.h:
* runtime/JSCPtrTag.h: Added.
* runtime/NativeFunction.h:
* runtime/PtrTag.h: Removed.
* runtime/VMTraps.cpp:

Source/WebCore:

No new tests needed.  This is covered by existing tests.

* cssjit/CSSPtrTag.h:
* cssjit/SelectorCompiler.h:
(WebCore::SelectorCompiler::ruleCollectorSimpleSelectorCheckerFunction):
(WebCore::SelectorCompiler::querySelectorSimpleSelectorCheckerFunction):
(WebCore::SelectorCompiler::ruleCollectorSelectorCheckerFunctionWithCheckingContext):
(WebCore::SelectorCompiler::querySelectorSelectorCheckerFunctionWithCheckingContext):

Source/WTF:

This is in preparation for doing pointer profiling at the WTF layer as well.
Also deleted an unused ptrTag() function.

* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/PtrTag.h: Copied from Source/JavaScriptCore/runtime/PtrTag.h.
(WTF::makePtrTagHash):
(JSC::ptrTagName): Deleted.
(JSC::tagForPtr): Deleted.
(JSC::ptrTag): Deleted.
(JSC::tagCodePtr): Deleted.
(JSC::untagCodePtr): Deleted.
(JSC::retagCodePtr): Deleted.
(JSC::removeCodePtrTag): Deleted.
(JSC::tagCFunctionPtr): Deleted.
(JSC::untagCFunctionPtr): Deleted.
(JSC::assertIsCFunctionPtr): Deleted.
(JSC::assertIsNullOrCFunctionPtr): Deleted.
(JSC::assertIsNotTagged): Deleted.
(JSC::assertIsTagged): Deleted.
(JSC::assertIsNullOrTagged): Deleted.
(JSC::assertIsTaggedWith): Deleted.
(JSC::assertIsNullOrTaggedWith): Deleted.

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

28 files changed:
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/assembler/ARM64Assembler.h
Source/JavaScriptCore/assembler/AbstractMacroAssembler.h
Source/JavaScriptCore/assembler/MacroAssemblerCodeRef.cpp
Source/JavaScriptCore/assembler/MacroAssemblerCodeRef.h
Source/JavaScriptCore/b3/B3MathExtras.cpp
Source/JavaScriptCore/bytecode/LLIntCallLinkInfo.h
Source/JavaScriptCore/disassembler/Disassembler.h
Source/JavaScriptCore/ftl/FTLJITCode.cpp
Source/JavaScriptCore/interpreter/InterpreterInlines.h
Source/JavaScriptCore/jit/ExecutableAllocator.h
Source/JavaScriptCore/jit/JITOperations.cpp
Source/JavaScriptCore/jit/ThunkGenerator.h
Source/JavaScriptCore/jit/ThunkGenerators.h
Source/JavaScriptCore/llint/LLIntOffsetsExtractor.cpp
Source/JavaScriptCore/llint/LLIntPCRanges.h
Source/JavaScriptCore/runtime/JSCPtrTag.h [new file with mode: 0644]
Source/JavaScriptCore/runtime/NativeFunction.h
Source/JavaScriptCore/runtime/VMTraps.cpp
Source/WTF/ChangeLog
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/wtf/CMakeLists.txt
Source/WTF/wtf/PtrTag.h [moved from Source/JavaScriptCore/runtime/PtrTag.h with 83% similarity]
Source/WebCore/ChangeLog
Source/WebCore/cssjit/CSSPtrTag.h
Source/WebCore/cssjit/SelectorCompiler.h

index 5cc6a7b..ead6ddc 100644 (file)
@@ -770,6 +770,7 @@ set(JavaScriptCore_PRIVATE_FRAMEWORK_HEADERS
     runtime/JSCJSValue.h
     runtime/JSCJSValueInlines.h
     runtime/JSCPoison.h
+    runtime/JSCPtrTag.h
     runtime/JSCallee.h
     runtime/JSCast.h
     runtime/JSCell.h
@@ -838,7 +839,6 @@ set(JavaScriptCore_PRIVATE_FRAMEWORK_HEADERS
     runtime/Operations.h
     runtime/Options.h
     runtime/ParseInt.h
-    runtime/PtrTag.h
     runtime/PrivateName.h
     runtime/ProgramExecutable.h
     runtime/PromiseDeferredTimer.h
index f44fc2e..4f080a7 100644 (file)
@@ -1,3 +1,33 @@
+2018-04-25  Mark Lam  <mark.lam@apple.com>
+
+        Push the definition of PtrTag down to the WTF layer.
+        https://bugs.webkit.org/show_bug.cgi?id=184976
+        <rdar://problem/39723901>
+
+        Reviewed by Saam Barati.
+
+        * CMakeLists.txt:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * assembler/ARM64Assembler.h:
+        * assembler/AbstractMacroAssembler.h:
+        * assembler/MacroAssemblerCodeRef.cpp:
+        * assembler/MacroAssemblerCodeRef.h:
+        * b3/B3MathExtras.cpp:
+        * bytecode/LLIntCallLinkInfo.h:
+        * disassembler/Disassembler.h:
+        * ftl/FTLJITCode.cpp:
+        * interpreter/InterpreterInlines.h:
+        * jit/ExecutableAllocator.h:
+        * jit/JITOperations.cpp:
+        * jit/ThunkGenerator.h:
+        * jit/ThunkGenerators.h:
+        * llint/LLIntOffsetsExtractor.cpp:
+        * llint/LLIntPCRanges.h:
+        * runtime/JSCPtrTag.h: Added.
+        * runtime/NativeFunction.h:
+        * runtime/PtrTag.h: Removed.
+        * runtime/VMTraps.cpp:
+
 2018-04-25  Keith Miller  <keith_miller@apple.com>
 
         getUnlinkedGlobalFunctionExecutable should only save things to the code cache if the option is set
index 488e5b3..383a06b 100644 (file)
                FE63DD541EA9B61E00103A69 /* Printer.h in Headers */ = {isa = PBXBuildFile; fileRef = FE63DD531EA9B60E00103A69 /* Printer.h */; settings = {ATTRIBUTES = (Private, ); }; };
                FE6491371D78F01D00A694D4 /* ExceptionScope.h in Headers */ = {isa = PBXBuildFile; fileRef = FE6491361D78F01300A694D4 /* ExceptionScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
                FE68C6371B90DE040042BCB3 /* MacroAssemblerPrinter.h in Headers */ = {isa = PBXBuildFile; fileRef = FE68C6361B90DDD90042BCB3 /* MacroAssemblerPrinter.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               FE6C1E4A20366F0100BDC2B7 /* PtrTag.h in Headers */ = {isa = PBXBuildFile; fileRef = FE9AE1C82032C887002B6934 /* PtrTag.h */; settings = {ATTRIBUTES = (Private, ); }; };
                FE6F56DE1E64EAD600D17801 /* VMTraps.h in Headers */ = {isa = PBXBuildFile; fileRef = FE6F56DD1E64E92000D17801 /* VMTraps.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               FE7497E6209001B10003565B /* JSCPtrTag.h in Headers */ = {isa = PBXBuildFile; fileRef = FE7497E5209001B00003565B /* JSCPtrTag.h */; settings = {ATTRIBUTES = (Private, ); }; };
                FE7C41961B97FC4B00F4D598 /* PingPongStackOverflowTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEDA50D41B97F442009A3B4F /* PingPongStackOverflowTest.cpp */; };
                FE80C1971D775CDD008510C0 /* CatchScope.h in Headers */ = {isa = PBXBuildFile; fileRef = FE80C1961D775B27008510C0 /* CatchScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
                FE99B2491C24C3D300C82159 /* JITNegGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE99B2481C24B6D300C82159 /* JITNegGenerator.h */; };
                FE68C6361B90DDD90042BCB3 /* MacroAssemblerPrinter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerPrinter.h; sourceTree = "<group>"; };
                FE6F56DC1E64E92000D17801 /* VMTraps.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VMTraps.cpp; sourceTree = "<group>"; };
                FE6F56DD1E64E92000D17801 /* VMTraps.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VMTraps.h; sourceTree = "<group>"; };
+               FE7497E5209001B00003565B /* JSCPtrTag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCPtrTag.h; sourceTree = "<group>"; };
                FE80C1961D775B27008510C0 /* CatchScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CatchScope.h; sourceTree = "<group>"; };
                FE80C1981D775FB4008510C0 /* CatchScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CatchScope.cpp; sourceTree = "<group>"; };
                FE80C19A1D7768FD008510C0 /* ExceptionEventLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExceptionEventLocation.cpp; sourceTree = "<group>"; };
                FE98B5B61BB9AE110073E7A6 /* JITSubGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITSubGenerator.h; sourceTree = "<group>"; };
                FE99B2471C24B6D300C82159 /* JITNegGenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITNegGenerator.cpp; sourceTree = "<group>"; };
                FE99B2481C24B6D300C82159 /* JITNegGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITNegGenerator.h; sourceTree = "<group>"; };
-               FE9AE1C82032C887002B6934 /* PtrTag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PtrTag.h; sourceTree = "<group>"; };
                FEA0861E182B7A0400F6D851 /* Breakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Breakpoint.h; sourceTree = "<group>"; };
                FEA0861F182B7A0400F6D851 /* DebuggerPrimitives.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DebuggerPrimitives.h; sourceTree = "<group>"; };
                FEA0C4001CDD7D0E00481991 /* FunctionWhitelist.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FunctionWhitelist.cpp; sourceTree = "<group>"; };
                                2A05ABD41961DF2400341750 /* JSPropertyNameEnumerator.h */,
                                862553CE16136AA5009F17D0 /* JSProxy.cpp */,
                                862553CF16136AA5009F17D0 /* JSProxy.h */,
+                               FE7497E5209001B00003565B /* JSCPtrTag.h */,
                                534638721E70D01500F12AC1 /* JSRunLoopTimer.cpp */,
                                534638701E70CF3D00F12AC1 /* JSRunLoopTimer.h */,
                                14874AE115EBDE4A002E3587 /* JSScope.cpp */,
                                79B00CBB1C6AB07E0088C65D /* ProxyObject.h */,
                                79160DBB1C8E3EC8008C085A /* ProxyRevoke.cpp */,
                                79160DBC1C8E3EC8008C085A /* ProxyRevoke.h */,
-                               FE9AE1C82032C887002B6934 /* PtrTag.h */,
                                0F5780A118FE1E98001E72D9 /* PureNaN.h */,
                                0F0CD4C015F1A6040032F1C0 /* PutDirectIndexMode.h */,
                                147B84620E6DE6B1004775A4 /* PutPropertySlot.h */,
                                7C008CDB187124BB00955C24 /* JSPromiseDeferred.h in Headers */,
                                7C184E1F17BEE22E007CB63A /* JSPromisePrototype.h in Headers */,
                                996B731F1BDA08EF00331B84 /* JSPromisePrototype.lut.h in Headers */,
+                               FE7497E6209001B10003565B /* JSCPtrTag.h in Headers */,
                                2A05ABD61961DF2400341750 /* JSPropertyNameEnumerator.h in Headers */,
                                862553D216136E1A009F17D0 /* JSProxy.h in Headers */,
                                A552C3801ADDB8FE00139726 /* JSRemoteInspector.h in Headers */,
                                79B00CBD1C6AB07E0088C65D /* ProxyConstructor.h in Headers */,
                                79B00CBF1C6AB07E0088C65D /* ProxyObject.h in Headers */,
                                79160DBE1C8E3EC8008C085A /* ProxyRevoke.h in Headers */,
-                               FE6C1E4A20366F0100BDC2B7 /* PtrTag.h in Headers */,
                                0F5780A218FE1E98001E72D9 /* PureNaN.h in Headers */,
                                0F15CD231BA5F9860031FFD3 /* PutByIdFlags.h in Headers */,
                                0F9332A414CA7DD90085F3C6 /* PutByIdStatus.h in Headers */,
index d02dd3d..49f1aee 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "AssemblerBuffer.h"
 #include "AssemblerCommon.h"
-#include "PtrTag.h"
+#include "JSCPtrTag.h"
 #include <limits.h>
 #include <wtf/Assertions.h>
 #include <wtf/Vector.h>
index a82d629..cf03f68 100644 (file)
 #include "CPU.h"
 #include "CodeLocation.h"
 #include "JSCJSValue.h"
+#include "JSCPtrTag.h"
 #include "MacroAssemblerCodeRef.h"
 #include "MacroAssemblerHelpers.h"
 #include "Options.h"
-#include "PtrTag.h"
 #include <wtf/CryptographicallyRandomNumber.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/SharedTask.h>
index 35aeba7..cf51d87 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "Disassembler.h"
 #include "JSCInlines.h"
-#include "PtrTag.h"
+#include "JSCPtrTag.h"
 #include <mutex>
 
 namespace JSC {
index 2c15cce..b1eb74c 100644 (file)
@@ -27,7 +27,7 @@
 
 #include "ExecutableAllocator.h"
 #include "JSCPoison.h"
-#include "PtrTag.h"
+#include "JSCPtrTag.h"
 #include <wtf/DataLog.h>
 #include <wtf/PrintStream.h>
 #include <wtf/RefPtr.h>
index 9a6c738..695c654 100644 (file)
@@ -35,8 +35,8 @@
 #include "B3ConstPtrValue.h"
 #include "B3UpsilonValue.h"
 #include "B3ValueInlines.h"
+#include "JSCPtrTag.h"
 #include "MathCommon.h"
-#include "PtrTag.h"
 
 namespace JSC { namespace B3 {
 
index 47e2c38..84b5c11 100644 (file)
@@ -25,9 +25,9 @@
 
 #pragma once
 
+#include "JSCPtrTag.h"
 #include "JSFunction.h"
 #include "MacroAssemblerCodeRef.h"
-#include "PtrTag.h"
 #include <wtf/SentinelLinkedList.h>
 
 namespace JSC {
index dd45e66..16ce02d 100644 (file)
@@ -25,8 +25,8 @@
 
 #pragma once
 
+#include "JSCPtrTag.h"
 #include "JSExportMacros.h"
-#include "PtrTag.h"
 #include <functional>
 #include <wtf/PrintStream.h>
 #include <wtf/text/CString.h>
index 931bf12..d4f6112 100644 (file)
@@ -29,7 +29,7 @@
 #if ENABLE(FTL_JIT)
 
 #include "FTLState.h"
-#include "PtrTag.h"
+#include "JSCPtrTag.h"
 
 namespace JSC { namespace FTL {
 
index 319d121..d59d901 100644 (file)
@@ -28,8 +28,8 @@
 
 #include "Instruction.h"
 #include "Interpreter.h"
+#include "JSCPtrTag.h"
 #include "LLIntData.h"
-#include "PtrTag.h"
 #include "UnlinkedCodeBlock.h"
 
 namespace JSC {
index 9516ddb..4c797ef 100644 (file)
@@ -26,7 +26,7 @@
 #pragma once
 
 #include "JITCompilationEffort.h"
-#include "PtrTag.h"
+#include "JSCPtrTag.h"
 #include <stddef.h> // for ptrdiff_t
 #include <limits>
 #include <wtf/Assertions.h>
index 5ec06b0..365bb73 100644 (file)
@@ -55,6 +55,7 @@
 #include "JSAsyncFunction.h"
 #include "JSAsyncGeneratorFunction.h"
 #include "JSCInlines.h"
+#include "JSCPtrTag.h"
 #include "JSGeneratorFunction.h"
 #include "JSGlobalObjectFunctions.h"
 #include "JSLexicalEnvironment.h"
@@ -64,7 +65,6 @@
 #include "PolymorphicAccess.h"
 #include "ProgramCodeBlock.h"
 #include "PropertyName.h"
-#include "PtrTag.h"
 #include "RegExpObject.h"
 #include "Repatch.h"
 #include "ScopedArguments.h"
index 1cf375d..e1c489a 100644 (file)
@@ -27,7 +27,7 @@
 
 #if ENABLE(JIT)
 
-#include "PtrTag.h"
+#include "JSCPtrTag.h"
 
 namespace JSC {
 class VM;
index 0c8c274..eb32e73 100644 (file)
@@ -26,7 +26,7 @@
 #pragma once
 
 #include "CodeSpecializationKind.h"
-#include "PtrTag.h"
+#include "JSCPtrTag.h"
 
 #if ENABLE(JIT)
 namespace JSC {
index 30f6054..961b27c 100644 (file)
@@ -38,6 +38,7 @@
 #include "Interpreter.h"
 #include "JSArray.h"
 #include "JSArrayBufferView.h"
+#include "JSCPtrTag.h"
 #include "JSCast.h"
 #include "JSFunction.h"
 #include "JSGlobalObject.h"
@@ -51,7 +52,6 @@
 #include "MarkedSpace.h"
 #include "NativeExecutable.h"
 #include "ProtoCallFrame.h"
-#include "PtrTag.h"
 #include "ShadowChicken.h"
 #include "Structure.h"
 #include "StructureChain.h"
index 0ef0aa8..942185e 100644 (file)
@@ -25,7 +25,7 @@
 
 #pragma once
 
-#include "PtrTag.h"
+#include "JSCPtrTag.h"
 
 namespace JSC {
 
diff --git a/Source/JavaScriptCore/runtime/JSCPtrTag.h b/Source/JavaScriptCore/runtime/JSCPtrTag.h
new file mode 100644 (file)
index 0000000..642ab6a
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/PtrTag.h>
+
+namespace JSC {
+
+using PtrTag = WTF::PtrTag;
+
+#define FOR_EACH_JSC_PTRTAG(v) \
+    v(B3CCallPtrTag) \
+    v(B3CompilationPtrTag) \
+    v(BytecodePtrTag) \
+    v(DisassemblyPtrTag) \
+    v(ExceptionHandlerPtrTag) \
+    v(JITThunkPtrTag) \
+    v(JITStubRoutinePtrTag) \
+    v(JSEntryPtrTag) \
+    v(JSInternalPtrTag) \
+    v(JSSwitchPtrTag) \
+    v(LinkBufferPtrTag) \
+    v(OperationPtrTag) \
+    v(OSRExitPtrTag) \
+    v(SlowPathPtrTag) \
+    v(WasmEntryPtrTag) \
+    v(Yarr8BitPtrTag) \
+    v(Yarr16BitPtrTag) \
+    v(YarrMatchOnly8BitPtrTag) \
+    v(YarrMatchOnly16BitPtrTag) \
+    v(YarrBacktrackPtrTag) \
+
+FOR_EACH_JSC_PTRTAG(WTF_DECLARE_PTRTAG)
+
+} // namespace JSC
+
index 958dcc5..d514443 100644 (file)
@@ -26,7 +26,7 @@
 #pragma once
 
 #include "JSCJSValue.h"
-#include "PtrTag.h"
+#include "JSCPtrTag.h"
 
 namespace JSC {
 
index 4526c76..e6e848f 100644 (file)
 #include "DFGCommonData.h"
 #include "ExceptionHelpers.h"
 #include "HeapInlines.h"
+#include "JSCPtrTag.h"
 #include "LLIntPCRanges.h"
 #include "MachineContext.h"
 #include "MachineStackMarker.h"
 #include "MacroAssembler.h"
 #include "MacroAssemblerCodeRef.h"
-#include "PtrTag.h"
 #include "VM.h"
 #include "VMInspector.h"
 #include "Watchdog.h"
index 34d6827..877c79b 100644 (file)
@@ -1,3 +1,35 @@
+2018-04-25  Mark Lam  <mark.lam@apple.com>
+
+        Push the definition of PtrTag down to the WTF layer.
+        https://bugs.webkit.org/show_bug.cgi?id=184976
+        <rdar://problem/39723901>
+
+        Reviewed by Saam Barati.
+
+        This is in preparation for doing pointer profiling at the WTF layer as well.
+        Also deleted an unused ptrTag() function.
+
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/CMakeLists.txt:
+        * wtf/PtrTag.h: Copied from Source/JavaScriptCore/runtime/PtrTag.h.
+        (WTF::makePtrTagHash):
+        (JSC::ptrTagName): Deleted.
+        (JSC::tagForPtr): Deleted.
+        (JSC::ptrTag): Deleted.
+        (JSC::tagCodePtr): Deleted.
+        (JSC::untagCodePtr): Deleted.
+        (JSC::retagCodePtr): Deleted.
+        (JSC::removeCodePtrTag): Deleted.
+        (JSC::tagCFunctionPtr): Deleted.
+        (JSC::untagCFunctionPtr): Deleted.
+        (JSC::assertIsCFunctionPtr): Deleted.
+        (JSC::assertIsNullOrCFunctionPtr): Deleted.
+        (JSC::assertIsNotTagged): Deleted.
+        (JSC::assertIsTagged): Deleted.
+        (JSC::assertIsNullOrTagged): Deleted.
+        (JSC::assertIsTaggedWith): Deleted.
+        (JSC::assertIsNullOrTaggedWith): Deleted.
+
 2018-04-25  Dean Jackson  <dino@apple.com>
 
         Make a better flag for system preview, and disable it where necessary
index 3c6cf32..dc3d369 100644 (file)
                FE05FAE61FDB214300093230 /* DumbPtrTraits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DumbPtrTraits.h; sourceTree = "<group>"; };
                FE05FAFE1FE5007500093230 /* WTFAssertions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WTFAssertions.cpp; sourceTree = "<group>"; };
                FE05FB041FE8453200093230 /* PoisonedUniquePtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PoisonedUniquePtr.h; sourceTree = "<group>"; };
+               FE7497E4208FFCAA0003565B /* PtrTag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PtrTag.h; sourceTree = "<group>"; };
                FE8225301B2A1E5B00BA68FD /* NakedPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NakedPtr.h; sourceTree = "<group>"; };
                FE85416C1FBE285B008DA5DA /* Poisoned.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Poisoned.cpp; sourceTree = "<group>"; };
                FE85416D1FBE285C008DA5DA /* Poisoned.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Poisoned.h; sourceTree = "<group>"; };
                                0FC4488216FE9FE100844BE9 /* ProcessID.h */,
                                7AF023B42061E16F00A8EFD6 /* ProcessPrivilege.cpp */,
                                7AF023B32061E16C00A8EFD6 /* ProcessPrivilege.h */,
+                               FE7497E4208FFCAA0003565B /* PtrTag.h */,
                                143F611D1565F0F900DB514A /* RAMSize.cpp */,
                                143F611E1565F0F900DB514A /* RAMSize.h */,
                                C8F597CA2A57417FBAB92FD6 /* RandomDevice.cpp */,
index ea7ee7d..eeef51f 100644 (file)
@@ -167,6 +167,7 @@ set(WTF_PUBLIC_HEADERS
     PriorityQueue.h
     ProcessID.h
     ProcessPrivilege.h
+    PtrTag.h
     RAMSize.h
     RandomDevice.h
     RandomNumber.h
similarity index 83%
rename from Source/JavaScriptCore/runtime/PtrTag.h
rename to Source/WTF/wtf/PtrTag.h
index 1a12105..7b95876 100644 (file)
 
 #include <wtf/PointerPreparations.h>
 
-namespace JSC {
+namespace WTF {
 
-#define FOR_EACH_BASE_PTRTAG_ENUM(v) \
+#define FOR_EACH_BASE_WTF_PTRTAG(v) \
     v(NoPtrTag) \
     v(CFunctionPtrTag) \
 
-#define FOR_EACH_ADDITIONAL_PTRTAG_ENUM(v) \
-    v(B3CCallPtrTag) \
-    v(B3CompilationPtrTag) \
-    v(BytecodePtrTag) \
-    v(DisassemblyPtrTag) \
-    v(ExceptionHandlerPtrTag) \
-    v(JITThunkPtrTag) \
-    v(JITStubRoutinePtrTag) \
-    v(JSEntryPtrTag) \
-    v(JSInternalPtrTag) \
-    v(JSSwitchPtrTag) \
-    v(LinkBufferPtrTag) \
-    v(OperationPtrTag) \
-    v(OSRExitPtrTag) \
-    v(SlowPathPtrTag) \
-    v(WasmEntryPtrTag) \
-    v(Yarr8BitPtrTag) \
-    v(Yarr16BitPtrTag) \
-    v(YarrMatchOnly8BitPtrTag) \
-    v(YarrMatchOnly16BitPtrTag) \
-    v(YarrBacktrackPtrTag) \
-
-#define FOR_EACH_PTRTAG_ENUM(v) \
-    FOR_EACH_BASE_PTRTAG_ENUM(v) \
-    FOR_EACH_ADDITIONAL_PTRTAG_ENUM(v) \
+#define FOR_EACH_ADDITIONAL_WTF_PTRTAG(v) \
+
+#define FOR_EACH_WTF_PTRTAG(v) \
+    FOR_EACH_BASE_WTF_PTRTAG(v) \
+    FOR_EACH_ADDITIONAL_WTF_PTRTAG(v) \
 
 enum PtrTag : uintptr_t {
     NoPtrTag,
     CFunctionPtrTag,
+};
+
+#ifndef WTF_PTRTAG_HASH
+template<size_t N>
+constexpr uintptr_t makePtrTagHash(const char (&str)[N])
+{
+    uintptr_t result = 134775813;
+    for (size_t i = 0; i < N; ++i)
+        result += ((result * str[i]) ^ (result >> 16));
+    return result & 0xffff;
+}
 
-#ifndef PTRTAG_ENUM_HASH
-#define DECLARE_PTRTAG_ENUM(tag)  tag,
-#else
-#define DECLARE_PTRTAG_ENUM(tag)  tag = PTRTAG_ENUM_HASH(tag),
+#define WTF_PTRTAG_HASH(tag) WTF::makePtrTagHash(#tag)
 #endif
-    FOR_EACH_ADDITIONAL_PTRTAG_ENUM(DECLARE_PTRTAG_ENUM)
-#undef DECLARE_PTRTAG_ENUM
-};
+
+#define WTF_DECLARE_PTRTAG(tag) \
+    constexpr PtrTag tag = static_cast<PtrTag>(WTF_PTRTAG_HASH(#tag)); \
+    static_assert(tag != NoPtrTag && tag != CFunctionPtrTag, "");
 
 static_assert(static_cast<uintptr_t>(NoPtrTag) == static_cast<uintptr_t>(0), "");
 static_assert(static_cast<uintptr_t>(CFunctionPtrTag) == static_cast<uintptr_t>(1), "");
 
-inline const char* ptrTagName(PtrTag tag)
-{
-#define RETURN_PTRTAG_NAME(_tagName) case _tagName: return #_tagName;
-    switch (tag) {
-        FOR_EACH_PTRTAG_ENUM(RETURN_PTRTAG_NAME)
-    default: return "<unknown>";
-    }
-#undef RETURN_PTRTAG_NAME
-}
+FOR_EACH_ADDITIONAL_WTF_PTRTAG(WTF_DECLARE_PTRTAG)
 
 #if !USE(POINTER_PROFILING)
 
 inline const char* tagForPtr(const void*) { return "<no tag>"; }
 
-template<typename... Arguments>
-inline constexpr PtrTag ptrTag(Arguments&&...) { return NoPtrTag; }
-
 template<typename T, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value && !std::is_same<T, PtrType>::value>>
 inline constexpr T tagCodePtr(PtrType ptr, PtrTag) { return bitwise_cast<T>(ptr); }
 
@@ -173,8 +151,29 @@ template<typename PtrType> void assertIsNullOrTaggedWith(PtrType, PtrTag) { }
 
 #endif // !USE(POINTER_PROFILING)
 
-} // namespace JSC
+} // namespace WTF
+
+using WTF::CFunctionPtrTag;
+using WTF::NoPtrTag;
+using WTF::PtrTag;
 
 #if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/PtrTagSupport.h>)
 #include <WebKitAdditions/PtrTagSupport.h>
 #endif
+
+using WTF::tagForPtr;
+
+using WTF::tagCodePtr;
+using WTF::untagCodePtr;
+using WTF::retagCodePtr;
+using WTF::removeCodePtrTag;
+using WTF::tagCFunctionPtr;
+using WTF::untagCFunctionPtr;
+
+using WTF::assertIsCFunctionPtr;
+using WTF::assertIsNullOrCFunctionPtr;
+using WTF::assertIsNotTagged;
+using WTF::assertIsTagged;
+using WTF::assertIsNullOrTagged;
+using WTF::assertIsTaggedWith;
+using WTF::assertIsNullOrTaggedWith;
index 72e1d3b..c4f2b67 100644 (file)
@@ -1,3 +1,20 @@
+2018-04-25  Mark Lam  <mark.lam@apple.com>
+
+        Push the definition of PtrTag down to the WTF layer.
+        https://bugs.webkit.org/show_bug.cgi?id=184976
+        <rdar://problem/39723901>
+
+        Reviewed by Saam Barati.
+
+        No new tests needed.  This is covered by existing tests.
+
+        * cssjit/CSSPtrTag.h:
+        * cssjit/SelectorCompiler.h:
+        (WebCore::SelectorCompiler::ruleCollectorSimpleSelectorCheckerFunction):
+        (WebCore::SelectorCompiler::querySelectorSimpleSelectorCheckerFunction):
+        (WebCore::SelectorCompiler::ruleCollectorSelectorCheckerFunctionWithCheckingContext):
+        (WebCore::SelectorCompiler::querySelectorSelectorCheckerFunctionWithCheckingContext):
+
 2018-04-25  Eric Carlson  <eric.carlson@apple.com>
 
         [iOS] remove media element parameter from MediaElementSession methods
index 0c9bb07..71e2b5d 100644 (file)
 
 #if ENABLE(CSS_SELECTOR_JIT)
 
-#include <JavaScriptCore/PtrTag.h>
+#include <JavaScriptCore/JSCPtrTag.h>
 
 namespace WebCore {
 
-static constexpr JSC::PtrTag CSSSelectorPtrTag = static_cast<JSC::PtrTag>(0xc551);
-static constexpr JSC::PtrTag CSSOperationPtrTag = static_cast<JSC::PtrTag>(0xc552);
+#define FOR_EACH_CSS_PTRTAG(v) \
+    v(CSSSelectorPtrTag) \
+    v(CSSOperationPtrTag) \
+
+FOR_EACH_CSS_PTRTAG(WTF_DECLARE_PTRTAG)
 
 } // namespace WebCore
 
index 6099b86..8fa9499 100644 (file)
@@ -58,25 +58,25 @@ SelectorCompilationStatus compileSelector(const CSSSelector*, SelectorContext, J
 inline RuleCollectorSimpleSelectorChecker ruleCollectorSimpleSelectorCheckerFunction(void* executableAddress, SelectorCompilationStatus compilationStatus)
 {
     ASSERT_UNUSED(compilationStatus, compilationStatus == SelectorCompilationStatus::SimpleSelectorChecker);
-    return JSC::untagCFunctionPtr<RuleCollectorSimpleSelectorChecker, CSSSelectorPtrTag>(executableAddress);
+    return WTF::untagCFunctionPtr<RuleCollectorSimpleSelectorChecker, CSSSelectorPtrTag>(executableAddress);
 }
 
 inline QuerySelectorSimpleSelectorChecker querySelectorSimpleSelectorCheckerFunction(void* executableAddress, SelectorCompilationStatus compilationStatus)
 {
     ASSERT_UNUSED(compilationStatus, compilationStatus == SelectorCompilationStatus::SimpleSelectorChecker);
-    return JSC::untagCFunctionPtr<QuerySelectorSimpleSelectorChecker, CSSSelectorPtrTag>(executableAddress);
+    return WTF::untagCFunctionPtr<QuerySelectorSimpleSelectorChecker, CSSSelectorPtrTag>(executableAddress);
 }
 
 inline RuleCollectorSelectorCheckerWithCheckingContext ruleCollectorSelectorCheckerFunctionWithCheckingContext(void* executableAddress, SelectorCompilationStatus compilationStatus)
 {
     ASSERT_UNUSED(compilationStatus, compilationStatus == SelectorCompilationStatus::SelectorCheckerWithCheckingContext);
-    return JSC::untagCFunctionPtr<RuleCollectorSelectorCheckerWithCheckingContext, CSSSelectorPtrTag>(executableAddress);
+    return WTF::untagCFunctionPtr<RuleCollectorSelectorCheckerWithCheckingContext, CSSSelectorPtrTag>(executableAddress);
 }
 
 inline QuerySelectorSelectorCheckerWithCheckingContext querySelectorSelectorCheckerFunctionWithCheckingContext(void* executableAddress, SelectorCompilationStatus compilationStatus)
 {
     ASSERT_UNUSED(compilationStatus, compilationStatus == SelectorCompilationStatus::SelectorCheckerWithCheckingContext);
-    return JSC::untagCFunctionPtr<QuerySelectorSelectorCheckerWithCheckingContext, CSSSelectorPtrTag>(executableAddress);
+    return WTF::untagCFunctionPtr<QuerySelectorSelectorCheckerWithCheckingContext, CSSSelectorPtrTag>(executableAddress);
 }
 
 } // namespace SelectorCompiler