Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: runtime/vm/cpuid.cc

Issue 182943002: - Actually allocate memory. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698