Changeset 229367 in webkit


Ignore:
Timestamp:
Mar 7, 2018 10:21:41 AM (6 years ago)
Author:
mark.lam@apple.com
Message:

Simplify the variants of FunctionPtr constructors.
https://bugs.webkit.org/show_bug.cgi?id=183399
<rdar://problem/38212980>

Reviewed by Yusuke Suzuki.

  • assembler/MacroAssemblerCodeRef.h:

(JSC::FunctionPtr::FunctionPtr):

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r229366 r229367  
     12018-03-07  Mark Lam  <mark.lam@apple.com>
     2
     3        Simplify the variants of FunctionPtr constructors.
     4        https://bugs.webkit.org/show_bug.cgi?id=183399
     5        <rdar://problem/38212980>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        * assembler/MacroAssemblerCodeRef.h:
     10        (JSC::FunctionPtr::FunctionPtr):
     11
    1122018-03-06  Filip Pizlo  <fpizlo@apple.com>
    213
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerCodeRef.h

    r229125 r229367  
    6464    FunctionPtr() { }
    6565
    66     template<typename returnType>
    67     FunctionPtr(returnType(*value)())
    68         : m_value((void*)value)
    69     {
    70         PoisonedMasmPtr::assertIsNotPoisoned(m_value);
    71         ASSERT_VALID_CODE_POINTER(m_value);
    72     }
    73 
    74     template<typename returnType, typename argType1>
    75     FunctionPtr(returnType(*value)(argType1))
    76         : m_value((void*)value)
    77     {
    78         PoisonedMasmPtr::assertIsNotPoisoned(m_value);
    79         ASSERT_VALID_CODE_POINTER(m_value);
    80     }
    81 
    82     template<typename returnType, typename argType1, typename argType2>
    83     FunctionPtr(returnType(*value)(argType1, argType2))
    84         : m_value((void*)value)
    85     {
    86         PoisonedMasmPtr::assertIsNotPoisoned(m_value);
    87         ASSERT_VALID_CODE_POINTER(m_value);
    88     }
    89 
    90     template<typename returnType, typename argType1, typename argType2, typename argType3>
    91     FunctionPtr(returnType(*value)(argType1, argType2, argType3))
    92         : m_value((void*)value)
    93     {
    94         PoisonedMasmPtr::assertIsNotPoisoned(m_value);
    95         ASSERT_VALID_CODE_POINTER(m_value);
    96     }
    97 
    98     template<typename returnType, typename argType1, typename argType2, typename argType3, typename argType4>
    99     FunctionPtr(returnType(*value)(argType1, argType2, argType3, argType4))
    100         : m_value((void*)value)
    101     {
    102         PoisonedMasmPtr::assertIsNotPoisoned(m_value);
    103         ASSERT_VALID_CODE_POINTER(m_value);
    104     }
    105 
    106     template<typename returnType, typename argType1, typename argType2, typename argType3, typename argType4, typename argType5>
    107     FunctionPtr(returnType(*value)(argType1, argType2, argType3, argType4, argType5))
    108         : m_value((void*)value)
    109     {
    110         PoisonedMasmPtr::assertIsNotPoisoned(m_value);
    111         ASSERT_VALID_CODE_POINTER(m_value);
    112     }
    113 
    114     template<typename returnType, typename argType1, typename argType2, typename argType3, typename argType4, typename argType5, typename argType6>
    115     FunctionPtr(returnType(*value)(argType1, argType2, argType3, argType4, argType5, argType6))
    116         : m_value((void*)value)
    117     {
    118         PoisonedMasmPtr::assertIsNotPoisoned(m_value);
    119         ASSERT_VALID_CODE_POINTER(m_value);
    120     }
     66    template<typename returnType, typename... Arguments>
     67    FunctionPtr(returnType(*value)(Arguments...))
     68        : m_value(reinterpret_cast<void*>(value))
     69    {
     70        PoisonedMasmPtr::assertIsNotPoisoned(m_value);
     71        ASSERT_VALID_CODE_POINTER(m_value);
     72    }
     73
    12174// MSVC doesn't seem to treat functions with different calling conventions as
    12275// different types; these methods already defined for fastcall, below.
    12376#if CALLING_CONVENTION_IS_STDCALL && !OS(WINDOWS)
    12477
    125     template<typename returnType>
    126     FunctionPtr(returnType (CDECL *value)())
    127         : m_value((void*)value)
    128     {
    129         PoisonedMasmPtr::assertIsNotPoisoned(m_value);
    130         ASSERT_VALID_CODE_POINTER(m_value);
    131     }
    132 
    133     template<typename returnType, typename argType1>
    134     FunctionPtr(returnType (CDECL *value)(argType1))
    135         : m_value((void*)value)
    136     {
    137         PoisonedMasmPtr::assertIsNotPoisoned(m_value);
    138         ASSERT_VALID_CODE_POINTER(m_value);
    139     }
    140 
    141     template<typename returnType, typename argType1, typename argType2>
    142     FunctionPtr(returnType (CDECL *value)(argType1, argType2))
    143         : m_value((void*)value)
    144     {
    145         PoisonedMasmPtr::assertIsNotPoisoned(m_value);
    146         ASSERT_VALID_CODE_POINTER(m_value);
    147     }
    148 
    149     template<typename returnType, typename argType1, typename argType2, typename argType3>
    150     FunctionPtr(returnType (CDECL *value)(argType1, argType2, argType3))
    151         : m_value((void*)value)
    152     {
    153         PoisonedMasmPtr::assertIsNotPoisoned(m_value);
    154         ASSERT_VALID_CODE_POINTER(m_value);
    155     }
    156 
    157     template<typename returnType, typename argType1, typename argType2, typename argType3, typename argType4>
    158     FunctionPtr(returnType (CDECL *value)(argType1, argType2, argType3, argType4))
    159         : m_value((void*)value)
    160     {
    161         PoisonedMasmPtr::assertIsNotPoisoned(m_value);
    162         ASSERT_VALID_CODE_POINTER(m_value);
    163     }
    164 #endif
     78    template<typename returnType, typename... Arguments>
     79    FunctionPtr(returnType(CDECL *value)(Arguments...))
     80        : m_value(reinterpret_cast<void*>(value))
     81    {
     82        PoisonedMasmPtr::assertIsNotPoisoned(m_value);
     83        ASSERT_VALID_CODE_POINTER(m_value);
     84    }
     85
     86#endif // CALLING_CONVENTION_IS_STDCALL && !OS(WINDOWS)
    16587
    16688#if COMPILER_SUPPORTS(FASTCALL_CALLING_CONVENTION)
    16789
    168     template<typename returnType>
    169     FunctionPtr(returnType (FASTCALL *value)())
    170         : m_value((void*)value)
    171     {
    172         PoisonedMasmPtr::assertIsNotPoisoned(m_value);
    173         ASSERT_VALID_CODE_POINTER(m_value);
    174     }
    175 
    176     template<typename returnType, typename argType1>
    177     FunctionPtr(returnType (FASTCALL *value)(argType1))
    178         : m_value((void*)value)
    179     {
    180         PoisonedMasmPtr::assertIsNotPoisoned(m_value);
    181         ASSERT_VALID_CODE_POINTER(m_value);
    182     }
    183 
    184     template<typename returnType, typename argType1, typename argType2>
    185     FunctionPtr(returnType (FASTCALL *value)(argType1, argType2))
    186         : m_value((void*)value)
    187     {
    188         PoisonedMasmPtr::assertIsNotPoisoned(m_value);
    189         ASSERT_VALID_CODE_POINTER(m_value);
    190     }
    191 
    192     template<typename returnType, typename argType1, typename argType2, typename argType3>
    193     FunctionPtr(returnType (FASTCALL *value)(argType1, argType2, argType3))
    194         : m_value((void*)value)
    195     {
    196         PoisonedMasmPtr::assertIsNotPoisoned(m_value);
    197         ASSERT_VALID_CODE_POINTER(m_value);
    198     }
    199 
    200     template<typename returnType, typename argType1, typename argType2, typename argType3, typename argType4>
    201     FunctionPtr(returnType (FASTCALL *value)(argType1, argType2, argType3, argType4))
    202         : m_value((void*)value)
    203     {
    204         PoisonedMasmPtr::assertIsNotPoisoned(m_value);
    205         ASSERT_VALID_CODE_POINTER(m_value);
    206     }
    207 #endif
     90    template<typename returnType, typename... Arguments>
     91    FunctionPtr(returnType(FASTCALL *value)(Arguments...))
     92        : m_value(reinterpret_cast<void*>(value))
     93    {
     94        PoisonedMasmPtr::assertIsNotPoisoned(m_value);
     95        ASSERT_VALID_CODE_POINTER(m_value);
     96    }
     97
     98#endif // COMPILER_SUPPORTS(FASTCALL_CALLING_CONVENTION)
    20899
    209100    template<typename FunctionType>
Note: See TracChangeset for help on using the changeset viewer.