Skip to content

Commit 1b05814

Browse files
committed
1 parent 7c9fe49 commit 1b05814

File tree

3 files changed

+50
-6
lines changed

3 files changed

+50
-6
lines changed

runtime/vm/cpu_dbc.cc

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
#if defined(TARGET_ARCH_DBC)
77

88
#include "vm/cpu.h"
9+
#include "vm/cpu_dbc.h"
910

11+
#include "vm/cpuinfo.h"
1012

1113
namespace dart {
1214

13-
1415
void CPU::FlushICache(uword start, uword size) {
1516
// Nothing to do.
1617
}
@@ -21,6 +22,31 @@ const char* CPU::Id() {
2122
}
2223

2324

25+
const char* HostCPUFeatures::hardware_ = NULL;
26+
#if defined(DEBUG)
27+
bool HostCPUFeatures::initialized_ = false;
28+
#endif
29+
30+
void HostCPUFeatures::InitOnce() {
31+
CpuInfo::InitOnce();
32+
hardware_ = CpuInfo::GetCpuModel();
33+
#if defined(DEBUG)
34+
initialized_ = true;
35+
#endif
36+
}
37+
38+
39+
void HostCPUFeatures::Cleanup() {
40+
DEBUG_ASSERT(initialized_);
41+
#if defined(DEBUG)
42+
initialized_ = false;
43+
#endif
44+
ASSERT(hardware_ != NULL);
45+
free(const_cast<char*>(hardware_));
46+
hardware_ = NULL;
47+
CpuInfo::Cleanup();
48+
}
49+
2450
} // namespace dart
2551

2652
#endif // defined TARGET_ARCH_DBC

runtime/vm/cpu_dbc.h

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,33 @@ namespace dart {
1212

1313
class HostCPUFeatures: public AllStatic {
1414
public:
15-
static const char* hardware() { return "simdbc"; }
15+
static void InitOnce();
16+
static void Cleanup();
17+
18+
static const char* hardware() {
19+
DEBUG_ASSERT(initialized_);
20+
return hardware_;
21+
}
22+
23+
private:
24+
static const char* hardware_;
25+
#if defined(DEBUG)
26+
static bool initialized_;
27+
#endif
1628
};
1729

1830
class TargetCPUFeatures : public AllStatic {
1931
public:
20-
static void InitOnce() {}
21-
static void Cleanup() {}
32+
static void InitOnce() {
33+
HostCPUFeatures::InitOnce();
34+
}
35+
static void Cleanup() {
36+
HostCPUFeatures::Cleanup();
37+
}
38+
39+
static const char* hardware() {
40+
return CPU::Id();
41+
}
2242

2343
static bool double_truncate_round_supported() {
2444
return true;

runtime/vm/cpuinfo_test.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@
99

1010
namespace dart {
1111

12-
#if !defined(TARGET_ARCH_DBC)
1312
UNIT_TEST_CASE(GetCpuModelTest) {
1413
const char* cpumodel = CpuInfo::GetCpuModel();
1514
EXPECT_NE(strlen(cpumodel), 0UL);
1615
// caller is responsible for deleting the returned cpumodel string.
1716
free(const_cast<char*>(cpumodel));
1817
}
19-
#endif
2018

2119
} // namespace dart

0 commit comments

Comments
 (0)