Title: [287458] trunk/Source/_javascript_Core
Revision
287458
Author
ysuz...@apple.com
Date
2021-12-26 23:46:43 -0800 (Sun, 26 Dec 2021)

Log Message

[JSC] Use SlowPathReturnType instead of EncodedMatchResult
https://bugs.webkit.org/show_bug.cgi?id=234686

Reviewed by Filip Pizlo.

This patch replaces YarrJIT's EncodedMatchResult with SlowPathReturnType so that
CCallHelpers can handle it correctly.

* runtime/MatchResult.h:
(JSC::MatchResult::MatchResult):
(JSC::MatchResult::failed):
* runtime/SlowPathReturnType.h:
(JSC::decodeResult):
* yarr/YarrJIT.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (287457 => 287458)


--- trunk/Source/_javascript_Core/ChangeLog	2021-12-27 07:38:42 UTC (rev 287457)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-12-27 07:46:43 UTC (rev 287458)
@@ -1,3 +1,20 @@
+2021-12-26  Yusuke Suzuki  <ysuz...@apple.com>
+
+        [JSC] Use SlowPathReturnType instead of EncodedMatchResult
+        https://bugs.webkit.org/show_bug.cgi?id=234686
+
+        Reviewed by Filip Pizlo.
+
+        This patch replaces YarrJIT's EncodedMatchResult with SlowPathReturnType so that
+        CCallHelpers can handle it correctly.
+
+        * runtime/MatchResult.h:
+        (JSC::MatchResult::MatchResult):
+        (JSC::MatchResult::failed):
+        * runtime/SlowPathReturnType.h:
+        (JSC::decodeResult):
+        * yarr/YarrJIT.h:
+
 2021-12-23  Mark Lam  <mark....@apple.com>
 
         Make DeferredWorkTimer::addPendingWork() return a Ticket.

Modified: trunk/Source/_javascript_Core/runtime/MatchResult.h (287457 => 287458)


--- trunk/Source/_javascript_Core/runtime/MatchResult.h	2021-12-27 07:38:42 UTC (rev 287457)
+++ trunk/Source/_javascript_Core/runtime/MatchResult.h	2021-12-27 07:46:43 UTC (rev 287458)
@@ -25,28 +25,15 @@
 
 #pragma once
 
+#include "SlowPathReturnType.h"
 #include <wtf/NotFound.h>
 #include <wtf/PrintStream.h>
 
 namespace JSC {
 
-struct MatchResult;
-#if CPU(ADDRESS32)
-using EncodedMatchResult = uint64_t;
-#else
-struct EncodedMatchResult {
-    size_t start;
-    size_t end;
-};
-#endif
+struct MatchResult {
+    constexpr MatchResult() = default;
 
-struct MatchResult {
-    MatchResult()
-        : start(WTF::notFound)
-        , end(0)
-    {
-    }
-    
     ALWAYS_INLINE MatchResult(size_t start, size_t end)
         : start(start)
         , end(end)
@@ -53,21 +40,12 @@
     {
     }
 
-#if CPU(ADDRESS32)
-    ALWAYS_INLINE MatchResult(EncodedMatchResult match)
-        : start(bitwise_cast<MatchResult>(match).start)
-        , end(bitwise_cast<MatchResult>(match).end)
+    ALWAYS_INLINE MatchResult(SlowPathReturnType match)
     {
+        decodeResult(match, start, end);
     }
-#else
-    ALWAYS_INLINE MatchResult(EncodedMatchResult match)
-        : start(match.start)
-        , end(match.end)
-    {
-    }
-#endif
 
-    ALWAYS_INLINE static MatchResult failed()
+    ALWAYS_INLINE static constexpr MatchResult failed()
     {
         return MatchResult();
     }
@@ -84,11 +62,13 @@
     
     void dump(PrintStream&) const;
 
-    size_t start;
-    size_t end;
+    size_t start { WTF::notFound };
+    size_t end { 0 };
 };
 
-static_assert(sizeof(EncodedMatchResult) == 2 * sizeof(size_t), "https://bugs.webkit.org/show_bug.cgi?id=198518#c11");
-static_assert(sizeof(MatchResult) == sizeof(EncodedMatchResult), "Match result and EncodedMatchResult should be the same size");
+#if ENABLE(JIT)
+static_assert(sizeof(SlowPathReturnType) == 2 * sizeof(size_t), "https://bugs.webkit.org/show_bug.cgi?id=198518#c11");
+static_assert(sizeof(MatchResult) == sizeof(SlowPathReturnType), "Match result and SlowPathReturnType should be the same size");
+#endif
 
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/runtime/SlowPathReturnType.h (287457 => 287458)


--- trunk/Source/_javascript_Core/runtime/SlowPathReturnType.h	2021-12-27 07:38:42 UTC (rev 287457)
+++ trunk/Source/_javascript_Core/runtime/SlowPathReturnType.h	2021-12-27 07:46:43 UTC (rev 287458)
@@ -54,6 +54,12 @@
     b = reinterpret_cast<void*>(result.b);
 }
 
+inline void decodeResult(SlowPathReturnType result, size_t& a, size_t& b)
+{
+    a = static_cast<size_t>(result.a);
+    b = static_cast<size_t>(result.b);
+}
+
 #else // USE(JSVALUE32_64)
 typedef int64_t SlowPathReturnType;
 
@@ -80,6 +86,14 @@
     a = u.pair.a;
     b = u.pair.b;
 }
