Changeset 281544 in webkit


Ignore:
Timestamp:
Aug 24, 2021 8:47:18 PM (3 years ago)
Author:
mark.lam@apple.com
Message:

Refactor ENABLE(JIT_OPERATION_VALIDATION) code to emit no code when disabled.
https://bugs.webkit.org/show_bug.cgi?id=229482
rdar://82318317

Reviewed by Yusuke Suzuki.

Source/JavaScriptCore:

  • assembler/JITOperationList.cpp:

(JSC::addPointers):
(JSC::JITOperationList::populatePointersInJavaScriptCore):
(JSC::JITOperationList::populatePointersInJavaScriptCoreForLLInt):
(JSC::JITOperationList::populatePointersInEmbedder):

  • assembler/JITOperationList.h:

(JSC::JITOperationList::map const):
(JSC::JITOperationList::assertIsJITOperation):
(JSC::JITOperationList::initialize):
(JSC::JITOperationList::populatePointersInJavaScriptCore):
(JSC::JITOperationList::populatePointersInJavaScriptCoreForLLInt):

  • runtime/JSCPtrTag.h:

(JSC::tagJSCCodePtrImpl):
(JSC::untagJSCCodePtrImpl):

Source/WebCore:

  • bindings/js/WebCoreJITOperations.cpp:

(WebCore::populateJITOperations):

  • bindings/js/WebCoreJITOperations.h:

(WebCore::populateJITOperations):

  • testing/js/WebCoreTestSupport.cpp:

(WebCoreTestSupport::populateJITOperations):

  • testing/js/WebCoreTestSupport.h:

