Diff
Modified: trunk/Source/_javascript_Core/CMakeLists.txt (229816 => 229817)
--- trunk/Source/_javascript_Core/CMakeLists.txt 2018-03-21 18:44:35 UTC (rev 229816)
+++ trunk/Source/_javascript_Core/CMakeLists.txt 2018-03-21 19:33:01 UTC (rev 229817)
@@ -83,6 +83,7 @@
runtime/NumberConstructor.cpp
runtime/NumberPrototype.cpp
runtime/ObjectConstructor.cpp
+ runtime/PtrTag.cpp
runtime/ReflectObject.cpp
runtime/RegExpConstructor.cpp
runtime/RegExpPrototype.cpp
Modified: trunk/Source/_javascript_Core/ChangeLog (229816 => 229817)
--- trunk/Source/_javascript_Core/ChangeLog 2018-03-21 18:44:35 UTC (rev 229816)
+++ trunk/Source/_javascript_Core/ChangeLog 2018-03-21 19:33:01 UTC (rev 229817)
@@ -1,5 +1,23 @@
2018-03-21 Mark Lam <[email protected]>
+ Refactor the PtrTag list as a macro so that we can auto-generate code that enumerates each PtrTag.
+ https://bugs.webkit.org/show_bug.cgi?id=183861
+ <rdar://problem/38716822>
+
+ Reviewed by Filip Pizlo.
+
+ Also added ptrTagName() to aid debugging. ptrTagName() is implemented using this
+ new PtrTag macro list.
+
+ * CMakeLists.txt:
+ * _javascript_Core.xcodeproj/project.pbxproj:
+ * Sources.txt:
+ * runtime/PtrTag.cpp: Added.
+ (JSC::ptrTagName):
+ * runtime/PtrTag.h:
+
+2018-03-21 Mark Lam <[email protected]>
+
Use CodeBlock::instructions()[] and CodeBlock::bytecodeOffset() instead of doing own pointer math.
https://bugs.webkit.org/show_bug.cgi?id=183857
<rdar://problem/38712184>
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (229816 => 229817)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2018-03-21 18:44:35 UTC (rev 229816)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2018-03-21 19:33:01 UTC (rev 229817)
@@ -4702,6 +4702,7 @@
FE6491381D78F3A300A694D4 /* ExceptionScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExceptionScope.cpp; sourceTree = "<group>"; };
FE68C6351B90DDD90042BCB3 /* MacroAssemblerPrinter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MacroAssemblerPrinter.cpp; sourceTree = "<group>"; };
FE68C6361B90DDD90042BCB3 /* MacroAssemblerPrinter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerPrinter.h; sourceTree = "<group>"; };
+ FE6C1E57203FF6E200BDC2B7 /* PtrTag.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PtrTag.cpp; 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>"; };
FE80C1961D775B27008510C0 /* CatchScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CatchScope.h; sourceTree = "<group>"; };
@@ -6879,6 +6880,7 @@
79B00CBB1C6AB07E0088C65D /* ProxyObject.h */,
79160DBB1C8E3EC8008C085A /* ProxyRevoke.cpp */,
79160DBC1C8E3EC8008C085A /* ProxyRevoke.h */,
+ FE6C1E57203FF6E200BDC2B7 /* PtrTag.cpp */,
FE9AE1C82032C887002B6934 /* PtrTag.h */,
0F5780A118FE1E98001E72D9 /* PureNaN.h */,
0F0CD4C015F1A6040032F1C0 /* PutDirectIndexMode.h */,
Modified: trunk/Source/_javascript_Core/Sources.txt (229816 => 229817)
--- trunk/Source/_javascript_Core/Sources.txt 2018-03-21 18:44:35 UTC (rev 229816)
+++ trunk/Source/_javascript_Core/Sources.txt 2018-03-21 19:33:01 UTC (rev 229817)
@@ -872,6 +872,7 @@
runtime/ObjectPrototype.cpp
runtime/Operations.cpp
runtime/Options.cpp
+runtime/PtrTag.cpp
runtime/ProgramExecutable.cpp
runtime/PromiseDeferredTimer.cpp
runtime/PropertyDescriptor.cpp
Added: trunk/Source/_javascript_Core/runtime/PtrTag.cpp (0 => 229817)
--- trunk/Source/_javascript_Core/runtime/PtrTag.cpp (rev 0)
+++ trunk/Source/_javascript_Core/runtime/PtrTag.cpp 2018-03-21 19:33:01 UTC (rev 229817)
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "PtrTag.h"
+
+#include <algorithm>
+
+namespace JSC {
+
+const char* ptrTagName(PtrTag tag)
+{
+#define HANDLE_PTRTAG_CASE(_tagName) case _tagName: return #_tagName;
+
+ switch (tag) {
+ FOR_EACH_PTRTAG_ENUM(HANDLE_PTRTAG_CASE)
+ default: return "<unknown>";
+ }
+
+#undef HANDLE_PTRTAG_CASE
+}
+
+} // namespace JSC
Modified: trunk/Source/_javascript_Core/runtime/PtrTag.h (229816 => 229817)
--- trunk/Source/_javascript_Core/runtime/PtrTag.h 2018-03-21 18:44:35 UTC (rev 229816)
+++ trunk/Source/_javascript_Core/runtime/PtrTag.h 2018-03-21 19:33:01 UTC (rev 229817)
@@ -29,31 +29,42 @@
namespace JSC {
+#define FOR_EACH_PTRTAG_ENUM(v) \
+ v(NoPtrTag) \
+ v(NearCallPtrTag) \
+ v(NearJumpPtrTag) \
+ v(CFunctionPtrTag) \
+ \
+ v(BytecodePtrTag) \
+ v(BytecodeHelperPtrTag) \
+ v(CodeEntryPtrTag) \
+ v(CodeEntryWithArityCheckPtrTag) \
+ v(ExceptionHandlerPtrTag) \
+ v(JITCodePtrTag) \
+ v(JITOperationPtrTag) \
+ v(JITThunkPtrTag) \
+ v(NativeCodePtrTag) \
+ v(SlowPathPtrTag) \
+ \
+ v(Yarr8BitPtrTag) \
+ v(Yarr16BitPtrTag) \
+ v(YarrMatchOnly8BitPtrTag) \
+ v(YarrMatchOnly16BitPtrTag) \
+ v(YarrBacktrackPtrTag) \
+
+
enum PtrTag : uintptr_t {
- NoPtrTag = 0,
- NearCallPtrTag,
- NearJumpPtrTag,
+#define DECLARE_PTRTAG_ENUM(tag) tag,
+ FOR_EACH_PTRTAG_ENUM(DECLARE_PTRTAG_ENUM)
+#undef DECLARE_PTRTAG_ENUM
+};
- CFunctionPtrTag,
+static_assert(static_cast<uintptr_t>(NoPtrTag) == static_cast<uintptr_t>(0), "");
+static_assert(static_cast<uintptr_t>(NearCallPtrTag) == static_cast<uintptr_t>(1), "");
+static_assert(static_cast<uintptr_t>(NearJumpPtrTag) == static_cast<uintptr_t>(2), "");
- BytecodePtrTag,
- BytecodeHelperPtrTag,
- CodeEntryPtrTag,
- CodeEntryWithArityCheckPtrTag,
- ExceptionHandlerPtrTag,
- JITCodePtrTag,
- JITOperationPtrTag,
- JITThunkPtrTag,
- NativeCodePtrTag,
- SlowPathPtrTag,
+JS_EXPORT_PRIVATE const char* ptrTagName(PtrTag);
- Yarr8BitPtrTag,
- Yarr16BitPtrTag,
- YarrMatchOnly8BitPtrTag,
- YarrMatchOnly16BitPtrTag,
- YarrBacktrackPtrTag,
-};
-
uintptr_t nextPtrTagID();
#if !USE(POINTER_PROFILING)