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/constants.h"
12#include "vm/cpuinfo.h"
13#include "vm/heap/heap.h"
14#include "vm/isolate.h"
15#include "vm/object.h"
16
17namespace dart {
18
19DEFINE_FLAG(bool, use_sse41, true, "Use SSE 4.1 if available");
20
21void CPU::FlushICache(uword start, uword size) {
22 // Nothing to be done here.
23}
24
25const char* CPU::Id() {
26 return "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
39void HostCPUFeatures::Init() {
40 CpuInfo::Init();
41 hardware_ = CpuInfo::GetCpuModel();
42 sse4_1_supported_ = CpuInfo::FieldContains(kCpuInfoFeatures, "sse4_1") ||
43 CpuInfo::FieldContains(kCpuInfoFeatures, "sse4.1");
44 popcnt_supported_ = CpuInfo::FieldContains(kCpuInfoFeatures, "popcnt");
45 abm_supported_ = CpuInfo::FieldContains(kCpuInfoFeatures, "abm");
46#if defined(DEBUG)
47 initialized_ = true;
48#endif
49}
50
51void HostCPUFeatures::Cleanup() {
52 DEBUG_ASSERT(initialized_);
53#if defined(DEBUG)
54 initialized_ = false;
55#endif
56 ASSERT(hardware_ != NULL);
57 free(const_cast<char*>(hardware_));
58 hardware_ = NULL;
59 CpuInfo::Cleanup();
60}
61
62} // namespace dart
63
64#endif // defined TARGET_ARCH_X64
65