OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
6 | 6 |
7 #if defined(TARGET_ARCH_ARM64) | 7 #if defined(TARGET_ARCH_ARM64) |
8 | 8 |
9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
10 #include "vm/cpuinfo.h" | 10 #include "vm/cpuinfo.h" |
11 #include "vm/simulator.h" | 11 #include "vm/simulator.h" |
12 | 12 |
13 #if defined(HOST_ARCH_ARM64) | 13 #if !defined(USING_SIMULATOR) |
14 #include <sys/syscall.h> /* NOLINT */ | 14 #include <sys/syscall.h> /* NOLINT */ |
15 #include <unistd.h> /* NOLINT */ | 15 #include <unistd.h> /* NOLINT */ |
16 #endif | 16 #endif |
17 | 17 |
18 namespace dart { | 18 namespace dart { |
19 | 19 |
20 void CPU::FlushICache(uword start, uword size) { | 20 void CPU::FlushICache(uword start, uword size) { |
21 #if defined(HOST_ARCH_ARM64) | 21 #if !defined(USING_SIMULATOR) |
22 // Nothing to do. Flushing no instructions. | 22 // Nothing to do. Flushing no instructions. |
23 if (size == 0) { | 23 if (size == 0) { |
24 return; | 24 return; |
25 } | 25 } |
26 | 26 |
27 // ARM recommends using the gcc intrinsic __clear_cache on Linux and Android. | 27 // ARM recommends using the gcc intrinsic __clear_cache on Linux and Android. |
28 // blogs.arm.com/software-enablement/141-caches-and-self-modifying-code/ | 28 // blogs.arm.com/software-enablement/141-caches-and-self-modifying-code/ |
29 #if defined(__linux__) || defined(ANDROID) | 29 #if defined(__linux__) || defined(ANDROID) |
30 extern void __clear_cache(char*, char*); | 30 extern void __clear_cache(char*, char*); |
31 char* beg = reinterpret_cast<char*>(start); | 31 char* beg = reinterpret_cast<char*>(start); |
32 char* end = reinterpret_cast<char*>(start + size); | 32 char* end = reinterpret_cast<char*>(start + size); |
33 ::__clear_cache(beg, end); | 33 ::__clear_cache(beg, end); |
34 #else | 34 #else |
35 #error FlushICache only tested/supported on Linux and Android | 35 #error FlushICache only tested/supported on Linux and Android |
36 #endif | 36 #endif |
37 | 37 |
38 #endif | 38 #endif |
39 } | 39 } |
40 | 40 |
41 | 41 |
42 const char* CPU::Id() { | 42 const char* CPU::Id() { |
43 return | 43 return |
44 #if !defined(HOST_ARCH_ARM64) | 44 #if defined(USING_SIMULATOR) |
45 "sim" | 45 "sim" |
46 #endif // !defined(HOST_ARCH_ARM64) | 46 #endif // !defined(HOST_ARCH_ARM64) |
47 "arm64"; | 47 "arm64"; |
48 } | 48 } |
49 | 49 |
50 | 50 |
51 const char* HostCPUFeatures::hardware_ = NULL; | 51 const char* HostCPUFeatures::hardware_ = NULL; |
52 #if defined(DEBUG) | 52 #if defined(DEBUG) |
53 bool HostCPUFeatures::initialized_ = false; | 53 bool HostCPUFeatures::initialized_ = false; |
54 #endif | 54 #endif |
55 | 55 |
56 | 56 |
57 #if defined(HOST_ARCH_ARM64) | 57 #if !defined(USING_SIMULATOR) |
58 void HostCPUFeatures::InitOnce() { | 58 void HostCPUFeatures::InitOnce() { |
59 CpuInfo::InitOnce(); | 59 CpuInfo::InitOnce(); |
60 hardware_ = CpuInfo::GetCpuModel(); | 60 hardware_ = CpuInfo::GetCpuModel(); |
61 #if defined(DEBUG) | 61 #if defined(DEBUG) |
62 initialized_ = true; | 62 initialized_ = true; |
63 #endif | 63 #endif |
64 } | 64 } |
65 | 65 |
66 | 66 |
67 void HostCPUFeatures::Cleanup() { | 67 void HostCPUFeatures::Cleanup() { |
68 DEBUG_ASSERT(initialized_); | 68 DEBUG_ASSERT(initialized_); |
69 #if defined(DEBUG) | 69 #if defined(DEBUG) |
70 initialized_ = false; | 70 initialized_ = false; |
71 #endif | 71 #endif |
72 ASSERT(hardware_ != NULL); | 72 ASSERT(hardware_ != NULL); |
73 free(const_cast<char*>(hardware_)); | 73 free(const_cast<char*>(hardware_)); |
74 hardware_ = NULL; | 74 hardware_ = NULL; |
75 CpuInfo::Cleanup(); | 75 CpuInfo::Cleanup(); |
76 } | 76 } |
77 | 77 |
78 #else | 78 #else // !defined(USING_SIMULATOR) |
79 | 79 |
80 void HostCPUFeatures::InitOnce() { | 80 void HostCPUFeatures::InitOnce() { |
81 CpuInfo::InitOnce(); | 81 CpuInfo::InitOnce(); |
82 hardware_ = CpuInfo::GetCpuModel(); | 82 hardware_ = CpuInfo::GetCpuModel(); |
83 #if defined(DEBUG) | 83 #if defined(DEBUG) |
84 initialized_ = true; | 84 initialized_ = true; |
85 #endif | 85 #endif |
86 } | 86 } |
87 | 87 |
88 | 88 |
89 void HostCPUFeatures::Cleanup() { | 89 void HostCPUFeatures::Cleanup() { |
90 DEBUG_ASSERT(initialized_); | 90 DEBUG_ASSERT(initialized_); |
91 #if defined(DEBUG) | 91 #if defined(DEBUG) |
92 initialized_ = false; | 92 initialized_ = false; |
93 #endif | 93 #endif |
94 ASSERT(hardware_ != NULL); | 94 ASSERT(hardware_ != NULL); |
95 free(const_cast<char*>(hardware_)); | 95 free(const_cast<char*>(hardware_)); |
96 hardware_ = NULL; | 96 hardware_ = NULL; |
97 CpuInfo::Cleanup(); | 97 CpuInfo::Cleanup(); |
98 } | 98 } |
99 #endif // defined(HOST_ARCH_ARM64) | 99 #endif // !defined(USING_SIMULATOR) |
100 | 100 |
101 } // namespace dart | 101 } // namespace dart |
102 | 102 |
103 #endif // defined TARGET_ARCH_ARM64 | 103 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |