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 #if defined(TARGET_ARCH_ARM64) | 6 #if defined(TARGET_ARCH_ARM64) |
7 | 7 |
8 #include "vm/cpu.h" | 8 #include "vm/cpu.h" |
9 #include "vm/cpu_arm64.h" | 9 #include "vm/cpu_arm64.h" |
10 | 10 |
11 #include "vm/cpuinfo.h" | 11 #include "vm/cpuinfo.h" |
12 #include "vm/simulator.h" | 12 #include "vm/simulator.h" |
13 | 13 |
14 #if !defined(USING_SIMULATOR) | 14 #if !defined(USING_SIMULATOR) |
15 #include <sys/syscall.h> /* NOLINT */ | 15 #include <sys/syscall.h> /* NOLINT */ |
16 #include <unistd.h> /* NOLINT */ | 16 #include <unistd.h> /* NOLINT */ |
17 #endif | 17 #endif |
18 | 18 |
19 namespace dart { | 19 namespace dart { |
20 | 20 |
21 void CPU::FlushICache(uword start, uword size) { | 21 void CPU::FlushICache(uword start, uword size) { |
22 #if TARGET_OS_IOS | 22 #if TARGET_OS_IOS |
23 // Precompilation never patches code so there should be no I cache flushes. | 23 // Precompilation never patches code so there should be no I cache flushes. |
24 UNREACHABLE(); | 24 UNREACHABLE(); |
25 #endif | 25 #endif |
26 | 26 |
27 #if !defined(USING_SIMULATOR) && !TARGET_OS_IOS | 27 #if !defined(USING_SIMULATOR) && !TARGET_OS_IOS |
28 // Nothing to do. Flushing no instructions. | 28 // Nothing to do. Flushing no instructions. |
29 if (size == 0) { | 29 if (size == 0) { |
30 return; | 30 return; |
31 } | 31 } |
32 | 32 |
33 // ARM recommends using the gcc intrinsic __clear_cache on Linux and Android. | 33 // ARM recommends using the gcc intrinsic __clear_cache on Linux and Android. |
34 // blogs.arm.com/software-enablement/141-caches-and-self-modifying-code/ | 34 // blogs.arm.com/software-enablement/141-caches-and-self-modifying-code/ |
35 #if defined(TARGET_OS_ANDROID) || \ | 35 #if defined(TARGET_OS_ANDROID) || defined(TARGET_OS_FUCHSIA) || \ |
36 defined(TARGET_OS_FUCHSIA) || \ | 36 defined(TARGET_OS_LINUX) |
37 defined(TARGET_OS_LINUX) | 37 extern void __clear_cache(char*, char*); |
38 extern void __clear_cache(char*, char*); | 38 char* beg = reinterpret_cast<char*>(start); |
39 char* beg = reinterpret_cast<char*>(start); | 39 char* end = reinterpret_cast<char*>(start + size); |
40 char* end = reinterpret_cast<char*>(start + size); | 40 ::__clear_cache(beg, end); |
41 ::__clear_cache(beg, end); | 41 #else |
42 #else | 42 #error FlushICache only tested/supported on Android, Fuchsia, and Linux |
43 #error FlushICache only tested/supported on Android, Fuchsia, and Linux | 43 #endif |
44 #endif | |
45 | 44 |
46 #endif | 45 #endif |
47 } | 46 } |
48 | 47 |
49 | 48 |
50 const char* CPU::Id() { | 49 const char* CPU::Id() { |
51 return | 50 return |
52 #if defined(USING_SIMULATOR) | 51 #if defined(USING_SIMULATOR) |
53 "sim" | 52 "sim" |
54 #endif // !defined(HOST_ARCH_ARM64) | 53 #endif // !defined(HOST_ARCH_ARM64) |
55 "arm64"; | 54 "arm64"; |
56 } | 55 } |
57 | 56 |
58 | 57 |
59 const char* HostCPUFeatures::hardware_ = NULL; | 58 const char* HostCPUFeatures::hardware_ = NULL; |
60 #if defined(DEBUG) | 59 #if defined(DEBUG) |
61 bool HostCPUFeatures::initialized_ = false; | 60 bool HostCPUFeatures::initialized_ = false; |
62 #endif | 61 #endif |
63 | 62 |
64 | 63 |
65 #if !defined(USING_SIMULATOR) | 64 #if !defined(USING_SIMULATOR) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 ASSERT(hardware_ != NULL); | 101 ASSERT(hardware_ != NULL); |
103 free(const_cast<char*>(hardware_)); | 102 free(const_cast<char*>(hardware_)); |
104 hardware_ = NULL; | 103 hardware_ = NULL; |
105 CpuInfo::Cleanup(); | 104 CpuInfo::Cleanup(); |
106 } | 105 } |
107 #endif // !defined(USING_SIMULATOR) | 106 #endif // !defined(USING_SIMULATOR) |
108 | 107 |
109 } // namespace dart | 108 } // namespace dart |
110 | 109 |
111 #endif // defined TARGET_ARCH_ARM64 | 110 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |