| 1 | // Copyright (c) 2011, 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_IA32) |
| 7 | |
| 8 | #include "vm/cpu.h" |
| 9 | #include "vm/cpu_ia32.h" |
| 10 | |
| 11 | #include "vm/compiler/assembler/assembler.h" |
| 12 | #include "vm/constants.h" |
| 13 | #include "vm/cpuinfo.h" |
| 14 | #include "vm/heap/heap.h" |
| 15 | #include "vm/isolate.h" |
| 16 | #include "vm/object.h" |
| 17 | |
| 18 | namespace dart { |
| 19 | |
| 20 | DEFINE_FLAG(bool, use_sse41, true, "Use SSE 4.1 if available" ); |
| 21 | |
| 22 | void CPU::FlushICache(uword start, uword size) { |
| 23 | // Nothing to be done here. |
| 24 | } |
| 25 | |
| 26 | const char* CPU::Id() { |
| 27 | return "ia32" ; |
| 28 | } |
| 29 | |
| 30 | const char* HostCPUFeatures::hardware_ = nullptr; |
| 31 | bool HostCPUFeatures::sse2_supported_ = false; |
| 32 | bool HostCPUFeatures::sse4_1_supported_ = false; |
| 33 | bool HostCPUFeatures::popcnt_supported_ = false; |
| 34 | bool HostCPUFeatures::abm_supported_ = false; |
| 35 | #if defined(DEBUG) |
| 36 | bool HostCPUFeatures::initialized_ = false; |
| 37 | #endif |
| 38 | |
| 39 | void HostCPUFeatures::Init() { |
| 40 | CpuInfo::Init(); |
| 41 | hardware_ = CpuInfo::GetCpuModel(); |
| 42 | sse2_supported_ = CpuInfo::FieldContains(kCpuInfoFeatures, "sse2" ); |
| 43 | sse4_1_supported_ = CpuInfo::FieldContains(kCpuInfoFeatures, "sse4_1" ) || |
| 44 | 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 | |
| 52 | void HostCPUFeatures::Cleanup() { |
| 53 | DEBUG_ASSERT(initialized_); |
| 54 | #if defined(DEBUG) |
| 55 | initialized_ = false; |
| 56 | #endif |
| 57 | ASSERT(hardware_ != NULL); |
| 58 | free(const_cast<char*>(hardware_)); |
| 59 | hardware_ = NULL; |
| 60 | CpuInfo::Cleanup(); |
| 61 | } |
| 62 | |
| 63 | } // namespace dart |
| 64 | |
| 65 | #endif // defined TARGET_ARCH_IA32 |
| 66 | |