Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Unified Diff: runtime/platform/globals.h

Issue 70993002: - Convert heap sizes to words from bytes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/heap.h » ('j') | runtime/vm/pages.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/platform/globals.h
===================================================================
--- runtime/platform/globals.h (revision 30304)
+++ runtime/platform/globals.h (working copy)
@@ -281,6 +281,24 @@
const intptr_t GB = MB * KB;
const intptr_t GBLog2 = MBLog2 + KBLog2;
+const intptr_t KBInWords = KB >> kWordSizeLog2;
+const intptr_t KBInWordsLog2 = KBLog2 - kWordSizeLog2;
+const intptr_t MBInWords = KB * KBInWords;
+const intptr_t MBInWordsLog2 = KBLog2 + KBInWordsLog2;
+const intptr_t GBInWords = MB * KBInWords;
+const intptr_t GBInWordsLog2 = MBLog2 + KBInWordsLog2;
+
+// Helpers to round memory sizes to human readable values.
+inline intptr_t RoundWordsToKB(intptr_t size_in_words) {
+ return (size_in_words + (KBInWords >> 1)) >> KBInWordsLog2;
+}
+inline intptr_t RoundWordsToMB(intptr_t size_in_words) {
+ return (size_in_words + (MBInWords >> 1)) >> MBInWordsLog2;
+}
+inline intptr_t RoundWordsToGB(intptr_t size_in_words) {
+ return (size_in_words + (GBInWords >> 1)) >> GBInWordsLog2;
+}
+
const intptr_t kIntptrOne = 1;
const intptr_t kIntptrMin = (kIntptrOne << (kBitsPerWord - 1));
const intptr_t kIntptrMax = ~kIntptrMin;
@@ -296,6 +314,16 @@
const int kNanosecondsPerSecond = (kNanosecondsPerMicrosecond *
kMicrosecondsPerSecond);
+// Helpers to round micro second times to human understandable values.
+inline double RoundMicrosecondsToSeconds(int64_t micros) {
+ const int k1M = 1000000; // Converting us to secs.
+ return static_cast<double>(micros + (k1M >> 1)) / k1M;
+}
+inline double RoundMicrosecondsToMilliseconds(int64_t micros) {
+ const int k1K = 1000; // Conversting us to ms.
+ return static_cast<double>(micros + (k1K >> 1)) / k1K;
+}
+
// A macro to disallow the copy constructor and operator= functions.
// This should be used in the private: declarations for a class.
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
« no previous file with comments | « no previous file | runtime/vm/heap.h » ('j') | runtime/vm/pages.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698