Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if !defined(TARGET_OS_MACOS) | 6 #if !defined(TARGET_OS_MACOS) |
| 7 #include "vm/cpuid.h" | 7 #include "vm/cpuid.h" |
| 8 | 8 |
| 9 #if defined(HOST_ARCH_IA32) || defined(HOST_ARCH_X64) | 9 #if defined(HOST_ARCH_IA32) || defined(HOST_ARCH_X64) |
| 10 // GetCpuId() on Windows, __get_cpuid() on Linux | 10 // GetCpuId() on Windows, __get_cpuid() on Linux |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 // Yes, these are supposed to be out of order. | 43 // Yes, these are supposed to be out of order. |
| 44 *reinterpret_cast<uint32_t*>(id_string) = info[1]; | 44 *reinterpret_cast<uint32_t*>(id_string) = info[1]; |
| 45 *reinterpret_cast<uint32_t*>(id_string + 4) = info[3]; | 45 *reinterpret_cast<uint32_t*>(id_string + 4) = info[3]; |
| 46 *reinterpret_cast<uint32_t*>(id_string + 8) = info[2]; | 46 *reinterpret_cast<uint32_t*>(id_string + 8) = info[2]; |
| 47 CpuId::id_string_ = id_string; | 47 CpuId::id_string_ = id_string; |
| 48 | 48 |
| 49 GetCpuId(1, info); | 49 GetCpuId(1, info); |
| 50 CpuId::sse41_ = (info[2] & (1 << 19)) != 0; | 50 CpuId::sse41_ = (info[2] & (1 << 19)) != 0; |
| 51 CpuId::sse2_ = (info[3] & (1 << 26)) != 0; | 51 CpuId::sse2_ = (info[3] & (1 << 26)) != 0; |
| 52 | 52 |
| 53 char* brand_string = reinterpret_cast<char*>(3 * 4 * sizeof(uint32_t)); | 53 char* brand_string = |
| 54 reinterpret_cast<char*>(malloc(3 * 4 * sizeof(uint32_t))); | |
|
Florian Schneider
2014/02/27 10:03:22
If you use new char[] and delete[] instead of mall
Ivan Posva
2014/02/27 10:13:41
Thank you for your insight. But the whole point of
Florian Schneider
2014/02/27 10:21:29
Why use strdup then? I thought the point of return
| |
| 54 for (uint32_t i = 0x80000002; i <= 0x80000004; i++) { | 55 for (uint32_t i = 0x80000002; i <= 0x80000004; i++) { |
| 55 uint32_t off = (i - 0x80000002U) * 4 * sizeof(uint32_t); | 56 uint32_t off = (i - 0x80000002U) * 4 * sizeof(uint32_t); |
| 56 GetCpuId(i, info); | 57 GetCpuId(i, info); |
| 57 *reinterpret_cast<int32_t*>(brand_string + off) = info[0]; | 58 *reinterpret_cast<int32_t*>(brand_string + off) = info[0]; |
| 58 *reinterpret_cast<int32_t*>(brand_string + off + 4) = info[1]; | 59 *reinterpret_cast<int32_t*>(brand_string + off + 4) = info[1]; |
| 59 *reinterpret_cast<int32_t*>(brand_string + off + 8) = info[2]; | 60 *reinterpret_cast<int32_t*>(brand_string + off + 8) = info[2]; |
| 60 *reinterpret_cast<int32_t*>(brand_string + off + 12) = info[3]; | 61 *reinterpret_cast<int32_t*>(brand_string + off + 12) = info[3]; |
| 61 } | 62 } |
| 62 CpuId::brand_string_ = brand_string; | 63 CpuId::brand_string_ = brand_string; |
| 63 } | 64 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 UNREACHABLE(); | 108 UNREACHABLE(); |
| 108 return NULL; | 109 return NULL; |
| 109 } | 110 } |
| 110 } | 111 } |
| 111 } | 112 } |
| 112 | 113 |
| 113 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) | 114 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
| 114 } // namespace dart | 115 } // namespace dart |
| 115 | 116 |
| 116 #endif // !defined(TARGET_OS_MACOS) | 117 #endif // !defined(TARGET_OS_MACOS) |
| OLD | NEW |