void ThreadContextTTD::LoadInvertedRootMap(JsUtil::BaseDictionary<Js::RecyclableObject*, TTD_LOG_PTR_ID, HeapAllocator>& objToLogIdMap) const
 {
     for(auto iter = this->m_ttdRootTagToObjectMap.GetIterator(); iter.IsValid(); iter.MoveNext())
     {
         objToLogIdMap.AddNew(iter.CurrentValue(), iter.CurrentKey());
     }
 }
    RuntimeContextInfo::~RuntimeContextInfo()
    {
        for(auto iter = this->m_coreObjToPathMap.GetIterator(); iter.IsValid(); iter.MoveNext())
        {
            TT_HEAP_DELETE(UtilSupport::TTAutoString, iter.CurrentValue());
        }

        for(auto iter = this->m_coreBodyToPathMap.GetIterator(); iter.IsValid(); iter.MoveNext())
        {
            TT_HEAP_DELETE(UtilSupport::TTAutoString, iter.CurrentValue());
        }

        for(auto iter = this->m_coreDbgScopeToPathMap.GetIterator(); iter.IsValid(); iter.MoveNext())
        {
            TT_HEAP_DELETE(UtilSupport::TTAutoString, iter.CurrentValue());
        }
    }
Exemple #3
0
    TTDCompareMap::~TTDCompareMap()
    {
        TT_HEAP_FREE_ARRAY(char16, this->PathBuffer, 256);

        TT_HEAP_FREE_ARRAY(TTD::fPtr_AssertSnapEquivAddtlInfo, this->SnapObjCmpVTable, (int32)NSSnapObjects::SnapObjectType::Limit);

        //delete all the compare paths
        for(auto iter = this->H1PtrToPathMap.GetIterator(); iter.IsValid(); iter.MoveNext())
        {
            TT_HEAP_DELETE(TTDComparePath, iter.CurrentValue());
        }
    }
    Js::FunctionBody* ScriptContextTTD::FindRootBodyByTopLevelCtr(uint32 bodyCtrId) const
    {
        for(auto iter = this->m_ttdTopLevelScriptLoad.GetIterator(); iter.IsValid(); iter.MoveNext())
        {
            if(iter.CurrentValue().TopLevelBodyCtr == bodyCtrId)
            {
                return TTD_COERCE_PTR_ID_TO_FUNCTIONBODY(iter.CurrentValue().ContextSpecificBodyPtrId);
            }
        }

        for(auto iter = this->m_ttdTopLevelNewFunction.GetIterator(); iter.IsValid(); iter.MoveNext())
        {
            if(iter.CurrentValue().TopLevelBodyCtr == bodyCtrId)
            {
                return TTD_COERCE_PTR_ID_TO_FUNCTIONBODY(iter.CurrentValue().ContextSpecificBodyPtrId);
            }
        }

        for(auto iter = this->m_ttdTopLevelEval.GetIterator(); iter.IsValid(); iter.MoveNext())
        {
            if(iter.CurrentValue().TopLevelBodyCtr == bodyCtrId)
            {
                return TTD_COERCE_PTR_ID_TO_FUNCTIONBODY(iter.CurrentValue().ContextSpecificBodyPtrId);
            }
        }

        return nullptr;
    }
    void ScriptContextTTD::GetLoadedSources(const JsUtil::BaseHashSet<Js::FunctionBody*, HeapAllocator>* onlyLiveTopLevelBodies, JsUtil::List<TTD::TopLevelFunctionInContextRelation, HeapAllocator>& topLevelScriptLoad, JsUtil::List<TTD::TopLevelFunctionInContextRelation, HeapAllocator>& topLevelNewFunction, JsUtil::List<TTD::TopLevelFunctionInContextRelation, HeapAllocator>& topLevelEval)
    {
        TTDAssert(topLevelScriptLoad.Count() == 0 && topLevelNewFunction.Count() == 0 && topLevelEval.Count() == 0, "Should be empty when you call this.");

        for(auto iter = this->m_ttdTopLevelScriptLoad.GetIterator(); iter.IsValid(); iter.MoveNext())
        {
            Js::FunctionBody* body = TTD_COERCE_PTR_ID_TO_FUNCTIONBODY(iter.CurrentValue().ContextSpecificBodyPtrId);
            if(onlyLiveTopLevelBodies == nullptr || onlyLiveTopLevelBodies->Contains(body))
            {
                topLevelScriptLoad.Add(iter.CurrentValue());
            }
        }

        for(auto iter = this->m_ttdTopLevelNewFunction.GetIterator(); iter.IsValid(); iter.MoveNext())
        {
            Js::FunctionBody* body = TTD_COERCE_PTR_ID_TO_FUNCTIONBODY(iter.CurrentValue().ContextSpecificBodyPtrId);
            if(onlyLiveTopLevelBodies == nullptr || onlyLiveTopLevelBodies->Contains(body))
            {
                topLevelNewFunction.Add(iter.CurrentValue());
            }
        }

        for(auto iter = this->m_ttdTopLevelEval.GetIterator(); iter.IsValid(); iter.MoveNext())
        {
            Js::FunctionBody* body = TTD_COERCE_PTR_ID_TO_FUNCTIONBODY(iter.CurrentValue().ContextSpecificBodyPtrId);
            if(onlyLiveTopLevelBodies == nullptr || onlyLiveTopLevelBodies->Contains(body))
            {
                topLevelEval.Add(iter.CurrentValue());
            }
        }
    }
