Diff
Modified: trunk/Source/_javascript_Core/API/JSClassRef.cpp (231402 => 231403)
--- trunk/Source/_javascript_Core/API/JSClassRef.cpp 2018-05-07 02:46:36 UTC (rev 231402)
+++ trunk/Source/_javascript_Core/API/JSClassRef.cpp 2018-05-07 02:46:40 UTC (rev 231403)
@@ -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 @@
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.
Modified: trunk/Source/_javascript_Core/ChangeLog (231402 => 231403)
--- trunk/Source/_javascript_Core/ChangeLog 2018-05-07 02:46:36 UTC (rev 231402)
+++ trunk/Source/_javascript_Core/ChangeLog 2018-05-07 02:46:40 UTC (rev 231403)
@@ -1,3 +1,41 @@
+2018-05-06 Yusuke Suzuki <[email protected]>
+
+ [JSC] Remove "using namespace std;" from JSC, bmalloc, WTF
+ https://bugs.webkit.org/show_bug.cgi?id=185362
+
+ Reviewed by Sam Weinig.
+
+ "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 <[email protected]>
DFG CFA phase should only do clobber asserts in debug
Modified: trunk/Source/_javascript_Core/bytecode/Opcode.cpp (231402 => 231403)
--- trunk/Source/_javascript_Core/bytecode/Opcode.cpp 2018-05-07 02:46:36 UTC (rev 231402)
+++ trunk/Source/_javascript_Core/bytecode/Opcode.cpp 2018-05-07 02:46:40 UTC (rev 231403)
@@ -37,8 +37,6 @@
#include <wtf/DataLog.h>
#endif
-using namespace std;
-
namespace JSC {
const char* const opcodeNames[] = {
Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp (231402 => 231403)
--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp 2018-05-07 02:46:36 UTC (rev 231402)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp 2018-05-07 02:46:40 UTC (rev 231403)
@@ -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 @@
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();
Modified: trunk/Source/_javascript_Core/heap/Heap.cpp (231402 => 231403)
--- trunk/Source/_javascript_Core/heap/Heap.cpp 2018-05-07 02:46:36 UTC (rev 231402)
+++ trunk/Source/_javascript_Core/heap/Heap.cpp 2018-05-07 02:46:40 UTC (rev 231403)
@@ -102,8 +102,6 @@
#include "JSCGLibWrapperObject.h"
#endif
-using namespace std;
-
namespace JSC {
namespace {
@@ -120,7 +118,7 @@
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 @@
// 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;
Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (231402 => 231403)
--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2018-05-07 02:46:36 UTC (rev 231402)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2018-05-07 02:46:40 UTC (rev 231403)
@@ -90,8 +90,6 @@
#include "JIT.h"
#endif
-using namespace std;
-
namespace JSC {
JSValue eval(CallFrame* callFrame)
Modified: trunk/Source/_javascript_Core/jit/JIT.cpp (231402 => 231403)
--- trunk/Source/_javascript_Core/jit/JIT.cpp 2018-05-07 02:46:36 UTC (rev 231402)
+++ trunk/Source/_javascript_Core/jit/JIT.cpp 2018-05-07 02:46:40 UTC (rev 231403)
@@ -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;
Modified: trunk/Source/_javascript_Core/parser/Parser.cpp (231402 => 231403)
--- trunk/Source/_javascript_Core/parser/Parser.cpp 2018-05-07 02:46:36 UTC (rev 231402)
+++ trunk/Source/_javascript_Core/parser/Parser.cpp 2018-05-07 02:46:40 UTC (rev 231403)
@@ -86,8 +86,6 @@
#define semanticFailureDueToKeyword(...) semanticFailureDueToKeywordCheckingToken(m_token, __VA_ARGS__);
-using namespace std;
-
namespace JSC {
ALWAYS_INLINE static SourceParseMode getAsynFunctionBodyParseMode(SourceParseMode parseMode)
Modified: trunk/Source/_javascript_Core/runtime/JSArray.cpp (231402 => 231403)
--- trunk/Source/_javascript_Core/runtime/JSArray.cpp 2018-05-07 02:46:36 UTC (rev 231402)
+++ trunk/Source/_javascript_Core/runtime/JSArray.cpp 2018-05-07 02:46:40 UTC (rev 231403)
@@ -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";
Modified: trunk/Source/_javascript_Core/runtime/JSLexicalEnvironment.cpp (231402 => 231403)
--- trunk/Source/_javascript_Core/runtime/JSLexicalEnvironment.cpp 2018-05-07 02:46:36 UTC (rev 231402)
+++ trunk/Source/_javascript_Core/runtime/JSLexicalEnvironment.cpp 2018-05-07 02:46:40 UTC (rev 231403)
@@ -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) };
Modified: trunk/Source/_javascript_Core/runtime/JSModuleEnvironment.cpp (231402 => 231403)
--- trunk/Source/_javascript_Core/runtime/JSModuleEnvironment.cpp 2018-05-07 02:46:36 UTC (rev 231402)
+++ trunk/Source/_javascript_Core/runtime/JSModuleEnvironment.cpp 2018-05-07 02:46:40 UTC (rev 231403)
@@ -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) };
Modified: trunk/Source/_javascript_Core/runtime/Structure.cpp (231402 => 231403)
--- trunk/Source/_javascript_Core/runtime/Structure.cpp 2018-05-07 02:46:36 UTC (rev 231402)
+++ trunk/Source/_javascript_Core/runtime/Structure.cpp 2018-05-07 02:46:40 UTC (rev 231403)
@@ -46,9 +46,6 @@
#define DUMP_STRUCTURE_ID_STATISTICS 0
-using namespace std;
-using namespace WTF;
-
namespace JSC {
#if DUMP_STRUCTURE_ID_STATISTICS
Modified: trunk/Source/_javascript_Core/shell/DLLLauncherMain.cpp (231402 => 231403)
--- trunk/Source/_javascript_Core/shell/DLLLauncherMain.cpp 2018-05-07 02:46:36 UTC (rev 231402)
+++ trunk/Source/_javascript_Core/shell/DLLLauncherMain.cpp 2018-05-07 02:46:40 UTC (rev 231403)
@@ -35,8 +35,6 @@
#include <vector>
#include <windows.h>
-using namespace std;
-
#if defined _M_IX86
#define PROCESSORARCHITECTURE "x86"
#elif defined _M_IA64
@@ -58,62 +56,62 @@
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());
@@ -120,11 +118,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)
@@ -140,7 +138,7 @@
#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 @@
#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,13 +183,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()))
@@ -198,7 +196,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*[]);
Modified: trunk/Source/bmalloc/ChangeLog (231402 => 231403)
--- trunk/Source/bmalloc/ChangeLog 2018-05-07 02:46:36 UTC (rev 231402)
+++ trunk/Source/bmalloc/ChangeLog 2018-05-07 02:46:40 UTC (rev 231403)
@@ -1,3 +1,13 @@
+2018-05-06 Yusuke Suzuki <[email protected]>
+
+ [JSC] Remove "using namespace std;" from JSC, bmalloc, WTF
+ https://bugs.webkit.org/show_bug.cgi?id=185362
+
+ Reviewed by Sam Weinig.
+
+ * bmalloc/Allocator.cpp:
+ * bmalloc/Deallocator.cpp:
+
2018-05-03 Filip Pizlo <[email protected]>
Strings should not be allocated in a gigacage
Modified: trunk/Source/bmalloc/bmalloc/Allocator.cpp (231402 => 231403)
--- trunk/Source/bmalloc/bmalloc/Allocator.cpp 2018-05-07 02:46:36 UTC (rev 231402)
+++ trunk/Source/bmalloc/bmalloc/Allocator.cpp 2018-05-07 02:46:40 UTC (rev 231403)
@@ -34,8 +34,6 @@
#include <algorithm>
#include <cstdlib>
-using namespace std;
-
namespace bmalloc {
Allocator::Allocator(Heap& heap, Deallocator& deallocator)
Modified: trunk/Source/bmalloc/bmalloc/Deallocator.cpp (231402 => 231403)
--- trunk/Source/bmalloc/bmalloc/Deallocator.cpp 2018-05-07 02:46:36 UTC (rev 231402)
+++ trunk/Source/bmalloc/bmalloc/Deallocator.cpp 2018-05-07 02:46:40 UTC (rev 231403)
@@ -35,8 +35,6 @@
#include <cstdlib>
#include <sys/mman.h>
-using namespace std;
-
namespace bmalloc {
Deallocator::Deallocator(Heap& heap)