}
#define DEFINE_OPERAND_CACHE(name, type) \
- name* name::cache = NULL; \
- void name::SetUpCache() { \
+ L##name* L##name::cache = NULL; \
+ \
+ void L##name::SetUpCache() { \
if (cache) return; \
- cache = new name[kNumCachedOperands]; \
+ cache = new L##name[kNumCachedOperands]; \
for (int i = 0; i < kNumCachedOperands; i++) { \
cache[i].ConvertTo(type, i); \
} \
} \
+ \
+ void L##name::TearDownCache() { \
+ delete[] cache; \
+ }
-DEFINE_OPERAND_CACHE(LConstantOperand, CONSTANT_OPERAND)
-DEFINE_OPERAND_CACHE(LStackSlot, STACK_SLOT)
-DEFINE_OPERAND_CACHE(LDoubleStackSlot, DOUBLE_STACK_SLOT)
-DEFINE_OPERAND_CACHE(LRegister, REGISTER)
-DEFINE_OPERAND_CACHE(LDoubleRegister, DOUBLE_REGISTER)
-
+LITHIUM_OPERAND_LIST(DEFINE_OPERAND_CACHE)
#undef DEFINE_OPERAND_CACHE
void LOperand::SetUpCaches() {
- LConstantOperand::SetUpCache();
- LStackSlot::SetUpCache();
- LDoubleStackSlot::SetUpCache();
- LRegister::SetUpCache();
- LDoubleRegister::SetUpCache();
+#define LITHIUM_OPERAND_SETUP(name, type) L##name::SetUpCache();
+ LITHIUM_OPERAND_LIST(LITHIUM_OPERAND_SETUP)
+#undef LITHIUM_OPERAND_SETUP
+}
+
+
+void LOperand::TearDownCaches() {
+#define LITHIUM_OPERAND_TEARDOWN(name, type) L##name::TearDownCache();
+ LITHIUM_OPERAND_LIST(LITHIUM_OPERAND_TEARDOWN)
+#undef LITHIUM_OPERAND_TEARDOWN
}
+
bool LParallelMove::IsRedundant() const {
for (int i = 0; i < move_operands_.length(); ++i) {
if (!move_operands_[i].IsRedundant()) return false;
namespace v8 {
namespace internal {
+#define LITHIUM_OPERAND_LIST(V) \
+ V(ConstantOperand, CONSTANT_OPERAND) \
+ V(StackSlot, STACK_SLOT) \
+ V(DoubleStackSlot, DOUBLE_STACK_SLOT) \
+ V(Register, REGISTER) \
+ V(DoubleRegister, DOUBLE_REGISTER)
+
+
class LOperand: public ZoneObject {
public:
enum Kind {
Kind kind() const { return KindField::decode(value_); }
int index() const { return static_cast<int>(value_) >> kKindFieldWidth; }
- bool IsConstantOperand() const { return kind() == CONSTANT_OPERAND; }
- bool IsStackSlot() const { return kind() == STACK_SLOT; }
- bool IsDoubleStackSlot() const { return kind() == DOUBLE_STACK_SLOT; }
- bool IsRegister() const { return kind() == REGISTER; }
- bool IsDoubleRegister() const { return kind() == DOUBLE_REGISTER; }
- bool IsArgument() const { return kind() == ARGUMENT; }
- bool IsUnallocated() const { return kind() == UNALLOCATED; }
- bool IsIgnored() const { return kind() == INVALID; }
+#define LITHIUM_OPERAND_PREDICATE(name, type) \
+ bool Is##name() const { return kind() == type; }
+ LITHIUM_OPERAND_LIST(LITHIUM_OPERAND_PREDICATE)
+ LITHIUM_OPERAND_PREDICATE(Argument, ARGUMENT)
+ LITHIUM_OPERAND_PREDICATE(Unallocated, UNALLOCATED)
+ LITHIUM_OPERAND_PREDICATE(Ignored, INVALID)
+#undef LITHIUM_OPERAND_PREDICATE
bool Equals(LOperand* other) const { return value_ == other->value_; }
void PrintTo(StringStream* stream);
ASSERT(this->index() == index);
}
- // Calls SetUpCache() for each subclass. Don't forget to update this method
- // if you add a new LOperand subclass.
+ // Calls SetUpCache()/TearDownCache() for each subclass.
static void SetUpCaches();
+ static void TearDownCaches();
protected:
static const int kKindFieldWidth = 3;
}
static void SetUpCache();
+ static void TearDownCache();
private:
static const int kNumCachedOperands = 128;
}
static void SetUpCache();
+ static void TearDownCache();
private:
static const int kNumCachedOperands = 128;
}
static void SetUpCache();
+ static void TearDownCache();
private:
static const int kNumCachedOperands = 128;
}
static void SetUpCache();
+ static void TearDownCache();
private:
static const int kNumCachedOperands = 16;
}
static void SetUpCache();
+ static void TearDownCache();
private:
static const int kNumCachedOperands = 16;