Made CPUIDCPUInfo non-abstract to support looking for CPU features during CPU identification.

This commit is contained in:
dev
2015-12-15 17:19:37 +00:00
parent 0e6e90baf0
commit 93fbdcd443
2 changed files with 12 additions and 17 deletions

View File

@@ -5,7 +5,7 @@ package freenet.support.CPUInformation;
* Ref: http://en.wikipedia.org/wiki/CPUID
* @since 0.8.7
*/
abstract class CPUIDCPUInfo implements CPUInfo
public class CPUIDCPUInfo implements CPUInfo
{
public String getVendor()
{
@@ -124,8 +124,7 @@ abstract class CPUIDCPUInfo implements CPUInfo
* @since 0.9.24
*/
public boolean hasBMI1() {
return this.hasABM() &&
(CPUID.getExtendedEBXFeatureFlags() & (1 << 3)) != 0; // Extended EBX Feature Bit 3
return (CPUID.getExtendedEBXFeatureFlags() & (1 << 3)) != 0; // Extended EBX Feature Bit 3
}
/**
@@ -133,8 +132,7 @@ abstract class CPUIDCPUInfo implements CPUInfo
* @since 0.9.24
*/
public boolean hasBMI2() {
return this.hasABM() &&
(CPUID.getExtendedEBXFeatureFlags() & (1 << 8)) != 0; // Extended EBX Feature Bit 8
return (CPUID.getExtendedEBXFeatureFlags() & (1 << 8)) != 0; // Extended EBX Feature Bit 8
}
/**
@@ -158,8 +156,11 @@ abstract class CPUIDCPUInfo implements CPUInfo
* @since 0.9.24
*/
public boolean hasABM() {
return this.hasFMA3() &&
this.hasMOVBE() &&
(CPUID.getExtendedECXCPUFlags() & (1 << 5)) != 0; // Extended EBX Bit 5
return (CPUID.getExtendedECXCPUFlags() & (1 << 5)) != 0; // Extended EBX Bit 5
}
}
@Override
public String getCPUModelString() throws UnknownCPUException {
throw new UnknownCPUException("Class CPUIDCPUInfo cannot indentify CPUs");
}
}

View File

@@ -37,13 +37,7 @@ class IntelInfoImpl extends CPUIDCPUInfo implements IntelCPUInfo
public boolean IsCoreiCompatible(){ return isCoreiCompatible; }
public boolean IsSandyCompatible(){ return isSandyCompatible; }
public boolean IsIvyCompatible(){ return isIvyCompatible; }
public boolean IsHaswellCompatible(){
// Some Celeron Haswell CPUs do not support BMI2, which
// GMP-6.0 assumes is present in all Haswell CPUs and causes
// crashes. Mark these CPUs as non-Haswell.
return this.hasBMI2() && isHaswellCompatible;
}
public boolean IsHaswellCompatible(){ return isHaswellCompatible; }
public boolean IsBroadwellCompatible(){ return isBroadwellCompatible; }
public String getCPUModelString() throws UnknownCPUException
@@ -382,7 +376,7 @@ class IntelInfoImpl extends CPUIDCPUInfo implements IntelCPUInfo
case 0x3f:
case 0x45:
case 0x46:
CPUInfo c = CPUID.getInfo();
CPUIDCPUInfo c = new CPUIDCPUInfo();
if (c.hasAVX2() && c.hasBMI1() && c.hasBMI2()) {
isSandyCompatible = true;
isIvyCompatible = true;