Exemple #6
0
bool IntBounds::SubCannotOverflowBasedOnRelativeBounds(const int n) const
{
    Assert(n != 0);

    if(n >= 0)
    {
        const int minBoundOffset = n;
        for(auto it = relativeLowerBounds.GetIterator(); it.IsValid(); it.MoveNext())
        {
            // If (a > b), then (a - 1) cannot overflow
            const ValueRelativeOffset &bound = it.CurrentValue();
            if(bound.Offset() >= minBoundOffset)
                return true;
        }
        return false;
    }

    return n != IntConstMin && AddCannotOverflowBasedOnRelativeBounds(-n);
}
void LevelMenuEntry::Render( IRender *pRender, int x, int y )
{
	if ( !m_rightOn.IsValid() )
	{
		m_rightOff = pRender->LoadImage( "Data/Sprites2/ui/selectlevel_btn_normal.png" );
		m_rightOn = pRender->LoadImage( "Data/Sprites2/ui/selectlevel_btn_selected.png" );
		m_arrowLeft = pRender->LoadImage( "Data/Sprites2/ui/arrow_left_selected.png" );
		m_arrowRight = pRender->LoadImage( "Data/Sprites2/ui/arrow_right_selected.png" );
		m_arrowLeftPressed = pRender->LoadImage( "Data/Sprites2/ui/arrow_left_normal.png" );
		m_arrowRightPressed = pRender->LoadImage( "Data/Sprites2/ui/arrow_right_normal.png" );
	}

	m_screenX = x + m_x + m_w - 577 - 68;

	if ( !m_selected )
		pRender->DrawImage( m_rightOff, x + m_x + m_w - 577 - 68, y + m_y );
	else
	{
		pRender->DrawImage( m_rightOn, x + m_x + m_w - 577 - 68, y + m_y );
		if ( m_needArrows )
		{
			if ( m_pressedLeft )
				pRender->DrawImage( m_arrowLeftPressed, x + m_x + m_w - 577 - 68 + 20, y + m_y + 10 );
			else
				pRender->DrawImage( m_arrowLeft, x + m_x + m_w - 577 - 68 + 20, y + m_y + 10 );

			if ( m_pressedRight )
				pRender->DrawImage( m_arrowRightPressed, x + m_x + m_w - 68 - 125, y + m_y + 10 );				
			else
				pRender->DrawImage( m_arrowRight, x + m_x + m_w - 68 - 125, y + m_y + 10 );
		}
	}

	Color off( 73, 198, 135 );
	Color on( 136, 247, 27 );

	const char *value = CurrentValue();
	pRender->DrawAlignedText( x + m_x + m_w - 577/2 - 101, y + m_y + 13, m_selected ? on : off, 25, TEXT_ALIGN_CENTER, "%s", value );
}
    ThreadContextTTD::~ThreadContextTTD()
    {
        for(auto iter = this->m_ttdContextToExternalRefMap.GetIterator(); iter.IsValid(); iter.MoveNext())
        {
            this->m_threadCtx->GetRecycler()->RootRelease(iter.CurrentValue());
        }
        this->m_ttdContextToExternalRefMap.Clear();

        this->m_activeContext = nullptr;
        this->m_contextList.Clear();

        this->m_ttdRootTagToObjectMap.Clear();
        this->m_ttdMayBeLongLivedRoot.Clear();

        if(this->m_ttdRecordRootWeakMap != nullptr)
        {
            this->m_ttdRecordRootWeakMap.Unroot(this->m_threadCtx->GetRecycler());
        }

        if(this->m_ttdReplayRootPinSet != nullptr)
        {
            this->m_ttdReplayRootPinSet.Unroot(this->m_threadCtx->GetRecycler());
        }
    }
    uint32 ScriptContextTTD::FindTopLevelCtrForBody(Js::FunctionBody* body) const
    {
        Js::FunctionBody* rootBody = body;
        while(this->ResolveParentBody(rootBody) != nullptr)
        {
            rootBody = this->ResolveParentBody(rootBody);
        }

        TTD_PTR_ID trgtid = TTD_CONVERT_FUNCTIONBODY_TO_PTR_ID(rootBody);

        for(auto iter = this->m_ttdTopLevelScriptLoad.GetIterator(); iter.IsValid(); iter.MoveNext())
        {
            if(iter.CurrentValue().ContextSpecificBodyPtrId == trgtid)
            {
                return iter.CurrentValue().TopLevelBodyCtr;
            }
        }

        for(auto iter = this->m_ttdTopLevelNewFunction.GetIterator(); iter.IsValid(); iter.MoveNext())
        {
            if(iter.CurrentValue().ContextSpecificBodyPtrId == trgtid)
            {
                return iter.CurrentValue().TopLevelBodyCtr;
            }
        }

        for(auto iter = this->m_ttdTopLevelEval.GetIterator(); iter.IsValid(); iter.MoveNext())
        {
            if(iter.CurrentValue().ContextSpecificBodyPtrId == trgtid)
            {
                return iter.CurrentValue().TopLevelBodyCtr;
            }
        }

        TTDAssert(false, "We are missing a top-level function reference.");
        return 0;
    }
