Bug 792581 - part 20: Replace LL_UI2L macro with int64_t cast. r=ehsan
authorAndrew Quartey <andrew.quartey@gmail.com>
Thu, 25 Oct 2012 19:25:57 -0400
changeset 111458 5fb440887096d1c497b2a15adeebe2a20a15f229
parent 111457 ca811b55072619f3515e5eccf439256ee1b2fb2b
child 111459 9aa2637e2b6b1a86f08fb14b99eb05aadb3d42c5
push id17075
push userandrew.quartey@gmail.com
push dateThu, 25 Oct 2012 23:26:26 +0000
treeherdermozilla-inbound@b3a9ae0f6abf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs792581
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 792581 - part 20: Replace LL_UI2L macro with int64_t cast. r=ehsan
dom/file/ArchiveZipFile.cpp
js/xpconnect/loader/mozJSComponentLoader.cpp
netwerk/cache/nsCache.cpp
netwerk/streamconv/converters/ParseFTPList.cpp
tools/trace-malloc/spacetrace.c
tools/trace-malloc/tmfrags.c
tools/trace-malloc/tmstats.c
xpcom/ds/nsCRT.cpp
xpcom/ds/nsVariant.cpp
xpcom/io/nsStorageStream.cpp
--- a/dom/file/ArchiveZipFile.cpp
+++ b/dom/file/ArchiveZipFile.cpp
@@ -322,17 +322,17 @@ ArchiveInputStream::Seek(int32_t aWhence
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 ArchiveInputStream::Tell(int64_t *aResult)
 {
-  LL_UI2L(*aResult, mData.cursor);
+  *aResult = mData.cursor;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 ArchiveInputStream::SetEOF()
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
--- a/js/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
@@ -736,18 +736,17 @@ mozJSComponentLoader::GlobalForLocation(
 #ifdef HAVE_PR_MEMMAP
             int64_t fileSize;
             rv = aComponentFile->GetFileSize(&fileSize);
             if (NS_FAILED(rv)) {
                 JS_SetOptions(cx, oldopts);
                 return rv;
             }
 
-            int64_t maxSize;
-            LL_UI2L(maxSize, UINT32_MAX);
+            int64_t maxSize = UINT32_MAX;
             if (fileSize > maxSize) {
                 NS_ERROR("file too large");
                 JS_SetOptions(cx, oldopts);
                 return NS_ERROR_FAILURE;
             }
 
             PRFileDesc *fileHandle;
             rv = aComponentFile->OpenNSPRFileDesc(PR_RDONLY, 0, &fileHandle);
--- a/netwerk/cache/nsCache.cpp
+++ b/netwerk/cache/nsCache.cpp
@@ -48,19 +48,17 @@ SecondsFromPRTime(PRTime prTime)
   int64_t  microSecondsPerSecond = PR_USEC_PER_SEC;
   return uint32_t(prTime / microSecondsPerSecond);
 }
 
 
 PRTime
 PRTimeFromSeconds(uint32_t seconds)
 {
-  int64_t intermediateResult;
-
-  LL_UI2L(intermediateResult, seconds);
+  int64_t intermediateResult = seconds;
   PRTime prTime = intermediateResult * PR_USEC_PER_SEC;
   return prTime;
 }
 
 
 nsresult
 ClientIDFromCacheKey(const nsACString&  key, char ** result)
 {
--- a/netwerk/streamconv/converters/ParseFTPList.cpp
+++ b/netwerk/streamconv/converters/ParseFTPList.cpp
@@ -481,20 +481,17 @@ int ParseFTPList(const char *line, struc
                *
                * A block is always 512 bytes on OpenVMS, compute size.
                * So its rounded up to the next block, so what, its better
                * than not showing the size at all.
                * A block is always 512 bytes on OpenVMS, compute size.
                * So its rounded up to the next block, so what, its better
                * than not showing the size at all.
               */
-              uint64_t fsz, factor;
-              LL_UI2L(fsz, strtoul(tokens[1], (char **)0, 10));
-              LL_UI2L(factor, 512);
-              fsz *= factor;
+              uint64_t fsz = uint64_t(strtoul(tokens[1], (char **)0, 10) * 512);
               PR_snprintf(result->fe_size, sizeof(result->fe_size), 
                           "%lld", fsz);
             } 
 
           } /* if (result->fe_type != 'd') */
 
           p = tokens[2] + 2;
           if (*p == '-')
--- a/tools/trace-malloc/spacetrace.c
+++ b/tools/trace-malloc/spacetrace.c
@@ -106,25 +106,17 @@ showHelp(void)
 ** ticks2xsec
 **
 ** Convert platform specific ticks to second units
 ** Returns 0 on success.
 */
 uint32_t
 ticks2xsec(tmreader * aReader, uint32_t aTicks, uint32_t aResolution)
 {
-    uint64_t bigone;
-    uint64_t tmp64;
-
-    LL_UI2L(bigone, aResolution);
-    LL_UI2L(tmp64, aTicks);
-    bigone *= tmp64;
-    LL_UI2L(tmp64, aReader->ticksPerSec);
-    bigone /= tmp64;
-    return (uint32_t)bigone;
+    return (uint32_t)((aResolution * aTicks)/aReader->ticksPerSec);
 }
 
 #define ticks2msec(reader, ticks) ticks2xsec((reader), (ticks), 1000)
 #define ticks2usec(reader, ticks) ticks2xsec((reader), (ticks), 1000000)
 
 /*
 ** initOptions
 **
@@ -658,18 +650,18 @@ recalculateAllocationCost(STOptions * in
         uint32_t timeval =
             aAllocation->mMaxTimeval - aAllocation->mMinTimeval;
         uint32_t size = byteSize(inOptions, aAllocation);
         uint64_t weight64 = LL_INIT(0, 0);
         uint32_t heapCost = aAllocation->mHeapRuntimeCost;
         uint64_t timeval64 = LL_INIT(0, 0);
         uint64_t size64 = LL_INIT(0, 0);
 
-        LL_UI2L(timeval64, timeval);
-        LL_UI2L(size64, size);
+        timeval64 = timeval;
+        size64 = size;
         weight64 = timeval64 * size64;
 
         /*
          ** First, update this run.
          */
         aRun->mStats[inContext->mIndex].mCompositeCount++;
         aRun->mStats[inContext->mIndex].mHeapRuntimeCost += heapCost;
         aRun->mStats[inContext->mIndex].mSize += size;
@@ -952,19 +944,17 @@ harvestRun(const STRun * aInRun, STRun *
                 if ((bytesize < aOptions->mSizeMin) ||
                     (bytesize > aOptions->mSizeMax)) {
                     continue;
                 }
 
                 /*
                  ** Check weight restrictions.
                  */
-                LL_UI2L(bytesize64, bytesize);
-                LL_UI2L(lifetime64, lifetime);
-                weight64 = bytesize64 * lifetime64;
+                weight64 = (uint64_t)(bytesize * lifetime);
                 if (weight64 < aOptions->mWeightMin64 ||
                     weight64 > aOptions->mWeightMax64) {
                     continue;
                 }
 
                 /*
                  ** Possibly restrict the callsite by text.
                  ** Do this last, as it is a heavier check.
@@ -1089,23 +1079,21 @@ compareAllocations(const void *aAlloc1, 
                 {
                     uint64_t weight164 = LL_INIT(0, 0);
                     uint64_t weight264 = LL_INIT(0, 0);
                     uint64_t bytesize164 = LL_INIT(0, 0);
                     uint64_t bytesize264 = LL_INIT(0, 0);
                     uint64_t timeval164 = LL_INIT(0, 0);
                     uint64_t timeval264 = LL_INIT(0, 0);
 
-                    LL_UI2L(bytesize164, byteSize(inOptions, alloc1));
-                    LL_UI2L(timeval164,
-                            (alloc1->mMaxTimeval - alloc1->mMinTimeval));
+                    bytesize164 = byteSize(inOptions, alloc1);
+                    timeval164 = alloc1->mMaxTimeval - alloc1->mMinTimeval;
                     weight164 = bytesize164 * timeval164;
-                    LL_UI2L(bytesize264, byteSize(inOptions, alloc2));
-                    LL_UI2L(timeval264,
-                            (alloc2->mMaxTimeval - alloc2->mMinTimeval));
+                    bytesize264 = byteSize(inOptions, alloc2);
+                    timeval264 = alloc2->mMaxTimeval - alloc2->mMinTimeval;
                     weight264 = bytesize264 * timeval264;
 
                     if (weight164 < weight264) {
                         retval = __LINE__;
                     }
                     else if (weight164 > weight264) {
                         retval = -__LINE__;
                     }
@@ -2711,23 +2699,19 @@ displayTopAllocations(STRequest * inRequ
                  && loop < aRun->mAllocationCount; loop++) {
                 current = aRun->mAllocations[loop];
                 if (NULL != current) {
                     uint32_t lifespan =
                         current->mMaxTimeval - current->mMinTimeval;
                     uint32_t size = byteSize(&inRequest->mOptions, current);
                     uint32_t heapCost = current->mHeapRuntimeCost;
                     uint64_t weight64 = LL_INIT(0, 0);
-                    uint64_t size64 = LL_INIT(0, 0);
-                    uint64_t lifespan64 = LL_INIT(0, 0);
                     char buffer[32];
 
-                    LL_UI2L(size64, size);
-                    LL_UI2L(lifespan64, lifespan);
-                    weight64 = size64 * lifespan64;
+                    weight64 =(uint64_t)(size * lifespan);
 
                     PR_fprintf(inRequest->mFD, "<tr>\n");
 
                     /*
                      ** Rank.
                      */
                     PR_fprintf(inRequest->mFD, "<td align=right>%u</td>\n",
                                loop + 1);
@@ -2835,23 +2819,19 @@ displayMemoryLeaks(STRequest * inRequest
                  */
                 if (TM_EVENT_FREE !=
                     current->mEvents[current->mEventCount - 1].mEventType) {
                     uint32_t lifespan =
                         current->mMaxTimeval - current->mMinTimeval;
                     uint32_t size = byteSize(&inRequest->mOptions, current);
                     uint32_t heapCost = current->mHeapRuntimeCost;
                     uint64_t weight64 = LL_INIT(0, 0);
-                    uint64_t size64 = LL_INIT(0, 0);
-                    uint64_t lifespan64 = LL_INIT(0, 0);
                     char buffer[32];
 
-                    LL_UI2L(size64, size);
-                    LL_UI2L(lifespan64, lifespan);
-                    weight64 = size64 * lifespan64;
+                    weight64 =(uint64_t)(size * lifespan);
 
                     /*
                      ** One more shown.
                      */
                     displayed++;
 
                     PR_fprintf(inRequest->mFD, "<tr>\n");
 
@@ -3093,24 +3073,20 @@ displayAllocationDetails(STRequest * inR
 
     if (NULL != aAllocation) {
         uint32_t traverse = 0;
         uint32_t bytesize = byteSize(&inRequest->mOptions, aAllocation);
         uint32_t timeval =
             aAllocation->mMaxTimeval - aAllocation->mMinTimeval;
         uint32_t heapCost = aAllocation->mHeapRuntimeCost;
         uint64_t weight64 = LL_INIT(0, 0);
-        uint64_t bytesize64 = LL_INIT(0, 0);
-        uint64_t timeval64 = LL_INIT(0, 0);
         uint32_t cacheval = 0;
         int displayRes = 0;
 
-        LL_UI2L(bytesize64, bytesize);
-        LL_UI2L(timeval64, timeval);
-        weight64 = bytesize64 * timeval64;
+        weight64 = (uint64_t)(bytesize * timeval);
 
         PR_fprintf(inRequest->mFD, "<p>Allocation %u Details:</p>\n",
                    aAllocation->mRunIndex);
 
         PR_fprintf(inRequest->mFD, "<div id=\"allocation-details\"><table class=\"data summary\">\n");
         PR_fprintf(inRequest->mFD,
                    "<tr><td align=left>Final Size:</td><td align=right>%u</td></tr>\n",
                    bytesize);
@@ -4415,22 +4391,20 @@ graphWeight(STRequest * inRequest, STRun
                  */
                 for (loop = 0; loop < aRun->mAllocationCount; loop++) {
                     if (prevTimeval < aRun->mAllocations[loop]->mMinTimeval
                         && timeval >= aRun->mAllocations[loop]->mMinTimeval) {
                         uint64_t size64 = LL_INIT(0, 0);
                         uint64_t lifespan64 = LL_INIT(0, 0);
                         uint64_t weight64 = LL_INIT(0, 0);
 
-                        LL_UI2L(size64,
-                                byteSize(&inRequest->mOptions,
-                                         aRun->mAllocations[loop]));
-                        LL_UI2L(lifespan64,
-                                (aRun->mAllocations[loop]->mMaxTimeval -
-                                 aRun->mAllocations[loop]->mMinTimeval));
+                        size64 = byteSize(&inRequest->mOptions,
+                                          aRun->mAllocations[loop]);
+                        lifespan64 = aRun->mAllocations[loop]->mMaxTimeval -
+                                     aRun->mAllocations[loop]->mMinTimeval;
                         weight64 = size64 * lifespan64;
 
                         YData64[traverse] += weight64;
                     }
                 }
             }
 
             /*
@@ -4482,37 +4456,34 @@ graphWeight(STRequest * inRequest, STRun
                 char *timevals[11];
                 char *bytes[11];
                 char timevalSpace[11][32];
                 char byteSpace[11][32];
                 int legendColors[1];
                 const char *legends[1] = { "Memory Weight" };
                 uint64_t percent64 = LL_INIT(0, 0);
                 uint64_t result64 = LL_INIT(0, 0);
-                uint64_t hundred64 = LL_INIT(0, 0);
+
                 uint32_t cached = 0;
-
-                LL_UI2L(hundred64, 100);
+                uint64_t hundred64 = 100;
 
                 /*
                  ** Figure out what the labels will say.
                  */
                 for (traverse = 0; traverse < 11; traverse++) {
                     timevals[traverse] = timevalSpace[traverse];
                     bytes[traverse] = byteSpace[traverse];
 
                     cached =
                         ((globals.mMaxTimeval -
                           globals.mMinTimeval) * percents[traverse]) / 100;
                     PR_snprintf(timevals[traverse], 32, ST_TIMEVAL_FORMAT,
                                 ST_TIMEVAL_PRINTABLE(cached));
 
-                    LL_UI2L(percent64, percents[traverse]);
-                    result64 = maxWeight64 - minWeight64;
-                    result64 *= percent64;
+                    result64 = (maxWeight64 - minWeight64) * percents[traverse];
                     result64 /= hundred64;
                     PR_snprintf(bytes[traverse], 32, "%llu", result64);
                 }
 
                 red = gdImageColorAllocate(graph, 255, 0, 0);
                 legendColors[0] = red;
 
                 drawGraph(graph, -1, "Allocation Weights", "Seconds",
--- a/tools/trace-malloc/tmfrags.c
+++ b/tools/trace-malloc/tmfrags.c
@@ -411,25 +411,17 @@ int initOptions(Options* outOptions, int
 }
 
 
 uint32_t ticks2xsec(tmreader* aReader, uint32_t aTicks, uint32_t aResolution)
 /*
 ** Convert platform specific ticks to second units
 */
 {
-    uint64_t bigone;
-    uint64_t tmp64;
-
-    LL_UI2L(bigone, aResolution);
-    LL_UI2L(tmp64, aTicks);
-    bigone *= tmp64;
-    LL_UI2L(tmp64, aReader->ticksPerSec);
-    bigone /= tmp64;
-    return uint32(bigone);
+    return (uint32)((aResolution * aTicks) / aReader->ticksPerSec);
 }
 
 
 void cleanOptions(Options* inOptions)
 /*
 **  Clean up any open handles.
 */
 {
--- a/tools/trace-malloc/tmstats.c
+++ b/tools/trace-malloc/tmstats.c
@@ -410,23 +410,22 @@ void showHelp(Options* inOptions)
 
 void addVariance(VarianceState* inVariance, unsigned inValue)
 /*
 **  Add a value to a variance state.
 */
 {
     uint64_t squared;
     uint64_t bigValue;
-    
-    LL_UI2L(bigValue, inValue);
 
+    bigValue = inValue;
     inVariance->mSum += bigValue;
 
     squared = bigValue * bigValue;
-    inVariance->mSquaredSum, inVariance->mSquaredSum += squared;
+    inVariance->mSquaredSum += squared;
 
     inVariance->mCount++;
 }
 
 
 double getAverage(VarianceState* inVariance)
 /*
 **  Determine the mean/average based on the given state.
@@ -523,25 +522,17 @@ unsigned actualByteSize(Options* inOptio
 
 
 uint32_t ticks2xsec(tmreader* aReader, uint32_t aTicks, uint32_t aResolution)
 /*
 ** Convert platform specific ticks to second units
 ** Returns 0 on success.
 */
 {
-    uint64_t bigone;
-    uint64_t tmp64;
-
-    LL_UI2L(bigone, aResolution);
-    LL_UI2L(tmp64, aTicks);
-    bigone *= tmp64;
-    LL_UI2L(tmp64, aReader->ticksPerSec);
-    bigone /= tmp64;
-    return (uint32_t)bigone;
+    return (uint32_t)((aResolution * aTicks) / aReader->ticksPerSec);
 }
 #define ticks2msec(reader, ticks) ticks2xsec((reader), (ticks), 1000)
 
 
 void tmEventHandler(tmreader* inReader, tmevent* inEvent)
 /*
 **  Callback from the tmreader_eventloop.
 **  Keep it simple in here, this is where we'll spend the most time.
--- a/xpcom/ds/nsCRT.cpp
+++ b/xpcom/ds/nsCRT.cpp
@@ -169,20 +169,19 @@ PRUnichar* nsCRT::strndup(const PRUnicha
 
 // This should use NSPR but NSPR isn't exporting its PR_strtoll function
 // Until then...
 int64_t nsCRT::atoll(const char *str)
 {
     if (!str)
         return LL_Zero();
 
-    int64_t ll = LL_Zero(), digitll = LL_Zero();
+    int64_t ll = LL_Zero();
 
     while (*str && *str >= '0' && *str <= '9') {
         ll *= 10;
-        LL_UI2L(digitll, (*str - '0'));
-        ll += digitll;
+        ll += *str - '0';
         str++;
     }
 
     return ll;
 }
 
--- a/xpcom/ds/nsVariant.cpp
+++ b/xpcom/ds/nsVariant.cpp
@@ -645,17 +645,17 @@ nsVariant::ConvertToInt64(const nsDiscri
     if(NS_FAILED(rv))
         return rv;
     switch(tempData.mType)
     {
     case nsIDataType::VTYPE_INT32:
         *_retval = tempData.u.mInt32Value;
         return rv;
     case nsIDataType::VTYPE_UINT32:
-        LL_UI2L(*_retval, tempData.u.mUint32Value);
+        *_retval = tempData.u.mUint32Value;
         return rv;
     case nsIDataType::VTYPE_DOUBLE:
         // XXX should check for data loss here!
         LL_D2L(*_retval, tempData.u.mDoubleValue);
         return rv;
     default:
         NS_ERROR("bad type returned from ToManageableNumber");
         return NS_ERROR_CANNOT_CONVERT_DATA;
--- a/xpcom/io/nsStorageStream.cpp
+++ b/xpcom/io/nsStorageStream.cpp
@@ -476,17 +476,17 @@ nsStorageInputStream::Seek(int32_t aWhen
 }
 
 NS_IMETHODIMP
 nsStorageInputStream::Tell(int64_t *aResult)
 {
     if (NS_FAILED(mStatus))
         return mStatus;
 
-    LL_UI2L(*aResult, mLogicalCursor);
+    *aResult = mLogicalCursor;
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsStorageInputStream::SetEOF()
 {
     NS_NOTREACHED("nsStorageInputStream::SetEOF");
     return NS_ERROR_NOT_IMPLEMENTED;