(WebCoreTestSupport::populateJITOperations):

Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r281541 r281544  
     12021-08-24  Mark Lam  <mark.lam@apple.com>
     2
     3        Refactor ENABLE(JIT_OPERATION_VALIDATION) code to emit no code when disabled.
     4        https://bugs.webkit.org/show_bug.cgi?id=229482
     5        rdar://82318317
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        * assembler/JITOperationList.cpp:
     10        (JSC::addPointers):
     11        (JSC::JITOperationList::populatePointersInJavaScriptCore):
     12        (JSC::JITOperationList::populatePointersInJavaScriptCoreForLLInt):
     13        (JSC::JITOperationList::populatePointersInEmbedder):
     14        * assembler/JITOperationList.h:
     15        (JSC::JITOperationList::map const):
     16        (JSC::JITOperationList::assertIsJITOperation):
     17        (JSC::JITOperationList::initialize):
     18        (JSC::JITOperationList::populatePointersInJavaScriptCore):
     19        (JSC::JITOperationList::populatePointersInJavaScriptCoreForLLInt):
     20        * runtime/JSCPtrTag.h:
     21        (JSC::tagJSCCodePtrImpl):
     22        (JSC::untagJSCCodePtrImpl):
     23
    1242021-08-24  Mark Lam  <mark.lam@apple.com>
    225
  • trunk/Source/JavaScriptCore/assembler/JITOperationList.cpp

    r270764 r281544  
    11/*
    2  * Copyright (C) 2020 Apple Inc. All rights reserved.
     2 * Copyright (C) 2020-2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3737namespace JSC {
    3838
     39#if ENABLE(JIT_OPERATION_VALIDATION)
     40
    3941LazyNeverDestroyed<JITOperationList> jitOperationList;
    4042
    41 #if ENABLE(JIT_OPERATION_VALIDATION)
    4243extern const uintptr_t startOfJITOperationsInJSC __asm("section$start$__DATA_CONST$__jsc_ops");
    4344extern const uintptr_t endOfJITOperationsInJSC __asm("section$end$__DATA_CONST$__jsc_ops");
    44 #endif
    4545
    4646void JITOperationList::initialize()
     
    4949}
    5050
    51 #if ENABLE(JIT_OPERATION_VALIDATION)
    5251static SUPPRESS_ASAN ALWAYS_INLINE void addPointers(HashMap<void*, void*>& map, const uintptr_t* beginOperations, const uintptr_t* endOperations)
    5352{
     
    6665    }
    6766}
    68 #endif
    6967
    7068void JITOperationList::populatePointersInJavaScriptCore()
    7169{
    72 #if ENABLE(JIT_OPERATION_VALIDATION)
    7370    static std::once_flag onceKey;
    7471    std::call_once(onceKey, [] {
     
    7673            addPointers(jitOperationList->m_validatedOperations, &startOfJITOperationsInJSC, &endOfJITOperationsInJSC);
    7774    });
    78 #endif
    7975}
    8076
    8177void JITOperationList::populatePointersInJavaScriptCoreForLLInt()
    8278{
    83 #if ENABLE(JIT_OPERATION_VALIDATION)
    8479    static std::once_flag onceKey;
    8580    std::call_once(onceKey, [] {
     
    125120#undef LLINT_RETURN_LOCATION
    126121    });
    127 #endif
    128122}
    129123
     
    133127    UNUSED_PARAM(beginOperations);
    134128    UNUSED_PARAM(endOperations);
    135 #if ENABLE(JIT_OPERATION_VALIDATION)
    136129    if (Options::useJIT())
    137130        addPointers(jitOperationList->m_validatedOperations, beginOperations, endOperations);
    138 #endif
    139131}
    140132
     133#endif // ENABLE(JIT_OPERATION_VALIDATION)
     134
    141135} // namespace JSC
  • trunk/Source/JavaScriptCore/assembler/JITOperationList.h

    r270764 r281544  
    11/*
    2  * Copyright (C) 2020 Apple Inc. All rights reserved.
     2 * Copyright (C) 2020-2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3333namespace JSC {
    3434
     35#if ENABLE(JIT_OPERATION_VALIDATION)
     36
    3537class JITOperationList {
    3638public:
     
    4042    void* map(void* pointer) const
    4143    {
    42 #if ENABLE(JIT_OPERATION_VALIDATION)
    4344        return m_validatedOperations.get(removeCodePtrTag(pointer));
    44 #else
    45         return pointer;
    46 #endif
    4745    }
    4846
     
    5553    {
    5654        UNUSED_PARAM(function);
    57 #if ENABLE(JIT_OPERATION_VALIDATION)
    5855        ASSERT(!Options::useJIT() || JITOperationList::instance().map(bitwise_cast<void*>(function)));
    59 #endif
    6056    }
    6157
     
    7167}
    7268
     69#else // not ENABLE(JIT_OPERATION_VALIDATION)
     70
     71class JITOperationList {
     72public:
     73    static void initialize() { }
     74
     75    static void populatePointersInJavaScriptCore() { }
     76    static void populatePointersInJavaScriptCoreForLLInt() { }
     77
     78    template<typename T> static void assertIsJITOperation(T) { }
     79};
     80
     81#endif // ENABLE(JIT_OPERATION_VALIDATION)
     82
    7383} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/JSCPtrTag.h

    r271594 r281544  
    128128    if constexpr (calleeType == PtrTagCalleeType::Native) {
    129129        static_assert(tag == OperationPtrTag);
    130         JITOperationList::instance().assertIsJITOperation(ptr);
     130        JITOperationList::assertIsJITOperation(ptr);
    131131#if ENABLE(JIT_CAGE)
    132132        if (Options::useJITCage())
     
    146146    if constexpr (calleeType == PtrTagCalleeType::Native) {
    147147        static_assert(tag == OperationPtrTag);
    148         JITOperationList::instance().assertIsJITOperation(ptr);
     148        JITOperationList::assertIsJITOperation(ptr);
    149149#if ENABLE(JIT_CAGE)
    150150        if (Options::useJITCage()) {
  • trunk/Source/WebCore/ChangeLog

    r281543 r281544  
     12021-08-24  Mark Lam  <mark.lam@apple.com>
     2
     3        Refactor ENABLE(JIT_OPERATION_VALIDATION) code to emit no code when disabled.
     4        https://bugs.webkit.org/show_bug.cgi?id=229482
     5        rdar://82318317
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        * bindings/js/WebCoreJITOperations.cpp:
     10        (WebCore::populateJITOperations):
     11        * bindings/js/WebCoreJITOperations.h:
     12        (WebCore::populateJITOperations):
     13        * testing/js/WebCoreTestSupport.cpp:
     14        (WebCoreTestSupport::populateJITOperations):
     15        * testing/js/WebCoreTestSupport.h:
     16        (WebCoreTestSupport::populateJITOperations):
     17
    1182021-08-24  Jean-Yves Avenard  <jya@apple.com>
    219
  • trunk/Source/WebCore/bindings/js/WebCoreJITOperations.cpp

    r270764 r281544  
    11/*
    2  * Copyright (C) 2020 Apple Inc. All rights reserved.
     2 * Copyright (C) 2020-2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3434extern const uintptr_t startOfJITOperationsInWebCore __asm("section$start$__DATA_CONST$__jsc_ops");
    3535extern const uintptr_t endOfJITOperationsInWebCore __asm("section$end$__DATA_CONST$__jsc_ops");
    36 #endif
    3736
    3837void populateJITOperations()
    3938{
    40 #if ENABLE(JIT_OPERATION_VALIDATION)
    4139    static std::once_flag onceKey;
    4240    std::call_once(onceKey, [] {
    4341        JSC::JITOperationList::populatePointersInEmbedder(&startOfJITOperationsInWebCore, &endOfJITOperationsInWebCore);
    4442    });
    45 #endif
    4643}
     44#endif // ENABLE(JIT_OPERATION_VALIDATION)
    4745
    4846}
  • trunk/Source/WebCore/bindings/js/WebCoreJITOperations.h

    r267938 r281544  
    11/*
    2  * Copyright (C) 2020 Apple Inc. All rights reserved.
     2 * Copyright (C) 2020-2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828namespace WebCore {
    2929
     30#if ENABLE(JIT_OPERATION_VALIDATION)
    3031WEBCORE_EXPORT void populateJITOperations();
     32#else
     33inline void populateJITOperations() { }
     34#endif
    3135
    3236}
  • trunk/Source/WebCore/testing/js/WebCoreTestSupport.cpp

    r280758 r281544  
    11/*
    22 * Copyright (C) 2011, 2015 Google Inc. All rights reserved.
    3  * Copyright (C) 2016-2020 Apple Inc. All rights reserved.
     3 * Copyright (C) 2016-2021 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    246246extern const uintptr_t startOfJITOperationsInWebCoreTestSupport __asm("section$start$__DATA_CONST$__jsc_ops");
    247247extern const uintptr_t endOfJITOperationsInWebCoreTestSupport __asm("section$end$__DATA_CONST$__jsc_ops");
    248 #endif
    249248
    250249void populateJITOperations()
    251250{
    252 #if ENABLE(JIT_OPERATION_VALIDATION)
    253251    static std::once_flag onceKey;
    254252    std::call_once(onceKey, [] {
    255253        JSC::JITOperationList::populatePointersInEmbedder(&startOfJITOperationsInWebCoreTestSupport, &endOfJITOperationsInWebCoreTestSupport);
    256254    });
    257 #endif
    258 }
    259 
    260 }
     255}
     256#endif // ENABLE(JIT_OPERATION_VALIDATION)
     257
     258}
  • trunk/Source/WebCore/testing/js/WebCoreTestSupport.h

    r268316 r281544  
    11/*
    22 * Copyright (C) 2011, 2015 Google Inc. All rights reserved.
    3  * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
     3 * Copyright (C) 2016-2021 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    6868void setAdditionalSupportedImageTypesForTesting(const WTF::String&) TEST_SUPPORT_EXPORT;
    6969
     70#if ENABLE(JIT_OPERATION_VALIDATION)
    7071void populateJITOperations() TEST_SUPPORT_EXPORT;
     72#else
     73inline void populateJITOperations() { }
     74#endif
    7175
    7276} // namespace WebCoreTestSupport
Note: See TracChangeset for help on using the changeset viewer.