- Revision
- 278942
- Author
- fpi...@apple.com
- Date
- 2021-06-16 11:08:37 -0700 (Wed, 16 Jun 2021)
Log Message
RegisterSet should be smaller
https://bugs.webkit.org/show_bug.cgi?id=227078
Reviewed by Geoff Garen.
Previously, every RegisterSet would have an extra 64-bit word in it just to hold state
relevant to hashtable keys.
But RegisterSet is almost never used as a hashtable key.
This patch moves the hashtable key support into a subclass, HashableRegisterSet. That class
ends up only being used in one place.
On ARM64, this makes RegisterSet use 64 bits instead of 128 bits.
On X86_64, this makes RegisterSet use 32 bits instead of 64 bits.
* _javascript_Core.xcodeproj/project.pbxproj:
* ftl/FTLSlowPathCallKey.h:
(JSC::FTL::SlowPathCallKey::SlowPathCallKey):
* jit/HashableRegisterSet.h: Added.
(JSC::HashableRegisterSet::HashableRegisterSet):
(JSC::HashableRegisterSet::isEmptyValue const):
(JSC::HashableRegisterSet::isDeletedValue const):
(JSC::RegisterSetHash::hash):
(JSC::RegisterSetHash::equal):
* jit/RegisterSet.h:
(): Deleted.
(JSC::RegisterSet::isEmptyValue const): Deleted.
(JSC::RegisterSet::isDeletedValue const): Deleted.
(JSC::RegisterSetHash::hash): Deleted.
(JSC::RegisterSetHash::equal): Deleted.
Modified Paths
Added Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (278941 => 278942)
--- trunk/Source/_javascript_Core/ChangeLog 2021-06-16 18:00:28 UTC (rev 278941)
+++ trunk/Source/_javascript_Core/ChangeLog 2021-06-16 18:08:37 UTC (rev 278942)
@@ -1,3 +1,38 @@
+2021-06-16 Filip Pizlo <fpi...@apple.com>
+
+ RegisterSet should be smaller
+ https://bugs.webkit.org/show_bug.cgi?id=227078
+
+ Reviewed by Geoff Garen.
+
+ Previously, every RegisterSet would have an extra 64-bit word in it just to hold state
+ relevant to hashtable keys.
+
+ But RegisterSet is almost never used as a hashtable key.
+
+ This patch moves the hashtable key support into a subclass, HashableRegisterSet. That class
+ ends up only being used in one place.
+
+ On ARM64, this makes RegisterSet use 64 bits instead of 128 bits.
+
+ On X86_64, this makes RegisterSet use 32 bits instead of 64 bits.
+
+ * _javascript_Core.xcodeproj/project.pbxproj:
+ * ftl/FTLSlowPathCallKey.h:
+ (JSC::FTL::SlowPathCallKey::SlowPathCallKey):
+ * jit/HashableRegisterSet.h: Added.
+ (JSC::HashableRegisterSet::HashableRegisterSet):
+ (JSC::HashableRegisterSet::isEmptyValue const):
+ (JSC::HashableRegisterSet::isDeletedValue const):
+ (JSC::RegisterSetHash::hash):
+ (JSC::RegisterSetHash::equal):
+ * jit/RegisterSet.h:
+ (): Deleted.
+ (JSC::RegisterSet::isEmptyValue const): Deleted.
+ (JSC::RegisterSet::isDeletedValue const): Deleted.
+ (JSC::RegisterSetHash::hash): Deleted.
+ (JSC::RegisterSetHash::equal): Deleted.
+
2021-06-16 Tadeu Zagallo <tzaga...@apple.com>
AssemblyHelpers should save/restore callee save FPRs
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (278941 => 278942)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2021-06-16 18:00:28 UTC (rev 278941)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2021-06-16 18:08:37 UTC (rev 278942)
@@ -518,6 +518,7 @@
0FB4FB751BC843140025CA5A /* FTLLazySlowPathCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FB4FB721BC843140025CA5A /* FTLLazySlowPathCall.h */; };
0FB5467714F59B5C002C2989 /* LazyOperandValueProfile.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FB5467614F59AD1002C2989 /* LazyOperandValueProfile.h */; settings = {ATTRIBUTES = (Private, ); }; };
0FB5467B14F5C7E1002C2989 /* MethodOfGettingAValueProfile.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FB5467A14F5C7D4002C2989 /* MethodOfGettingAValueProfile.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 0FB57069267A642E0080FA8B /* HashableRegisterSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FB57068267A642E0080FA8B /* HashableRegisterSet.h */; };
0FB7F39515ED8E4600F167B2 /* ArrayConventions.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FB7F38915ED8E3800F167B2 /* ArrayConventions.h */; settings = {ATTRIBUTES = (Private, ); }; };
0FB7F39615ED8E4600F167B2 /* ArrayStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FB7F38A15ED8E3800F167B2 /* ArrayStorage.h */; settings = {ATTRIBUTES = (Private, ); }; };
0FB7F39715ED8E4600F167B2 /* Butterfly.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FB7F38B15ED8E3800F167B2 /* Butterfly.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -2957,6 +2958,7 @@
0FB5467814F5C468002C2989 /* LazyOperandValueProfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LazyOperandValueProfile.cpp; sourceTree = "<group>"; };
0FB5467A14F5C7D4002C2989 /* MethodOfGettingAValueProfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MethodOfGettingAValueProfile.h; sourceTree = "<group>"; };
0FB5467C14F5CFD3002C2989 /* MethodOfGettingAValueProfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MethodOfGettingAValueProfile.cpp; sourceTree = "<group>"; };
+ 0FB57068267A642E0080FA8B /* HashableRegisterSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HashableRegisterSet.h; sourceTree = "<group>"; };
0FB7F38915ED8E3800F167B2 /* ArrayConventions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArrayConventions.h; sourceTree = "<group>"; };
0FB7F38A15ED8E3800F167B2 /* ArrayStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArrayStorage.h; sourceTree = "<group>"; };
0FB7F38B15ED8E3800F167B2 /* Butterfly.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Butterfly.h; sourceTree = "<group>"; };
@@ -6195,6 +6197,7 @@
1429D92C0ED22D7000B89619 /* jit */ = {
isa = PBXGroup;
children = (
+ 0FB57068267A642E0080FA8B /* HashableRegisterSet.h */,
0F24E53B17EA9F5900ABB217 /* AssemblyHelpers.cpp */,
0F24E53C17EA9F5900ABB217 /* AssemblyHelpers.h */,
723998F6265DBCDB0057867F /* BaselineJITPlan.cpp */,
@@ -10090,6 +10093,7 @@
0F2B66E517B6B5AB00A7AE3F /* JSArrayBufferConstructor.h in Headers */,
0F2B66E717B6B5AB00A7AE3F /* JSArrayBufferPrototype.h in Headers */,
A38D250E25800D440042BFDD /* JSArrayBufferPrototypeInlines.h in Headers */,
+ 0FB57069267A642E0080FA8B /* HashableRegisterSet.h in Headers */,
0F2B66E917B6B5AB00A7AE3F /* JSArrayBufferView.h in Headers */,
0F2B66EA17B6B5AB00A7AE3F /* JSArrayBufferViewInlines.h in Headers */,
539FB8BA1C99DA7C00940FA1 /* JSArrayInlines.h in Headers */,
Modified: trunk/Source/_javascript_Core/ftl/FTLSlowPathCallKey.h (278941 => 278942)
--- trunk/Source/_javascript_Core/ftl/FTLSlowPathCallKey.h 2021-06-16 18:00:28 UTC (rev 278941)
+++ trunk/Source/_javascript_Core/ftl/FTLSlowPathCallKey.h 2021-06-16 18:08:37 UTC (rev 278942)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,8 +27,8 @@
#if ENABLE(FTL_JIT)
+#include "HashableRegisterSet.h"
#include "MacroAssemblerCodeRef.h"
-#include "RegisterSet.h"
namespace JSC { namespace FTL {
@@ -77,12 +77,12 @@
enum DeletedValueTag { DeletedValue };
SlowPathCallKey(EmptyValueTag)
- : m_usedRegisters(RegisterSet::EmptyValue)
+ : m_usedRegisters(HashableRegisterSet::EmptyValue)
{
}
SlowPathCallKey(DeletedValueTag)
- : m_usedRegisters(RegisterSet::DeletedValue)
+ : m_usedRegisters(HashableRegisterSet::DeletedValue)
{
}
@@ -102,7 +102,7 @@
}
private:
- RegisterSet m_usedRegisters;
+ HashableRegisterSet m_usedRegisters;
FunctionPtr<OperationPtrTag> m_callTarget;
RegisterSet m_argumentRegisters;
ptrdiff_t m_offset { 0 };
Added: trunk/Source/_javascript_Core/jit/HashableRegisterSet.h (0 => 278942)
--- trunk/Source/_javascript_Core/jit/HashableRegisterSet.h (rev 0)
+++ trunk/Source/_javascript_Core/jit/HashableRegisterSet.h 2021-06-16 18:08:37 UTC (rev 278942)
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if !ENABLE(C_LOOP)
+
+#include "RegisterSet.h"
+
+namespace JSC {
+
+class HashableRegisterSet : public RegisterSet {
+ enum State {
+ Normal,
+ Empty,
+ Deleted
+ };
+
+public:
+ constexpr HashableRegisterSet() { }
+
+ template<typename... Regs>
+ constexpr explicit HashableRegisterSet(Regs... regs)
+ : RegisterSet(regs...)
+ {
+ }
+
+ enum EmptyValueTag { EmptyValue };
+ enum DeletedValueTag { DeletedValue };
+
+ HashableRegisterSet(EmptyValueTag)
+ : m_state(Empty)
+ {
+ }
+
+ HashableRegisterSet(DeletedValueTag)
+ : m_state(Deleted)
+ {
+ }
+
+ bool isEmptyValue() const
+ {
+ return m_state == Empty;
+ }
+
+ bool isDeletedValue() const
+ {
+ return m_state == Deleted;
+ }
+
+private:
+ State m_state { Normal };
+};
+
+struct RegisterSetHash {
+ static unsigned hash(const HashableRegisterSet& set) { return set.hash(); }
+ static bool equal(const HashableRegisterSet& a, const HashableRegisterSet& b) { return a == b; }
+ static constexpr bool safeToCompareToEmptyOrDeleted = false;
+};
+
+} // namespace JSC
+
+namespace WTF {
+
+template<typename T> struct DefaultHash;
+template<> struct DefaultHash<JSC::HashableRegisterSet> : JSC::RegisterSetHash { };
+
+template<typename T> struct HashTraits;
+template<> struct HashTraits<JSC::HashableRegisterSet> : public CustomHashTraits<JSC::HashableRegisterSet> { };
+
+} // namespace WTF
+
+#endif // !ENABLE(C_LOOP)
+
Modified: trunk/Source/_javascript_Core/jit/RegisterSet.h (278941 => 278942)
--- trunk/Source/_javascript_Core/jit/RegisterSet.h 2021-06-16 18:00:28 UTC (rev 278941)
+++ trunk/Source/_javascript_Core/jit/RegisterSet.h 2021-06-16 18:08:37 UTC (rev 278942)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -35,7 +35,7 @@
namespace JSC {
-typedef Bitmap<MacroAssembler::numGPRs + MacroAssembler::numFPRs + 1> RegisterBitmap;
+typedef Bitmap<MacroAssembler::numGPRs + MacroAssembler::numFPRs> RegisterBitmap;
class RegisterAtOffsetList;
class RegisterSet {
@@ -133,30 +133,6 @@
JS_EXPORT_PRIVATE void dump(PrintStream&) const;
- enum EmptyValueTag { EmptyValue };
- enum DeletedValueTag { DeletedValue };
-
- RegisterSet(EmptyValueTag)
- {
- m_bits.set(hashSpecialBitIndex);
- }
-
- RegisterSet(DeletedValueTag)
- {
- m_bits.set(hashSpecialBitIndex);
- m_bits.set(deletedBitIndex);
- }
-
- bool isEmptyValue() const
- {
- return m_bits.get(hashSpecialBitIndex) && !m_bits.get(deletedBitIndex);
- }
-
- bool isDeletedValue() const
- {
- return m_bits.get(hashSpecialBitIndex) && m_bits.get(deletedBitIndex);
- }
-
bool operator==(const RegisterSet& other) const { return m_bits == other.m_bits; }
bool operator!=(const RegisterSet& other) const { return m_bits != other.m_bits; }
@@ -222,28 +198,10 @@
// These offsets mirror the logic in Reg.h.
static constexpr unsigned gprOffset = 0;
static constexpr unsigned fprOffset = gprOffset + MacroAssembler::numGPRs;
- static constexpr unsigned hashSpecialBitIndex = fprOffset + MacroAssembler::numFPRs;
- static constexpr unsigned deletedBitIndex = 0;
RegisterBitmap m_bits;
};
-struct RegisterSetHash {
- static unsigned hash(const RegisterSet& set) { return set.hash(); }
- static bool equal(const RegisterSet& a, const RegisterSet& b) { return a == b; }
- static constexpr bool safeToCompareToEmptyOrDeleted = false;
-};
-
} // namespace JSC
-namespace WTF {
-
-template<typename T> struct DefaultHash;
-template<> struct DefaultHash<JSC::RegisterSet> : JSC::RegisterSetHash { };
-
-template<typename T> struct HashTraits;
-template<> struct HashTraits<JSC::RegisterSet> : public CustomHashTraits<JSC::RegisterSet> { };
-
-} // namespace WTF
-
#endif // !ENABLE(C_LOOP)