summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/jit/RegisterSet.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/jit/RegisterSet.h')
-rw-r--r--Source/JavaScriptCore/jit/RegisterSet.h135
1 files changed, 95 insertions, 40 deletions
diff --git a/Source/JavaScriptCore/jit/RegisterSet.h b/Source/JavaScriptCore/jit/RegisterSet.h
index 84ad226ad..0359066e3 100644
--- a/Source/JavaScriptCore/jit/RegisterSet.h
+++ b/Source/JavaScriptCore/jit/RegisterSet.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,92 +23,150 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef RegisterSet_h
-#define RegisterSet_h
-
-#include <wtf/Platform.h>
+#pragma once
#if ENABLE(JIT)
#include "FPRInfo.h"
#include "GPRInfo.h"
#include "MacroAssembler.h"
+#include "Reg.h"
#include "TempRegisterSet.h"
-#include <wtf/BitVector.h>
+#include <wtf/Bitmap.h>
namespace JSC {
class RegisterSet {
public:
- RegisterSet() { }
+ template<typename... Regs>
+ explicit RegisterSet(Regs... regs)
+ {
+ setMany(regs...);
+ }
- static RegisterSet stackRegisters();
- static RegisterSet specialRegisters();
- static RegisterSet calleeSaveRegisters();
- static RegisterSet allGPRs();
- static RegisterSet allFPRs();
+ JS_EXPORT_PRIVATE static RegisterSet stackRegisters();
+ JS_EXPORT_PRIVATE static RegisterSet reservedHardwareRegisters();
+ static RegisterSet runtimeRegisters();
+ static RegisterSet specialRegisters(); // The union of stack, reserved hardware, and runtime registers.
+ JS_EXPORT_PRIVATE static RegisterSet calleeSaveRegisters();
+ static RegisterSet vmCalleeSaveRegisters(); // Callee save registers that might be saved and used by any tier.
+ static RegisterSet llintBaselineCalleeSaveRegisters(); // Registers saved and used by the LLInt.
+ static RegisterSet dfgCalleeSaveRegisters(); // Registers saved and used by the DFG JIT.
+ static RegisterSet ftlCalleeSaveRegisters(); // Registers that might be saved and used by the FTL JIT.
+#if ENABLE(WEBASSEMBLY)
+ static RegisterSet webAssemblyCalleeSaveRegisters(); // Registers saved and used by the WebAssembly JIT.
+#endif
+ static RegisterSet volatileRegistersForJSCall();
+ static RegisterSet stubUnavailableRegisters(); // The union of callee saves and special registers.
+ JS_EXPORT_PRIVATE static RegisterSet macroScratchRegisters();
+ JS_EXPORT_PRIVATE static RegisterSet allGPRs();
+ JS_EXPORT_PRIVATE static RegisterSet allFPRs();
static RegisterSet allRegisters();
+ static RegisterSet argumentGPRS();
- void set(GPRReg reg, bool value = true)
+ static RegisterSet registersToNotSaveForJSCall();
+ static RegisterSet registersToNotSaveForCCall();
+
+ void set(Reg reg, bool value = true)
{
- m_vector.set(MacroAssembler::registerIndex(reg), value);
+ ASSERT(!!reg);
+ m_bits.set(reg.index(), value);
}
- void set(JSValueRegs regs)
+ void set(JSValueRegs regs, bool value = true)
{
if (regs.tagGPR() != InvalidGPRReg)
- set(regs.tagGPR());
- set(regs.payloadGPR());
+ set(regs.tagGPR(), value);
+ set(regs.payloadGPR(), value);
}
- void clear(GPRReg reg)
+ void clear(Reg reg)
{
+ ASSERT(!!reg);
set(reg, false);
}
- bool get(GPRReg reg) const { return m_vector.get(MacroAssembler::registerIndex(reg)); }
-
- void set(FPRReg reg, bool value = true)
+ bool get(Reg reg) const
{
- m_vector.set(MacroAssembler::registerIndex(reg), value);
+ ASSERT(!!reg);
+ return m_bits.get(reg.index());
}
- void clear(FPRReg reg)
+ template<typename Iterable>
+ void setAll(const Iterable& iterable)
{
- set(reg, false);
+ for (Reg reg : iterable)
+ set(reg);
}
- bool get(FPRReg reg) const { return m_vector.get(MacroAssembler::registerIndex(reg)); }
+ void merge(const RegisterSet& other) { m_bits.merge(other.m_bits); }
+ void filter(const RegisterSet& other) { m_bits.filter(other.m_bits); }
+ void exclude(const RegisterSet& other) { m_bits.exclude(other.m_bits); }
- void merge(const RegisterSet& other) { m_vector.merge(other.m_vector); }
- void filter(const RegisterSet& other) { m_vector.filter(other.m_vector); }
- void exclude(const RegisterSet& other) { m_vector.exclude(other.m_vector); }
+ size_t numberOfSetGPRs() const;
+ size_t numberOfSetFPRs() const;
+ size_t numberOfSetRegisters() const { return m_bits.count(); }
- size_t numberOfSetRegisters() const { return m_vector.bitCount(); }
+ bool isEmpty() const { return m_bits.isEmpty(); }
- void dump(PrintStream&) const;
+ JS_EXPORT_PRIVATE void dump(PrintStream&) const;
enum EmptyValueTag { EmptyValue };
enum DeletedValueTag { DeletedValue };
RegisterSet(EmptyValueTag)
- : m_vector(BitVector::EmptyValue)
{
+ m_bits.set(hashSpecialBitIndex);
}
RegisterSet(DeletedValueTag)
- : m_vector(BitVector::DeletedValue)
{
+ m_bits.set(hashSpecialBitIndex);
+ m_bits.set(deletedBitIndex);
}
- bool isEmptyValue() const { return m_vector.isEmptyValue(); }
- bool isDeletedValue() const { return m_vector.isDeletedValue(); }
+ 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_vector == other.m_vector; }
- unsigned hash() const { return m_vector.hash(); }
+ bool operator==(const RegisterSet& other) const { return m_bits == other.m_bits; }
+ bool operator!=(const RegisterSet& other) const { return m_bits != other.m_bits; }
+
+ unsigned hash() const { return m_bits.hash(); }
+
+ template<typename Func>
+ void forEach(const Func& func) const
+ {
+ m_bits.forEachSetBit(
+ [&] (size_t index) {
+ func(Reg::fromIndex(index));
+ });
+ }
private:
- BitVector m_vector;
+ void setAny(Reg reg) { set(reg); }
+ void setAny(const RegisterSet& set) { merge(set); }
+ void setMany() { }
+ template<typename RegType, typename... Regs>
+ void setMany(RegType reg, Regs... regs)
+ {
+ setAny(reg);
+ setMany(regs...);
+ }
+
+ // These offsets mirror the logic in Reg.h.
+ static const unsigned gprOffset = 0;
+ static const unsigned fprOffset = gprOffset + MacroAssembler::numGPRs;
+ static const unsigned hashSpecialBitIndex = fprOffset + MacroAssembler::numFPRs;
+ static const unsigned deletedBitIndex = 0;
+
+ Bitmap<MacroAssembler::numGPRs + MacroAssembler::numFPRs + 1> m_bits;
};
struct RegisterSetHash {
@@ -132,6 +190,3 @@ template<> struct HashTraits<JSC::RegisterSet> : public CustomHashTraits<JSC::Re
} // namespace WTF
#endif // ENABLE(JIT)
-
-#endif // RegisterSet_h
-