+
+inline void decodeResult(SlowPathReturnType result, size_t& a, size_t& b)
+{
+    SlowPathReturnTypeEncoding u;
+    u.i = result;
+    a = bitwise_cast<size_t>(u.pair.a);
+    b = bitwise_cast<size_t>(u.pair.b);
+}
 #endif // USE(JSVALUE32_64)
 
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/yarr/YarrJIT.h (287457 => 287458)


--- trunk/Source/_javascript_Core/yarr/YarrJIT.h	2021-12-27 07:38:42 UTC (rev 287457)
+++ trunk/Source/_javascript_Core/yarr/YarrJIT.h	2021-12-27 07:46:43 UTC (rev 287458)
@@ -198,7 +198,7 @@
 };
 
 #if CPU(ARM64E)
-extern "C" EncodedMatchResult vmEntryToYarrJIT(const void* input, UCPURegister start, UCPURegister length, int* output, MatchingContextHolder* matchingContext, const void* codePtr);
+extern "C" SlowPathReturnType vmEntryToYarrJIT(const void* input, UCPURegister start, UCPURegister length, int* output, MatchingContextHolder* matchingContext, const void* codePtr);
 extern "C" void vmEntryToYarrJITAfter(void);
 #endif
 
@@ -271,10 +271,10 @@
     WTF_MAKE_FAST_ALLOCATED;
     WTF_MAKE_NONCOPYABLE(YarrCodeBlock);
 
-    using YarrJITCode8 = EncodedMatchResult (*)(const LChar* input, UCPURegister start, UCPURegister length, int* output, MatchingContextHolder& matchingContext) YARR_CALL;
-    using YarrJITCode16 = EncodedMatchResult (*)(const UChar* input, UCPURegister start, UCPURegister length, int* output, MatchingContextHolder& matchingContext) YARR_CALL;
-    using YarrJITCodeMatchOnly8 = EncodedMatchResult (*)(const LChar* input, UCPURegister start, UCPURegister length, void*, MatchingContextHolder& matchingContext) YARR_CALL;
-    using YarrJITCodeMatchOnly16 = EncodedMatchResult (*)(const UChar* input, UCPURegister start, UCPURegister length, void*, MatchingContextHolder& matchingContext) YARR_CALL;
+    using YarrJITCode8 = SlowPathReturnType (*)(const LChar* input, UCPURegister start, UCPURegister length, int* output, MatchingContextHolder& matchingContext) YARR_CALL;
+    using YarrJITCode16 = SlowPathReturnType (*)(const UChar* input, UCPURegister start, UCPURegister length, int* output, MatchingContextHolder& matchingContext) YARR_CALL;
+    using YarrJITCodeMatchOnly8 = SlowPathReturnType (*)(const LChar* input, UCPURegister start, UCPURegister length, void*, MatchingContextHolder& matchingContext) YARR_CALL;
+    using YarrJITCodeMatchOnly16 = SlowPathReturnType (*)(const UChar* input, UCPURegister start, UCPURegister length, void*, MatchingContextHolder& matchingContext) YARR_CALL;
 
 public:
     YarrCodeBlock() = default;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to