Changeset 207282 in webkit


Ignore:
Timestamp:
Oct 13, 2016 4:30:25 AM (7 years ago)
Author:
pvollan@apple.com
Message:

[Win] Encode function pointers.
https://bugs.webkit.org/show_bug.cgi?id=163331

Reviewed by Brent Fulgham.

We should encode stored function pointers.

  • platform/win/SoftLinking.h:
Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r207281 r207282  
     12016-10-12  Per Arne Vollan  <pvollan@apple.com>
     2
     3        [Win] Encode function pointers.
     4        https://bugs.webkit.org/show_bug.cgi?id=163331
     5
     6        Reviewed by Brent Fulgham.
     7
     8        We should encode stored function pointers.
     9
     10        * platform/win/SoftLinking.h:
     11
    1122016-10-13  Youenn Fablet  <youenn@apple.com>
    213
  • trunk/Source/WebCore/platform/win/SoftLinking.h

    r184799 r207282  
    4545
    4646#define SOFT_LINK(library, functionName, resultType, callingConvention, parameterDeclarations, parameterNames) \
    47     static resultType callingConvention init##functionName parameterDeclarations; \
    48     static resultType (callingConvention*softLink##functionName) parameterDeclarations = init##functionName; \
    49     \
    50     static resultType callingConvention init##functionName parameterDeclarations \
    51     { \
    52         softLink##functionName = reinterpret_cast<resultType (callingConvention*) parameterDeclarations>(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName)); \
    53         ASSERT(softLink##functionName); \
    54         return softLink##functionName parameterNames; \
    55     } \
     47    static resultType(callingConvention*softLink##functionName) parameterDeclarations = nullptr; \
    5648    \
    5749    inline resultType functionName parameterDeclarations \
    5850    { \
    59         return softLink##functionName parameterNames; \
     51        if (!softLink##functionName) \
     52            softLink##functionName = reinterpret_cast<resultType(callingConvention*)parameterDeclarations>(::EncodePointer(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName))); \
     53        return reinterpret_cast<resultType (callingConvention*) parameterDeclarations>(::DecodePointer(softLink##functionName)) parameterNames; \
    6054    }
    6155
     
    6761        static bool initialized; \
    6862        \
    69         if (initialized) \
    70             return ptr; \
    71         initialized = true; \
    72         \
    73         ptr = reinterpret_cast<functionName##PtrType>(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName)); \
    74         return ptr; \
     63        if (!initialized) { \
     64            ptr = reinterpret_cast<functionName##PtrType>(::EncodePointer(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName))); \
     65            initialized = true; \
     66        } \
     67        return reinterpret_cast<functionName##PtrType>(::DecodePointer(ptr)); \
    7568    } \
    7669
     
    8275        static bool initialized; \
    8376        \
    84         if (initialized) \
    85             return ptr; \
    86         initialized = true; \
    87         \
    88         static HINSTANCE libraryInstance = ::GetModuleHandle(L#library); \
    89         \
    90         ptr = reinterpret_cast<functionName##PtrType>(SOFT_LINK_GETPROCADDRESS(libraryInstance, #functionName)); \
    91         return ptr; \
     77        if (!initialized) { \
     78            static HINSTANCE libraryInstance = ::GetModuleHandle(L#library); \
     79            ptr = reinterpret_cast<functionName##PtrType>(::EncodePointer(SOFT_LINK_GETPROCADDRESS(libraryInstance, #functionName))); \
     80            initialized = true; \
     81        } \
     82        \
     83        return reinterpret_cast<functionName##PtrType>(::DecodePointer(ptr)); \
    9284    } \
    9385
     
    10092*/
    10193#define SOFT_LINK_DLL_IMPORT(library, functionName, resultType, callingConvention, parameterDeclarations, parameterNames) \
    102     static resultType callingConvention init##functionName parameterDeclarations; \
    103     static resultType(callingConvention*softLink##functionName) parameterDeclarations = init##functionName; \
    104     \
    105     static resultType callingConvention init##functionName parameterDeclarations \
    106     { \
    107         softLink##functionName = reinterpret_cast<resultType (callingConvention*)parameterDeclarations>(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName)); \
    108         ASSERT(softLink##functionName); \
    109         return softLink##functionName parameterNames; \
    110     } \
     94    static resultType(callingConvention*softLink##functionName) parameterDeclarations = nullptr; \
    11195    \
    11296    inline resultType softLink_##functionName parameterDeclarations \
    11397    { \
    114         return softLink##functionName parameterNames; \
     98        if (!softLink##functionName) \
     99            softLink##functionName = reinterpret_cast<resultType(callingConvention*)parameterDeclarations>(::EncodePointer(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName))); \
     100        return reinterpret_cast<resultType(callingConvention*)parameterDeclarations>(::DecodePointer(softLink##functionName)) parameterNames; \
    115101    }
    116102
     
    122108        static bool initialized; \
    123109        \
    124         if (initialized) \
    125             return ptr; \
    126         initialized = true; \
    127         \
    128         ptr = reinterpret_cast<resultType(callingConvention*)parameterDeclarations>(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName)); \
    129         return ptr; \
     110        if (!initialized) { \
     111            ptr = reinterpret_cast<resultType(callingConvention*)parameterDeclarations>(::EncodePointer(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName))); \
     112            initialized = true; \
     113        } \
     114        return reinterpret_cast<functionName##PtrType>(::DecodePointer(ptr)); \
    130115    } \
    131116
     
    137122        static bool initialized; \
    138123        \
    139         if (initialized) \
    140             return ptr; \
    141         initialized = true; \
    142         \
    143         ptr = reinterpret_cast<resultType(callingConvention*)parameterDeclarations>(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName)); \
    144         return ptr; \
     124        if (!initialized) { \
     125            ptr = reinterpret_cast<resultType(callingConvention*)parameterDeclarations>(::EncodePointer(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName))); \
     126            initialized = true; \
     127        } \
     128        return reinterpret_cast<functionName##PtrType>(::DecodePointer(ptr)); \
    145129    } \
    146130
Note: See TracChangeset for help on using the changeset viewer.