Changeset 261877 in webkit


Ignore:
Timestamp:
May 19, 2020 11:49:07 AM (4 years ago)
Author:
mark.lam@apple.com
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/JavaScriptCore:

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:
Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r261857 r261877  
     12020-05-19  Mark Lam  <mark.lam@apple.com>
     2
     3        Put PtrTagLookup data structures in Configs for freezing.
     4        https://bugs.webkit.org/show_bug.cgi?id=212089
     5        <rdar://problem/63401487>
     6
     7        Reviewed by Robin Morisset.
     8
     9        PtrTagLookup data structures were always meant to only be initialized once at
     10        initialization time and never modified thereafter.  This patch puts them in the
     11        Configs for freezing to document and enforce this invariant.
     12
     13        * runtime/JSCConfig.h:
     14        * runtime/JSCPtrTag.cpp:
     15        (JSC::initializePtrTagLookup):
     16
    1172020-05-19  Youenn Fablet  <youenn@apple.com>
    218
  • trunk/Source/JavaScriptCore/runtime/JSCConfig.h

    r258857 r261877  
    11/*
    2  * Copyright (C) 2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828#include "OptionsList.h"
    2929#include <wtf/PageBlock.h>
     30#include <wtf/PtrTag.h>
    3031#include <wtf/StdLibExtras.h>
    3132
     
    8182
    8283            void (*shellTimeoutCheckCallback)(VM&);
     84
     85            WTF::PtrTagLookup ptrTagLookupRecord;
    8386        };
    8487        char ensureSize[ConfigSizeToProtect];
  • trunk/Source/JavaScriptCore/runtime/JSCPtrTag.cpp

    r251372 r261877  
    11/*
    2  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2018-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#include "config.h"
    2727#include "JSCPtrTag.h"
     28
     29#include "JSCConfig.h"
    2830
    2931namespace JSC {
     
    5355void initializePtrTagLookup()
    5456{
    55     static WTF::PtrTagLookup lookup = { tagForPtr, ptrTagName };
     57    WTF::PtrTagLookup& lookup = g_jscConfig.ptrTagLookupRecord;
     58    lookup.initialize(tagForPtr, ptrTagName);
    5659    WTF::registerPtrTagLookup(&lookup);
    5760}
  • trunk/Source/WTF/ChangeLog

    r261870 r261877  
     12020-05-19  Mark Lam  <mark.lam@apple.com>
     2
     3        Put PtrTagLookup data structures in Configs for freezing.
     4        https://bugs.webkit.org/show_bug.cgi?id=212089
     5        <rdar://problem/63401487>
     6
     7        Reviewed by Robin Morisset.
     8
     9        * wtf/PtrTag.cpp:
     10        (WTF::tagForPtr):
     11        (WTF::ptrTagName):
     12        (WTF::registerPtrTagLookup):
     13        * wtf/PtrTag.h:
     14        (WTF::PtrTagLookup::initialize):
     15        * wtf/WTFConfig.h:
     16
    1172020-05-19  Mark Lam  <mark.lam@apple.com>
    218
  • trunk/Source/WTF/wtf/PtrTag.cpp

    r251372 r261877  
    11/*
    2  * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2018-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2727#include <wtf/PtrTag.h>
    2828
     29#include <wtf/WTFConfig.h>
     30
    2931namespace WTF {
    3032
    3133#if CPU(ARM64E)
    3234
    33 static PtrTagLookup* s_ptrTagLookup = nullptr;
    34 
    3535static const char* tagForPtr(const void* ptr)
    3636{
    37     PtrTagLookup* lookup = s_ptrTagLookup;
     37    PtrTagLookup* lookup = g_wtfConfig.ptrTagLookupHead;
    3838    while (lookup) {
    3939        const char* tagName = lookup->tagForPtr(ptr);
     
    5757static const char* ptrTagName(PtrTag tag)
    5858{
    59     PtrTagLookup* lookup = s_ptrTagLookup;
     59    PtrTagLookup* lookup = g_wtfConfig.ptrTagLookupHead;
    6060    while (lookup) {
    6161        const char* tagName = lookup->ptrTagName(tag);
     
    7575void registerPtrTagLookup(PtrTagLookup* lookup)
    7676{
    77     lookup->next = s_ptrTagLookup;
    78     s_ptrTagLookup = lookup;
     77    lookup->next = g_wtfConfig.ptrTagLookupHead;
     78    g_wtfConfig.ptrTagLookupHead = lookup;
    7979}
    8080
  • trunk/Source/WTF/wtf/PtrTag.h

    r261870 r261877  
    8686
    8787struct PtrTagLookup {
    88     const char* (*tagForPtr)(const void*);
    89     const char* (*ptrTagName)(PtrTag);
    90     PtrTagLookup* next { nullptr };
     88    using TagForPtrFunc = const char* (*)(const void*);
     89    using PtrTagNameFunc = const char* (*)(PtrTag);
     90
     91    void initialize(TagForPtrFunc tagForPtr, PtrTagNameFunc ptrTagName)
     92    {
     93        this->tagForPtr = tagForPtr;
     94        this->ptrTagName = ptrTagName;
     95    }
     96
     97    TagForPtrFunc tagForPtr;
     98    PtrTagNameFunc ptrTagName;
     99    PtrTagLookup* next;
    91100};
    92101
  • trunk/Source/WTF/wtf/WTFConfig.h

    r261538 r261877  
    3030#include <wtf/ExportMacros.h>
    3131#include <wtf/PageBlock.h>
     32#include <wtf/PtrTag.h>
    3233#include <wtf/StdLibExtras.h>
    3334#include <wtf/threads/Signals.h>
     
    5657            SignalHandlers signalHandlers;
    5758#endif
     59            PtrTagLookup* ptrTagLookupHead;
    5860        };
    5961        char ensureSize[ConfigSizeToProtect];
Note: See TracChangeset for help on using the changeset viewer.