Changeset 203938 in webkit


Ignore:
Timestamp:
Jul 29, 2016 8:22:19 PM (8 years ago)
Author:
ddkilzer@apple.com
Message:

ANGLE: Fix global constructors and exit-time destructors
<https://webkit.org/b/160332>

Reviewed by Darin Adler.

  • Configurations/Base.xcconfig:
  • Add warning flags.
  • src/common/angleutils.cpp:

(FormatString):

  • src/common/angleutils.h:

(MakeStaticString):

  • src/common/debug.cpp:
  • src/common/mathutil.cpp:

(gl::g_sharedexp_max):
(gl::convertRGBFloatsTo999E5):

  • src/compiler/translator/ShaderLang.cpp:

(ShGetUniformRegisterMap):

  • src/libANGLE/Caps.cpp:

(gl::TextureCapsMap::get):

  • src/libANGLE/Device.cpp:

(egl::GetDeviceSet):

  • src/libANGLE/Display.cpp:

(egl::Display::getClientExtensionString):

  • src/libANGLE/formatutils.cpp:

(gl::BuildFormatMap):
(gl::BuildInternalFormatInfoMap):
(gl::GetInternalFormatMap):
(gl::BuildAllSizedInternalFormatSet):
(gl::GetSizedInternalFormat):
(gl::GetAllSizedInternalFormats):

  • src/libANGLE/validationES3.cpp:

(gl::BuildES3FormatSet):
(gl::ValidateTexImageFormatCombination):
(gl::BuildSizedEffectiveInternalFormatList):
(gl::BuildUnsizedEffectiveInternalFormatList):
(gl::GetEffectiveInternalFormat):
(gl::BuildValidES3CopyTexImageCombinations):
(gl::IsValidES3CopyTexImageCombination):

  • Fix global constructors and exit-time destructors.
