Changeset 1e3e02d


Ignore:
Timestamp:
Dec 16, 2015 3:02:03 PM (4 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
89e5e1d
Parents:
1f4a266
Message:

CPUID: Clear ECX register to ensure it will work with EAX=7
Tested on linux only
Add nativeJcpuidVersion()
Only call getCPUVendorID() once in getInfo()
Change all @since to 0.9.25 in hopes it will come true
Tab removal
Javadoc tweaks

Location:
core
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • core/c/jcpuid/src/jcpuid.c

    r1f4a266 r1e3e02d  
    11#include "jcpuid.h"
     2
     3/*
     4 * Versions:
     5 *
     6 * 1: Original version
     7 *
     8 * 2: (I2P 0.8.7)
     9 *    Add PIC-compatibility
     10 *
     11 * 3: (I2P 0.9.25)
     12 *    Added:
     13 *      nativeJcpuidVersion()
     14 *    Set ECX to 0 to support function 7
     15 *
     16 */
     17#define JCPUID_VERSION 3
     18
     19/* since version 3 */
     20JNIEXPORT jint JNICALL Java_net_i2p_util_NativeBigInteger_nativeJcpuidVersion
     21        (JNIEnv* env, jclass cls) {
     22    return (jint) JCPUID_VERSION;
     23}
    224
    325/**
     
    5375                {
    5476                        mov eax, iFunction
     77                        // When iFunction is 7, ECX must be 0, just set it all the time
     78                        mov ecx, 0
    5579                        cpuid
    5680                        mov a, eax
     
    77101                        : "=a" (a), "=b" (b), "=c" (c), "=d" (d)
    78102#endif
    79                         :"a"(iFunction)
     103                        /* When iFunction is 7, ECX must be 0, just set it all the time */
     104                        :"a"(iFunction), "c"(0)
    80105                        : "cc"
    81106                );
  • core/java/src/freenet/support/CPUInformation/CPUID.java

    r1f4a266 r1e3e02d  
    205205
    206206    /**
    207      *  @since 0.9.24
     207     *  @since 0.9.25
    208208     */
    209209    static int getExtendedEBXFeatureFlags()
     
    218218    /**
    219219     *  There's almost nothing in here.
    220      *  @since 0.9.24
     220     *  @since 0.9.25
    221221     */
    222222    static int getExtendedECXFeatureFlags()
     
    275275        if(!_nativeOk)
    276276            throw new UnknownCPUException("Failed to read CPU information from the system. Please verify the existence of the jcpuid dll/so.");
    277         if(getCPUVendorID().equals("CentaurHauls"))
     277        String id = getCPUVendorID();
     278        if(id.equals("CentaurHauls"))
    278279            return new VIAInfoImpl();
    279280        if(!isX86)
    280281            throw new UnknownCPUException("Failed to read CPU information from the system. The CPUID instruction exists on x86 CPU's only");
    281         if(getCPUVendorID().equals("AuthenticAMD"))
     282        if(id.equals("AuthenticAMD"))
    282283            return new AMDInfoImpl();
    283         if(getCPUVendorID().equals("GenuineIntel"))
     284        if(id.equals("GenuineIntel"))
    284285            return new IntelInfoImpl();
    285         throw new UnknownCPUException("Unknown CPU type: '"+getCPUVendorID()+"'");
     286        throw new UnknownCPUException("Unknown CPU type: '" + id + '\'');
    286287    }
    287288
  • core/java/src/freenet/support/CPUInformation/CPUIDCPUInfo.java

    r1f4a266 r1e3e02d  
    4949    /**
    5050     * @return true iff the CPU supports the AVX instruction set.
    51      * @since 0.9.21
     51     * @since 0.9.25
    5252     */
    5353    public boolean hasAVX()
     
    6060    /**
    6161     * @return true iff the CPU supports the AVX2 instruction set.
    62      * @since 0.9.21
     62     * @since 0.9.25
    6363     */
    6464    public boolean hasAVX2() {
     
    7878     *
    7979     * @return true iff the CPU supports the AVX-512 Foundation instruction set.
    80      * @since 0.9.21
     80     * @since 0.9.25
    8181     */
    8282    public boolean hasAVX512()
     
    8787    /**
    8888     * @return true iff the CPU supports the ADX instruction set.
    89      * @since 0.9.21
     89     * @since 0.9.25
    9090     */
    9191    public boolean hasADX()
     
    9696    /**
    9797     * @return true iff the CPU supports TBM.
    98      * @since 0.9.21
     98     * @since 0.9.25
    9999     */
    100100    public boolean hasTBM()
     
    113113    /**
    114114     * @return true iff the CPU supports the 64-bit support
    115      * @since 0.9.21
     115     * @since 0.9.25
    116116     */
    117117    public boolean hasX64() {
     
    121121    /**
    122122     * @return true iff the CPU supports the BMI1 instruction set.
    123      * @since 0.9.24
     123     * @since 0.9.25
    124124     */
    125125    public boolean hasBMI1() {
     
    129129    /**
    130130     * @return true iff the CPU supports the BMI2 instruction set.
    131      * @since 0.9.24
     131     * @since 0.9.25
    132132     */
    133133    public boolean hasBMI2() {
     
    137137    /**
    138138     * @return true iff the CPU supports the FMA3 instruction set.
    139      * @since 0.9.24
     139     * @since 0.9.25
    140140     */
    141141    public boolean hasFMA3() {
     
    145145    /**
    146146     * @return true iff the CPU supports the MOVBE instruction set.
    147      * @since 0.9.24
     147     * @since 0.9.25
    148148     */
    149149    public boolean hasMOVBE() {
     
    152152
    153153    /**
     154     * Also known as LZCNT
    154155     * @return true iff the CPU supports the ABM instruction set.
    155      * @since 0.9.24
     156     * @since 0.9.25
    156157     */
    157158    public boolean hasABM() {
    158         return (CPUID.getExtendedECXCPUFlags() & (1 << 5)) != 0; // Extended EBX Bit 5
     159        return (CPUID.getExtendedECXCPUFlags() & (1 << 5)) != 0; // Extended ECX Bit 5
    159160    }
    160161
    161         @Override
    162         public String getCPUModelString() throws UnknownCPUException {
     162    @Override
     163    public String getCPUModelString() throws UnknownCPUException {
    163164        throw new UnknownCPUException("Class CPUIDCPUInfo cannot indentify CPUs");
    164         }
     165    }
    165166}
  • core/java/src/freenet/support/CPUInformation/CPUInfo.java

    r1f4a266 r1e3e02d  
    7272    /**
    7373     * @return true iff the CPU supports the AVX instruction set.
    74      * @since 0.9.21
     74     * @since 0.9.25
    7575     */
    7676    public boolean hasAVX();
     
    7878    /**
    7979     * @return true iff the CPU supports the AVX2 instruction set.
    80      * @since 0.9.21
     80     * @since 0.9.25
    8181     */
    8282    public boolean hasAVX2();
     
    9494     *
    9595     * @return true iff the CPU supports the AVX-512 Foundation instruction set.
    96      * @since 0.9.21
     96     * @since 0.9.25
    9797     */
    9898    public boolean hasAVX512();
     
    100100    /**
    101101     * @return true iff the CPU supports the ADX instruction set.
    102      * @since 0.9.21
     102     * @since 0.9.25
    103103     */
    104104    public boolean hasADX();
     
    106106    /**
    107107     * @return true iff the CPU supports TBM.
    108      * @since 0.9.21
     108     * @since 0.9.25
    109109     */
    110110    public boolean hasTBM();
     
    118118    /**
    119119     * @return true iff the CPU supports the 64-bit support
    120      * @since 0.9.21
     120     * @since 0.9.25
    121121     */
    122122    public boolean hasX64();
     
    124124    /**
    125125     * @return true iff the CPU supports the BMI1 instruction set.
    126      * @since 0.9.24
     126     * @since 0.9.25
    127127     */
    128128    public boolean hasBMI1();
     
    130130    /**
    131131     * @return true iff the CPU supports the BMI2 instruction set.
    132      * @since 0.9.24
     132     * @since 0.9.25
    133133     */
    134134    public boolean hasBMI2();
     
    136136    /**
    137137     * @return true iff the CPU supports the FMA3 instruction set.
    138      * @since 0.9.24
     138     * @since 0.9.25
    139139     */
    140140    public boolean hasFMA3();
     
    142142    /**
    143143     * @return true iff the CPU supports the MOVBE instruction set.
    144      * @since 0.9.24
     144     * @since 0.9.25
    145145     */
    146146    public boolean hasMOVBE();
    147147
    148148    /**
     149     * Also known as LZCNT
    149150     * @return true iff the CPU supports the ABM instruction set.
    150      * @since 0.9.24
     151     * @since 0.9.25
    151152     */
    152153    public boolean hasABM();
  • core/java/src/freenet/support/CPUInformation/IntelCPUInfo.java

    r1f4a266 r1e3e02d  
    8080     * In general, this requires 32nm or smaller process.
    8181     * @return true if the CPU implements at least a SandyBridge level instruction/feature set.
     82     * @since 0.9.25
    8283     */
    8384    public boolean IsSandyCompatible();
     
    9394     *
    9495     * @return true if the CPU implements at least a IvyBridge level instruction/feature set.
     96     * @since 0.9.25
    9597     */
    9698    public boolean IsIvyCompatible();
     
    114116     * In general, this requires 22nm or smaller process.
    115117     * @return true if the CPU implements at least a Haswell level instruction/feature set.
     118     * @since 0.9.25
    116119     */
    117120    public boolean IsHaswellCompatible();
     
    127130     *
    128131     * @return true if the CPU implements at least a Broadwell level instruction/feature set.
     132     * @since 0.9.25
    129133     */
    130134    public boolean IsBroadwellCompatible();
  • core/java/src/freenet/support/CPUInformation/IntelInfoImpl.java

    r1f4a266 r1e3e02d  
    377377                    case 0x45:
    378378                    case 0x46:
    379                         CPUIDCPUInfo c = new CPUIDCPUInfo();
     379                        CPUIDCPUInfo c = new CPUIDCPUInfo();
    380380                        if (c.hasAVX2() && c.hasBMI1()  && c.hasBMI2() &&
    381                                 c.hasFMA3() && c.hasMOVBE() && c.hasABM()) {
     381                            c.hasFMA3() && c.hasMOVBE() && c.hasABM()) {
    382382                            isSandyCompatible = true;
    383383                            isIvyCompatible = true;
  • core/java/src/net/i2p/util/NativeBigInteger.java

    r1f4a266 r1e3e02d  
    157157    private final static String JBIGI_OPTIMIZATION_VIAC32     = "viac32";
    158158    /**
    159      * The optimization levels defined here are since 0.9.21. Each of the 32-bit processors below
     159     * The optimization levels defined here are since 0.9.25. Each of the 32-bit processors below
    160160     * needs an explicit fallback in getResourceList() or getMiddleName2().
    161161     * 64-bit processors will fallback to athlon64 and athlon in getResourceList().
    162      * @since 0.9.21
     162     * @since 0.9.25
    163163     */
    164164    private final static String JBIGI_OPTIMIZATION_COREI_SBR   = "coreisbr";
     
    180180    /**
    181181     * ARM
    182      * @since 0.9.21
     182     * @since 0.9.25
    183183     */
    184184    private final static String JBIGI_OPTIMIZATION_ARM_ARMV5           = "armv5";
     
    193193    /**
    194194     * None, no optimizations. The default fallback for x86.
    195      * @since 0.9.21
     195     * @since 0.9.25
    196196     */
    197197    private final static String JBIGI_OPTIMIZATION_X86       = "none";
     
    562562     *  Set the jbigi and libgmp versions. Call after loading.
    563563     *  Sets _jbigiVersion, _nativeOk3, and _libGMPVersion.
    564      *  @since 0.9.21
     564     *  @since 0.9.25
    565565     */
    566566    private static void setVersions() {
     
    10021002    }
    10031003   
    1004     /** @since 0.9.21 */
     1004    /** @since 0.9.25 */
    10051005    private static void error(String s) {
    10061006        error(s, null);
    10071007    }
    10081008   
    1009     /** @since 0.9.21 */
     1009    /** @since 0.9.25 */
    10101010    private static void error(String s, Throwable t) {
    10111011        if(_doLog) {
Note: See TracChangeset for help on using the changeset viewer.