| 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 #if !defined(HOST_OS_FUCHSIA) | 15 #if !defined(HOST_OS_FUCHSIA) |
| 16 #include <sys/syscall.h> /* NOLINT */ | 16 #include <sys/syscall.h> |
| 17 #else |
| 18 #include <magenta/syscalls.h> |
| 17 #endif | 19 #endif |
| 18 #include <unistd.h> /* NOLINT */ | 20 #include <unistd.h> |
| 19 #endif | 21 #endif |
| 20 | 22 |
| 21 namespace dart { | 23 namespace dart { |
| 22 | 24 |
| 23 void CPU::FlushICache(uword start, uword size) { | 25 void CPU::FlushICache(uword start, uword size) { |
| 24 #if HOST_OS_IOS | 26 #if HOST_OS_IOS |
| 25 // Precompilation never patches code so there should be no I cache flushes. | 27 // Precompilation never patches code so there should be no I cache flushes. |
| 26 UNREACHABLE(); | 28 UNREACHABLE(); |
| 27 #endif | 29 #endif |
| 28 | 30 |
| 29 #if !defined(USING_SIMULATOR) && !HOST_OS_IOS | 31 #if !defined(USING_SIMULATOR) && !HOST_OS_IOS |
| 30 // Nothing to do. Flushing no instructions. | 32 // Nothing to do. Flushing no instructions. |
| 31 if (size == 0) { | 33 if (size == 0) { |
| 32 return; | 34 return; |
| 33 } | 35 } |
| 34 | 36 |
| 35 // ARM recommends using the gcc intrinsic __clear_cache on Linux and Android. | 37 // ARM recommends using the gcc intrinsic __clear_cache on Linux and Android. |
| 36 // blogs.arm.com/software-enablement/141-caches-and-self-modifying-code/ | 38 // blogs.arm.com/software-enablement/141-caches-and-self-modifying-code/ |
| 37 #if defined(HOST_OS_ANDROID) || defined(HOST_OS_FUCHSIA) || \ | 39 #if defined(HOST_OS_ANDROID) || defined(HOST_OS_LINUX) |
| 38 defined(HOST_OS_LINUX) | |
| 39 extern void __clear_cache(char*, char*); | 40 extern void __clear_cache(char*, char*); |
| 40 char* beg = reinterpret_cast<char*>(start); | 41 char* beg = reinterpret_cast<char*>(start); |
| 41 char* end = reinterpret_cast<char*>(start + size); | 42 char* end = reinterpret_cast<char*>(start + size); |
| 42 ::__clear_cache(beg, end); | 43 ::__clear_cache(beg, end); |
| 44 #elif defined(HOST_OS_FUCHSIA) |
| 45 mx_status_t result = mx_cache_flush(reinterpret_cast<const void*>(start), |
| 46 size, MX_CACHE_FLUSH_INSN); |
| 47 ASSERT(result == MX_OK); |
| 43 #else | 48 #else |
| 44 #error FlushICache only tested/supported on Android, Fuchsia, and Linux | 49 #error FlushICache only tested/supported on Android, Fuchsia, and Linux |
| 45 #endif | 50 #endif |
| 46 | 51 |
| 47 #endif | 52 #endif |
| 48 } | 53 } |
| 49 | 54 |
| 50 const char* CPU::Id() { | 55 const char* CPU::Id() { |
| 51 return | 56 return |
| 52 #if defined(USING_SIMULATOR) | 57 #if defined(USING_SIMULATOR) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 ASSERT(hardware_ != NULL); | 103 ASSERT(hardware_ != NULL); |
| 99 free(const_cast<char*>(hardware_)); | 104 free(const_cast<char*>(hardware_)); |
| 100 hardware_ = NULL; | 105 hardware_ = NULL; |
| 101 CpuInfo::Cleanup(); | 106 CpuInfo::Cleanup(); |
| 102 } | 107 } |
| 103 #endif // !defined(USING_SIMULATOR) | 108 #endif // !defined(USING_SIMULATOR) |
| 104 | 109 |
| 105 } // namespace dart | 110 } // namespace dart |
| 106 | 111 |
| 107 #endif // defined TARGET_ARCH_ARM64 | 112 #endif // defined TARGET_ARCH_ARM64 |
| OLD | NEW |