зеркало из https://github.com/mozilla/gecko-dev.git
bug 1415336 - use system-info to detect latest CPU instruction set for the update url on all platforms. r=mhowell
Fixes Linux CPU instruction set detection added in bug 1277359 Adds OS X CPU instruction set detection Changes Windows CPU instruction added in bug 1271761 to use system-info
This commit is contained in:
Родитель
ad412b48b1
Коммит
4ba2eb0286
|
@ -176,47 +176,16 @@ function getMemoryMB() {
|
|||
* Gets the supported CPU instruction set.
|
||||
*/
|
||||
XPCOMUtils.defineLazyGetter(this, "gInstructionSet", function aus_gIS() {
|
||||
if (AppConstants.platform == "win") {
|
||||
const PF_MMX_INSTRUCTIONS_AVAILABLE = 3; // MMX
|
||||
const PF_XMMI_INSTRUCTIONS_AVAILABLE = 6; // SSE
|
||||
const PF_XMMI64_INSTRUCTIONS_AVAILABLE = 10; // SSE2
|
||||
const PF_SSE3_INSTRUCTIONS_AVAILABLE = 13; // SSE3
|
||||
|
||||
let lib = ctypes.open("kernel32.dll");
|
||||
let IsProcessorFeaturePresent = lib.declare("IsProcessorFeaturePresent",
|
||||
ctypes.winapi_abi,
|
||||
ctypes.int32_t, /* success */
|
||||
ctypes.uint32_t); /* DWORD */
|
||||
let instructionSet = "unknown";
|
||||
try {
|
||||
if (IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE)) {
|
||||
instructionSet = "SSE3";
|
||||
} else if (IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE)) {
|
||||
instructionSet = "SSE2";
|
||||
} else if (IsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE)) {
|
||||
instructionSet = "SSE";
|
||||
} else if (IsProcessorFeaturePresent(PF_MMX_INSTRUCTIONS_AVAILABLE)) {
|
||||
instructionSet = "MMX";
|
||||
const CPU_EXTENSIONS = ["hasSSE4_2", "hasSSE4_1", "hasSSE4A", "hasSSSE3",
|
||||
"hasSSE3", "hasSSE2", "hasSSE", "hasMMX",
|
||||
"hasNEON", "hasARMv7", "hasARMv6"];
|
||||
for (let ext of CPU_EXTENSIONS) {
|
||||
if (Services.sysinfo.getProperty(ext)) {
|
||||
return ext.substring(3);
|
||||
}
|
||||
} catch (e) {
|
||||
instructionSet = "error";
|
||||
Cu.reportError("Error getting processor instruction set. " +
|
||||
"Exception: " + e);
|
||||
}
|
||||
|
||||
lib.close();
|
||||
return instructionSet;
|
||||
}
|
||||
|
||||
if (AppConstants == "linux") {
|
||||
let instructionSet = "unknown";
|
||||
if (navigator.cpuHasSSE2) {
|
||||
instructionSet = "SSE2";
|
||||
}
|
||||
return instructionSet;
|
||||
}
|
||||
|
||||
return "NA";
|
||||
return "unknown";
|
||||
});
|
||||
|
||||
/* Windows only getter that returns the processor architecture. */
|
||||
|
|
|
@ -136,38 +136,16 @@ function getProcArchitecture() {
|
|||
|
||||
// Gets the supported CPU instruction set.
|
||||
function getInstructionSet() {
|
||||
if (AppConstants.platform == "win") {
|
||||
const PF_MMX_INSTRUCTIONS_AVAILABLE = 3; // MMX
|
||||
const PF_XMMI_INSTRUCTIONS_AVAILABLE = 6; // SSE
|
||||
const PF_XMMI64_INSTRUCTIONS_AVAILABLE = 10; // SSE2
|
||||
const PF_SSE3_INSTRUCTIONS_AVAILABLE = 13; // SSE3
|
||||
|
||||
let lib = ctypes.open("kernel32.dll");
|
||||
let IsProcessorFeaturePresent = lib.declare("IsProcessorFeaturePresent",
|
||||
ctypes.winapi_abi,
|
||||
ctypes.int32_t, /* success */
|
||||
ctypes.uint32_t); /* DWORD */
|
||||
let instructionSet = "unknown";
|
||||
try {
|
||||
if (IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE)) {
|
||||
instructionSet = "SSE3";
|
||||
} else if (IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE)) {
|
||||
instructionSet = "SSE2";
|
||||
} else if (IsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE)) {
|
||||
instructionSet = "SSE";
|
||||
} else if (IsProcessorFeaturePresent(PF_MMX_INSTRUCTIONS_AVAILABLE)) {
|
||||
instructionSet = "MMX";
|
||||
const CPU_EXTENSIONS = ["hasSSE4_2", "hasSSE4_1", "hasSSE4A", "hasSSSE3",
|
||||
"hasSSE3", "hasSSE2", "hasSSE", "hasMMX",
|
||||
"hasNEON", "hasARMv7", "hasARMv6"];
|
||||
for (let ext of CPU_EXTENSIONS) {
|
||||
if (Services.sysinfo.getProperty(ext)) {
|
||||
return ext.substring(3);
|
||||
}
|
||||
} catch (e) {
|
||||
Cu.reportError("Error getting processor instruction set. " +
|
||||
"Exception: " + e);
|
||||
}
|
||||
|
||||
lib.close();
|
||||
return instructionSet;
|
||||
}
|
||||
|
||||
return "NA";
|
||||
return "error";
|
||||
}
|
||||
|
||||
// Gets the RAM size in megabytes. This will round the value because sysinfo
|
||||
|
|
Загрузка…
Ссылка в новой задаче