summaryrefslogtreecommitdiff
path: root/indra/llcommon/llfasttimer_class.cpp
diff options
context:
space:
mode:
authorTofu Linden <tofu.linden@lindenlab.com>2010-02-06 21:38:57 +0000
committerTofu Linden <tofu.linden@lindenlab.com>2010-02-06 21:38:57 +0000
commita4d224ff9316bf3b99e17f72f844d91e0ef80cc7 (patch)
tree4b9d374e333574104ac808e7e3b331c6bac41459 /indra/llcommon/llfasttimer_class.cpp
parent346cabd557d921dea4f3a122df1e4f8eec4fc9f0 (diff)
EXT-5055 LLInstanceTracker promotes some dangerous patterns - detect them
Diffstat (limited to 'indra/llcommon/llfasttimer_class.cpp')
-rw-r--r--indra/llcommon/llfasttimer_class.cpp111
1 files changed, 62 insertions, 49 deletions
diff --git a/indra/llcommon/llfasttimer_class.cpp b/indra/llcommon/llfasttimer_class.cpp
index 6d8d81e114..2e5edb1f3b 100644
--- a/indra/llcommon/llfasttimer_class.cpp
+++ b/indra/llcommon/llfasttimer_class.cpp
@@ -218,9 +218,10 @@ LLFastTimer::DeclareTimer::DeclareTimer(const std::string& name)
// static
void LLFastTimer::DeclareTimer::updateCachedPointers()
{
+ DeclareTimer::LLInstanceTrackerScopedGuard guard;
// propagate frame state pointers to timer declarations
- for (DeclareTimer::instance_iter it = DeclareTimer::beginInstances();
- it != DeclareTimer::endInstances();
+ for (DeclareTimer::instance_iter it = guard.beginInstances();
+ it != guard.endInstances();
++it)
{
// update cached pointer
@@ -371,20 +372,23 @@ void LLFastTimer::NamedTimer::buildHierarchy()
if (sCurFrameIndex < 0 ) return;
// set up initial tree
- for (instance_iter it = NamedTimer::beginInstances();
- it != endInstances();
- ++it)
{
- NamedTimer& timer = *it;
- if (&timer == NamedTimerFactory::instance().getRootTimer()) continue;
-
- // bootstrap tree construction by attaching to last timer to be on stack
- // when this timer was called
- if (timer.getFrameState().mLastCaller && timer.mParent == NamedTimerFactory::instance().getRootTimer())
+ NamedTimer::LLInstanceTrackerScopedGuard guard;
+ for (instance_iter it = guard.beginInstances();
+ it != guard.endInstances();
+ ++it)
{
- timer.setParent(timer.getFrameState().mLastCaller->mTimer);
- // no need to push up tree on first use, flag can be set spuriously
- timer.getFrameState().mMoveUpTree = false;
+ NamedTimer& timer = *it;
+ if (&timer == NamedTimerFactory::instance().getRootTimer()) continue;
+
+ // bootstrap tree construction by attaching to last timer to be on stack
+ // when this timer was called
+ if (timer.getFrameState().mLastCaller && timer.mParent == NamedTimerFactory::instance().getRootTimer())
+ {
+ timer.setParent(timer.getFrameState().mLastCaller->mTimer);
+ // no need to push up tree on first use, flag can be set spuriously
+ timer.getFrameState().mMoveUpTree = false;
+ }
}
}
@@ -486,18 +490,21 @@ void LLFastTimer::NamedTimer::resetFrame()
F64 total_time = 0;
LLSD sd;
- for (NamedTimer::instance_iter it = NamedTimer::beginInstances();
- it != NamedTimer::endInstances();
- ++it)
{
- NamedTimer& timer = *it;
- FrameState& info = timer.getFrameState();
- sd[timer.getName()]["Time"] = (LLSD::Real) (info.mSelfTimeCounter*iclock_freq);
- sd[timer.getName()]["Calls"] = (LLSD::Integer) info.mCalls;
-
- // computing total time here because getting the root timer's getCountHistory
- // doesn't work correctly on the first frame
- total_time = total_time + info.mSelfTimeCounter * iclock_freq;
+ NamedTimer::LLInstanceTrackerScopedGuard guard;
+ for (NamedTimer::instance_iter it = guard.beginInstances();
+ it != guard.endInstances();
+ ++it)
+ {
+ NamedTimer& timer = *it;
+ FrameState& info = timer.getFrameState();
+ sd[timer.getName()]["Time"] = (LLSD::Real) (info.mSelfTimeCounter*iclock_freq);
+ sd[timer.getName()]["Calls"] = (LLSD::Integer) info.mCalls;
+
+ // computing total time here because getting the root timer's getCountHistory
+ // doesn't work correctly on the first frame
+ total_time = total_time + info.mSelfTimeCounter * iclock_freq;
+ }
}
sd["Total"]["Time"] = (LLSD::Real) total_time;
@@ -531,21 +538,24 @@ void LLFastTimer::NamedTimer::resetFrame()
DeclareTimer::updateCachedPointers();
// reset for next frame
- for (NamedTimer::instance_iter it = NamedTimer::beginInstances();
- it != NamedTimer::endInstances();
- ++it)
{
- NamedTimer& timer = *it;
-
- FrameState& info = timer.getFrameState();
- info.mSelfTimeCounter = 0;
- info.mCalls = 0;
- info.mLastCaller = NULL;
- info.mMoveUpTree = false;
- // update parent pointer in timer state struct
- if (timer.mParent)
+ NamedTimer::LLInstanceTrackerScopedGuard guard;
+ for (NamedTimer::instance_iter it = guard.beginInstances();
+ it != guard.endInstances();
+ ++it)
{
- info.mParent = &timer.mParent->getFrameState();
+ NamedTimer& timer = *it;
+
+ FrameState& info = timer.getFrameState();
+ info.mSelfTimeCounter = 0;
+ info.mCalls = 0;
+ info.mLastCaller = NULL;
+ info.mMoveUpTree = false;
+ // update parent pointer in timer state struct
+ if (timer.mParent)
+ {
+ info.mParent = &timer.mParent->getFrameState();
+ }
}
}
@@ -575,20 +585,23 @@ void LLFastTimer::NamedTimer::reset()
}
// reset all history
- for (NamedTimer::instance_iter it = NamedTimer::beginInstances();
- it != NamedTimer::endInstances();
- ++it)
{
- NamedTimer& timer = *it;
- if (&timer != NamedTimerFactory::instance().getRootTimer())
+ NamedTimer::LLInstanceTrackerScopedGuard guard;
+ for (NamedTimer::instance_iter it = guard.beginInstances();
+ it != guard.endInstances();
+ ++it)
{
- timer.setParent(NamedTimerFactory::instance().getRootTimer());
+ NamedTimer& timer = *it;
+ if (&timer != NamedTimerFactory::instance().getRootTimer())
+ {
+ timer.setParent(NamedTimerFactory::instance().getRootTimer());
+ }
+
+ timer.mCountAverage = 0;
+ timer.mCallAverage = 0;
+ memset(timer.mCountHistory, 0, sizeof(U32) * HISTORY_NUM);
+ memset(timer.mCallHistory, 0, sizeof(U32) * HISTORY_NUM);
}
-
- timer.mCountAverage = 0;
- timer.mCallAverage = 0;
- memset(timer.mCountHistory, 0, sizeof(U32) * HISTORY_NUM);
- memset(timer.mCallHistory, 0, sizeof(U32) * HISTORY_NUM);
}
sLastFrameIndex = 0;