Modified: trunk/Source/_javascript_Core/ChangeLog (233859 => 233860)
--- trunk/Source/_javascript_Core/ChangeLog 2018-07-16 19:09:12 UTC (rev 233859)
+++ trunk/Source/_javascript_Core/ChangeLog 2018-07-16 19:49:11 UTC (rev 233860)
@@ -1,3 +1,20 @@
+2018-07-16 Yusuke Suzuki <[email protected]>
+
+ [JSC] Make SourceParseMode small
+ https://bugs.webkit.org/show_bug.cgi?id=187705
+
+ Reviewed by Mark Lam.
+
+ Each SourceParseMode is distinct. So we do not need to make it a set-style (power of 2 style).
+ Originally, this is done to make SourceParseModeSet faster because it is critical in our parser.
+ But we can keep SourceParseModeSet fast by `1U << mode | set`. And we can make SourceParseMode
+ within 5 bits. This reduces the size of UnlinkedCodeBlock from 288 to 280.
+
+ * parser/ParserModes.h:
+ (JSC::SourceParseModeSet::SourceParseModeSet):
+ (JSC::SourceParseModeSet::contains):
+ (JSC::SourceParseModeSet::mergeSourceParseModes):
+
2018-07-12 Yusuke Suzuki <[email protected]>
[JSC] Generator and AsyncGeneratorMethod's prototype is incorrect
Modified: trunk/Source/_javascript_Core/parser/ParserModes.h (233859 => 233860)
--- trunk/Source/_javascript_Core/parser/ParserModes.h 2018-07-16 19:09:12 UTC (rev 233859)
+++ trunk/Source/_javascript_Core/parser/ParserModes.h 2018-07-16 19:49:11 UTC (rev 233860)
@@ -42,51 +42,52 @@
enum class FunctionMode { FunctionExpression, FunctionDeclaration, MethodDefinition };
-enum class SourceParseMode : uint32_t {
- NormalFunctionMode = 0b00000000000000000000000000000001,
- GeneratorBodyMode = 0b00000000000000000000000000000010,
- GeneratorWrapperFunctionMode = 0b00000000000000000000000000000100,
- GetterMode = 0b00000000000000000000000000001000,
- SetterMode = 0b00000000000000000000000000010000,
- MethodMode = 0b00000000000000000000000000100000,
- ArrowFunctionMode = 0b00000000000000000000000001000000,
- AsyncFunctionBodyMode = 0b00000000000000000000000010000000,
- AsyncArrowFunctionBodyMode = 0b00000000000000000000000100000000,
- AsyncFunctionMode = 0b00000000000000000000001000000000,
- AsyncMethodMode = 0b00000000000000000000010000000000,
- AsyncArrowFunctionMode = 0b00000000000000000000100000000000,
- ProgramMode = 0b00000000000000000001000000000000,
- ModuleAnalyzeMode = 0b00000000000000000010000000000000,
- ModuleEvaluateMode = 0b00000000000000000100000000000000,
- AsyncGeneratorBodyMode = 0b00000000000000001000000000000000,
- AsyncGeneratorWrapperFunctionMode = 0b00000000000000010000000000000000,
- AsyncGeneratorWrapperMethodMode = 0b00000000000000100000000000000000,
- GeneratorWrapperMethodMode = 0b00000000000001000000000000000000,
+// Keep it less than 32, it means this should be within 5 bits.
+enum class SourceParseMode : uint8_t {
+ NormalFunctionMode = 0,
+ GeneratorBodyMode = 1,
+ GeneratorWrapperFunctionMode = 2,
+ GetterMode = 3,
+ SetterMode = 4,
+ MethodMode = 5,
+ ArrowFunctionMode = 6,
+ AsyncFunctionBodyMode = 7,
+ AsyncArrowFunctionBodyMode = 8,
+ AsyncFunctionMode = 9,
+ AsyncMethodMode = 10,
+ AsyncArrowFunctionMode = 11,
+ ProgramMode = 12,
+ ModuleAnalyzeMode = 13,
+ ModuleEvaluateMode = 14,
+ AsyncGeneratorBodyMode = 15,
+ AsyncGeneratorWrapperFunctionMode = 16,
+ AsyncGeneratorWrapperMethodMode = 17,
+ GeneratorWrapperMethodMode = 18,
};
class SourceParseModeSet {
public:
template<typename... Modes>
- SourceParseModeSet(Modes... args)
+ constexpr SourceParseModeSet(Modes... args)
: m_mask(mergeSourceParseModes(args...))
{
}
- ALWAYS_INLINE bool contains(SourceParseMode mode)
+ ALWAYS_INLINE constexpr bool contains(SourceParseMode mode)
{
- return static_cast<unsigned>(mode) & m_mask;
+ return (1U << static_cast<unsigned>(mode)) & m_mask;
}
private:
- ALWAYS_INLINE static unsigned mergeSourceParseModes(SourceParseMode mode)
+ ALWAYS_INLINE static constexpr unsigned mergeSourceParseModes(SourceParseMode mode)
{
- return static_cast<unsigned>(mode);
+ return (1U << static_cast<unsigned>(mode));
}
template<typename... Rest>
- ALWAYS_INLINE static unsigned mergeSourceParseModes(SourceParseMode mode, Rest... rest)
+ ALWAYS_INLINE static constexpr unsigned mergeSourceParseModes(SourceParseMode mode, Rest... rest)
{
- return static_cast<unsigned>(mode) | mergeSourceParseModes(rest...);
+ return (1U << static_cast<unsigned>(mode)) | mergeSourceParseModes(rest...);
}
const unsigned m_mask;