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

Unified Diff: runtime/platform/globals.h

Issue 9209001: Move utils.h and utils.cc from runtime/vm to runtime/platform (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 months 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/platform/platform_headers.gypi » ('j') | runtime/vm/assembler.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/platform/globals.h
diff --git a/runtime/platform/globals.h b/runtime/platform/globals.h
index 24212cba20e3d2da16f594f55fd85b456dfed2f7..1944b7ae81355513a81bea6939e56dd163890be0 100644
--- a/runtime/platform/globals.h
+++ b/runtime/platform/globals.h
@@ -61,6 +61,120 @@
#error Automatic target os detection failed.
#endif
+// Processor architecture detection. For more info on what's defined, see:
+// http://msdn.microsoft.com/en-us/library/b0084kay.aspx
+// http://www.agner.org/optimize/calling_conventions.pdf
+// or with gcc, run: "echo | gcc -E -dM -"
+#if defined(_M_X64) || defined(__x86_64__)
+#define HOST_ARCH_X64 1
+#define ARCH_IS_64_BIT 1
+#elif defined(_M_IX86) || defined(__i386__)
+#define HOST_ARCH_IA32 1
+#define ARCH_IS_32_BIT 1
+#elif defined(__ARMEL__)
+#define HOST_ARCH_ARM 1
+#define ARCH_IS_32_BIT 1
+#else
+#error Architecture was not detected as supported by Dart.
+#endif
+
+#if !defined(TARGET_ARCH_ARM)
+#if !defined(TARGET_ARCH_X64)
+#if !defined(TARGET_ARCH_IA32)
+// No target architecture specified pick the one matching the host architecture.
+#if defined(HOST_ARCH_ARM)
+#define TARGET_ARCH_ARM 1
+#elif defined(HOST_ARCH_X64)
+#define TARGET_ARCH_X64 1
+#elif defined(HOST_ARCH_IA32)
+#define TARGET_ARCH_IA32 1
+#else
+#error Automatic target architecture detection failed.
+#endif
+#endif
+#endif
+#endif
+
+// Verify that host and target architectures match, we cannot
+// have a 64 bit Dart VM generating 32 bit code or vice-versa.
+#if defined(TARGET_ARCH_X64)
+#if !defined(ARCH_IS_64_BIT)
+#error Mismatched Host/Target architectures.
+#endif
+#elif defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_ARM)
+#if !defined(ARCH_IS_32_BIT)
+#error Mismatched Host/Target architectures.
+#endif
+#endif
+
+
+// Printf format for intptr_t on Windows.
+#if !defined(PRIxPTR) && defined(TARGET_OS_WINDOWS)
+#if defined(ARCH_IS_32_BIT)
+#define PRIxPTR "x"
+#else
+#define PRIxPTR "llx"
+#endif // defined(ARCH_IS_32_BIT)
+#endif // !defined(PRIxPTR) && defined(TARGET_OS_WINDOWS)
+
+
+// Suffixes for 64-bit integer literals.
+#ifdef _MSC_VER
+#define DART_INT64_C(x) x##I64
+#define DART_UINT64_C(x) x##UI64
+#else
+#define DART_INT64_C(x) x##LL
+#define DART_UINT64_C(x) x##ULL
+#endif
+
+
+// The following macro works on both 32 and 64-bit platforms.
+// Usage: instead of writing 0x1234567890123456
+// write DART_2PART_UINT64_C(0x12345678,90123456);
+#define DART_2PART_UINT64_C(a, b) \
+ (((static_cast<uint64_t>(a) << 32) + 0x##b##u))
+
+
+// Types for native machine words. Guaranteed to be able to hold pointers and
+// integers.
+typedef intptr_t word;
+typedef uintptr_t uword;
+
+// A type large enough to contain the value of the C++ vtable. This is needed
+// to support the handle operations.
Ivan Posva 2012/01/13 23:51:01 This is not needed in platform/globals.h.
Søren Gjesse 2012/01/16 10:53:00 Moved back to vm/globals.h
+typedef uword cpp_vtable;
+
+// Byte sizes.
+const int kWordSize = sizeof(word);
+#ifdef ARCH_IS_32_BIT
+const int kWordSizeLog2 = 2;
+#else
+const int kWordSizeLog2 = 3;
+#endif
+
+// Bit sizes.
+const int kBitsPerByte = 8;
+const int kBitsPerByteLog2 = 3;
+const int kBitsPerWord = kWordSize * kBitsPerByte;
+
+// System-wide named constants.
+const int KB = 1024;
+const int MB = KB * KB;
+const int GB = KB * KB * KB;
+const intptr_t kIntptrOne = 1;
+const intptr_t kIntptrMin = (kIntptrOne << (kBitsPerWord - 1));
+const intptr_t kIntptrMax = ~kIntptrMin;
+
+// Time constants.
+const int kMillisecondsPerSecond = 1000;
+const int kMicrosecondsPerMillisecond = 1000;
+const int kMicrosecondsPerSecond = (kMicrosecondsPerMillisecond *
+ kMillisecondsPerSecond);
+const int kNanosecondsPerMicrosecond = 1000;
+const int kNanosecondsPerMillisecond = (kNanosecondsPerMicrosecond *
+ kMicrosecondsPerMillisecond);
+const int kNanosecondsPerSecond = (kNanosecondsPerMicrosecond *
+ kMicrosecondsPerSecond);
// A macro to disallow the copy constructor and operator= functions.
// This should be used in the private: declarations for a class.
« no previous file with comments | « no previous file | runtime/platform/platform_headers.gypi » ('j') | runtime/vm/assembler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698