/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#ifndef LazyOperandValueProfile_h
#define LazyOperandValueProfile_h
-#include <wtf/Platform.h>
-
-#if ENABLE(VALUE_PROFILER)
-
+#include "ConcurrentJITLock.h"
#include "ValueProfile.h"
+#include "VirtualRegister.h"
#include <wtf/HashMap.h>
#include <wtf/Noncopyable.h>
#include <wtf/OwnPtr.h>
public:
LazyOperandValueProfileKey()
: m_bytecodeOffset(0) // 0 = empty value
- , m_operand(-1) // not a valid operand index in our current scheme
+ , m_operand(VirtualRegister()) // not a valid operand index in our current scheme
{
}
LazyOperandValueProfileKey(WTF::HashTableDeletedValueType)
: m_bytecodeOffset(1) // 1 = deleted value
- , m_operand(-1) // not a valid operand index in our current scheme
+ , m_operand(VirtualRegister()) // not a valid operand index in our current scheme
{
}
- LazyOperandValueProfileKey(unsigned bytecodeOffset, int operand)
+ LazyOperandValueProfileKey(unsigned bytecodeOffset, VirtualRegister operand)
: m_bytecodeOffset(bytecodeOffset)
, m_operand(operand)
{
- ASSERT(operand != -1);
+ ASSERT(m_operand.isValid());
}
bool operator!() const
{
- return m_operand == -1;
+ return !m_operand.isValid();
}
bool operator==(const LazyOperandValueProfileKey& other) const
unsigned hash() const
{
- return WTF::intHash(m_bytecodeOffset) + m_operand;
+ return WTF::intHash(m_bytecodeOffset) + m_operand.offset();
}
unsigned bytecodeOffset() const
ASSERT(!!*this);
return m_bytecodeOffset;
}
- int operand() const
+
+ VirtualRegister operand() const
{
ASSERT(!!*this);
return m_operand;
bool isHashTableDeletedValue() const
{
- return m_operand == -1 && m_bytecodeOffset;
+ return !m_operand.isValid() && m_bytecodeOffset;
}
private:
unsigned m_bytecodeOffset;
- int m_operand;
+ VirtualRegister m_operand;
};
struct LazyOperandValueProfileKeyHash {
struct LazyOperandValueProfile : public MinimalValueProfile {
LazyOperandValueProfile()
: MinimalValueProfile()
- , m_operand(-1)
+ , m_operand(VirtualRegister())
{
}
return LazyOperandValueProfileKey(m_bytecodeOffset, m_operand);
}
- int m_operand;
+ VirtualRegister m_operand;
typedef SegmentedVector<LazyOperandValueProfile, 8> List;
};
CompressedLazyOperandValueProfileHolder();
~CompressedLazyOperandValueProfileHolder();
- void computeUpdatedPredictions(OperationInProgress);
+ void computeUpdatedPredictions(const ConcurrentJITLocker&);
- LazyOperandValueProfile* add(const LazyOperandValueProfileKey& key);
+ LazyOperandValueProfile* add(
+ const ConcurrentJITLocker&, const LazyOperandValueProfileKey& key);
private:
friend class LazyOperandValueProfileParser;
class LazyOperandValueProfileParser {
WTF_MAKE_NONCOPYABLE(LazyOperandValueProfileParser);
public:
- explicit LazyOperandValueProfileParser(
- CompressedLazyOperandValueProfileHolder& holder);
+ explicit LazyOperandValueProfileParser();
~LazyOperandValueProfileParser();
+ void initialize(
+ const ConcurrentJITLocker&, CompressedLazyOperandValueProfileHolder& holder);
+
LazyOperandValueProfile* getIfPresent(
const LazyOperandValueProfileKey& key) const;
- SpeculatedType prediction(const LazyOperandValueProfileKey& key) const;
+ SpeculatedType prediction(
+ const ConcurrentJITLocker&, const LazyOperandValueProfileKey& key) const;
private:
- CompressedLazyOperandValueProfileHolder& m_holder;
HashMap<LazyOperandValueProfileKey, LazyOperandValueProfile*> m_map;
};
} // namespace JSC
-#endif // ENABLE(VALUE_PROFILER)
-
#endif // LazyOperandValueProfile_h