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

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

Issue 120723003: Refactors CPU feature detection. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Cleanup Created 6 years, 11 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 6
7 #if defined(TARGET_ARCH_MIPS) 7 #if defined(TARGET_ARCH_MIPS)
8 8
9 #include "vm/cpu.h"
10 #include "vm/cpuinfo.h"
11 #include "vm/simulator.h"
12
9 #if defined(HOST_ARCH_MIPS) 13 #if defined(HOST_ARCH_MIPS)
10 #include <asm/cachectl.h> /* NOLINT */ 14 #include <asm/cachectl.h> /* NOLINT */
11 #include <sys/syscall.h> /* NOLINT */ 15 #include <sys/syscall.h> /* NOLINT */
12 #include <unistd.h> /* NOLINT */ 16 #include <unistd.h> /* NOLINT */
13 #endif 17 #endif
14 18
15 #include "vm/cpu.h"
16
17 namespace dart { 19 namespace dart {
18 20
19 void CPU::FlushICache(uword start, uword size) { 21 void CPU::FlushICache(uword start, uword size) {
20 #if defined(HOST_ARCH_MIPS) 22 #if defined(HOST_ARCH_MIPS)
21 int res; 23 int res;
22 // See http://www.linux-mips.org/wiki/Cacheflush_Syscall. 24 // See http://www.linux-mips.org/wiki/Cacheflush_Syscall.
23 res = syscall(__NR_cacheflush, start, size, ICACHE); 25 res = syscall(__NR_cacheflush, start, size, ICACHE);
24 ASSERT(res == 0); 26 ASSERT(res == 0);
25 #else // defined(HOST_ARCH_MIPS) 27 #else // defined(HOST_ARCH_MIPS)
26 // When running in simulated mode we do not need to flush the ICache because 28 // When running in simulated mode we do not need to flush the ICache because
27 // we are not running on the actual hardware. 29 // we are not running on the actual hardware.
28 #endif // defined(HOST_ARCH_MIPS) 30 #endif // defined(HOST_ARCH_MIPS)
29 } 31 }
30 32
31 33
32 const char* CPU::Id() { 34 const char* CPU::Id() {
33 return 35 return
34 #if !defined(HOST_ARCH_MIPS) 36 #if !defined(HOST_ARCH_MIPS)
35 "sim" 37 "sim"
36 #endif // !defined(HOST_ARCH_MIPS) 38 #endif // !defined(HOST_ARCH_MIPS)
37 "mips"; 39 "mips";
38 } 40 }
39 41
42
43 char CPUFeatures::hardware_[HARDWARE_LEN] = {0};
44 #if defined(DEBUG)
45 bool CPUFeatures::initialized_ = false;
46 #endif
47
48
49 char* CPUFeatures::hardware() {
50 DEBUG_ASSERT(initialized_);
51 return hardware_;
52 }
53
54
55 void CPUFeatures::InitOnce() {
56 CpuInfo::Read();
57 CpuInfo::GetCpuModel(hardware_, HARDWARE_LEN);
58 #if !defined(USING_SIMULATOR)
59 // Has a floating point unit.
60 ASSERT(CpuInfo::FieldContains("cpu model", "FPU"));
61 #endif // defined(USING_SIMULATOR)
62 #if defined(DEBUG)
63 initialized_ = true;
64 #endif
65 }
66
40 } // namespace dart 67 } // namespace dart
41 68
42 #endif // defined TARGET_ARCH_MIPS 69 #endif // defined TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698