MethodOfGettingAValueProfile.cpp [plain text]
#include "config.h"
#include "MethodOfGettingAValueProfile.h"
#if ENABLE(DFG_JIT)
#include "ArithProfile.h"
#include "CCallHelpers.h"
#include "CodeBlock.h"
#include "JSCJSValueInlines.h"
namespace JSC {
MethodOfGettingAValueProfile MethodOfGettingAValueProfile::fromLazyOperand(
CodeBlock* codeBlock, const LazyOperandValueProfileKey& key)
{
MethodOfGettingAValueProfile result;
result.m_kind = LazyOperand;
result.u.lazyOperand.codeBlock = codeBlock;
result.u.lazyOperand.bytecodeOffset = key.bytecodeIndex();
result.u.lazyOperand.operand = key.operand();
return result;
}
void MethodOfGettingAValueProfile::emitReportValue(CCallHelpers& jit, JSValueRegs regs, GPRReg tempGPR, TagRegistersMode mode) const
{
switch (m_kind) {
case None:
return;
case Ready:
jit.storeValue(regs, u.profile->specFailBucket(0));
return;
case LazyOperand: {
LazyOperandValueProfileKey key(u.lazyOperand.bytecodeOffset, u.lazyOperand.operand);
ConcurrentJSLocker locker(u.lazyOperand.codeBlock->m_lock);
LazyOperandValueProfile* profile =
u.lazyOperand.codeBlock->lazyOperandValueProfiles(locker).add(locker, key);
jit.storeValue(regs, profile->specFailBucket(0));
return;
}
case UnaryArithProfileReady: {
u.unaryArithProfile->emitObserveResult(jit, regs, tempGPR, mode);
return;
}
case BinaryArithProfileReady: {
u.binaryArithProfile->emitObserveResult(jit, regs, tempGPR, mode);
return;
}
}
RELEASE_ASSERT_NOT_REACHED();
}
void MethodOfGettingAValueProfile::reportValue(JSValue value)
{
switch (m_kind) {
case None:
return;
case Ready:
*u.profile->specFailBucket(0) = JSValue::encode(value);
return;
case LazyOperand: {
LazyOperandValueProfileKey key(u.lazyOperand.bytecodeOffset, u.lazyOperand.operand);
ConcurrentJSLocker locker(u.lazyOperand.codeBlock->m_lock);
LazyOperandValueProfile* profile =
u.lazyOperand.codeBlock->lazyOperandValueProfiles(locker).add(locker, key);
*profile->specFailBucket(0) = JSValue::encode(value);
return;
}
case UnaryArithProfileReady: {
u.unaryArithProfile->observeResult(value);
return;
}
case BinaryArithProfileReady: {
u.binaryArithProfile->observeResult(value);
return;
}
}
RELEASE_ASSERT_NOT_REACHED();
}
}
#endif // ENABLE(DFG_JIT)