Title: [261877] trunk/Source
Revision
261877
Author
[email protected]
Date
2020-05-19 11:49:07 -0700 (Tue, 19 May 2020)

Log Message

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:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (261876 => 261877)


--- trunk/Source/_javascript_Core/ChangeLog	2020-05-19 18:41:14 UTC (rev 261876)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-05-19 18:49:07 UTC (rev 261877)
@@ -1,3 +1,19 @@
+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-19  Youenn Fablet  <[email protected]>
 
         [ Mac wk1 Debug ] imported/w3c/web-platform-tests/fetch/api/basic/stream-safe-creation.any.html  is flaky crashing with alerts - WTFCrashWithInfo - SC::JSObject::get(JSC::JSGlobalObject*, JSC::PropertyName)

Modified: trunk/Source/_javascript_Core/runtime/JSCConfig.h (261876 => 261877)


--- trunk/Source/_javascript_Core/runtime/JSCConfig.h	2020-05-19 18:41:14 UTC (rev 261876)
+++ trunk/Source/_javascript_Core/runtime/JSCConfig.h	2020-05-19 18:49:07 UTC (rev 261877)
@@ -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
@@ -27,6 +27,7 @@
 
 #include "OptionsList.h"
 #include <wtf/PageBlock.h>
+#include <wtf/PtrTag.h>
 #include <wtf/StdLibExtras.h>
 
 namespace JSC {
@@ -80,6 +81,8 @@
             OptionsStorage options;
 
             void (*shellTimeoutCheckCallback)(VM&);
+
+            WTF::PtrTagLookup ptrTagLookupRecord;
         };
         char ensureSize[ConfigSizeToProtect];
     };

Modified: trunk/Source/_javascript_Core/runtime/JSCPtrTag.cpp (261876 => 261877)


--- trunk/Source/_javascript_Core/runtime/JSCPtrTag.cpp	2020-05-19 18:41:14 UTC (rev 261876)
+++ trunk/Source/_javascript_Core/runtime/JSCPtrTag.cpp	2020-05-19 18:49:07 UTC (rev 261877)
@@ -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: trunk/Source/WTF/ChangeLog (261876 => 261877)


--- trunk/Source/WTF/ChangeLog	2020-05-19 18:41:14 UTC (rev 261876)
+++ trunk/Source/WTF/ChangeLog	2020-05-19 18:49:07 UTC (rev 261877)
@@ -1,5 +1,21 @@
 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-19  Mark Lam  <[email protected]>
+
         Remove unnecessary debug logging from release builds.
         https://bugs.webkit.org/show_bug.cgi?id=212084
         <rdar://problem/63398704>

Modified: trunk/Source/WTF/wtf/PtrTag.cpp (261876 => 261877)


--- trunk/Source/WTF/wtf/PtrTag.cpp	2020-05-19 18:41:14 UTC (rev 261876)
+++ trunk/Source/WTF/wtf/PtrTag.cpp	2020-05-19 18:49:07 UTC (rev 261877)
@@ -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: trunk/Source/WTF/wtf/PtrTag.h (261876 => 261877)


--- trunk/Source/WTF/wtf/PtrTag.h	2020-05-19 18:41:14 UTC (rev 261876)
+++ trunk/Source/WTF/wtf/PtrTag.h	2020-05-19 18:49:07 UTC (rev 261877)
@@ -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: trunk/Source/WTF/wtf/WTFConfig.h (261876 => 261877)


--- trunk/Source/WTF/wtf/WTFConfig.h	2020-05-19 18:41:14 UTC (rev 261876)
+++ trunk/Source/WTF/wtf/WTFConfig.h	2020-05-19 18:49:07 UTC (rev 261877)
@@ -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>
 
@@ -55,6 +56,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