| Index: runtime/vm/cpu_x64.cc
|
| ===================================================================
|
| --- runtime/vm/cpu_x64.cc (revision 31402)
|
| +++ runtime/vm/cpu_x64.cc (working copy)
|
| @@ -8,13 +8,18 @@
|
|
|
| #include "vm/cpu.h"
|
|
|
| +#include "vm/assembler.h"
|
| #include "vm/constants_x64.h"
|
| +#include "vm/cpuinfo.h"
|
| #include "vm/heap.h"
|
| #include "vm/isolate.h"
|
| #include "vm/object.h"
|
|
|
| namespace dart {
|
|
|
| +DEFINE_FLAG(bool, use_sse41, true, "Use SSE 4.1 if available");
|
| +
|
| +
|
| void CPU::FlushICache(uword start, uword size) {
|
| // Nothing to be done here.
|
| }
|
| @@ -24,6 +29,62 @@
|
| return "x64";
|
| }
|
|
|
| +
|
| +bool CPUFeatures::sse4_1_supported_ = false;
|
| +char CPUFeatures::hardware_[HARDWARE_LEN] = {0};
|
| +#ifdef DEBUG
|
| +bool CPUFeatures::initialized_ = false;
|
| +#endif
|
| +
|
| +
|
| +bool CPUFeatures::sse4_1_supported() {
|
| + DEBUG_ASSERT(initialized_);
|
| + return sse4_1_supported_ && FLAG_use_sse41;
|
| +}
|
| +
|
| +
|
| +char* CPUFeatures::hardware() {
|
| + DEBUG_ASSERT(initialized_);
|
| + return hardware_;
|
| +}
|
| +
|
| +
|
| +#define __ assembler.
|
| +void CPUFeatures::InitOnce() {
|
| + Assembler assembler;
|
| + __ pushq(RBP);
|
| + __ pushq(RBX);
|
| + __ movq(RBP, RSP);
|
| + // Get feature information in ECX:EDX and return it in RAX.
|
| + // Note that cpuid operates the same in 64-bit and 32-bit mode.
|
| + __ movq(RAX, Immediate(1));
|
| + __ cpuid();
|
| + __ movl(RAX, RCX); // Zero extended.
|
| + __ shlq(RAX, Immediate(32));
|
| + __ movl(RCX, RDX); // Zero extended.
|
| + __ orq(RAX, RCX);
|
| + __ movq(RSP, RBP);
|
| + __ popq(RBX);
|
| + __ popq(RBP);
|
| + __ ret();
|
| +
|
| + const Code& code =
|
| + Code::Handle(Code::FinalizeCode("DetectCPUFeatures", &assembler));
|
| + Instructions& instructions = Instructions::Handle(code.instructions());
|
| + typedef uint64_t (*DetectCPUFeatures)();
|
| + uint64_t features =
|
| + reinterpret_cast<DetectCPUFeatures>(instructions.EntryPoint())();
|
| + sse4_1_supported_ = (features & kSSE4_1BitMask) != 0;
|
| +
|
| + CpuInfo::Read();
|
| + CpuInfo::GetCpuModel(hardware_, HARDWARE_LEN);
|
| +
|
| +#ifdef DEBUG
|
| + initialized_ = true;
|
| +#endif
|
| +}
|
| +#undef __
|
| +
|
| } // namespace dart
|
|
|
| #endif // defined TARGET_ARCH_X64
|
|
|