mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-16 22:04:36 +00:00
Bug 779687 - Add detection for ARMv7 CPUs. r=dougt
This commit is contained in:
parent
ceb13c3600
commit
1099676e48
@ -369,20 +369,20 @@ TelemetryPing.prototype = {
|
||||
let fields = ["cpucount", "memsize", "arch", "version", "device", "manufacturer", "hardware",
|
||||
"hasMMX", "hasSSE", "hasSSE2", "hasSSE3",
|
||||
"hasSSSE3", "hasSSE4A", "hasSSE4_1", "hasSSE4_2",
|
||||
"hasEDSP", "hasARMv6", "hasNEON"];
|
||||
"hasEDSP", "hasARMv6", "hasARMv7", "hasNEON"];
|
||||
for each (let field in fields) {
|
||||
let value;
|
||||
try {
|
||||
value = sysInfo.getProperty(field);
|
||||
} catch (e) {
|
||||
continue
|
||||
continue;
|
||||
}
|
||||
if (field == "memsize") {
|
||||
// Send RAM size in megabytes. Rounding because sysinfo doesn't
|
||||
// always provide RAM in multiples of 1024.
|
||||
value = Math.round(value / 1024 / 1024)
|
||||
value = Math.round(value / 1024 / 1024);
|
||||
}
|
||||
ret[field] = value
|
||||
ret[field] = value;
|
||||
}
|
||||
|
||||
// gfxInfo fields are not always available, get what we can.
|
||||
|
@ -57,6 +57,7 @@ static const struct PropItems {
|
||||
// ARM-specific bits.
|
||||
{ "hasEDSP", mozilla::supports_edsp },
|
||||
{ "hasARMv6", mozilla::supports_armv6 },
|
||||
{ "hasARMv7", mozilla::supports_armv7 },
|
||||
{ "hasNEON", mozilla::supports_neon }
|
||||
};
|
||||
|
||||
|
@ -60,6 +60,29 @@ check_armv6(void)
|
||||
}
|
||||
# endif // !MOZILLA_PRESUME_ARMV6
|
||||
|
||||
# if !defined(MOZILLA_PRESUME_ARMV7)
|
||||
static bool
|
||||
check_armv7(void)
|
||||
{
|
||||
# if defined(MOZILLA_MAY_SUPPORT_ARMV7)
|
||||
__try
|
||||
{
|
||||
// ARMv7 DMB (Data Memory Barrier) for stores (DMB.ST)
|
||||
// The Data Memory Barrier existed before ARMv7 as a
|
||||
// cp15 operation, but ARMv7 introduced a dedicated
|
||||
// instruction, DMB.
|
||||
emit(0xF57FF05E);
|
||||
return true;
|
||||
}
|
||||
__except(GetExceptionCode()==EXCEPTION_ILLEGAL_INSTRUCTION)
|
||||
{
|
||||
//Ignore exception.
|
||||
}
|
||||
# endif
|
||||
return false;
|
||||
}
|
||||
# endif // !MOZILLA_PRESUME_ARMV7
|
||||
|
||||
# if !defined(MOZILLA_PRESUME_NEON)
|
||||
static bool
|
||||
check_neon(void)
|
||||
@ -88,7 +111,8 @@ check_neon(void)
|
||||
enum{
|
||||
MOZILLA_HAS_EDSP_FLAG=1,
|
||||
MOZILLA_HAS_ARMV6_FLAG=2,
|
||||
MOZILLA_HAS_NEON_FLAG=4
|
||||
MOZILLA_HAS_ARMV7_FLAG=4,
|
||||
MOZILLA_HAS_NEON_FLAG=8
|
||||
};
|
||||
|
||||
static unsigned
|
||||
@ -96,6 +120,7 @@ get_arm_cpu_flags(void)
|
||||
{
|
||||
unsigned flags;
|
||||
FILE *fin;
|
||||
bool armv6_processor = false;
|
||||
flags = 0;
|
||||
/*Reading /proc/self/auxv would be easier, but that doesn't work reliably on
|
||||
Android. This also means that detection will fail in Scratchbox, which is
|
||||
@ -126,10 +151,32 @@ get_arm_cpu_flags(void)
|
||||
version = atoi(buf + 17);
|
||||
if (version >= 6)
|
||||
flags |= MOZILLA_HAS_ARMV6_FLAG;
|
||||
if (version >= 7)
|
||||
flags |= MOZILLA_HAS_ARMV7_FLAG;
|
||||
}
|
||||
/* media/webrtc/trunk/src/system_wrappers/source/cpu_features_arm.c
|
||||
* Unfortunately, it seems that certain ARMv6-based CPUs
|
||||
* report an incorrect architecture number of 7!
|
||||
*
|
||||
* We try to correct this by looking at the 'elf_format'
|
||||
* field reported by the 'Processor' field, which is of the
|
||||
* form of "(v7l)" for an ARMv7-based CPU, and "(v6l)" for
|
||||
* an ARMv6-one.
|
||||
*/
|
||||
if (memcmp(buf, "Processor\t:", 11) == 0) {
|
||||
if (strstr(buf, "(v6l)") != 0) {
|
||||
armv6_processor = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(fin);
|
||||
}
|
||||
if (armv6_processor) {
|
||||
// ARMv6 pretending to be ARMv7? clear flag
|
||||
if (flags & MOZILLA_HAS_ARMV7_FLAG) {
|
||||
flags &= ~MOZILLA_HAS_ARMV7_FLAG;
|
||||
}
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
@ -152,6 +199,14 @@ check_armv6(void)
|
||||
}
|
||||
# endif
|
||||
|
||||
# if !defined(MOZILLA_PRESUME_ARMV7)
|
||||
static bool
|
||||
check_armv7(void)
|
||||
{
|
||||
return (arm_cpu_flags & MOZILLA_HAS_ARMV7_FLAG) != 0;
|
||||
}
|
||||
# endif
|
||||
|
||||
# if !defined(MOZILLA_PRESUME_NEON)
|
||||
static bool
|
||||
check_neon(void)
|
||||
@ -172,6 +227,9 @@ namespace mozilla {
|
||||
# if !defined(MOZILLA_PRESUME_ARMV6)
|
||||
bool armv6_enabled = check_armv6();
|
||||
# endif
|
||||
# if !defined(MOZILLA_PRESUME_ARMV7)
|
||||
bool armv7_enabled = check_armv7();
|
||||
# endif
|
||||
# if !defined(MOZILLA_PRESUME_NEON)
|
||||
bool neon_enabled = check_neon();
|
||||
# endif
|
||||
|
@ -71,6 +71,13 @@
|
||||
# if defined(HAVE_ARM_NEON)
|
||||
# define MOZILLA_MAY_SUPPORT_NEON 1
|
||||
# endif
|
||||
# endif
|
||||
|
||||
// ARMv7 support was merged in gcc 4.3.
|
||||
# if __GNUC__> 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
|
||||
# if defined(HAVE_ARM_SIMD)
|
||||
# define MOZILLA_MAY_SUPPORT_ARMV7 1
|
||||
# endif
|
||||
# endif
|
||||
|
||||
// When using -mfpu=neon, gcc generates neon instructions.
|
||||
@ -95,6 +102,7 @@
|
||||
# define MOZILLA_MAY_SUPPORT_EDSP 1
|
||||
# if defined(HAVE_ARM_SIMD)
|
||||
# define MOZILLA_MAY_SUPPORT_ARMV6 1
|
||||
# define MOZILLA_MAY_SUPPORT_ARMV7 1
|
||||
# endif
|
||||
# if defined(HAVE_ARM_NEON)
|
||||
# define MOZILLA_MAY_SUPPORT_NEON 1
|
||||
@ -112,6 +120,9 @@ namespace mozilla {
|
||||
#if !defined(MOZILLA_PRESUME_ARMV6)
|
||||
extern bool NS_COM_GLUE armv6_enabled;
|
||||
#endif
|
||||
#if !defined(MOZILLA_PRESUME_ARMV7)
|
||||
extern bool NS_COM_GLUE armv7_enabled;
|
||||
#endif
|
||||
#if !defined(MOZILLA_PRESUME_NEON)
|
||||
extern bool NS_COM_GLUE neon_enabled;
|
||||
#endif
|
||||
@ -138,6 +149,16 @@ namespace mozilla {
|
||||
inline bool supports_armv6() { return false; }
|
||||
#endif
|
||||
|
||||
#if defined(MOZILLA_PRESUME_ARMV7)
|
||||
# define MOZILLA_MAY_SUPPORT_ARMV7 1
|
||||
inline bool supports_armv7() { return true; }
|
||||
#elif defined(MOZILLA_MAY_SUPPORT_ARMV7) \
|
||||
&& defined(MOZILLA_ARM_HAVE_CPUID_DETECTION)
|
||||
inline bool supports_armv7() { return arm_private::armv7_enabled; }
|
||||
#else
|
||||
inline bool supports_armv7() { return false; }
|
||||
#endif
|
||||
|
||||
#if defined(MOZILLA_PRESUME_NEON)
|
||||
# define MOZILLA_MAY_SUPPORT_NEON 1
|
||||
inline bool supports_neon() { return true; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user