Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
cpu_arm64.cc
Go to the documentation of this 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
3// BSD-style license that can be found in the LICENSE file.
4
5#include "vm/globals.h"
6#if defined(TARGET_ARCH_ARM64)
7
8#include "vm/cpu.h"
9#include "vm/cpu_arm64.h"
10
11#include "vm/cpuinfo.h"
12
13#if !defined(USING_SIMULATOR)
14#if defined(DART_HOST_OS_FUCHSIA)
15#include <zircon/syscalls.h>
16#elif defined(DART_HOST_OS_MACOS) || defined(DART_HOST_OS_IOS)
17#include <libkern/OSCacheControl.h>
18#elif defined(DART_HOST_OS_WINDOWS)
19#include <processthreadsapi.h>
20#endif
21#endif
22
23namespace dart {
24
26#if defined(DART_PRECOMPILED_RUNTIME)
28#elif !defined(USING_SIMULATOR)
29 // Nothing to do. Flushing no instructions.
30 if (size == 0) {
31 return;
32 }
33
34// ARM recommends using the gcc intrinsic __clear_cache on Linux and Android.
35//
36// https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/caches-and-self-modifying-code
37//
38// On iOS we use sys_icache_invalidate from Darwin. See:
39//
40// https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/sys_icache_invalidate.3.html
41#if defined(DART_HOST_OS_MACOS) || defined(DART_HOST_OS_IOS)
42 sys_icache_invalidate(reinterpret_cast<void*>(start), size);
43#elif defined(DART_HOST_OS_ANDROID) || defined(DART_HOST_OS_LINUX)
44 char* beg = reinterpret_cast<char*>(start);
45 char* end = reinterpret_cast<char*>(start + size);
46 __builtin___clear_cache(beg, end);
47#elif defined(DART_HOST_OS_FUCHSIA)
48 zx_status_t result = zx_cache_flush(reinterpret_cast<const void*>(start),
49 size, ZX_CACHE_FLUSH_INSN);
50 ASSERT(result == ZX_OK);
51#elif defined(DART_HOST_OS_WINDOWS)
52 BOOL result = FlushInstructionCache(
53 GetCurrentProcess(), reinterpret_cast<const void*>(start), size);
54 ASSERT(result != 0);
55#else
56#error FlushICache not implemented for this OS
57#endif
58
59#endif
60}
61
62const char* CPU::Id() {
63 return
64#if defined(USING_SIMULATOR)
65 "sim"
66#endif // !defined(USING_SIMULATOR)
67 "arm64";
68}
69
70const char* HostCPUFeatures::hardware_ = nullptr;
71#if defined(DEBUG)
72bool HostCPUFeatures::initialized_ = false;
73#endif
74
75#if !defined(USING_SIMULATOR)
78 hardware_ = CpuInfo::GetCpuModel();
79#if defined(DEBUG)
80 initialized_ = true;
81#endif
82}
83
85 DEBUG_ASSERT(initialized_);
86#if defined(DEBUG)
87 initialized_ = false;
88#endif
89 ASSERT(hardware_ != nullptr);
90 free(const_cast<char*>(hardware_));
91 hardware_ = nullptr;
93}
94
95#else // !defined(USING_SIMULATOR)
96
99 hardware_ = CpuInfo::GetCpuModel();
100#if defined(DEBUG)
101 initialized_ = true;
102#endif
103}
104
106 DEBUG_ASSERT(initialized_);
107#if defined(DEBUG)
108 initialized_ = false;
109#endif
110 ASSERT(hardware_ != nullptr);
111 free(const_cast<char*>(hardware_));
112 hardware_ = nullptr;
114}
115#endif // !defined(USING_SIMULATOR)
116
117} // namespace dart
118
119#endif // defined TARGET_ARCH_ARM64
#define UNREACHABLE()
Definition assert.h:248
#define DEBUG_ASSERT(cond)
Definition assert.h:321
static const char * Id()
static void FlushICache(uword start, uword size)
static void Init()
static const char * GetCpuModel()
Definition cpuinfo.h:59
static void Cleanup()
static void Init()
static void Cleanup()
#define ASSERT(E)
glong glong end
GAsyncResult * result
uintptr_t uword
Definition globals.h:501
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259
int BOOL