From 93fbdcd443ad74a92a1c86dfb3015a254bc6dfeb Mon Sep 17 00:00:00 2001 From: dev Date: Tue, 15 Dec 2015 17:19:37 +0000 Subject: [PATCH] Made CPUIDCPUInfo non-abstract to support looking for CPU features during CPU identification. --- .../support/CPUInformation/CPUIDCPUInfo.java | 19 ++++++++++--------- .../support/CPUInformation/IntelInfoImpl.java | 10 ++-------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/core/java/src/freenet/support/CPUInformation/CPUIDCPUInfo.java b/core/java/src/freenet/support/CPUInformation/CPUIDCPUInfo.java index cc835d8f0..a6d2d845a 100644 --- a/core/java/src/freenet/support/CPUInformation/CPUIDCPUInfo.java +++ b/core/java/src/freenet/support/CPUInformation/CPUIDCPUInfo.java @@ -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"); + } +} \ No newline at end of file diff --git a/core/java/src/freenet/support/CPUInformation/IntelInfoImpl.java b/core/java/src/freenet/support/CPUInformation/IntelInfoImpl.java index 57f33b26e..a6fc03523 100644 --- a/core/java/src/freenet/support/CPUInformation/IntelInfoImpl.java +++ b/core/java/src/freenet/support/CPUInformation/IntelInfoImpl.java @@ -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;