Use constexpr in more places and remove some unnecessary external linkage.
https://bugs.webkit.org/show_bug.cgi?id=203115
Reviewed by Yusuke Suzuki.
Source/JavaScriptCore:
* API/JSWrapperMap.mm:
* heap/MarkedBlock.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
(Inspector::JSGlobalObjectInspectorController::appendAPIBacktrace):
* inspector/ScriptCallStack.h:
* interpreter/CLoopStack.h:
* interpreter/CallFrame.h:
* interpreter/ShadowChicken.h:
* jit/AssemblyHelpers.cpp:
(JSC::emitRandomThunkImpl):
* jit/GPRInfo.cpp:
* jit/GPRInfo.h:
* jit/JIT.h:
* jit/PCToCodeOriginMap.cpp:
* jit/SpecializedThunkJIT.h:
* jit/ThunkGenerators.cpp:
(JSC::roundThunkGenerator):
* jit/UnusedPointer.h:
* llint/LLIntData.h:
* llint/LLIntPCRanges.h:
* parser/Lexer.h:
* parser/Nodes.h:
* runtime/CodeCache.cpp:
* runtime/CodeCache.h:
* runtime/ErrorInstance.h:
* runtime/JSAsyncFunction.h:
* runtime/JSAsyncGeneratorFunction.h:
* runtime/JSBoundFunction.h:
* runtime/JSCallee.h:
* runtime/JSFunction.h:
* runtime/JSGeneratorFunction.h:
* runtime/JSNativeStdFunction.h:
* runtime/JSRunLoopTimer.cpp:
(): Deleted.
* runtime/JSRunLoopTimer.h:
* runtime/ProxyObject.h:
* runtime/Watchdog.cpp:
(): Deleted.
* runtime/Watchdog.h:
* wasm/js/WebAssemblyFunction.h:
* wasm/js/WebAssemblyFunctionBase.h:
* wasm/js/WebAssemblyWrapperFunction.h:
Source/WebCore:
No new tests because this patch adds no new functionality.
* html/track/TextTrackCueGeneric.cpp:
* html/track/VTTCue.cpp:
* page/EventHandler.cpp:
(WebCore::SyntheticTouchPoint::SyntheticTouchPoint):
* page/FrameTree.h:
* page/scrolling/ScrollingMomentumCalculator.cpp:
(WebCore::projectedInertialScrollDistance):
* platform/graphics/FontTaggedSettings.h:
* platform/graphics/Region.cpp:
* platform/graphics/filters/FELighting.cpp:
* rendering/TableLayout.h:
* rendering/svg/SVGRenderingContext.h:
Source/WebKit:
* UIProcess/API/APIContentRuleListStore.h:
* WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm:
Source/WTF:
Also removed unused lockSpinLimit in Threading.h.
* wtf/MD5.h:
* wtf/SHA1.h:
* wtf/StackBounds.h:
* wtf/Threading.h:
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/mac/IsNavigationActionTrusted.mm:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251263 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/API/JSWrapperMap.mm b/Source/JavaScriptCore/API/JSWrapperMap.mm
index a27bc15..b0da9b4 100644
--- a/Source/JavaScriptCore/API/JSWrapperMap.mm
+++ b/Source/JavaScriptCore/API/JSWrapperMap.mm
@@ -62,7 +62,7 @@
@end
-static const constexpr unsigned InitialBufferSize { 256 };
+static constexpr unsigned InitialBufferSize { 256 };
// Default conversion of selectors to property names.
// All semicolons are removed, lowercase letters following a semicolon are capitalized.
diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index b5a10a7..ee262b1 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,53 @@
+2019-10-17 Mark Lam <mark.lam@apple.com>
+
+ Use constexpr in more places and remove some unnecessary external linkage.
+ https://bugs.webkit.org/show_bug.cgi?id=203115
+
+ Reviewed by Yusuke Suzuki.
+
+ * API/JSWrapperMap.mm:
+ * heap/MarkedBlock.cpp:
+ * inspector/JSGlobalObjectInspectorController.cpp:
+ (Inspector::JSGlobalObjectInspectorController::appendAPIBacktrace):
+ * inspector/ScriptCallStack.h:
+ * interpreter/CLoopStack.h:
+ * interpreter/CallFrame.h:
+ * interpreter/ShadowChicken.h:
+ * jit/AssemblyHelpers.cpp:
+ (JSC::emitRandomThunkImpl):
+ * jit/GPRInfo.cpp:
+ * jit/GPRInfo.h:
+ * jit/JIT.h:
+ * jit/PCToCodeOriginMap.cpp:
+ * jit/SpecializedThunkJIT.h:
+ * jit/ThunkGenerators.cpp:
+ (JSC::roundThunkGenerator):
+ * jit/UnusedPointer.h:
+ * llint/LLIntData.h:
+ * llint/LLIntPCRanges.h:
+ * parser/Lexer.h:
+ * parser/Nodes.h:
+ * runtime/CodeCache.cpp:
+ * runtime/CodeCache.h:
+ * runtime/ErrorInstance.h:
+ * runtime/JSAsyncFunction.h:
+ * runtime/JSAsyncGeneratorFunction.h:
+ * runtime/JSBoundFunction.h:
+ * runtime/JSCallee.h:
+ * runtime/JSFunction.h:
+ * runtime/JSGeneratorFunction.h:
+ * runtime/JSNativeStdFunction.h:
+ * runtime/JSRunLoopTimer.cpp:
+ (): Deleted.
+ * runtime/JSRunLoopTimer.h:
+ * runtime/ProxyObject.h:
+ * runtime/Watchdog.cpp:
+ (): Deleted.
+ * runtime/Watchdog.h:
+ * wasm/js/WebAssemblyFunction.h:
+ * wasm/js/WebAssemblyFunctionBase.h:
+ * wasm/js/WebAssemblyWrapperFunction.h:
+
2019-10-17 Brent Fulgham <bfulgham@apple.com>
Build fix for newer versions of MSVC.
diff --git a/Source/JavaScriptCore/heap/MarkedBlock.cpp b/Source/JavaScriptCore/heap/MarkedBlock.cpp
index 19615cb..916f838 100644
--- a/Source/JavaScriptCore/heap/MarkedBlock.cpp
+++ b/Source/JavaScriptCore/heap/MarkedBlock.cpp
@@ -42,8 +42,6 @@
static constexpr bool verbose = false;
}
-const size_t MarkedBlock::blockSize;
-
static constexpr bool computeBalance = false;
static size_t balance;
diff --git a/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp b/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp
index bdbd31d..0ee73ed 100644
--- a/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp
+++ b/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp
@@ -156,8 +156,8 @@
void JSGlobalObjectInspectorController::appendAPIBacktrace(ScriptCallStack& callStack)
{
- static const int framesToShow = 31;
- static const int framesToSkip = 3; // WTFGetBacktrace, appendAPIBacktrace, reportAPIException.
+ static constexpr int framesToShow = 31;
+ static constexpr int framesToSkip = 3; // WTFGetBacktrace, appendAPIBacktrace, reportAPIException.
void* samples[framesToShow + framesToSkip];
int frames = framesToShow + framesToSkip;
diff --git a/Source/JavaScriptCore/inspector/ScriptCallStack.h b/Source/JavaScriptCore/inspector/ScriptCallStack.h
index f9eccdc..dc423a9 100644
--- a/Source/JavaScriptCore/inspector/ScriptCallStack.h
+++ b/Source/JavaScriptCore/inspector/ScriptCallStack.h
@@ -40,7 +40,7 @@
class JS_EXPORT_PRIVATE ScriptCallStack : public RefCounted<ScriptCallStack> {
public:
- static const size_t maxCallStackSizeToCapture = 200;
+ static constexpr size_t maxCallStackSizeToCapture = 200;
static Ref<ScriptCallStack> create();
static Ref<ScriptCallStack> create(Vector<ScriptCallFrame>&);
diff --git a/Source/JavaScriptCore/interpreter/CLoopStack.h b/Source/JavaScriptCore/interpreter/CLoopStack.h
index 1f4d99d..fc10e80 100644
--- a/Source/JavaScriptCore/interpreter/CLoopStack.h
+++ b/Source/JavaScriptCore/interpreter/CLoopStack.h
@@ -46,7 +46,7 @@
WTF_MAKE_NONCOPYABLE(CLoopStack);
public:
// Allow 8k of excess registers before we start trying to reap the stack
- static const ptrdiff_t maxExcessCapacity = 8 * 1024;
+ static constexpr ptrdiff_t maxExcessCapacity = 8 * 1024;
CLoopStack(VM&);
~CLoopStack();
diff --git a/Source/JavaScriptCore/interpreter/CallFrame.h b/Source/JavaScriptCore/interpreter/CallFrame.h
index d00c3c9..12ab022 100644
--- a/Source/JavaScriptCore/interpreter/CallFrame.h
+++ b/Source/JavaScriptCore/interpreter/CallFrame.h
@@ -84,23 +84,23 @@
struct CallerFrameAndPC {
alignas(CPURegister) CallFrame* callerFrame;
alignas(CPURegister) const Instruction* returnPC;
- static const int sizeInRegisters = 2 * sizeof(CPURegister) / sizeof(Register);
+ static constexpr int sizeInRegisters = 2 * sizeof(CPURegister) / sizeof(Register);
};
static_assert(CallerFrameAndPC::sizeInRegisters == sizeof(CallerFrameAndPC) / sizeof(Register), "CallerFrameAndPC::sizeInRegisters is incorrect.");
struct CallFrameSlot {
- static const int codeBlock = CallerFrameAndPC::sizeInRegisters;
- static const int callee = codeBlock + 1;
- static const int argumentCount = callee + 1;
- static const int thisArgument = argumentCount + 1;
- static const int firstArgument = thisArgument + 1;
+ static constexpr int codeBlock = CallerFrameAndPC::sizeInRegisters;
+ static constexpr int callee = codeBlock + 1;
+ static constexpr int argumentCount = callee + 1;
+ static constexpr int thisArgument = argumentCount + 1;
+ static constexpr int firstArgument = thisArgument + 1;
};
// Represents the current state of script execution.
// Passed as the first argument to most functions.
class CallFrame : private Register {
public:
- static const int headerSizeInRegisters = CallFrameSlot::argumentCount + 1;
+ static constexpr int headerSizeInRegisters = CallFrameSlot::argumentCount + 1;
// This function should only be called in very specific circumstances
// when you've guaranteed the callee can't be a Wasm callee, and can
diff --git a/Source/JavaScriptCore/interpreter/ShadowChicken.h b/Source/JavaScriptCore/interpreter/ShadowChicken.h
index 20880a6..dfaebe1 100644
--- a/Source/JavaScriptCore/interpreter/ShadowChicken.h
+++ b/Source/JavaScriptCore/interpreter/ShadowChicken.h
@@ -77,9 +77,9 @@
{
}
- static const constexpr unsigned unlikelyValue = 0x7a11;
+ static constexpr unsigned unlikelyValue = 0x7a11;
- static const constexpr intptr_t tailMarkerValue = static_cast<intptr_t>(unlikelyValue);
+ static constexpr intptr_t tailMarkerValue = static_cast<intptr_t>(unlikelyValue);
static JSObject* tailMarker()
{
return bitwise_cast<JSObject*>(tailMarkerValue);
diff --git a/Source/JavaScriptCore/jit/AssemblyHelpers.cpp b/Source/JavaScriptCore/jit/AssemblyHelpers.cpp
index 3a829c1..71311e6 100644
--- a/Source/JavaScriptCore/jit/AssemblyHelpers.cpp
+++ b/Source/JavaScriptCore/jit/AssemblyHelpers.cpp
@@ -446,7 +446,7 @@
// Convert `(53bit double integer value) / (1 << 53)` to `(53bit double integer value) * (1.0 / (1 << 53))`.
// In latter case, `1.0 / (1 << 53)` will become a double value represented as (mantissa = 0 & exp = 970, it means 1e-(2**54)).
- static const double scale = 1.0 / (1ULL << 53);
+ static constexpr double scale = 1.0 / (1ULL << 53);
// Multiplying 1e-(2**54) with the double integer does not change anything of the mantissa part of the double integer.
// It just reduces the exp part of the given 53bit double integer.
diff --git a/Source/JavaScriptCore/jit/GPRInfo.cpp b/Source/JavaScriptCore/jit/GPRInfo.cpp
index af8e358..c5ed795 100644
--- a/Source/JavaScriptCore/jit/GPRInfo.cpp
+++ b/Source/JavaScriptCore/jit/GPRInfo.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -39,13 +39,6 @@
#endif
}
-// This is in the .cpp file to work around clang issues.
-#if CPU(X86_64)
-const GPRReg GPRInfo::patchpointScratchRegister = MacroAssembler::s_scratchRegister;
-#elif CPU(ARM64)
-const GPRReg GPRInfo::patchpointScratchRegister = ARM64Registers::ip0;
-#endif
-
} // namespace JSC
#endif // ENABLE(ASSEMBLER)
diff --git a/Source/JavaScriptCore/jit/GPRInfo.h b/Source/JavaScriptCore/jit/GPRInfo.h
index 5953bc6..412bbc8 100644
--- a/Source/JavaScriptCore/jit/GPRInfo.h
+++ b/Source/JavaScriptCore/jit/GPRInfo.h
@@ -469,7 +469,7 @@
// FIXME: I believe that all uses of this are dead in the sense that it just causes the scratch
// register allocator to select a different register and potentially spill things. It would be better
// if we instead had a more explicit way of saying that we don't have a scratch register.
- static const GPRReg patchpointScratchRegister;
+ static constexpr GPRReg patchpointScratchRegister = MacroAssembler::s_scratchRegister;
static GPRReg toRegister(unsigned index)
{
@@ -655,7 +655,7 @@
static constexpr GPRReg nonPreservedNonReturnGPR = ARM64Registers::x2;
static constexpr GPRReg nonPreservedNonArgumentGPR0 = ARM64Registers::x8;
static constexpr GPRReg nonPreservedNonArgumentGPR1 = ARM64Registers::x9;
- static const GPRReg patchpointScratchRegister;
+ static constexpr GPRReg patchpointScratchRegister = ARM64Registers::ip0;
// GPRReg mapping is direct, the machine register numbers can
// be used directly as indices into the GPR RegisterBank.
diff --git a/Source/JavaScriptCore/jit/JIT.h b/Source/JavaScriptCore/jit/JIT.h
index 427e9ae..03f7981 100644
--- a/Source/JavaScriptCore/jit/JIT.h
+++ b/Source/JavaScriptCore/jit/JIT.h
@@ -185,11 +185,11 @@
using MacroAssembler::JumpList;
using MacroAssembler::Label;
- static const uintptr_t patchGetByIdDefaultStructure = unusedPointer;
- static const int patchGetByIdDefaultOffset = 0;
+ static constexpr uintptr_t patchGetByIdDefaultStructure = unusedPointer;
+ static constexpr int patchGetByIdDefaultOffset = 0;
// Magic number - initial offset cannot be representable as a signed 8bit value, or the X86Assembler
// will compress the displacement, and we may not be able to fit a patched offset.
- static const int patchPutByIdDefaultOffset = 256;
+ static constexpr int patchPutByIdDefaultOffset = 256;
public:
JIT(VM&, CodeBlock* = 0, unsigned loopOSREntryBytecodeOffset = 0);
diff --git a/Source/JavaScriptCore/jit/PCToCodeOriginMap.cpp b/Source/JavaScriptCore/jit/PCToCodeOriginMap.cpp
index 625e1f2..21298ad 100644
--- a/Source/JavaScriptCore/jit/PCToCodeOriginMap.cpp
+++ b/Source/JavaScriptCore/jit/PCToCodeOriginMap.cpp
@@ -55,7 +55,7 @@
void write(T item)
{
RELEASE_ASSERT(m_offset + sizeof(T) <= m_maxSize);
- static const uint8_t mask = std::numeric_limits<uint8_t>::max();
+ static constexpr uint8_t mask = std::numeric_limits<uint8_t>::max();
for (unsigned i = 0; i < sizeof(T); i++) {
*(m_buffer + m_offset) = static_cast<uint8_t>(item & mask);
item = item >> (sizeof(uint8_t) * 8);
@@ -145,8 +145,8 @@
}
-static const uint8_t sentinelPCDelta = 0;
-static const int8_t sentinelBytecodeDelta = 0;
+static constexpr uint8_t sentinelPCDelta = 0;
+static constexpr int8_t sentinelBytecodeDelta = 0;
PCToCodeOriginMap::PCToCodeOriginMap(PCToCodeOriginMapBuilder&& builder, LinkBuffer& linkBuffer)
{
diff --git a/Source/JavaScriptCore/jit/SpecializedThunkJIT.h b/Source/JavaScriptCore/jit/SpecializedThunkJIT.h
index 667229b..4f567d0 100644
--- a/Source/JavaScriptCore/jit/SpecializedThunkJIT.h
+++ b/Source/JavaScriptCore/jit/SpecializedThunkJIT.h
@@ -36,7 +36,7 @@
class SpecializedThunkJIT : public JSInterfaceJIT {
public:
- static const int ThisArgument = -1;
+ static constexpr int ThisArgument = -1;
SpecializedThunkJIT(VM& vm, int expectedArgCount)
: JSInterfaceJIT(&vm)
{
diff --git a/Source/JavaScriptCore/jit/ThunkGenerators.cpp b/Source/JavaScriptCore/jit/ThunkGenerators.cpp
index b79e08c..0442d1f 100644
--- a/Source/JavaScriptCore/jit/ThunkGenerators.cpp
+++ b/Source/JavaScriptCore/jit/ThunkGenerators.cpp
@@ -966,7 +966,7 @@
doubleResult.append(jit.branchDouble(MacroAssembler::DoubleEqual, SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::fpRegT1));
jit.ceilDouble(SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::fpRegT1);
- static const double halfConstant = -0.5;
+ static constexpr double halfConstant = -0.5;
jit.loadDouble(MacroAssembler::TrustedImmPtr(&halfConstant), SpecializedThunkJIT::fpRegT2);
jit.addDouble(SpecializedThunkJIT::fpRegT1, SpecializedThunkJIT::fpRegT2);
MacroAssembler::Jump shouldRoundDown = jit.branchDouble(MacroAssembler::DoubleGreaterThan, SpecializedThunkJIT::fpRegT2, SpecializedThunkJIT::fpRegT0);
@@ -975,7 +975,7 @@
MacroAssembler::Jump continuation = jit.jump();
shouldRoundDown.link(&jit);
- static const double oneConstant = 1.0;
+ static constexpr double oneConstant = 1.0;
jit.loadDouble(MacroAssembler::TrustedImmPtr(&oneConstant), SpecializedThunkJIT::fpRegT2);
jit.subDouble(SpecializedThunkJIT::fpRegT1, SpecializedThunkJIT::fpRegT2, SpecializedThunkJIT::fpRegT0);
diff --git a/Source/JavaScriptCore/jit/UnusedPointer.h b/Source/JavaScriptCore/jit/UnusedPointer.h
index 631d7d6..f0998d2 100644
--- a/Source/JavaScriptCore/jit/UnusedPointer.h
+++ b/Source/JavaScriptCore/jit/UnusedPointer.h
@@ -27,7 +27,7 @@
namespace JSC {
-static const uintptr_t unusedPointer = 0xd1e7beef;
+static constexpr uintptr_t unusedPointer = 0xd1e7beef;
} // namespace JSC
diff --git a/Source/JavaScriptCore/llint/LLIntData.h b/Source/JavaScriptCore/llint/LLIntData.h
index 26e32a9..8cc1152 100644
--- a/Source/JavaScriptCore/llint/LLIntData.h
+++ b/Source/JavaScriptCore/llint/LLIntData.h
@@ -197,19 +197,19 @@
#if ENABLE(JIT)
struct Registers {
- static const GPRReg pcGPR = GPRInfo::regT4;
+ static constexpr GPRReg pcGPR = GPRInfo::regT4;
#if CPU(X86_64) && !OS(WINDOWS)
- static const GPRReg metadataTableGPR = GPRInfo::regCS1;
- static const GPRReg pbGPR = GPRInfo::regCS2;
+ static constexpr GPRReg metadataTableGPR = GPRInfo::regCS1;
+ static constexpr GPRReg pbGPR = GPRInfo::regCS2;
#elif CPU(X86_64) && OS(WINDOWS)
- static const GPRReg metadataTableGPR = GPRInfo::regCS3;
- static const GPRReg pbGPR = GPRInfo::regCS4;
+ static constexpr GPRReg metadataTableGPR = GPRInfo::regCS3;
+ static constexpr GPRReg pbGPR = GPRInfo::regCS4;
#elif CPU(ARM64)
- static const GPRReg metadataTableGPR = GPRInfo::regCS6;
- static const GPRReg pbGPR = GPRInfo::regCS7;
+ static constexpr GPRReg metadataTableGPR = GPRInfo::regCS6;
+ static constexpr GPRReg pbGPR = GPRInfo::regCS7;
#elif CPU(MIPS) || CPU(ARM_THUMB2)
- static const GPRReg metadataTableGPR = GPRInfo::regCS0;
+ static constexpr GPRReg metadataTableGPR = GPRInfo::regCS0;
#endif
};
#endif
diff --git a/Source/JavaScriptCore/llint/LLIntPCRanges.h b/Source/JavaScriptCore/llint/LLIntPCRanges.h
index 82bdc55..ad7111b 100644
--- a/Source/JavaScriptCore/llint/LLIntPCRanges.h
+++ b/Source/JavaScriptCore/llint/LLIntPCRanges.h
@@ -47,7 +47,7 @@
}
#if !ENABLE(C_LOOP)
-static const GPRReg LLIntPC = GPRInfo::regT4;
+static constexpr GPRReg LLIntPC = GPRInfo::regT4;
#endif
} } // namespace JSC::LLInt
diff --git a/Source/JavaScriptCore/parser/Lexer.h b/Source/JavaScriptCore/parser/Lexer.h
index e702684..a58f76b 100644
--- a/Source/JavaScriptCore/parser/Lexer.h
+++ b/Source/JavaScriptCore/parser/Lexer.h
@@ -195,7 +195,7 @@
void fillTokenInfo(JSToken*, JSTokenType, int lineNumber, int endOffset, int lineStartOffset, JSTextPosition endPosition);
- static const size_t initialReadBufferCapacity = 32;
+ static constexpr size_t initialReadBufferCapacity = 32;
int m_lineNumber;
int m_lastLineNumber;
diff --git a/Source/JavaScriptCore/parser/Nodes.h b/Source/JavaScriptCore/parser/Nodes.h
index e23938b..9c3032a 100644
--- a/Source/JavaScriptCore/parser/Nodes.h
+++ b/Source/JavaScriptCore/parser/Nodes.h
@@ -2492,7 +2492,7 @@
private:
SwitchInfo::SwitchType tryTableSwitch(Vector<ExpressionNode*, 8>& literalVector, int32_t& min_num, int32_t& max_num);
- static const size_t s_tableSwitchMinimum = 3;
+ static constexpr size_t s_tableSwitchMinimum = 3;
ClauseListNode* m_list1;
CaseClauseNode* m_defaultClause;
ClauseListNode* m_list2;
diff --git a/Source/JavaScriptCore/runtime/CodeCache.cpp b/Source/JavaScriptCore/runtime/CodeCache.cpp
index b2cfe74..4f3c962 100644
--- a/Source/JavaScriptCore/runtime/CodeCache.cpp
+++ b/Source/JavaScriptCore/runtime/CodeCache.cpp
@@ -31,8 +31,6 @@
namespace JSC {
-const Seconds CodeCacheMap::workingSetTime = 10_s;
-
void CodeCacheMap::pruneSlowCase()
{
m_minCapacity = std::max(m_size - m_sizeAtLastPrune, static_cast<int64_t>(0));
diff --git a/Source/JavaScriptCore/runtime/CodeCache.h b/Source/JavaScriptCore/runtime/CodeCache.h
index 9818f4c..4919f00 100644
--- a/Source/JavaScriptCore/runtime/CodeCache.h
+++ b/Source/JavaScriptCore/runtime/CodeCache.h
@@ -179,18 +179,18 @@
// This constant factor biases cache capacity toward allowing a minimum
// working set to enter the cache before it starts evicting.
- static const Seconds workingSetTime;
- static const int64_t workingSetMaxBytes = 16000000;
- static const size_t workingSetMaxEntries = 2000;
+ static constexpr Seconds workingSetTime = 10_s;
+ static constexpr int64_t workingSetMaxBytes = 16000000;
+ static constexpr size_t workingSetMaxEntries = 2000;
// This constant factor biases cache capacity toward recent activity. We
// want to adapt to changing workloads.
- static const int64_t recencyBias = 4;
+ static constexpr int64_t recencyBias = 4;
// This constant factor treats a sampled event for one old object as if it
// happened for many old objects. Most old objects are evicted before we can
// sample them, so we need to extrapolate from the ones we do sample.
- static const int64_t oldObjectSamplingMultiplier = 32;
+ static constexpr int64_t oldObjectSamplingMultiplier = 32;
size_t numberOfEntries() const { return static_cast<size_t>(m_map.size()); }
bool canPruneQuickly() const { return numberOfEntries() < workingSetMaxEntries; }
@@ -243,20 +243,20 @@
template <> struct CacheTypes<UnlinkedProgramCodeBlock> {
typedef JSC::ProgramNode RootNode;
- static const SourceCodeType codeType = SourceCodeType::ProgramType;
- static const SourceParseMode parseMode = SourceParseMode::ProgramMode;
+ static constexpr SourceCodeType codeType = SourceCodeType::ProgramType;
+ static constexpr SourceParseMode parseMode = SourceParseMode::ProgramMode;
};
template <> struct CacheTypes<UnlinkedEvalCodeBlock> {
typedef JSC::EvalNode RootNode;
- static const SourceCodeType codeType = SourceCodeType::EvalType;
- static const SourceParseMode parseMode = SourceParseMode::ProgramMode;
+ static constexpr SourceCodeType codeType = SourceCodeType::EvalType;
+ static constexpr SourceParseMode parseMode = SourceParseMode::ProgramMode;
};
template <> struct CacheTypes<UnlinkedModuleProgramCodeBlock> {
typedef JSC::ModuleProgramNode RootNode;
- static const SourceCodeType codeType = SourceCodeType::ModuleType;
- static const SourceParseMode parseMode = SourceParseMode::ModuleEvaluateMode;
+ static constexpr SourceCodeType codeType = SourceCodeType::ModuleType;
+ static constexpr SourceParseMode parseMode = SourceParseMode::ModuleEvaluateMode;
};
template <class UnlinkedCodeBlockType, class ExecutableType = ScriptExecutable>
diff --git a/Source/JavaScriptCore/runtime/ErrorInstance.h b/Source/JavaScriptCore/runtime/ErrorInstance.h
index 97a89da..c8356ff 100644
--- a/Source/JavaScriptCore/runtime/ErrorInstance.h
+++ b/Source/JavaScriptCore/runtime/ErrorInstance.h
@@ -29,7 +29,7 @@
class ErrorInstance : public JSDestructibleObject {
public:
typedef JSDestructibleObject Base;
- const static unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetPropertyNames;
+ static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetPropertyNames;
enum SourceTextWhereErrorOccurred { FoundExactSource, FoundApproximateSource };
typedef String (*SourceAppender) (const String& originalMessage, const String& sourceText, RuntimeType, SourceTextWhereErrorOccurred);
diff --git a/Source/JavaScriptCore/runtime/JSAsyncFunction.h b/Source/JavaScriptCore/runtime/JSAsyncFunction.h
index cb198b5f..82be840 100644
--- a/Source/JavaScriptCore/runtime/JSAsyncFunction.h
+++ b/Source/JavaScriptCore/runtime/JSAsyncFunction.h
@@ -36,7 +36,7 @@
public:
typedef JSFunction Base;
- const static unsigned StructureFlags = Base::StructureFlags;
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
DECLARE_EXPORT_INFO;
diff --git a/Source/JavaScriptCore/runtime/JSAsyncGeneratorFunction.h b/Source/JavaScriptCore/runtime/JSAsyncGeneratorFunction.h
index 0ebf076..8bc520b 100644
--- a/Source/JavaScriptCore/runtime/JSAsyncGeneratorFunction.h
+++ b/Source/JavaScriptCore/runtime/JSAsyncGeneratorFunction.h
@@ -36,7 +36,7 @@
public:
using Base = JSFunction;
- const static unsigned StructureFlags = Base::StructureFlags;
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
DECLARE_EXPORT_INFO;
diff --git a/Source/JavaScriptCore/runtime/JSBoundFunction.h b/Source/JavaScriptCore/runtime/JSBoundFunction.h
index 225acb0..94b0b38 100644
--- a/Source/JavaScriptCore/runtime/JSBoundFunction.h
+++ b/Source/JavaScriptCore/runtime/JSBoundFunction.h
@@ -39,7 +39,7 @@
class JSBoundFunction final : public JSFunction {
public:
typedef JSFunction Base;
- const static unsigned StructureFlags = Base::StructureFlags & ~ImplementsDefaultHasInstance;
+ static constexpr unsigned StructureFlags = Base::StructureFlags & ~ImplementsDefaultHasInstance;
static_assert(StructureFlags & ImplementsHasInstance, "");
template<typename CellType, SubspaceAccess mode>
diff --git a/Source/JavaScriptCore/runtime/JSCallee.h b/Source/JavaScriptCore/runtime/JSCallee.h
index d783dc4..bbcebf3 100644
--- a/Source/JavaScriptCore/runtime/JSCallee.h
+++ b/Source/JavaScriptCore/runtime/JSCallee.h
@@ -45,7 +45,7 @@
public:
typedef JSNonFinalObject Base;
- const static unsigned StructureFlags = Base::StructureFlags | ImplementsHasInstance | ImplementsDefaultHasInstance;
+ static constexpr unsigned StructureFlags = Base::StructureFlags | ImplementsHasInstance | ImplementsDefaultHasInstance;
static JSCallee* create(VM& vm, JSGlobalObject* globalObject, JSScope* scope)
{
diff --git a/Source/JavaScriptCore/runtime/JSFunction.h b/Source/JavaScriptCore/runtime/JSFunction.h
index 3fef92d..df4d798 100644
--- a/Source/JavaScriptCore/runtime/JSFunction.h
+++ b/Source/JavaScriptCore/runtime/JSFunction.h
@@ -69,7 +69,7 @@
}
typedef JSCallee Base;
- const static unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetPropertyNames | OverridesGetCallData;
+ static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetPropertyNames | OverridesGetCallData;
static size_t allocationSize(Checked<size_t> inlineCapacity)
{
diff --git a/Source/JavaScriptCore/runtime/JSGeneratorFunction.h b/Source/JavaScriptCore/runtime/JSGeneratorFunction.h
index efd2890..63affc2 100644
--- a/Source/JavaScriptCore/runtime/JSGeneratorFunction.h
+++ b/Source/JavaScriptCore/runtime/JSGeneratorFunction.h
@@ -43,7 +43,7 @@
public:
using Base = JSFunction;
- const static unsigned StructureFlags = Base::StructureFlags;
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
DECLARE_EXPORT_INFO;
diff --git a/Source/JavaScriptCore/runtime/JSNativeStdFunction.h b/Source/JavaScriptCore/runtime/JSNativeStdFunction.h
index f6c73b3..6de700b 100644
--- a/Source/JavaScriptCore/runtime/JSNativeStdFunction.h
+++ b/Source/JavaScriptCore/runtime/JSNativeStdFunction.h
@@ -38,7 +38,7 @@
public:
typedef JSFunction Base;
- const static unsigned StructureFlags = Base::StructureFlags;
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
template<typename CellType, SubspaceAccess mode>
static IsoSubspace* subspaceFor(VM& vm)
diff --git a/Source/JavaScriptCore/runtime/JSRunLoopTimer.cpp b/Source/JavaScriptCore/runtime/JSRunLoopTimer.cpp
index 2a0c06c..07b0d49 100644
--- a/Source/JavaScriptCore/runtime/JSRunLoopTimer.cpp
+++ b/Source/JavaScriptCore/runtime/JSRunLoopTimer.cpp
@@ -44,8 +44,6 @@
namespace JSC {
-const Seconds JSRunLoopTimer::s_decade { 60 * 60 * 24 * 365 * 10 };
-
static inline JSRunLoopTimer::Manager::EpochTime epochTime(Seconds delay)
{
#if USE(CF)
diff --git a/Source/JavaScriptCore/runtime/JSRunLoopTimer.h b/Source/JavaScriptCore/runtime/JSRunLoopTimer.h
index f615b6f..97cb4f0 100644
--- a/Source/JavaScriptCore/runtime/JSRunLoopTimer.h
+++ b/Source/JavaScriptCore/runtime/JSRunLoopTimer.h
@@ -121,7 +121,7 @@
JS_EXPORT_PRIVATE Optional<Seconds> timeUntilFire();
protected:
- static const Seconds s_decade;
+ static constexpr Seconds s_decade { 60 * 60 * 24 * 365 * 10 };
Ref<JSLock> m_apiLock;
private:
diff --git a/Source/JavaScriptCore/runtime/ProxyObject.h b/Source/JavaScriptCore/runtime/ProxyObject.h
index f7c127e..97399f7 100644
--- a/Source/JavaScriptCore/runtime/ProxyObject.h
+++ b/Source/JavaScriptCore/runtime/ProxyObject.h
@@ -34,7 +34,7 @@
public:
typedef JSNonFinalObject Base;
- const static unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetCallData | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | OverridesGetPropertyNames | ProhibitsPropertyCaching;
+ static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetCallData | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | OverridesGetPropertyNames | ProhibitsPropertyCaching;
static ProxyObject* create(ExecState* exec, JSGlobalObject* globalObject, JSValue target, JSValue handler)
{
diff --git a/Source/JavaScriptCore/runtime/Watchdog.cpp b/Source/JavaScriptCore/runtime/Watchdog.cpp
index 63a0e59..46340b2 100644
--- a/Source/JavaScriptCore/runtime/Watchdog.cpp
+++ b/Source/JavaScriptCore/runtime/Watchdog.cpp
@@ -32,8 +32,6 @@
namespace JSC {
-const Seconds Watchdog::noTimeLimit { Seconds::infinity() };
-
Watchdog::Watchdog(VM* vm)
: m_vm(vm)
, m_timeLimit(noTimeLimit)
diff --git a/Source/JavaScriptCore/runtime/Watchdog.h b/Source/JavaScriptCore/runtime/Watchdog.h
index d2ae053..1ef5d70 100644
--- a/Source/JavaScriptCore/runtime/Watchdog.h
+++ b/Source/JavaScriptCore/runtime/Watchdog.h
@@ -54,7 +54,7 @@
void enteredVM();
void exitedVM();
- static const Seconds noTimeLimit;
+ static constexpr Seconds noTimeLimit = Seconds::infinity();
private:
void startTimer(Seconds timeLimit);
diff --git a/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.h b/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.h
index 395a5bd..f9cc80c 100644
--- a/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.h
+++ b/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.h
@@ -49,7 +49,7 @@
public:
using Base = WebAssemblyFunctionBase;
- const static unsigned StructureFlags = Base::StructureFlags;
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
static constexpr bool needsDestruction = true;
static void destroy(JSCell*);
diff --git a/Source/JavaScriptCore/wasm/js/WebAssemblyFunctionBase.h b/Source/JavaScriptCore/wasm/js/WebAssemblyFunctionBase.h
index a533b5d..35a2f95 100644
--- a/Source/JavaScriptCore/wasm/js/WebAssemblyFunctionBase.h
+++ b/Source/JavaScriptCore/wasm/js/WebAssemblyFunctionBase.h
@@ -38,7 +38,7 @@
public:
using Base = JSFunction;
- const static unsigned StructureFlags = Base::StructureFlags;
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
DECLARE_INFO;
diff --git a/Source/JavaScriptCore/wasm/js/WebAssemblyWrapperFunction.h b/Source/JavaScriptCore/wasm/js/WebAssemblyWrapperFunction.h
index b74b2dd..d6063c9 100644
--- a/Source/JavaScriptCore/wasm/js/WebAssemblyWrapperFunction.h
+++ b/Source/JavaScriptCore/wasm/js/WebAssemblyWrapperFunction.h
@@ -38,7 +38,7 @@
public:
using Base = WebAssemblyFunctionBase;
- const static unsigned StructureFlags = Base::StructureFlags;
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
template<typename CellType, SubspaceAccess mode>
static IsoSubspace* subspaceFor(VM& vm)
diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog
index 0e44522..10ce81b 100644
--- a/Source/WTF/ChangeLog
+++ b/Source/WTF/ChangeLog
@@ -1,3 +1,17 @@
+2019-10-17 Mark Lam <mark.lam@apple.com>
+
+ Use constexpr in more places and remove some unnecessary external linkage.
+ https://bugs.webkit.org/show_bug.cgi?id=203115
+
+ Reviewed by Yusuke Suzuki.
+
+ Also removed unused lockSpinLimit in Threading.h.
+
+ * wtf/MD5.h:
+ * wtf/SHA1.h:
+ * wtf/StackBounds.h:
+ * wtf/Threading.h:
+
2019-10-17 Sihui Liu <sihui_liu@apple.com>
Using version 1 CFRunloopSource for faster task dispatch
diff --git a/Source/WTF/wtf/MD5.h b/Source/WTF/wtf/MD5.h
index 5daac07..cddd703 100644
--- a/Source/WTF/wtf/MD5.h
+++ b/Source/WTF/wtf/MD5.h
@@ -51,7 +51,7 @@
WTF_EXPORT_PRIVATE void addBytes(const uint8_t* input, size_t length);
// Size of the SHA1 hash
- WTF_EXPORT_PRIVATE static const size_t hashSize = 16;
+ WTF_EXPORT_PRIVATE static constexpr size_t hashSize = 16;
// type for computing MD5 hash
typedef std::array<uint8_t, hashSize> Digest;
diff --git a/Source/WTF/wtf/SHA1.h b/Source/WTF/wtf/SHA1.h
index a1af8ca..2c7d9a3 100644
--- a/Source/WTF/wtf/SHA1.h
+++ b/Source/WTF/wtf/SHA1.h
@@ -57,7 +57,7 @@
WTF_EXPORT_PRIVATE void addBytes(const uint8_t* input, size_t length);
// Size of the SHA1 hash
- WTF_EXPORT_PRIVATE static const size_t hashSize = 20;
+ WTF_EXPORT_PRIVATE static constexpr size_t hashSize = 20;
// type for computing SHA1 hash
typedef std::array<uint8_t, hashSize> Digest;
diff --git a/Source/WTF/wtf/StackBounds.h b/Source/WTF/wtf/StackBounds.h
index 4d9183b..2421a9a 100644
--- a/Source/WTF/wtf/StackBounds.h
+++ b/Source/WTF/wtf/StackBounds.h
@@ -40,7 +40,7 @@
// functions was seen to be as high as 27k. Hence, 64k is chosen as a
// conservative availability value that is not too large but comfortably
// exceeds 27k with some buffer for error.
- const static size_t s_defaultAvailabilityDelta = 64 * 1024;
+ static constexpr size_t s_defaultAvailabilityDelta = 64 * 1024;
public:
enum class StackDirection { Upward, Downward };
diff --git a/Source/WTF/wtf/Threading.h b/Source/WTF/wtf/Threading.h
index c4d00b2..ed9cbba 100644
--- a/Source/WTF/wtf/Threading.h
+++ b/Source/WTF/wtf/Threading.h
@@ -143,7 +143,6 @@
static void initializeCurrentThreadInternal(const char* threadName);
static void initializeCurrentThreadEvenIfNonWTFCreated();
- WTF_EXPORT_PRIVATE static const unsigned lockSpinLimit;
WTF_EXPORT_PRIVATE static void yield();
WTF_EXPORT_PRIVATE static bool exchangeIsCompilationThread(bool newValue);
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index e1bd4af..42e8975 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2019-10-17 Mark Lam <mark.lam@apple.com>
+
+ Use constexpr in more places and remove some unnecessary external linkage.
+ https://bugs.webkit.org/show_bug.cgi?id=203115
+
+ Reviewed by Yusuke Suzuki.
+
+ No new tests because this patch adds no new functionality.
+
+ * html/track/TextTrackCueGeneric.cpp:
+ * html/track/VTTCue.cpp:
+ * page/EventHandler.cpp:
+ (WebCore::SyntheticTouchPoint::SyntheticTouchPoint):
+ * page/FrameTree.h:
+ * page/scrolling/ScrollingMomentumCalculator.cpp:
+ (WebCore::projectedInertialScrollDistance):
+ * platform/graphics/FontTaggedSettings.h:
+ * platform/graphics/Region.cpp:
+ * platform/graphics/filters/FELighting.cpp:
+ * rendering/TableLayout.h:
+ * rendering/svg/SVGRenderingContext.h:
+
2019-10-17 Simon Fraser <simon.fraser@apple.com>
[ Mojave+ ] Layout Test compositing/fixed-with-main-thread-scrolling.html is a flaky timeout
diff --git a/Source/WebCore/html/track/TextTrackCueGeneric.cpp b/Source/WebCore/html/track/TextTrackCueGeneric.cpp
index 7c55ddf..15dfa23 100644
--- a/Source/WebCore/html/track/TextTrackCueGeneric.cpp
+++ b/Source/WebCore/html/track/TextTrackCueGeneric.cpp
@@ -47,7 +47,7 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(TextTrackCueGeneric);
// This default value must be the same as the one specified in mediaControlsApple.css for -webkit-media-controls-closed-captions-container
-const static int DEFAULTCAPTIONFONTSIZE = 10;
+static constexpr int DEFAULTCAPTIONFONTSIZE = 10;
class TextTrackCueGenericBoxElement final : public VTTCueBox {
WTF_MAKE_ISO_ALLOCATED_INLINE(TextTrackCueGenericBoxElement);
diff --git a/Source/WebCore/html/track/VTTCue.cpp b/Source/WebCore/html/track/VTTCue.cpp
index e8e2182..9e02c26 100644
--- a/Source/WebCore/html/track/VTTCue.cpp
+++ b/Source/WebCore/html/track/VTTCue.cpp
@@ -63,9 +63,9 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(VTTCue);
// This constant should correspond with the percentage returned by CaptionUserPreferences::captionFontSizeScaleAndImportance.
-const static double DEFAULTCAPTIONFONTSIZEPERCENTAGE = 5;
+static constexpr double DEFAULTCAPTIONFONTSIZEPERCENTAGE = 5;
-static const int undefinedPosition = -1;
+static constexpr int undefinedPosition = -1;
static const CSSValueID displayWritingModeMap[] = {
CSSValueHorizontalTb, CSSValueVerticalRl, CSSValueVerticalLr
diff --git a/Source/WebCore/page/EventHandler.cpp b/Source/WebCore/page/EventHandler.cpp
index 7ce5b3d..21cb1f8 100644
--- a/Source/WebCore/page/EventHandler.cpp
+++ b/Source/WebCore/page/EventHandler.cpp
@@ -216,11 +216,11 @@
// The default values are based on http://dvcs.w3.org/hg/webevents/raw-file/tip/touchevents.html
explicit SyntheticTouchPoint(const PlatformMouseEvent& event)
{
- const static int idDefaultValue = 0;
- const static int radiusYDefaultValue = 1;
- const static int radiusXDefaultValue = 1;
- const static float rotationAngleDefaultValue = 0.0f;
- const static float forceDefaultValue = 1.0f;
+ static constexpr int idDefaultValue = 0;
+ static constexpr int radiusYDefaultValue = 1;
+ static constexpr int radiusXDefaultValue = 1;
+ static constexpr float rotationAngleDefaultValue = 0.0f;
+ static constexpr float forceDefaultValue = 1.0f;
m_id = idDefaultValue; // There is only one active TouchPoint.
m_screenPos = event.globalPosition();
diff --git a/Source/WebCore/page/FrameTree.h b/Source/WebCore/page/FrameTree.h
index 7afb5ca..734f2ab 100644
--- a/Source/WebCore/page/FrameTree.h
+++ b/Source/WebCore/page/FrameTree.h
@@ -32,7 +32,7 @@
class FrameTree {
WTF_MAKE_NONCOPYABLE(FrameTree);
public:
- const static unsigned invalidCount = static_cast<unsigned>(-1);
+ static constexpr unsigned invalidCount = static_cast<unsigned>(-1);
FrameTree(Frame& thisFrame, Frame* parentFrame)
: m_thisFrame(thisFrame)
diff --git a/Source/WebCore/page/scrolling/ScrollingMomentumCalculator.cpp b/Source/WebCore/page/scrolling/ScrollingMomentumCalculator.cpp
index c890f9e..1bfefaa 100644
--- a/Source/WebCore/page/scrolling/ScrollingMomentumCalculator.cpp
+++ b/Source/WebCore/page/scrolling/ScrollingMomentumCalculator.cpp
@@ -38,7 +38,7 @@
// by multiplying the initial wheel delta by a constant factor. By running a few experiments (i.e. logging scroll destination and initial
// wheel delta for many scroll gestures) we determined that this is a reasonable way to approximate where scrolling will take us without
// using _NSScrollingMomentumCalculator.
- const static double inertialScrollPredictionFactor = 16.7;
+ static constexpr double inertialScrollPredictionFactor = 16.7;
return inertialScrollPredictionFactor * initialWheelDelta;
}
diff --git a/Source/WebCore/platform/graphics/FontTaggedSettings.h b/Source/WebCore/platform/graphics/FontTaggedSettings.h
index b57457e..bf6097a 100644
--- a/Source/WebCore/platform/graphics/FontTaggedSettings.h
+++ b/Source/WebCore/platform/graphics/FontTaggedSettings.h
@@ -52,7 +52,7 @@
static bool isDeletedValue(const FontTag& value) { return value == FontTag({{ ff, ff, ff, ff }}); }
private:
- const static char ff = static_cast<char>(0xFF);
+ static constexpr char ff = static_cast<char>(0xFF);
};
template <typename T>
diff --git a/Source/WebCore/platform/graphics/Region.cpp b/Source/WebCore/platform/graphics/Region.cpp
index 6a701c1..351d1ff 100644
--- a/Source/WebCore/platform/graphics/Region.cpp
+++ b/Source/WebCore/platform/graphics/Region.cpp
@@ -249,14 +249,14 @@
}
struct Region::Shape::CompareContainsOperation {
- const static bool defaultResult = true;
+ static constexpr bool defaultResult = true;
inline static bool aOutsideB(bool& /* result */) { return false; }
inline static bool bOutsideA(bool& result) { result = false; return true; }
inline static bool aOverlapsB(bool& /* result */) { return false; }
};
struct Region::Shape::CompareIntersectsOperation {
- const static bool defaultResult = false;
+ static constexpr bool defaultResult = false;
inline static bool aOutsideB(bool& /* result */) { return false; }
inline static bool bOutsideA(bool& /* result */) { return false; }
inline static bool aOverlapsB(bool& result) { result = true; return true; }
diff --git a/Source/WebCore/platform/graphics/filters/FELighting.cpp b/Source/WebCore/platform/graphics/filters/FELighting.cpp
index 8878808..707ead9 100644
--- a/Source/WebCore/platform/graphics/filters/FELighting.cpp
+++ b/Source/WebCore/platform/graphics/filters/FELighting.cpp
@@ -84,15 +84,15 @@
return true;
}
-const static int cPixelSize = 4;
-const static int cAlphaChannelOffset = 3;
-const static uint8_t cOpaqueAlpha = static_cast<uint8_t>(0xFF);
+static constexpr int cPixelSize = 4;
+static constexpr int cAlphaChannelOffset = 3;
+static constexpr uint8_t cOpaqueAlpha = static_cast<uint8_t>(0xFF);
// These factors and the normal coefficients come from the table under https://www.w3.org/TR/SVG/filters.html#feDiffuseLightingElement.
-const static float cFactor1div2 = -1 / 2.f;
-const static float cFactor1div3 = -1 / 3.f;
-const static float cFactor1div4 = -1 / 4.f;
-const static float cFactor2div3 = -2 / 3.f;
+static constexpr float cFactor1div2 = -1 / 2.f;
+static constexpr float cFactor1div3 = -1 / 3.f;
+static constexpr float cFactor1div4 = -1 / 4.f;
+static constexpr float cFactor2div3 = -2 / 3.f;
inline IntSize FELighting::LightingData::topLeftNormal(int offset) const
{
diff --git a/Source/WebCore/rendering/TableLayout.h b/Source/WebCore/rendering/TableLayout.h
index 5b6cd01..dad561f 100644
--- a/Source/WebCore/rendering/TableLayout.h
+++ b/Source/WebCore/rendering/TableLayout.h
@@ -46,7 +46,7 @@
protected:
// FIXME: Once we enable SATURATED_LAYOUT_ARITHMETHIC, this should just be LayoutUnit::nearlyMax().
// Until then though, using nearlyMax causes overflow in some tests, so we just pick a large number.
- const static int tableMaxWidth = 1000000;
+ static constexpr int tableMaxWidth = 1000000;
RenderTable* m_table;
};
diff --git a/Source/WebCore/rendering/svg/SVGRenderingContext.h b/Source/WebCore/rendering/svg/SVGRenderingContext.h
index 08a7878..3b9a65c 100644
--- a/Source/WebCore/rendering/svg/SVGRenderingContext.h
+++ b/Source/WebCore/rendering/svg/SVGRenderingContext.h
@@ -90,7 +90,7 @@
};
// List of those flags which require actions during the destructor.
- const static int ActionsNeeded = RestoreGraphicsContext | EndOpacityLayer | EndShadowLayer | EndFilterLayer;
+ static constexpr int ActionsNeeded = RestoreGraphicsContext | EndOpacityLayer | EndShadowLayer | EndFilterLayer;
RenderElement* m_renderer { nullptr };
PaintInfo* m_paintInfo { nullptr };
diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog
index 499aa2c..41a2680 100644
--- a/Source/WebKit/ChangeLog
+++ b/Source/WebKit/ChangeLog
@@ -1,3 +1,13 @@
+2019-10-17 Mark Lam <mark.lam@apple.com>
+
+ Use constexpr in more places and remove some unnecessary external linkage.
+ https://bugs.webkit.org/show_bug.cgi?id=203115
+
+ Reviewed by Yusuke Suzuki.
+
+ * UIProcess/API/APIContentRuleListStore.h:
+ * WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm:
+
2019-10-17 Antoine Quint <graouts@apple.com>
[Web Animations] Enable the Web Animations JavaScript API by default
diff --git a/Source/WebKit/UIProcess/API/APIContentRuleListStore.h b/Source/WebKit/UIProcess/API/APIContentRuleListStore.h
index 35fb28e..0caee56 100644
--- a/Source/WebKit/UIProcess/API/APIContentRuleListStore.h
+++ b/Source/WebKit/UIProcess/API/APIContentRuleListStore.h
@@ -57,7 +57,7 @@
// Also update ContentRuleListStore::getContentRuleListSource to be able to find the original JSON
// source from old versions.
// Update ContentRuleListStore::getContentRuleListSource with this.
- const static uint32_t CurrentContentRuleListFileVersion = 10;
+ static constexpr uint32_t CurrentContentRuleListFileVersion = 10;
static ContentRuleListStore& defaultStore(bool legacyFilename);
static Ref<ContentRuleListStore> storeWithPath(const WTF::String& storePath, bool legacyFilename);
diff --git a/Source/WebKit/WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm b/Source/WebKit/WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm
index 0803789..5661ef9 100644
--- a/Source/WebKit/WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm
+++ b/Source/WebKit/WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm
@@ -34,7 +34,7 @@
#import <QuartzCore/QuartzCore.h>
#import <WebCore/WebCoreCALayerExtras.h>
-const static double fadeInDuration = 0.5;
+static constexpr double fadeInDuration = 0.5;
namespace WebKit {
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index 49e847e..1f29cd9 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,14 @@
+2019-10-17 Mark Lam <mark.lam@apple.com>
+
+ Use constexpr in more places and remove some unnecessary external linkage.
+ https://bugs.webkit.org/show_bug.cgi?id=203115
+
+ Reviewed by Yusuke Suzuki.
+
+ * TestWebKitAPI/Tests/WTF/WeakPtr.cpp:
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/mac/IsNavigationActionTrusted.mm:
+
2019-10-17 Sihui Liu <sihui_liu@apple.com>
Using version 1 CFRunloopSource for faster task dispatch
diff --git a/Tools/TestWebKitAPI/Tests/WTF/WeakPtr.cpp b/Tools/TestWebKitAPI/Tests/WTF/WeakPtr.cpp
index 7e63069..1220c74 100644
--- a/Tools/TestWebKitAPI/Tests/WTF/WeakPtr.cpp
+++ b/Tools/TestWebKitAPI/Tests/WTF/WeakPtr.cpp
@@ -560,7 +560,7 @@
TEST(WTF_WeakPtr, WeakHashSetExpansion)
{
unsigned initialCapacity;
- const static unsigned maxLoadCap = 3;
+ static constexpr unsigned maxLoadCap = 3;
{
WeakHashSet<Base> weakHashSet;
Base object;
diff --git a/Tools/TestWebKitAPI/Tests/mac/IsNavigationActionTrusted.mm b/Tools/TestWebKitAPI/Tests/mac/IsNavigationActionTrusted.mm
index 872033e..53d3720 100644
--- a/Tools/TestWebKitAPI/Tests/mac/IsNavigationActionTrusted.mm
+++ b/Tools/TestWebKitAPI/Tests/mac/IsNavigationActionTrusted.mm
@@ -31,11 +31,11 @@
#import <wtf/RetainPtr.h>
static bool didFinishTest;
-const static NSURL *targetUrl = [[NSURL alloc] initWithString:@"http://www.example.com/"];
-const static unsigned expectedModifierFlags = 0;
-const static int expectedButtonNumber = -2;
+static const NSURL *targetUrl = [[NSURL alloc] initWithString:@"http://www.example.com/"];
+static constexpr unsigned expectedModifierFlags = 0;
+static constexpr int expectedButtonNumber = -2;
-const static int expectedWKButtonNumber = 0; // unlike DOM spec, 0 is the value for no button in Cocoa.
+static constexpr int expectedWKButtonNumber = 0; // unlike DOM spec, 0 is the value for no button in Cocoa.
@interface NavigationActionDelegate : NSObject <WKNavigationDelegate>
@end