Title: [278322] trunk/Tools
Revision
278322
Author
[email protected]
Date
2021-06-01 13:04:18 -0700 (Tue, 01 Jun 2021)

Log Message

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

Reviewed by Don Olmstead.

Tools/win/DLLLauncher/DLLLauncherMain.cpp and
Source/_javascript_Core/shell/DLLLauncherMain.cpp should be same.
But, r231403 changed only _javascript_Core'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 _javascript_Core's one to overwrite Tools's one.

* win/DLLLauncher/DLLLauncherMain.cpp:
(copyEnvironmentVariable):
(getStringValue):
(applePathFromRegistry):
(appleApplicationSupportDirectory):
(iTunesDirectory):
(prependPath):
(fatalError):
(directoryExists):
(modifyPath):
(getLastErrorString):
(wWinMain):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (278321 => 278322)


--- trunk/Tools/ChangeLog	2021-06-01 19:24:53 UTC (rev 278321)
+++ trunk/Tools/ChangeLog	2021-06-01 20:04:18 UTC (rev 278322)
@@ -1,3 +1,34 @@
+2021-06-01  Fujii Hironori  <[email protected]>
+
+        Sync Tools/win/DLLLauncher/DLLLauncherMain.cpp with Source/_javascript_Core/shell/DLLLauncherMain.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=226451
+
+        Reviewed by Don Olmstead.
+
+        Tools/win/DLLLauncher/DLLLauncherMain.cpp and
+        Source/_javascript_Core/shell/DLLLauncherMain.cpp should be same.
+        But, r231403 changed only _javascript_Core'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 _javascript_Core's one to overwrite Tools's one.
+
+        * win/DLLLauncher/DLLLauncherMain.cpp:
+        (copyEnvironmentVariable):
+        (getStringValue):
+        (applePathFromRegistry):
+        (appleApplicationSupportDirectory):
+        (iTunesDirectory):
+        (prependPath):
+        (fatalError):
+        (directoryExists):
+        (modifyPath):
+        (getLastErrorString):
+        (wWinMain):
+
 2021-06-01  Chris Dumez  <[email protected]>
 
         REGRESSION (iOS 14.5): Can't go back and render previous page properly after "location.href"

Modified: trunk/Tools/win/DLLLauncher/DLLLauncherMain.cpp (278321 => 278322)


--- trunk/Tools/win/DLLLauncher/DLLLauncherMain.cpp	2021-06-01 19:24:53 UTC (rev 278321)
+++ trunk/Tools/win/DLLLauncher/DLLLauncherMain.cpp	2021-06-01 20:04:18 UTC (rev 278322)
@@ -35,8 +35,6 @@
 #include <vector>
 #include <windows.h>
 
-using namespace std;
-
 static void enableTerminationOnHeapCorruption()
 {
     HEAP_INFORMATION_CLASS heapEnableTerminationOnCorruption = static_cast<HEAP_INFORMATION_CLASS>(1);
@@ -43,64 +41,64 @@
     HeapSetInformation(0, heapEnableTerminationOnCorruption, 0, 0);
 }
 
-static wstring copyEnvironmentVariable(const wstring& variable)
+static std::wstring copyEnvironmentVariable(const std::wstring& variable)
 {
     DWORD length = ::GetEnvironmentVariableW(variable.c_str(), 0, 0);
     if (!length)
-        return wstring();
-    vector<wchar_t> buffer(length);
+        return std::wstring();
+    std::vector<wchar_t> buffer(length);
     if (!GetEnvironmentVariable(variable.c_str(), &buffer[0], buffer.size()) || !buffer[0])
-        return wstring();
+        return std::wstring();
     return &buffer[0];
 }
 
 #if !defined(WIN_CAIRO)
-static wstring getStringValue(HKEY key, const wstring& valueName)
+static std::wstring getStringValue(HKEY key, const std::wstring& valueName)
 {
     DWORD type = 0;
     DWORD bufferSize = 0;
     if (::RegQueryValueExW(key, valueName.c_str(), 0, &type, 0, &bufferSize) != ERROR_SUCCESS || type != REG_SZ)
-        return wstring();
+        return std::wstring();
 
-    vector<wchar_t> buffer(bufferSize / sizeof(wchar_t));
+    std::vector<wchar_t> buffer(bufferSize / sizeof(wchar_t));
     if (::RegQueryValueExW(key, valueName.c_str(), 0, &type, reinterpret_cast<LPBYTE>(&buffer[0]), &bufferSize) != ERROR_SUCCESS)
-        return wstring();
+        return std::wstring();
 
     return &buffer[0];
 }
 
-static wstring applePathFromRegistry(const wstring& key, const wstring& value)
+static std::wstring applePathFromRegistry(const std::wstring& key, const std::wstring& value)
 {
     HKEY applePathKey = 0;
     if (::RegOpenKeyExW(HKEY_LOCAL_MACHINE, key.c_str(), 0, KEY_READ, &applePathKey) != ERROR_SUCCESS)
-        return wstring();
-    wstring path = getStringValue(applePathKey, value);
+        return std::wstring();
+    std::wstring path = getStringValue(applePathKey, value);
     ::RegCloseKey(applePathKey);
     return path;
 }
 
-static wstring appleApplicationSupportDirectory()
+static std::wstring appleApplicationSupportDirectory()
 {
     return applePathFromRegistry(L"SOFTWARE\\Apple Inc.\\Apple Application Support", L"InstallDir");
 }
 
