Title: [261957] branches/safari-609-branch/Source
Revision
261957
Author
[email protected]
Date
2020-05-20 14:17:42 -0700 (Wed, 20 May 2020)

Log Message

Cherry-pick r261877. rdar://problem/63461428

    Put PtrTagLookup data structures in Configs for freezing.
    https://bugs.webkit.org/show_bug.cgi?id=212089
    <rdar://problem/63401487>

    Reviewed by Robin Morisset.

    Source/_javascript_Core:

    PtrTagLookup data structures were always meant to only be initialized once at
    initialization time and never modified thereafter.  This patch puts them in the
    Configs for freezing to document and enforce this invariant.

    * runtime/JSCConfig.h:
    * runtime/JSCPtrTag.cpp:
    (JSC::initializePtrTagLookup):

    Source/WTF:

    * wtf/PtrTag.cpp:
    (WTF::tagForPtr):
    (WTF::ptrTagName):
    (WTF::registerPtrTagLookup):
    * wtf/PtrTag.h:
    (WTF::PtrTagLookup::initialize):
    * wtf/WTFConfig.h:

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

Modified Paths

Diff

Modified: branches/safari-609-branch/Source/_javascript_Core/ChangeLog (261956 => 261957)


--- branches/safari-609-branch/Source/_javascript_Core/ChangeLog	2020-05-20 21:17:39 UTC (rev 261956)
+++ branches/safari-609-branch/Source/_javascript_Core/ChangeLog	2020-05-20 21:17:42 UTC (rev 261957)
@@ -1,5 +1,53 @@
 2020-05-20  Alan Coon  <[email protected]>
 
+        Cherry-pick r261877. rdar://problem/63461428
+
+    Put PtrTagLookup data structures in Configs for freezing.
+    https://bugs.webkit.org/show_bug.cgi?id=212089
+    <rdar://problem/63401487>
+    
+    Reviewed by Robin Morisset.
+    
+    Source/_javascript_Core:
+    
+    PtrTagLookup data structures were always meant to only be initialized once at
+    initialization time and never modified thereafter.  This patch puts them in the
+    Configs for freezing to document and enforce this invariant.
+    
+    * runtime/JSCConfig.h:
+    * runtime/JSCPtrTag.cpp:
+    (JSC::initializePtrTagLookup):
+    
+    Source/WTF:
+    
+    * wtf/PtrTag.cpp:
+    (WTF::tagForPtr):
+    (WTF::ptrTagName):
+    (WTF::registerPtrTagLookup):
+    * wtf/PtrTag.h:
+    (WTF::PtrTagLookup::initialize):
+    * wtf/WTFConfig.h:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261877 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-05-19  Mark Lam  <[email protected]>
+
+            Put PtrTagLookup data structures in Configs for freezing.
+            https://bugs.webkit.org/show_bug.cgi?id=212089
+            <rdar://problem/63401487>
+
+            Reviewed by Robin Morisset.
+
+            PtrTagLookup data structures were always meant to only be initialized once at
+            initialization time and never modified thereafter.  This patch puts them in the
+            Configs for freezing to document and enforce this invariant.
+
+            * runtime/JSCConfig.h:
+            * runtime/JSCPtrTag.cpp:
+            (JSC::initializePtrTagLookup):
+
+2020-05-20  Alan Coon  <[email protected]>
+
         Cherry-pick r261747. rdar://problem/63461445
 
     Remove debugging dataLogs in LinkBuffer::copyCompactAndLinkCode() for release builds.

Modified: branches/safari-609-branch/Source/_javascript_Core/runtime/JSCConfig.h (261956 => 261957)


--- branches/safari-609-branch/Source/_javascript_Core/runtime/JSCConfig.h	2020-05-20 21:17:39 UTC (rev 261956)
+++ branches/safari-609-branch/Source/_javascript_Core/runtime/JSCConfig.h	2020-05-20 21:17:42 UTC (rev 261957)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2019-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -26,6 +26,7 @@
 #pragma once
 
 #include "OptionsList.h"