Exemple #10
0
double Model_Stock::CurrentValue(const Data& r)
{
    return CurrentValue(&r);
}
Exemple #11
0
void IntBounds::MergeBoundSets(
    const Value *const bounds0Value,
    const IntBounds *const bounds0,
    const Value *const bounds1Value,
    const IntBounds *const bounds1,
    IntBounds *const mergedBounds)
{
    Assert(bounds0Value);
    bounds0->Verify();
    Assert(bounds1Value);
    bounds1->Verify();
    Assert(bounds0 != bounds1);
    Assert(mergedBounds);
    Assert(mergedBounds != bounds0);
    Assert(mergedBounds != bounds1);

    RelativeIntBoundSet *mergedBoundSet;
    const RelativeIntBoundSet *boundSet0, *boundSet1;
    if(Lower)
    {
        mergedBoundSet = &mergedBounds->relativeLowerBounds;
        boundSet0 = &bounds0->relativeLowerBounds;
        boundSet1 = &bounds1->relativeLowerBounds;
    }
    else
    {
        mergedBoundSet = &mergedBounds->relativeUpperBounds;
        boundSet0 = &bounds0->relativeUpperBounds;
        boundSet1 = &bounds1->relativeUpperBounds;
    }

    // Iterate over the smaller set and look up in the larger set for compatible bounds that can be merged
    const RelativeIntBoundSet *iterateOver, *lookUpIn;
    if(boundSet0->Count() <= boundSet1->Count())
    {
        iterateOver = boundSet0;
        lookUpIn = boundSet1;
    }
    else
    {
        iterateOver = boundSet1;
        lookUpIn = boundSet0;
    }
    for(auto it = iterateOver->GetIterator(); it.IsValid(); it.MoveNext())
    {
        const ValueRelativeOffset &iterateOver_bound(it.CurrentValue());
        const ValueNumber baseValueNumber = iterateOver_bound.BaseValueNumber();
        const ValueRelativeOffset *lookUpIn_bound;
        if(!lookUpIn->TryGetReference(baseValueNumber, &lookUpIn_bound))
            continue;
        ValueRelativeOffset mergedBound(iterateOver_bound);
        mergedBound.Merge<Lower, false>(*lookUpIn_bound);
        mergedBoundSet->Add(mergedBound);
    }

    // A value is implicitly bounded by itself, so preserve and merge bounds where one value is bounded by the other
    const ValueNumber bounds0ValueNumber = bounds0Value->GetValueNumber(), bounds1ValueNumber = bounds1Value->GetValueNumber();
    if(bounds0ValueNumber == bounds1ValueNumber)
        return;
    const ValueRelativeOffset *bound;
    if(boundSet0->TryGetReference(bounds1ValueNumber, &bound))
    {
        ValueRelativeOffset mergedBound(bounds1Value, true);
        mergedBound.Merge<Lower, false>(*bound);
        mergedBoundSet->Add(mergedBound);
    }
    if(boundSet1->TryGetReference(bounds0ValueNumber, &bound))
    {
        ValueRelativeOffset mergedBound(bounds0Value, true);
        mergedBound.Merge<Lower, false>(*bound);
        mergedBoundSet->Add(mergedBound);
    }
}
Exemple #12
0
void IntBounds::SetBound(
    const ValueNumber myValueNumber,
    const Value *const baseValue,
    const int offset,
    const bool wasEstablishedExplicitly)
{
    Assert(baseValue);
    Assert(baseValue->GetValueNumber() != myValueNumber);

    // Aggressively merge the constant lower or upper bound of the base value, adjusted by the offset
    ValueInfo const * const baseValueInfo = baseValue->GetValueInfo();
    int constantBoundBase;
    const bool success =
        Lower
            ? baseValueInfo->TryGetIntConstantLowerBound(&constantBoundBase, true)
            : baseValueInfo->TryGetIntConstantUpperBound(&constantBoundBase, true);
    Assert(success);
    const bool isBoundConstant = baseValueInfo->HasIntConstantValue();
    SetBound<Lower>(constantBoundBase, offset, wasEstablishedExplicitly && isBoundConstant);

    if(isBoundConstant)
        return;

    // If the base value has relative bounds, pull in the lower or upper bounds adjusted by the offset
    RelativeIntBoundSet &boundSet = Lower ? relativeLowerBounds : relativeUpperBounds;
    const RelativeIntBoundSet &oppositeBoundSet = Lower ? relativeUpperBounds : relativeLowerBounds;
    if(baseValueInfo->IsIntBounded())
    {
        const IntBounds *const baseValueBounds = baseValueInfo->AsIntBounded()->Bounds();
        const RelativeIntBoundSet &baseValueBoundSet =
            Lower ? baseValueBounds->relativeLowerBounds : baseValueBounds->relativeUpperBounds;
        for(auto it = baseValueBoundSet.GetIterator(); it.IsValid(); it.MoveNext())
        {
            ValueRelativeOffset bound(it.CurrentValue());
            if(bound.BaseValueNumber() == myValueNumber || !bound.Add(offset))
                continue;
            const ValueRelativeOffset *existingOppositeBound;
            if(oppositeBoundSet.TryGetReference(bound.BaseValueNumber(), &existingOppositeBound) &&
                (Lower ? bound.Offset() > existingOppositeBound->Offset() : bound.Offset() < existingOppositeBound->Offset()))
            {
                // This bound contradicts the existing opposite bound on the same base value number:
                //     - Setting a lower bound (base + offset) when (base + offset2) is an upper bound and (offset > offset2)
                //     - Setting an upper bound (base + offset) when (base + offset2) is a lower bound and (offset < offset2)
                continue;
            }
            ValueRelativeOffset *existingBound;
            if(boundSet.TryGetReference(bound.BaseValueNumber(), &existingBound))
                existingBound->Merge<Lower, true>(bound);
            else
                boundSet.Add(bound);
        }
    }

    // Set the base value as a relative bound
    const ValueRelativeOffset bound(baseValue, offset, wasEstablishedExplicitly);
    const ValueRelativeOffset *existingOppositeBound;
    if(oppositeBoundSet.TryGetReference(bound.BaseValueNumber(), &existingOppositeBound) &&
        (Lower ? offset > existingOppositeBound->Offset() : offset < existingOppositeBound->Offset()))
    {
        // This bound contradicts the existing opposite bound on the same base value number:
        //     - Setting a lower bound (base + offset) when (base + offset2) is an upper bound and (offset > offset2)
        //     - Setting an upper bound (base + offset) when (base + offset2) is a lower bound and (offset < offset2)
        return;
    }
    ValueRelativeOffset *existingBound;
    if(boundSet.TryGetReference(bound.BaseValueNumber(), &existingBound))
        existingBound->Merge<Lower, true>(bound);
    else
        boundSet.Add(bound);
}