| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/cpu.h" | 5 #include "base/cpu.h" |
| 6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
| 7 | 7 |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 // Tests whether we can run extended instructions represented by the CPU | 10 // Tests whether we can run extended instructions represented by the CPU |
| 11 // information. This test actually executes some extended instructions (such as | 11 // information. This test actually executes some extended instructions (such as |
| 12 // MMX, SSE, etc.) supported by the CPU and sees we can run them without | 12 // MMX, SSE, etc.) supported by the CPU and sees we can run them without |
| 13 // "undefined instruction" exceptions. That is, this test succeeds when this | 13 // "undefined instruction" exceptions. That is, this test succeeds when this |
| 14 // test finishes without a crash. | 14 // test finishes without a crash. |
| 15 TEST(CPU, RunExtendedInstructions) { | 15 TEST(CPU, RunExtendedInstructions) { |
| 16 #if defined(ARCH_CPU_X86_FAMILY) | 16 #if defined(ARCH_CPU_X86_FAMILY) |
| 17 // Retrieve the CPU information. | 17 // Retrieve the CPU information. |
| 18 base::CPU cpu; | 18 base::CPU cpu; |
| 19 | 19 |
| 20 #if defined(OS_WIN) | 20 // TODO(jschuh): crbug.com/168866 Find a way to enable this on Win64. |
| 21 #if defined(OS_WIN) && !defined(_M_X64) |
| 21 ASSERT_TRUE(cpu.has_mmx()); | 22 ASSERT_TRUE(cpu.has_mmx()); |
| 22 | 23 |
| 23 // Execute an MMX instruction. | 24 // Execute an MMX instruction. |
| 24 __asm emms; | 25 __asm emms; |
| 25 | 26 |
| 26 if (cpu.has_sse()) { | 27 if (cpu.has_sse()) { |
| 27 // Execute an SSE instruction. | 28 // Execute an SSE instruction. |
| 28 __asm xorps xmm0, xmm0; | 29 __asm xorps xmm0, xmm0; |
| 29 } | 30 } |
| 30 | 31 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 __asm__ __volatile__("pmuldq %%xmm0, %%xmm0\n" : : : "xmm0"); | 84 __asm__ __volatile__("pmuldq %%xmm0, %%xmm0\n" : : : "xmm0"); |
| 84 } | 85 } |
| 85 | 86 |
| 86 if (cpu.has_sse42()) { | 87 if (cpu.has_sse42()) { |
| 87 // Execute an SSE 4.2 instruction. | 88 // Execute an SSE 4.2 instruction. |
| 88 __asm__ __volatile__("crc32 %%eax, %%eax\n" : : : "eax"); | 89 __asm__ __volatile__("crc32 %%eax, %%eax\n" : : : "eax"); |
| 89 } | 90 } |
| 90 #endif | 91 #endif |
| 91 #endif | 92 #endif |
| 92 } | 93 } |
| OLD | NEW |