+#include <wtf/PtrTag.h>
 #include <wtf/StdLibExtras.h>
 
 namespace JSC {
@@ -85,6 +86,8 @@
             OptionsStorage options;
 
             void (*shellTimeoutCheckCallback)(VM&);
+
+            WTF::PtrTagLookup ptrTagLookupRecord;
         };
         char ensureSize[ConfigSizeToProtect];
     };

Modified: branches/safari-609-branch/Source/_javascript_Core/runtime/JSCPtrTag.cpp (261956 => 261957)


--- branches/safari-609-branch/Source/_javascript_Core/runtime/JSCPtrTag.cpp	2020-05-20 21:17:39 UTC (rev 261956)
+++ branches/safari-609-branch/Source/_javascript_Core/runtime/JSCPtrTag.cpp	2020-05-20 21:17:42 UTC (rev 261957)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2018-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "JSCPtrTag.h"
 
+#include "JSCConfig.h"
+
 namespace JSC {
 
 #if CPU(ARM64E)
@@ -52,7 +54,8 @@
 
 void initializePtrTagLookup()
 {
-    static WTF::PtrTagLookup lookup = { tagForPtr, ptrTagName };
+    WTF::PtrTagLookup& lookup = g_jscConfig.ptrTagLookupRecord;
+    lookup.initialize(tagForPtr, ptrTagName);
     WTF::registerPtrTagLookup(&lookup);
 }
 

Modified: branches/safari-609-branch/Source/WTF/ChangeLog (261956 => 261957)


--- branches/safari-609-branch/Source/WTF/ChangeLog	2020-05-20 21:17:39 UTC (rev 261956)
+++ branches/safari-609-branch/Source/WTF/ChangeLog	2020-05-20 21:17:42 UTC (rev 261957)
@@ -1,5 +1,53 @@
 2020-05-20  Alan Coon  <[email protected]>
 
+        Cherry-pick r261877. rdar://problem/63461428
+
+    Put PtrTagLookup data structures in Configs for freezing.
+    https://bugs.webkit.org/show_bug.cgi?id=212089
+    <rdar://problem/63401487>
+    
+    Reviewed by Robin Morisset.
+    
+    Source/_javascript_Core:
+    
+    PtrTagLookup data structures were always meant to only be initialized once at
+    initialization time and never modified thereafter.  This patch puts them in the
+    Configs for freezing to document and enforce this invariant.
+    
+    * runtime/JSCConfig.h:
+    * runtime/JSCPtrTag.cpp:
+    (JSC::initializePtrTagLookup):
+    
+    Source/WTF:
+    
+    * wtf/PtrTag.cpp:
+    (WTF::tagForPtr):
+    (WTF::ptrTagName):
+    (WTF::registerPtrTagLookup):
+    * wtf/PtrTag.h:
+    (WTF::PtrTagLookup::initialize):
+    * wtf/WTFConfig.h:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261877 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-05-19  Mark Lam  <[email protected]>
+
+            Put PtrTagLookup data structures in Configs for freezing.
+            https://bugs.webkit.org/show_bug.cgi?id=212089
+            <rdar://problem/63401487>
+
+            Reviewed by Robin Morisset.
+
+            * wtf/PtrTag.cpp:
+            (WTF::tagForPtr):
+            (WTF::ptrTagName):
+            (WTF::registerPtrTagLookup):
+            * wtf/PtrTag.h:
+            (WTF::PtrTagLookup::initialize):
+            * wtf/WTFConfig.h:
+
+2020-05-20  Alan Coon  <[email protected]>
+
         Cherry-pick r261870. rdar://problem/63461429
 
     Remove unnecessary debug logging from release builds.

Modified: branches/safari-609-branch/Source/WTF/wtf/PtrTag.cpp (261956 => 261957)


--- branches/safari-609-branch/Source/WTF/wtf/PtrTag.cpp	2020-05-20 21:17:39 UTC (rev 261956)
+++ branches/safari-609-branch/Source/WTF/wtf/PtrTag.cpp	2020-05-20 21:17:42 UTC (rev 261957)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2018-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -26,15 +26,15 @@
 #include "config.h"
 #include <wtf/PtrTag.h>
 
+#include <wtf/WTFConfig.h>
+
 namespace WTF {
 
 #if CPU(ARM64E)
 
-static PtrTagLookup* s_ptrTagLookup = nullptr;
-
 static const char* tagForPtr(const void* ptr)
 {
-    PtrTagLookup* lookup = s_ptrTagLookup;
+    PtrTagLookup* lookup = g_wtfConfig.ptrTagLookupHead;
     while (lookup) {
         const char* tagName = lookup->tagForPtr(ptr);
         if (tagName)
@@ -56,7 +56,7 @@
 
 static const char* ptrTagName(PtrTag tag)
 {
-    PtrTagLookup* lookup = s_ptrTagLookup;
+    PtrTagLookup* lookup = g_wtfConfig.ptrTagLookupHead;
     while (lookup) {
         const char* tagName = lookup->ptrTagName(tag);
         if (tagName)
@@ -74,8 +74,8 @@
 
 void registerPtrTagLookup(PtrTagLookup* lookup)
 {
-    lookup->next = s_ptrTagLookup;
-    s_ptrTagLookup = lookup;
+    lookup->next = g_wtfConfig.ptrTagLookupHead;
+    g_wtfConfig.ptrTagLookupHead = lookup;
 }
 
 void reportBadTag(const void* ptr, PtrTag expectedTag)

Modified: branches/safari-609-branch/Source/WTF/wtf/PtrTag.h (261956 => 261957)


--- branches/safari-609-branch/Source/WTF/wtf/PtrTag.h	2020-05-20 21:17:39 UTC (rev 261956)
+++ branches/safari-609-branch/Source/WTF/wtf/PtrTag.h	2020-05-20 21:17:42 UTC (rev 261957)
@@ -85,9 +85,18 @@
 #endif
 
 struct PtrTagLookup {
-    const char* (*tagForPtr)(const void*);
-    const char* (*ptrTagName)(PtrTag);
-    PtrTagLookup* next { nullptr };
+    using TagForPtrFunc = const char* (*)(const void*);
+    using PtrTagNameFunc = const char* (*)(PtrTag);
+
+    void initialize(TagForPtrFunc tagForPtr, PtrTagNameFunc ptrTagName)
+    {
+        this->tagForPtr = tagForPtr;
+        this->ptrTagName = ptrTagName;
+    }
+
+    TagForPtrFunc tagForPtr;
+    PtrTagNameFunc ptrTagName;
+    PtrTagLookup* next;
 };
 
 #if CPU(ARM64E)

Modified: branches/safari-609-branch/Source/WTF/wtf/WTFConfig.h (261956 => 261957)


--- branches/safari-609-branch/Source/WTF/wtf/WTFConfig.h	2020-05-20 21:17:39 UTC (rev 261956)
+++ branches/safari-609-branch/Source/WTF/wtf/WTFConfig.h	2020-05-20 21:17:42 UTC (rev 261957)
@@ -29,6 +29,7 @@
 #include <wtf/Atomics.h>
 #include <wtf/ExportMacros.h>
 #include <wtf/PageBlock.h>
+#include <wtf/PtrTag.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/threads/Signals.h>
 
@@ -61,6 +62,7 @@
 #if USE(PTHREADS) && HAVE(MACHINE_CONTEXT)
             SignalHandlers signalHandlers;
 #endif
+            PtrTagLookup* ptrTagLookupHead;
         };
         char ensureSize[ConfigSizeToProtect];
     };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to