| 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(HOST_ARCH_ARM64) |
| 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(HOST_ARCH_ARM64) |
| 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 the | 27 // ARM recommends using the gcc intrinsic __clear_cache on Linux and Android. |
| 28 // library call cacheflush from unistd.h on Android: | |
| 29 // blogs.arm.com/software-enablement/141-caches-and-self-modifying-code/ | 28 // blogs.arm.com/software-enablement/141-caches-and-self-modifying-code/ |
| 30 #if defined(__linux__) && !defined(ANDROID) | 29 #if defined(__linux__) || defined(ANDROID) |
| 31 extern void __clear_cache(char*, char*); | 30 extern void __clear_cache(char*, char*); |
| 32 char* beg = reinterpret_cast<char*>(start); | 31 char* beg = reinterpret_cast<char*>(start); |
| 33 char* end = reinterpret_cast<char*>(start + size); | 32 char* end = reinterpret_cast<char*>(start + size); |
| 34 ::__clear_cache(beg, end); | 33 ::__clear_cache(beg, end); |
| 35 #elif defined(ANDROID) | |
| 36 // TODO(zra): Verify that this is correct for arm64 in addition to arm. | |
| 37 cacheflush(start, start + size, 0); | |
| 38 #else | 34 #else |
| 39 #error FlushICache only tested/supported on Linux and Android | 35 #error FlushICache only tested/supported on Linux and Android |
| 40 #endif | 36 #endif |
| 41 | 37 |
| 42 #endif | 38 #endif |
| 43 } | 39 } |
| 44 | 40 |
| 45 | 41 |
| 46 const char* CPU::Id() { | 42 const char* CPU::Id() { |
| 47 return | 43 return |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 ASSERT(hardware_ != NULL); | 94 ASSERT(hardware_ != NULL); |
| 99 free(const_cast<char*>(hardware_)); | 95 free(const_cast<char*>(hardware_)); |
| 100 hardware_ = NULL; | 96 hardware_ = NULL; |
| 101 CpuInfo::Cleanup(); | 97 CpuInfo::Cleanup(); |
| 102 } | 98 } |
| 103 #endif // defined(HOST_ARCH_ARM64) | 99 #endif // defined(HOST_ARCH_ARM64) |
| 104 | 100 |
| 105 } // namespace dart | 101 } // namespace dart |
| 106 | 102 |
| 107 #endif // defined TARGET_ARCH_ARM64 | 103 #endif // defined TARGET_ARCH_ARM64 |
| OLD | NEW |