⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 278322 in webkit


Ignore:
Timestamp:
Jun 1, 2021, 1:04:18 PM (5 years ago)
Author:
Fujii Hironori
Message:

Sync Tools/win/DLLLauncher/DLLLauncherMain.cpp with Source/JavaScriptCore/shell/DLLLauncherMain.cpp
https://bugs.webkit.org/show_bug.cgi?id=226451

Reviewed by Don Olmstead.

Tools/win/DLLLauncher/DLLLauncherMain.cpp and
Source/JavaScriptCore/shell/DLLLauncherMain.cpp should be same.
But, r231403 changed only JavaScriptCore's one. r178530 changed
only Tools's one.

r178530 added flags for Debug CRT Heap. However, WebKit isn't
using Debug CRT Heap nowadays. And, using _CRTDBG_CHECK_ALWAYS_DF
flag makes WebKit unbearably slow.

Just copied JavaScriptCore's one to overwrite Tools's one.

  • win/DLLLauncher/DLLLauncherMain.cpp:

(copyEnvironmentVariable):
(getStringValue):
(applePathFromRegistry):
(appleApplicationSupportDirectory):
(iTunesDirectory):
(prependPath):
(fatalError):
(directoryExists):
(modifyPath):
(getLastErrorString):
(wWinMain):

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r278318 r278322  
     12021-06-01  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        Sync Tools/win/DLLLauncher/DLLLauncherMain.cpp with Source/JavaScriptCore/shell/DLLLauncherMain.cpp
     4        https://bugs.webkit.org/show_bug.cgi?id=226451
     5
     6        Reviewed by Don Olmstead.
     7
     8        Tools/win/DLLLauncher/DLLLauncherMain.cpp and
     9        Source/JavaScriptCore/shell/DLLLauncherMain.cpp should be same.
     10        But, r231403 changed only JavaScriptCore's one. r178530 changed
     11        only Tools's one.
     12
     13        r178530 added flags for Debug CRT Heap. However, WebKit isn't
     14        using Debug CRT Heap nowadays. And, using _CRTDBG_CHECK_ALWAYS_DF
     15        flag makes WebKit unbearably slow.
     16
     17        Just copied JavaScriptCore's one to overwrite Tools's one.
     18
     19        * win/DLLLauncher/DLLLauncherMain.cpp:
     20        (copyEnvironmentVariable):
     21        (getStringValue):
     22        (applePathFromRegistry):
     23        (appleApplicationSupportDirectory):
     24        (iTunesDirectory):
     25        (prependPath):
     26        (fatalError):
     27        (directoryExists):
     28        (modifyPath):
     29        (getLastErrorString):
     30        (wWinMain):
     31
    1322021-06-01  Chris Dumez  <cdumez@apple.com>
    233
  • trunk/Tools/win/DLLLauncher/DLLLauncherMain.cpp

    r274769 r278322  
    3636#include <windows.h>
    3737
    38 using namespace std;
    39 
    4038static void enableTerminationOnHeapCorruption()
    4139{
     
    4442}
    4543
    46 static wstring copyEnvironmentVariable(const wstring& variable)
     44static std::wstring copyEnvironmentVariable(const std::wstring& variable)
    4745{
    4846    DWORD length = ::GetEnvironmentVariableW(variable.c_str(), 0, 0);
    4947    if (!length)
    50         return wstring();
    51     vector<wchar_t> buffer(length);
     48        return std::wstring();
     49    std::vector<wchar_t> buffer(length);
    5250    if (!GetEnvironmentVariable(variable.c_str(), &buffer[0], buffer.size()) || !buffer[0])
    53         return wstring();
     51        return std::wstring();
    5452    return &buffer[0];
    5553}
    5654
    5755#if !defined(WIN_CAIRO)
    58 static wstring getStringValue(HKEY key, const wstring& valueName)
     56static std::wstring getStringValue(HKEY key, const std::wstring& valueName)
    5957{
    6058    DWORD type = 0;
    6159    DWORD bufferSize = 0;
    6260    if (::RegQueryValueExW(key, valueName.c_str(), 0, &type, 0, &bufferSize) != ERROR_SUCCESS || type != REG_SZ)
    63         return wstring();
    64 
    65     vector<wchar_t> buffer(bufferSize / sizeof(wchar_t));
     61        return std::wstring();
     62
     63    std::vector<wchar_t> buffer(bufferSize / sizeof(wchar_t));
    6664    if (::RegQueryValueExW(key, valueName.c_str(), 0, &type, reinterpret_cast<LPBYTE>(&buffer[0]), &bufferSize) != ERROR_SUCCESS)
    67         return wstring();
     65        return std::wstring();
    6866
    6967    return &buffer[0];
    7068}
    7169
    72 static wstring applePathFromRegistry(const wstring& key, const wstring& value)
     70static std::wstring applePathFromRegistry(const std::wstring& key, const std::wstring& value)
    7371{
    7472    HKEY applePathKey = 0;
    7573    if (::RegOpenKeyExW(HKEY_LOCAL_MACHINE, key.c_str(), 0, KEY_READ, &applePathKey) != ERROR_SUCCESS)
    76         return wstring();
    77     wstring path = getStringValue(applePathKey, value);
     74        return std::wstring();
     75    std::wstring path = getStringValue(applePathKey, value);
    7876    ::RegCloseKey(applePathKey);
    7977    return path;
    8078}
    8179
    82 static wstring appleApplicationSupportDirectory()
     80static std::wstring appleApplicationSupportDirectory()
    8381{
    8482    return applePathFromRegistry(L"SOFTWARE\\Apple Inc.\\Apple Application Support", L"InstallDir");
    8583}
    8684
    87 static wstring iTunesDirectory()
     85static std::wstring iTunesDirectory()
    8886{
    8987    return applePathFromRegistry(L"SOFTWARE\\Apple Computer, Inc.\\iTunes\\", L"InstallDir");
    9088}
    9189
    92 static bool prependPath(const wstring& directoryToPrepend)
    93 {
    94     wstring pathVariable = L"PATH";
    95     wstring oldPath = copyEnvironmentVariable(pathVariable);
    96     wstring newPath = directoryToPrepend + L';' + oldPath;
     90static bool prependPath(const std::wstring& directoryToPrepend)
     91{
     92    std::wstring pathVariable = L"PATH";
     93    std::wstring oldPath = copyEnvironmentVariable(pathVariable);
     94    std::wstring newPath = directoryToPrepend + L';' + oldPath;
    9795    return ::SetEnvironmentVariableW(pathVariable.c_str(), newPath.c_str());
    9896}
    9997#endif
    10098
    101 static int fatalError(const wstring& programName, const wstring& message)
    102 {
    103     wstring caption = programName + L" can't open.";
     99static int fatalError(const std::wstring& programName, const std::wstring& message)
     100{
     101    std::wstring caption = programName + L" can't open.";
    104102#if USE_CONSOLE_ENTRY_POINT
    105103    fwprintf(stderr, L"%s\n%s\n", caption.c_str(), message.c_str());
     
    110108}
    111109
    112 static bool directoryExists(const wstring& path)
     110static bool directoryExists(const std::wstring& path)
    113111{
    114112    DWORD attrib = ::GetFileAttributes(path.c_str());
     
    117115}
    118116
    119 static bool modifyPath(const wstring& programName)
     117static bool modifyPath(const std::wstring& programName)
    120118{
    121119#ifdef WIN_CAIRO
    122120
    123     wstring pathWinCairo = copyEnvironmentVariable(L"WEBKIT_LIBRARIES");
     121    std::wstring pathWinCairo = copyEnvironmentVariable(L"WEBKIT_LIBRARIES");
    124122    if (!directoryExists(pathWinCairo))
    125123        return true;
     
    136134
    137135#else
    138     auto modifyPathWith = [&] (const wstring& pathPrefix) {
     136    auto modifyPathWith = [&] (const std::wstring& pathPrefix) {
    139137        if (!prependPath(pathPrefix)) {
    140138            fatalError(programName, L"Failed to modify PATH environment variable.");
     
    144142    };
    145143
    146     const wstring& applicationSupportPathPrefix = appleApplicationSupportDirectory();
     144    const std::wstring& applicationSupportPathPrefix = appleApplicationSupportDirectory();
    147145    if (directoryExists(applicationSupportPathPrefix))
    148146        return modifyPathWith(applicationSupportPathPrefix);
    149147
    150     const wstring& iTunesPathPrefix = iTunesDirectory();
     148    const std::wstring& iTunesPathPrefix = iTunesDirectory();
    151149    if (directoryExists(iTunesPathPrefix))
    152150        return modifyPathWith(iTunesPathPrefix);
     
    157155}
    158156
    159 static wstring getLastErrorString(HRESULT hr)
     157static std::wstring getLastErrorString(HRESULT hr)
    160158{
    161159    static const DWORD kFlags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS;
     
    175173int main(int argc, const char* argv[])
    176174#else
    177 int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpstrCmdLine, _In_ int nCmdShow)
    178 #endif
    179 {
    180 #ifdef _CRTDBG_MAP_ALLOC
    181     _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
    182     _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
    183 #endif
    184 
    185     _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF);
    186 
     175int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpstrCmdLine, int nCmdShow)
     176#endif
     177{
    187178    enableTerminationOnHeapCorruption();
    188179
     
    194185    ::PathRemoveExtensionW(exePath);
    195186
    196     wstring programName = ::PathFindFileNameW(exePath);
     187    std::wstring programName = ::PathFindFileNameW(exePath);
    197188
    198189    if (!modifyPath(programName))
     
    200191
    201192    // Load our corresponding DLL.
    202     wstring dllName = programName + L"Lib.dll";
     193    std::wstring dllName = programName + L"Lib.dll";
    203194    if (!::PathRemoveFileSpecW(exePath))
    204195        return fatalError(programName, L"::PathRemoveFileSpecW failed: " + getLastErrorString(::GetLastError()));
     
    207198    HMODULE module = ::LoadLibraryW(exePath);
    208199    if (!module)
    209         return fatalError(programName, L"::LoadLibraryW failed: \npath=" + wstring(exePath) + L"\n" + getLastErrorString(::GetLastError()));
     200        return fatalError(programName, L"::LoadLibraryW failed: \npath=" + std::wstring(exePath) + L"\n" + getLastErrorString(::GetLastError()));
    210201
    211202#if USE_CONSOLE_ENTRY_POINT
Note: See TracChangeset for help on using the changeset viewer.