Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
cpu_x64.cc
Go to the documentation of this file.
1// Copyright (c) 2012, 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_X64)
7
8#include "vm/cpu.h"
9#include "vm/cpu_x64.h"
10
11#include "vm/cpuinfo.h"
12
13namespace dart {
14
15DEFINE_FLAG(bool, use_sse41, true, "Use SSE 4.1 if available");
16
18 // Nothing to be done here.
19}
20
21const char* CPU::Id() {
22 return
23#if defined(USING_SIMULATOR)
24 "sim"
25#endif // !defined(USING_SIMULATOR)
26 "x64";
27}
28
29const char* HostCPUFeatures::hardware_ = nullptr;
30bool HostCPUFeatures::sse2_supported_ = true;
31bool HostCPUFeatures::sse4_1_supported_ = false;
32bool HostCPUFeatures::popcnt_supported_ = false;
33bool HostCPUFeatures::abm_supported_ = false;
34
35#if defined(DEBUG)
36bool HostCPUFeatures::initialized_ = false;
37#endif
38
39#if !defined(USING_SIMULATOR)
42 hardware_ = CpuInfo::GetCpuModel();
43 sse4_1_supported_ = CpuInfo::FieldContains(kCpuInfoFeatures, "sse4_1") ||
45 popcnt_supported_ = CpuInfo::FieldContains(kCpuInfoFeatures, "popcnt");
46 abm_supported_ = CpuInfo::FieldContains(kCpuInfoFeatures, "abm");
47#if defined(DEBUG)
48 initialized_ = true;
49#endif
50}
51
53 DEBUG_ASSERT(initialized_);
54#if defined(DEBUG)
55 initialized_ = false;
56#endif
57 ASSERT(hardware_ != nullptr);
58 free(const_cast<char*>(hardware_));
59 hardware_ = nullptr;
61}
62
63#else // !defined(USING_SIMULATOR)
64
67 hardware_ = CpuInfo::GetCpuModel();
68 sse4_1_supported_ = false;
69 popcnt_supported_ = false;
70 abm_supported_ = false;
71#if defined(DEBUG)
72 initialized_ = true;
73#endif
74}
75
77 DEBUG_ASSERT(initialized_);
78#if defined(DEBUG)
79 initialized_ = false;
80#endif
81 ASSERT(hardware_ != nullptr);
82 free(const_cast<char*>(hardware_));
83 hardware_ = nullptr;
85}
86#endif // !defined(USING_SIMULATOR)
87
88} // namespace dart
89
90#endif // defined TARGET_ARCH_X64
#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 bool FieldContains(CpuInfoIndices idx, const char *search_string)
static void Init()
static void Cleanup()
#define ASSERT(E)
#define DEFINE_FLAG(type, name, default_value, comment)
Definition flags.h:16
@ kCpuInfoFeatures
Definition cpuinfo.h:19
uintptr_t uword
Definition globals.h:501