dart-sdk/runtime/vm/cpuinfo.h
zra@google.com 436a06a381 Fixes to run "Hello, world!" on arm64 hardware.
Primarily, in Dart code, instead of using R31 as our
stack pointer, on entry we copy it into a second
register (R18) and use that as our stack pointer after
moving R31 to the Dart stack limit. On calling back
into C++ from Dart code, R31 is restored, and R18 is
cached in the callee-saved register R26.

R=regis@google.com

Review URL: https://codereview.chromium.org//311903004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36930 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-03 18:38:28 +00:00

79 lines
2 KiB
C++

// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef VM_CPUINFO_H_
#define VM_CPUINFO_H_
#include "platform/assert.h"
#include "vm/allocation.h"
namespace dart {
// Indices into cpuinfo field name arrays.
enum CpuInfoIndices {
kCpuInfoProcessor = 0,
kCpuInfoModel = 1,
kCpuInfoHardware = 2,
kCpuInfoFeatures = 3,
kCpuInfoMax = 4,
};
// For Intel architectures, the method to use to get CPU information.
enum CpuInfoMethod {
// Use the cpuid instruction.
kCpuInfoCpuId,
// Use system calls.
kCpuInfoSystem,
// Use whatever the default is for a particular OS:
// Linux, Windows -> CpuId,
// Android, MacOS -> System.
kCpuInfoDefault,
};
class CpuInfo : public AllStatic {
public:
static void InitOnce();
static void Cleanup();
static const char* FieldName(CpuInfoIndices idx) {
ASSERT((idx >= 0) && (idx < kCpuInfoMax));
return fields_[idx];
}
// Returns true if the cpuinfo field contains the string.
static bool FieldContains(CpuInfoIndices idx, const char* search_string);
static bool FieldContainsByString(
const char* field, const char* search_string);
// Returns true if the cpuinfo field [field] exists and is non-empty.
static bool HasField(const char* field);
// Returns the field. Caller is responsible for freeing the result.
static const char* ExtractField(CpuInfoIndices idx);
static const char* ExtractFieldByString(const char* field);
// Returns the field describing the CPU model. Caller is responsible for
// freeing the result.
static const char* GetCpuModel() {
if (HasField(FieldName(kCpuInfoHardware))) {
return ExtractField(kCpuInfoHardware);
} else {
return "";
}
}
private:
// The method to use to acquire info about the CPU.
static CpuInfoMethod method_;
// Cpuinfo field names.
static const char* fields_[kCpuInfoMax];
};
} // namespace dart
#endif // VM_CPUINFO_H_