WebKit Bugzilla
Attachment 339676 Details for
Bug 185362
: [JSC] Remove "using namespace std;" from JSC, bmalloc, WTF
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-185362-20180506175323.patch (text/plain), 16.65 KB, created by
Yusuke Suzuki
on 2018-05-06 01:53:24 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Yusuke Suzuki
Created:
2018-05-06 01:53:24 PDT
Size:
16.65 KB
patch
obsolete
>Subversion Revision: 231399 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index b3b765d0f34ca83ccc0e51dd9a5a5549ee221710..ed17098ba5701c2d8a73de38021f4c385be9007d 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,41 @@ >+2018-05-06 Yusuke Suzuki <utatane.tea@gmail.com> >+ >+ [JSC] Remove "using namespace std;" from JSC, bmalloc, WTF >+ https://bugs.webkit.org/show_bug.cgi?id=185362 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ "namespace std" may include many names. It can conflict with names defined by our code, >+ and the other platform provided headers. For example, std::byte conflicts with Windows' >+ ::byte. >+ This patch removes "using namespace std;" from JSC and bmalloc. >+ >+ * API/JSClassRef.cpp: >+ (OpaqueJSClass::create): >+ * bytecode/Opcode.cpp: >+ * bytecompiler/BytecodeGenerator.cpp: >+ (JSC::BytecodeGenerator::newRegister): >+ * heap/Heap.cpp: >+ (JSC::Heap::updateAllocationLimits): >+ * interpreter/Interpreter.cpp: >+ * jit/JIT.cpp: >+ * parser/Parser.cpp: >+ * runtime/JSArray.cpp: >+ * runtime/JSLexicalEnvironment.cpp: >+ * runtime/JSModuleEnvironment.cpp: >+ * runtime/Structure.cpp: >+ * shell/DLLLauncherMain.cpp: >+ (getStringValue): >+ (applePathFromRegistry): >+ (appleApplicationSupportDirectory): >+ (copyEnvironmentVariable): >+ (prependPath): >+ (fatalError): >+ (directoryExists): >+ (modifyPath): >+ (getLastErrorString): >+ (wWinMain): >+ > 2018-05-05 Filip Pizlo <fpizlo@apple.com> > > DFG CFA phase should only do clobber asserts in debug >diff --git a/Source/bmalloc/ChangeLog b/Source/bmalloc/ChangeLog >index 4b2a3afea7141a0d4966c08787b50c9df11d248b..130b7b8a9c7ea874ece9795c536fdde26f6ba666 100644 >--- a/Source/bmalloc/ChangeLog >+++ b/Source/bmalloc/ChangeLog >@@ -1,3 +1,13 @@ >+2018-05-06 Yusuke Suzuki <utatane.tea@gmail.com> >+ >+ [JSC] Remove "using namespace std;" from JSC, bmalloc, WTF >+ https://bugs.webkit.org/show_bug.cgi?id=185362 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * bmalloc/Allocator.cpp: >+ * bmalloc/Deallocator.cpp: >+ > 2018-05-03 Filip Pizlo <fpizlo@apple.com> > > Strings should not be allocated in a gigacage >diff --git a/Source/JavaScriptCore/API/JSClassRef.cpp b/Source/JavaScriptCore/API/JSClassRef.cpp >index eb525f138fd6da443ee85c76fc63e5ed85df2415..ef0066daf4b7e7049189348633eae118f3f0652c 100644 >--- a/Source/JavaScriptCore/API/JSClassRef.cpp >+++ b/Source/JavaScriptCore/API/JSClassRef.cpp >@@ -37,7 +37,6 @@ > #include <wtf/text/StringHash.h> > #include <wtf/unicode/UTF8.h> > >-using namespace std; > using namespace JSC; > using namespace WTF::Unicode; > >@@ -119,7 +118,7 @@ Ref<OpaqueJSClass> OpaqueJSClass::create(const JSClassDefinition* clientDefiniti > > JSClassDefinition protoDefinition = kJSClassDefinitionEmpty; > protoDefinition.finalize = 0; >- swap(definition.staticFunctions, protoDefinition.staticFunctions); // Move static functions to the prototype. >+ std::swap(definition.staticFunctions, protoDefinition.staticFunctions); // Move static functions to the prototype. > > // We are supposed to use JSClassRetain/Release but since we know that we currently have > // the only reference to this class object we cheat and use a RefPtr instead. >diff --git a/Source/JavaScriptCore/bytecode/Opcode.cpp b/Source/JavaScriptCore/bytecode/Opcode.cpp >index 0d16dfc2f22d018470fb8ec11e85158cb9680d96..3a849c47f0171642049d220726aad73294c3493c 100644 >--- a/Source/JavaScriptCore/bytecode/Opcode.cpp >+++ b/Source/JavaScriptCore/bytecode/Opcode.cpp >@@ -37,8 +37,6 @@ > #include <wtf/DataLog.h> > #endif > >-using namespace std; >- > namespace JSC { > > const char* const opcodeNames[] = { >diff --git a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp >index 683952156a20136f0e228729be9e5112b2f0ba01..e7795db731a4a70e520b9584fc7464f02eee3441 100644 >--- a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp >+++ b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp >@@ -64,8 +64,6 @@ > #include <wtf/StdLibExtras.h> > #include <wtf/text/WTFString.h> > >-using namespace std; >- > namespace JSC { > > template<typename T> >@@ -1196,7 +1194,7 @@ UniquedStringImpl* BytecodeGenerator::visibleNameForParameter(DestructuringPatte > RegisterID* BytecodeGenerator::newRegister() > { > m_calleeLocals.append(virtualRegisterForLocal(m_calleeLocals.size())); >- int numCalleeLocals = max<int>(m_codeBlock->m_numCalleeLocals, m_calleeLocals.size()); >+ int numCalleeLocals = std::max<int>(m_codeBlock->m_numCalleeLocals, m_calleeLocals.size()); > numCalleeLocals = WTF::roundUpToMultipleOf(stackAlignmentRegisters(), numCalleeLocals); > m_codeBlock->m_numCalleeLocals = numCalleeLocals; > return &m_calleeLocals.last(); >diff --git a/Source/JavaScriptCore/heap/Heap.cpp b/Source/JavaScriptCore/heap/Heap.cpp >index 2f8ce661238451cfe98a4d2f45e08d4e6bc20d0b..3bc9e5b351473b6aa5ec0272b10556a21df6512f 100644 >--- a/Source/JavaScriptCore/heap/Heap.cpp >+++ b/Source/JavaScriptCore/heap/Heap.cpp >@@ -102,8 +102,6 @@ extern "C" void objc_autoreleasePoolPop(void *context); > #include "JSCGLibWrapperObject.h" > #endif > >-using namespace std; >- > namespace JSC { > > namespace { >@@ -120,7 +118,7 @@ double maxPauseMS(double thisPauseMS) > size_t minHeapSize(HeapType heapType, size_t ramSize) > { > if (heapType == LargeHeap) { >- double result = min( >+ double result = std::min( > static_cast<double>(Options::largeHeapSize()), > ramSize * Options::smallHeapRAMFraction()); > return static_cast<size_t>(result); >@@ -2231,7 +2229,7 @@ void Heap::updateAllocationLimits() > // To avoid pathological GC churn in very small and very large heaps, we set > // the new allocation limit based on the current size of the heap, with a > // fixed minimum. >- m_maxHeapSize = max(minHeapSize(m_heapType, m_ramSize), proportionalHeapSize(currentHeapSize, m_ramSize)); >+ m_maxHeapSize = std::max(minHeapSize(m_heapType, m_ramSize), proportionalHeapSize(currentHeapSize, m_ramSize)); > if (verbose) > dataLog("Full: maxHeapSize = ", m_maxHeapSize, "\n"); > m_maxEdenSize = m_maxHeapSize - currentHeapSize; >diff --git a/Source/JavaScriptCore/interpreter/Interpreter.cpp b/Source/JavaScriptCore/interpreter/Interpreter.cpp >index 4f72709b9fbeab536b2b44036f7b50f9c9b9ec73..5449c61590832fe891b34462839de1ad982bda60 100644 >--- a/Source/JavaScriptCore/interpreter/Interpreter.cpp >+++ b/Source/JavaScriptCore/interpreter/Interpreter.cpp >@@ -90,8 +90,6 @@ > #include "JIT.h" > #endif > >-using namespace std; >- > namespace JSC { > > JSValue eval(CallFrame* callFrame) >diff --git a/Source/JavaScriptCore/jit/JIT.cpp b/Source/JavaScriptCore/jit/JIT.cpp >index 4c34e53280596edd657539e79f6774b7b98f8879..e20708adfae546fba46abde8e3637bd5a9acd7e1 100644 >--- a/Source/JavaScriptCore/jit/JIT.cpp >+++ b/Source/JavaScriptCore/jit/JIT.cpp >@@ -55,8 +55,6 @@ > #include <wtf/GraphNodeWorklist.h> > #include <wtf/SimpleStats.h> > >-using namespace std; >- > namespace JSC { > namespace JITInternal { > static constexpr const bool verbose = false; >diff --git a/Source/JavaScriptCore/parser/Parser.cpp b/Source/JavaScriptCore/parser/Parser.cpp >index 89053a7200726e310eb98778530baedf09f68571..6e6fd4953594e273e820112114e32d85a6bccc63 100644 >--- a/Source/JavaScriptCore/parser/Parser.cpp >+++ b/Source/JavaScriptCore/parser/Parser.cpp >@@ -86,8 +86,6 @@ > > #define semanticFailureDueToKeyword(...) semanticFailureDueToKeywordCheckingToken(m_token, __VA_ARGS__); > >-using namespace std; >- > namespace JSC { > > ALWAYS_INLINE static SourceParseMode getAsynFunctionBodyParseMode(SourceParseMode parseMode) >diff --git a/Source/JavaScriptCore/runtime/JSArray.cpp b/Source/JavaScriptCore/runtime/JSArray.cpp >index 78bef94f0afb1ff2cef08fdad63e5130042cc40b..6fd86e710e08e8c8c66411be5dfe5ddc5ae29545 100644 >--- a/Source/JavaScriptCore/runtime/JSArray.cpp >+++ b/Source/JavaScriptCore/runtime/JSArray.cpp >@@ -35,9 +35,6 @@ > #include "TypeError.h" > #include <wtf/Assertions.h> > >-using namespace std; >-using namespace WTF; >- > namespace JSC { > > const char* const LengthExceededTheMaximumArrayLengthError = "Length exceeded the maximum array length"; >diff --git a/Source/JavaScriptCore/runtime/JSLexicalEnvironment.cpp b/Source/JavaScriptCore/runtime/JSLexicalEnvironment.cpp >index d801d5a7fa0b3fdc655fa9a0e10cd65c03270ff3..9943d0ed4f811bff60d4d2f5e8e1a5d0971639a2 100644 >--- a/Source/JavaScriptCore/runtime/JSLexicalEnvironment.cpp >+++ b/Source/JavaScriptCore/runtime/JSLexicalEnvironment.cpp >@@ -34,8 +34,6 @@ > #include "JSFunction.h" > #include "JSCInlines.h" > >-using namespace std; >- > namespace JSC { > > const ClassInfo JSLexicalEnvironment::s_info = { "JSLexicalEnvironment", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSLexicalEnvironment) }; >diff --git a/Source/JavaScriptCore/runtime/JSModuleEnvironment.cpp b/Source/JavaScriptCore/runtime/JSModuleEnvironment.cpp >index a9eb84a7cd6f311e5eb970d19d3d5fb99256777f..d9b9e5738de5f9be65ab2b8bf8c75f0cee262e8e 100644 >--- a/Source/JavaScriptCore/runtime/JSModuleEnvironment.cpp >+++ b/Source/JavaScriptCore/runtime/JSModuleEnvironment.cpp >@@ -34,8 +34,6 @@ > #include "JSCInlines.h" > #include "JSFunction.h" > >-using namespace std; >- > namespace JSC { > > const ClassInfo JSModuleEnvironment::s_info = { "JSModuleEnvironment", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSModuleEnvironment) }; >diff --git a/Source/JavaScriptCore/runtime/Structure.cpp b/Source/JavaScriptCore/runtime/Structure.cpp >index 720aff7966c9f2ee3a2c9e4d217c3214eb417491..a66ce566c8eee817cb069ec79eb5e17a56e6d508 100644 >--- a/Source/JavaScriptCore/runtime/Structure.cpp >+++ b/Source/JavaScriptCore/runtime/Structure.cpp >@@ -46,9 +46,6 @@ > > #define DUMP_STRUCTURE_ID_STATISTICS 0 > >-using namespace std; >-using namespace WTF; >- > namespace JSC { > > #if DUMP_STRUCTURE_ID_STATISTICS >diff --git a/Source/JavaScriptCore/shell/DLLLauncherMain.cpp b/Source/JavaScriptCore/shell/DLLLauncherMain.cpp >index 1770e2572117062acae76840485a91ab0b5f9c4e..33633c3110070d516ce542ecf5cba5b194ad9257 100644 >--- a/Source/JavaScriptCore/shell/DLLLauncherMain.cpp >+++ b/Source/JavaScriptCore/shell/DLLLauncherMain.cpp >@@ -35,8 +35,6 @@ > #include <vector> > #include <windows.h> > >-using namespace std; >- > #if defined _M_IX86 > #define PROCESSORARCHITECTURE "x86" > #elif defined _M_IA64 >@@ -58,73 +56,73 @@ static void enableTerminationOnHeapCorruption() > HeapSetInformation(0, heapEnableTerminationOnCorruption, 0, 0); > } > >-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 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]; > } > >-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()); > } > >-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."; > ::MessageBoxW(0, message.c_str(), caption.c_str(), MB_ICONERROR); > return 1; > } > >-static bool directoryExists(const wstring& path) >+static bool directoryExists(const std::wstring& path) > { > DWORD attrib = ::GetFileAttributes(path.c_str()); > > 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) >@@ -140,7 +138,7 @@ static bool modifyPath(const wstring& programName) > > #else > >- const wstring& pathPrefix = appleApplicationSupportDirectory(); >+ const std::wstring& pathPrefix = appleApplicationSupportDirectory(); > > if (!directoryExists(pathPrefix)) { > fatalError(programName, L"Failed to determine path to AAS directory."); >@@ -155,7 +153,7 @@ static bool modifyPath(const wstring& programName) > #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; >@@ -185,20 +183,20 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpstrCm > > ::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())) > 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*[]); >diff --git a/Source/bmalloc/bmalloc/Allocator.cpp b/Source/bmalloc/bmalloc/Allocator.cpp >index 770e78aca49aa6231b1943757f408eea87e96122..f2d93b7b634a7ada0b1efd2296cf421db5a39e96 100644 >--- a/Source/bmalloc/bmalloc/Allocator.cpp >+++ b/Source/bmalloc/bmalloc/Allocator.cpp >@@ -34,8 +34,6 @@ > #include <algorithm> > #include <cstdlib> > >-using namespace std; >- > namespace bmalloc { > > Allocator::Allocator(Heap& heap, Deallocator& deallocator) >diff --git a/Source/bmalloc/bmalloc/Deallocator.cpp b/Source/bmalloc/bmalloc/Deallocator.cpp >index 1b37051263659646fd44131ab61f28a8872d2192..556f3279d52a243ff0db2b34f55a3c0eaf92d303 100644 >--- a/Source/bmalloc/bmalloc/Deallocator.cpp >+++ b/Source/bmalloc/bmalloc/Deallocator.cpp >@@ -35,8 +35,6 @@ > #include <cstdlib> > #include <sys/mman.h> > >-using namespace std; >- > namespace bmalloc { > > Deallocator::Deallocator(Heap& heap)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185362
: 339676