-static wstring iTunesDirectory()
+static std::wstring iTunesDirectory()
 {
     return applePathFromRegistry(L"SOFTWARE\\Apple Computer, Inc.\\iTunes\\", L"InstallDir");
 }
 
-static bool prependPath(const wstring& directoryToPrepend)
+static bool prependPath(const std::wstring& directoryToPrepend)
 {
-    wstring pathVariable = L"PATH";
-    wstring oldPath = copyEnvironmentVariable(pathVariable);
-    wstring newPath = directoryToPrepend + L';' + oldPath;
+    std::wstring pathVariable = L"PATH";
+    std::wstring oldPath = copyEnvironmentVariable(pathVariable);
+    std::wstring newPath = directoryToPrepend + L';' + oldPath;
     return ::SetEnvironmentVariableW(pathVariable.c_str(), newPath.c_str());
 }
 #endif
 
-static int fatalError(const wstring& programName, const wstring& message)
+static int fatalError(const std::wstring& programName, const std::wstring& message)
 {
-    wstring caption = programName + L" can't open.";
+    std::wstring caption = programName + L" can't open.";
 #if USE_CONSOLE_ENTRY_POINT
     fwprintf(stderr, L"%s\n%s\n", caption.c_str(), message.c_str());
 #else
@@ -109,7 +107,7 @@
     return 1;
 }
 
-static bool directoryExists(const wstring& path)
+static bool directoryExists(const std::wstring& path)
 {
     DWORD attrib = ::GetFileAttributes(path.c_str());
 
@@ -116,11 +114,11 @@
     return ((attrib != INVALID_FILE_ATTRIBUTES) && (attrib & FILE_ATTRIBUTE_DIRECTORY));
 }
 
-static bool modifyPath(const wstring& programName)
+static bool modifyPath(const std::wstring& programName)
 {
 #ifdef WIN_CAIRO
 
-    wstring pathWinCairo = copyEnvironmentVariable(L"WEBKIT_LIBRARIES");
+    std::wstring pathWinCairo = copyEnvironmentVariable(L"WEBKIT_LIBRARIES");
     if (!directoryExists(pathWinCairo))
         return true;
 #if defined(_M_X64)
@@ -135,7 +133,7 @@
     return true;
 
 #else
-    auto modifyPathWith = [&] (const wstring& pathPrefix) {
+    auto modifyPathWith = [&] (const std::wstring& pathPrefix) {
         if (!prependPath(pathPrefix)) {
             fatalError(programName, L"Failed to modify PATH environment variable.");
             return false;
@@ -143,11 +141,11 @@
         return true;
     };
 
-    const wstring& applicationSupportPathPrefix = appleApplicationSupportDirectory();
+    const std::wstring& applicationSupportPathPrefix = appleApplicationSupportDirectory();
     if (directoryExists(applicationSupportPathPrefix))
         return modifyPathWith(applicationSupportPathPrefix);
 
-    const wstring& iTunesPathPrefix = iTunesDirectory();
+    const std::wstring& iTunesPathPrefix = iTunesDirectory();
     if (directoryExists(iTunesPathPrefix))
         return modifyPathWith(iTunesPathPrefix);
 
@@ -156,7 +154,7 @@
 #endif
 }
 
-static wstring getLastErrorString(HRESULT hr)
+static std::wstring getLastErrorString(HRESULT hr)
 {
     static const DWORD kFlags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS;
     static const size_t bufSize = 4096;
@@ -174,16 +172,9 @@
 #if USE_CONSOLE_ENTRY_POINT
 int main(int argc, const char* argv[])
 #else
-int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpstrCmdLine, _In_ int nCmdShow)
+int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpstrCmdLine, int nCmdShow)
 #endif
 {
-#ifdef _CRTDBG_MAP_ALLOC
-    _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
-    _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
-#endif
-
-    _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF);
-
     enableTerminationOnHeapCorruption();
 
     // Get the path of our executable.
@@ -193,13 +184,13 @@
 
     ::PathRemoveExtensionW(exePath);
 
-    wstring programName = ::PathFindFileNameW(exePath);
+    std::wstring programName = ::PathFindFileNameW(exePath);
 
     if (!modifyPath(programName))
         return 1;
 
     // Load our corresponding DLL.
-    wstring dllName = programName + L"Lib.dll";
+    std::wstring dllName = programName + L"Lib.dll";
     if (!::PathRemoveFileSpecW(exePath))
         return fatalError(programName, L"::PathRemoveFileSpecW failed: " + getLastErrorString(::GetLastError()));
     if (!::PathAppendW(exePath, dllName.c_str()))
@@ -206,7 +197,7 @@
         return fatalError(programName, L"::PathAppendW failed: " + getLastErrorString(::GetLastError()));
     HMODULE module = ::LoadLibraryW(exePath);
     if (!module)
-        return fatalError(programName, L"::LoadLibraryW failed: \npath=" + wstring(exePath) + L"\n" + getLastErrorString(::GetLastError()));
+        return fatalError(programName, L"::LoadLibraryW failed: \npath=" + std::wstring(exePath) + L"\n" + getLastErrorString(::GetLastError()));
 
 #if USE_CONSOLE_ENTRY_POINT
     typedef int (WINAPI*EntryPoint)(int, const char*[]);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to