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, VirtualRegister(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 ArithProfileReady: {
        u.arithProfile->observeResult(value);
        return;
    } }

    RELEASE_ASSERT_NOT_REACHED();
}
void MethodOfGettingAValueProfile::emitReportValue(CCallHelpers& jit, JSValueRegs regs) const
{
    switch (m_kind) {
    case None:
        return;
        
    case Ready:
        jit.storeValue(regs, u.profile->specFailBucket(0));
        return;
        
    case LazyOperand: {
        LazyOperandValueProfileKey key(u.lazyOperand.bytecodeOffset, VirtualRegister(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 ArithProfileReady: {
        u.arithProfile->emitObserveResult(jit, regs, DoNotHaveTagRegisters);
        return;
    } }
    
    RELEASE_ASSERT_NOT_REACHED();
}
EncodedJSValue* MethodOfGettingAValueProfile::getSpecFailBucket(unsigned index) const
{
    switch (m_kind) {
    case None:
        return 0;
        
    case Ready:
        return u.profile->specFailBucket(index);
        
    case LazyOperand: {
        LazyOperandValueProfileKey key(u.lazyOperand.bytecodeOffset, u.lazyOperand.operand);
        
        ConcurrentJITLocker locker(u.lazyOperand.codeBlock->m_lock);
        LazyOperandValueProfile* profile =
            u.lazyOperand.codeBlock->lazyOperandValueProfiles().add(locker, key);
        return profile->specFailBucket(index);
    }
        
    default:
        RELEASE_ASSERT_NOT_REACHED();
        return 0;
    }
}