From 8535b87544cc2e71896716a4cd1c3c2445ff4af0 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 26 Aug 2013 18:00:24 -0700 Subject: removed some unecessary template parameters from LLUnit member functions forced unit conversion code to inline unit conversion now no longer converts all the way to base and back, but tries to find equivalent units as early as possible fixed another llinfos instance scene monitor now outputs n/a for invalid samples --- indra/llcommon/llmemory.cpp | 4 ++-- indra/llcommon/llunit.h | 40 +++++++++++++++-------------------- indra/llcommon/tests/llunits_test.cpp | 1 - indra/newview/llscenemonitor.cpp | 31 +++++++++++++++++++++------ indra/newview/llviewermessage.cpp | 4 ++-- 5 files changed, 46 insertions(+), 34 deletions(-) diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index 06334c012a..cb2f853070 100755 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -206,8 +206,8 @@ bool LLMemory::isMemoryPoolLow() return true ; } - bool is_low = (S32)(sAvailPhysicalMemInKB < LOW_MEMORY_POOL_THRESHOLD || - sAllocatedPageSizeInKB + LOW_MEMORY_POOL_THRESHOLD > sMaxHeapSizeInKB) ; + bool is_low = (S32)(sAvailPhysicalMemInKB < LOW_MEMORY_POOL_THRESHOLD + || sAllocatedPageSizeInKB + LOW_MEMORY_POOL_THRESHOLD > sMaxHeapSizeInKB) ; //check the virtual address space fragmentation if(!is_low) diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index bfc011bb55..1ef4924578 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -82,24 +82,16 @@ struct LLUnit typedef STORAGE_TYPE storage_t; // value initialization - explicit LLUnit(storage_t value = storage_t()) + LL_FORCE_INLINE explicit LLUnit(storage_t value = storage_t()) : mValue(value) {} // unit initialization and conversion template - LLUnit(LLUnit other) + LL_FORCE_INLINE LLUnit(LLUnit other) : mValue(convert(other).mValue) {} - // unit assignment - template - self_t& operator = (LLUnit other) - { - mValue = convert(other).mValue; - return *this; - } - storage_t value() const { return mValue; @@ -122,14 +114,12 @@ struct LLUnit *this = LLUnit(value); } - template - void operator += (LLUnit other) + void operator += (self_t other) { mValue += convert(other).mValue; } - template - void operator -= (LLUnit other) + void operator -= (self_t other) { mValue -= convert(other).mValue; } @@ -139,8 +129,7 @@ struct LLUnit mValue *= multiplicand; } - template - void operator *= (LLUnit multiplicand) + void operator *= (self_t multiplicand) { // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template LL_BAD_TEMPLATE_INSTANTIATION(OTHER_UNIT, "Multiplication of unit types not supported."); @@ -151,15 +140,14 @@ struct LLUnit mValue /= divisor; } - template - void operator /= (LLUnit divisor) + void operator /= (self_t divisor) { // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template LL_BAD_TEMPLATE_INSTANTIATION(OTHER_UNIT, "Illegal in-place division of unit types."); } template - static self_t convert(LLUnit v) + LL_FORCE_INLINE static self_t convert(LLUnit v) { typedef typename LLResultTypePromote::type_t result_storage_t; LLUnit result; @@ -258,7 +246,7 @@ std::istream& operator >>(std::istream& s, LLUnitImplicit -LL_FORCE_INLINE S2 ll_convert_units(LLUnit in, LLUnit& out, ...) +LL_FORCE_INLINE S2 ll_convert_units(LLUnit in, LLUnit& out) { S2 divisor(1); @@ -272,7 +260,7 @@ LL_FORCE_INLINE S2 ll_convert_units(LLUnit in, LLUnit& out, ...) // T1 and T2 same type, just assign out.value((S2)in.value()); } - else if (LLIsSameType::value) + else if (T1::sLevel > T2::sLevel) { // reduce T1 LLUnit new_in; @@ -301,6 +289,10 @@ struct LLStorageType > typedef STORAGE_TYPE type_t; }; +// all of these operators need to perform type promotion on the storage type of the units, so they +// cannot be expressed as operations on identical types with implicit unit conversion +// e.g. typeof(S32Bytes(x) + F32Megabytes(y)) <==> F32Bytes + // // operator + // @@ -677,6 +669,7 @@ struct LLUnitInverseLinearOps #define LL_DECLARE_BASE_UNIT(base_unit_name, unit_label) \ struct base_unit_name \ { \ + static const int sLevel = 0; \ typedef base_unit_name base_unit_t; \ static const char* getUnitLabel() { return unit_label; } \ template \ @@ -690,6 +683,7 @@ struct base_unit_name #define LL_DECLARE_DERIVED_UNIT(base_unit_name, conversion_operation, unit_name, unit_label) \ struct unit_name \ { \ + static const int sLevel = base_unit_name::sLevel + 1; \ typedef base_unit_name base_unit_t; \ static const char* getUnitLabel() { return unit_label; } \ template \ @@ -700,7 +694,7 @@ struct unit_name }; \ \ template \ -S2 ll_convert_units(LLUnit in, LLUnit& out) \ +LL_FORCE_INLINE S2 ll_convert_units(LLUnit in, LLUnit& out) \ { \ typedef typename LLResultTypePromote::type_t result_storage_t; \ LLUnitLinearOps op = \ @@ -710,7 +704,7 @@ S2 ll_convert_units(LLUnit in, LLUnit& out) } \ \ template \ -S2 ll_convert_units(LLUnit in, LLUnit& out) \ +LL_FORCE_INLINE S2 ll_convert_units(LLUnit in, LLUnit& out) \ { \ typedef typename LLResultTypePromote::type_t result_storage_t; \ LLUnitInverseLinearOps op = \ diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp index 292c6122af..31d4f86159 100644 --- a/indra/llcommon/tests/llunits_test.cpp +++ b/indra/llcommon/tests/llunits_test.cpp @@ -271,6 +271,5 @@ namespace tut mega_bytes = (U32Megabytes)5 + (S32Megabytes)-1; ensure("can mix unsigned and signed in units addition", mega_bytes == (S32Megabytes)4); - } } diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 7fafabb493..57d58a9d4e 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -565,8 +565,9 @@ void LLSceneMonitor::dumpToFile(std::string file_name) for (S32 frame = 1; frame <= frame_count; frame++) { - samples += scene_load_recording.getPrevRecording(frame_count - frame).getSampleCount(*it); - row << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getSum(*it); + Recording& recording = scene_load_recording.getPrevRecording(frame_count - frame); + samples += recording.getSampleCount(*it); + row << ", " << recording.getSum(*it); } row << '\n'; @@ -597,8 +598,17 @@ void LLSceneMonitor::dumpToFile(std::string file_name) for (S32 frame = 1; frame <= frame_count; frame++) { - samples += scene_load_recording.getPrevRecording(frame_count - frame).getSampleCount(*it); - row << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getMean(*it); + Recording& recording = scene_load_recording.getPrevRecording(frame_count - frame); + samples += recording.getSampleCount(*it); + F64 mean = recording.getMean(*it); + if (llisnan(mean)) + { + row << ", n/a"; + } + else + { + row << ", " << mean; + } } row << '\n'; @@ -629,8 +639,17 @@ void LLSceneMonitor::dumpToFile(std::string file_name) for (S32 frame = 1; frame <= frame_count; frame++) { - samples += scene_load_recording.getPrevRecording(frame_count - frame).getSampleCount(*it); - row << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getMean(*it); + Recording& recording = scene_load_recording.getPrevRecording(frame_count - frame); + samples += recording.getSampleCount(*it); + F64 mean = recording.getMean(*it); + if (llisnan(mean)) + { + row << ", n/a"; + } + else + { + row << ", " << mean; + } } row << '\n'; diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index b4ed2adb07..7de8e1ff12 100755 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -7219,10 +7219,10 @@ void process_script_teleport_request(LLMessageSystem* msg, void**) LLFloaterWorldMap* instance = LLFloaterWorldMap::getInstance(); if(instance) { - llinfos << "Object named " << object_name + LL_INFOS() << "Object named " << object_name << " is offering TP to region " << sim_name << " position " << pos - << llendl; + << LL_ENDL; instance->trackURL(sim_name, (S32)pos.mV[VX], (S32)pos.mV[VY], (S32)pos.mV[VZ]); LLFloaterReg::showInstance("world_map", "center"); -- cgit v1.2.3