Location:
trunk/Source/ThirdParty/ANGLE
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/ThirdParty/ANGLE/ChangeLog

    r203169 r203938  
     12016-07-29  David Kilzer  <ddkilzer@apple.com>
     2
     3        ANGLE: Fix global constructors and exit-time destructors
     4        <https://webkit.org/b/160332>
     5
     6        Reviewed by Darin Adler.
     7
     8        * Configurations/Base.xcconfig:
     9        - Add warning flags.
     10
     11        * src/common/angleutils.cpp:
     12        (FormatString):
     13        * src/common/angleutils.h:
     14        (MakeStaticString):
     15        * src/common/debug.cpp:
     16        * src/common/mathutil.cpp:
     17        (gl::g_sharedexp_max):
     18        (gl::convertRGBFloatsTo999E5):
     19        * src/compiler/translator/ShaderLang.cpp:
     20        (ShGetUniformRegisterMap):
     21        * src/libANGLE/Caps.cpp:
     22        (gl::TextureCapsMap::get):
     23        * src/libANGLE/Device.cpp:
     24        (egl::GetDeviceSet):
     25        * src/libANGLE/Display.cpp:
     26        (egl::Display::getClientExtensionString):
     27        * src/libANGLE/formatutils.cpp:
     28        (gl::BuildFormatMap):
     29        (gl::BuildInternalFormatInfoMap):
     30        (gl::GetInternalFormatMap):
     31        (gl::BuildAllSizedInternalFormatSet):
     32        (gl::GetSizedInternalFormat):
     33        (gl::GetAllSizedInternalFormats):
     34        * src/libANGLE/validationES3.cpp:
     35        (gl::BuildES3FormatSet):
     36        (gl::ValidateTexImageFormatCombination):
     37        (gl::BuildSizedEffectiveInternalFormatList):
     38        (gl::BuildUnsizedEffectiveInternalFormatList):
     39        (gl::GetEffectiveInternalFormat):
     40        (gl::BuildValidES3CopyTexImageCombinations):
     41        (gl::IsValidES3CopyTexImageCombination):
     42        - Fix global constructors and exit-time destructors.
     43
    1442016-07-13  Enrica Casucci  <enrica@apple.com>
    245
  • trunk/Source/ThirdParty/ANGLE/Configurations/Base.xcconfig

    r203169 r203938  
    4343PREBINDING = NO;
    4444STRIP_INSTALLED_PRODUCT = NO;
     45WARNING_CFLAGS = -Wexit-time-destructors -Wglobal-constructors;
    4546
    4647SUPPORTED_PLATFORMS = iphoneos iphonesimulator macosx appletvos appletvsimulator watchos watchsimulator;
  • trunk/Source/ThirdParty/ANGLE/src/common/angleutils.cpp

    r199738 r203938  
    3737std::string FormatString(const char *fmt, va_list vararg)
    3838{
    39     static std::vector<char> buffer(512);
     39    static auto& buffer = *new std::vector<char>(512);
    4040
    4141    size_t len = FormatStringIntoVector(fmt, vararg, buffer);
  • trunk/Source/ThirdParty/ANGLE/src/common/angleutils.h

    r199738 r203938  
    117117inline const char* MakeStaticString(const std::string &str)
    118118{
    119     static std::set<std::string> strings;
     119    static auto& strings = *new std::set<std::string>;
    120120    std::set<std::string>::iterator it = strings.find(str);
    121121    if (it != strings.end())
  • trunk/Source/ThirdParty/ANGLE/src/common/debug.cpp

    r199738 r203938  
    3535    if (DebugAnnotationsActive())
    3636    {
    37         static std::vector<char> buffer(512);
     37        static auto& buffer = *new std::vector<char>(512);
    3838        size_t len = FormatStringIntoVector(format, vararg, buffer);
    3939        std::wstring formattedWideMessage(buffer.begin(), buffer.begin() + len);
  • trunk/Source/ThirdParty/ANGLE/src/common/mathutil.cpp

    r199738 r203938  
    3232static const int g_sharedexp_maxexponent = 31;
    3333
    34 static const float g_sharedexp_max = ((pow(2.0f, g_sharedexp_mantissabits) - 1) /
    35                                        pow(2.0f, g_sharedexp_mantissabits)) *
    36                                      pow(2.0f, g_sharedexp_maxexponent - g_sharedexp_bias);
     34static float g_sharedexp_max()
     35{
     36    static float sharedexp_max = ((powf(2.0f, g_sharedexp_mantissabits) - 1) /
     37                                   powf(2.0f, g_sharedexp_mantissabits)) *
     38                                 powf(2.0f, g_sharedexp_maxexponent - g_sharedexp_bias);
     39    return sharedexp_max;
     40}
    3741
    3842unsigned int convertRGBFloatsTo999E5(float red, float green, float blue)
    3943{
    40     const float red_c = std::max<float>(0, std::min(g_sharedexp_max, red));
    41     const float green_c = std::max<float>(0, std::min(g_sharedexp_max, green));
    42     const float blue_c = std::max<float>(0, std::min(g_sharedexp_max, blue));
     44    const float red_c = std::max<float>(0, std::min(g_sharedexp_max(), red));
     45    const float green_c = std::max<float>(0, std::min(g_sharedexp_max(), green));
     46    const float blue_c = std::max<float>(0, std::min(g_sharedexp_max(), blue));
    4347
    4448    const float max_c = std::max<float>(std::max<float>(red_c, green_c), blue_c);
  • trunk/Source/ThirdParty/ANGLE/src/compiler/translator/ShaderLang.cpp

    r199738 r203938  
    372372    return translator->getUniformRegisterMap();
    373373#else
    374     static std::map<std::string, unsigned int> map;
     374    static auto& map = *new std::map<std::string, unsigned int>;
    375375    return &map;
    376376#endif  // ANGLE_ENABLE_HLSL
  • trunk/Source/ThirdParty/ANGLE/src/libANGLE/Caps.cpp

    r199738 r203938  
    7373const TextureCaps &TextureCapsMap::get(GLenum internalFormat) const
    7474{
    75     static TextureCaps defaultUnsupportedTexture;
     75    static auto& defaultUnsupportedTexture = *new TextureCaps;
    7676    InternalFormatToCapsMap::const_iterator iter = mCapsMap.find(internalFormat);
    7777    return (iter != mCapsMap.end()) ? iter->second : defaultUnsupportedTexture;
  • trunk/Source/ThirdParty/ANGLE/src/libANGLE/Device.cpp

    r199738 r203938  
    3939static DeviceSet *GetDeviceSet()
    4040{
    41     static DeviceSet devices;
     41    static auto& devices = *new DeviceSet;
    4242    return &devices;
    4343}
  • trunk/Source/ThirdParty/ANGLE/src/libANGLE/Display.cpp

    r200107 r203938  
    8383static WindowSurfaceMap *GetWindowSurfaces()
    8484{
    85     static WindowSurfaceMap windowSurfaces;
     85    static auto& windowSurfaces = *new WindowSurfaceMap;
    8686    return &windowSurfaces;
    8787}
     
    9090static ANGLEPlatformDisplayMap *GetANGLEPlatformDisplayMap()
    9191{
    92     static ANGLEPlatformDisplayMap displays;
     92    static auto& displays = *new ANGLEPlatformDisplayMap;
    9393    return &displays;
    9494}
     
    9797static DevicePlatformDisplayMap *GetDevicePlatformDisplayMap()
    9898{
    99     static DevicePlatformDisplayMap displays;
     99    static auto& displays = *new DevicePlatformDisplayMap;
    100100    return &displays;
    101101}
     
    950950const std::string &Display::getClientExtensionString()
    951951{
    952     static const std::string clientExtensionsString = GenerateExtensionsString(getClientExtensions());
     952    static const auto& clientExtensionsString = *new std::string(GenerateExtensionsString(getClientExtensions()));
    953953    return clientExtensionsString;
    954954}
  • trunk/Source/ThirdParty/ANGLE/src/libANGLE/formatutils.cpp

    r199738 r203938  
    3030}
    3131
    32 FormatMap BuildFormatMap()
    33 {
    34     FormatMap map;
     32FormatMap& BuildFormatMap()
     33{
     34    auto& map = *new FormatMap;
    3535
    3636    //                       | Format               | Type                             | Internal format          |
     
    393393typedef std::map<GLenum, InternalFormat> InternalFormatInfoMap;
    394394
    395 static InternalFormatInfoMap BuildInternalFormatInfoMap()
    396 {
    397     InternalFormatInfoMap map;
     395static InternalFormatInfoMap& BuildInternalFormatInfoMap()
     396{
     397    auto& map = *new InternalFormatInfoMap;
    398398
    399399    // clang-format off
     
    577577static const InternalFormatInfoMap &GetInternalFormatMap()
    578578{
    579     static const InternalFormatInfoMap formatMap = BuildInternalFormatInfoMap();
     579    static const InternalFormatInfoMap& formatMap = BuildInternalFormatInfoMap();
    580580    return formatMap;
    581581}
    582582
    583 static FormatSet BuildAllSizedInternalFormatSet()
    584 {
    585     FormatSet result;
     583static FormatSet& BuildAllSizedInternalFormatSet()
     584{
     585    auto& result = *new FormatSet;
    586586
    587587    const InternalFormatInfoMap &formats = GetInternalFormatMap();
     
    743743    else
    744744    {
    745         static const FormatMap formatMap = BuildFormatMap();
     745        static const FormatMap& formatMap = BuildFormatMap();
    746746        FormatMap::const_iterator iter = formatMap.find(FormatTypePair(internalFormat, type));
    747747        if (iter != formatMap.end())
     
    758758const FormatSet &GetAllSizedInternalFormats()
    759759{
    760     static FormatSet formatSet = BuildAllSizedInternalFormatSet();
     760    static FormatSet& formatSet = BuildAllSizedInternalFormatSet();
    761761    return formatSet;
    762762}
  • trunk/Source/ThirdParty/ANGLE/src/libANGLE/validationES3.cpp

    r199738 r203938  
    4545}
    4646
    47 ES3FormatCombinationSet BuildES3FormatSet()
    48 {
    49     ES3FormatCombinationSet set;
     47ES3FormatCombinationSet& BuildES3FormatSet()
     48{
     49    auto& set = *new ES3FormatCombinationSet;
    5050
    5151    // Format combinations from ES 3.0.1 spec, table 3.2
     
    218218    bool typeSupported = false;
    219219
    220     static const ES3FormatCombinationSet es3FormatSet = BuildES3FormatSet();
     220    static const ES3FormatCombinationSet& es3FormatSet = BuildES3FormatSet();
    221221    for (ES3FormatCombinationSet::const_iterator i = es3FormatSet.begin(); i != es3FormatSet.end(); i++)
    222222    {
     
    592592typedef std::vector<EffectiveInternalFormatInfo> EffectiveInternalFormatList;
    593593
    594 static EffectiveInternalFormatList BuildSizedEffectiveInternalFormatList()
    595 {
    596     EffectiveInternalFormatList list;
     594static EffectiveInternalFormatList& BuildSizedEffectiveInternalFormatList()
     595{
     596    auto& list = *new EffectiveInternalFormatList;
    597597
    598598    // OpenGL ES 3.0.3 Specification, Table 3.17, pg 141: Effective internal format coresponding to destination internal format and
     
    613613}
    614614
    615 static EffectiveInternalFormatList BuildUnsizedEffectiveInternalFormatList()
    616 {
    617     EffectiveInternalFormatList list;
     615static EffectiveInternalFormatList& BuildUnsizedEffectiveInternalFormatList()
     616{
     617    auto& list = *new EffectiveInternalFormatList;
    618618
    619619    // OpenGL ES 3.0.3 Specification, Table 3.17, pg 141: Effective internal format coresponding to destination internal format and
     
    641641    if (destFormat.pixelBytes > 0)
    642642    {
    643         static const EffectiveInternalFormatList sizedList = BuildSizedEffectiveInternalFormatList();
     643        static const EffectiveInternalFormatList& sizedList = BuildSizedEffectiveInternalFormatList();
    644644        list = &sizedList;
    645645    }
    646646    else
    647647    {
    648         static const EffectiveInternalFormatList unsizedList = BuildUnsizedEffectiveInternalFormatList();
     648        static const EffectiveInternalFormatList& unsizedList = BuildUnsizedEffectiveInternalFormatList();
    649649        list = &unsizedList;
    650650        targetFormat = destFormat.format;
     
    684684typedef std::set<CopyConversion> CopyConversionSet;
    685685
    686 static CopyConversionSet BuildValidES3CopyTexImageCombinations()
    687 {
    688     CopyConversionSet set;
     686static CopyConversionSet& BuildValidES3CopyTexImageCombinations()
     687{
     688    auto& set = *new CopyConversionSet;
    689689
    690690    // From ES 3.0.1 spec, table 3.15
     
    734734    const InternalFormat &framebufferInternalFormatInfo = GetInternalFormatInfo(frameBufferInternalFormat);
    735735
    736     static const CopyConversionSet conversionSet = BuildValidES3CopyTexImageCombinations();
     736    static const CopyConversionSet& conversionSet = BuildValidES3CopyTexImageCombinations();
    737737    if (conversionSet.find(CopyConversion(textureInternalFormatInfo.format, framebufferInternalFormatInfo.format)) != conversionSet.end())
    738738    {
Note: See TracChangeset for help on using the changeset viewer.