Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6984890

Support benefit of conditional logical operators

XMLWordPrintable

    • x86
    • windows_xp

      A DESCRIPTION OF THE REQUEST :
      In a chain of conditional logical operators, the first exclusion should
      run fastest, i.e. have least branches.



      JUSTIFICATION :
        Programmer could control fast path.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -

        0x00b85347: cmp $0xd800,%ecx
        0x00b8534d: jge 0x00b8535c
        0x00b8534f: xor %eax,%eax
        0x00b85351: add $0x8,%esp
        0x00b85354: pop %ebp
        0x00b85355: test %eax,0x390000 ; {poll_return}
        0x00b8535b: ret
        0x00b8535c: cmp $0xdc00,%ecx
        0x00b85362: jge 0x00b8534f ;*if_icmplt
                                              ; -
      java.lang.Character::isHighSurrogate@3 (line 2795)
        0x00b85364: mov $0x1,%eax ;*ireturn
                                              ; -
      java.lang.Character::isHighSurrogate@17 (line 2795)
        0x00b85369: jmp 0x00b85351

      ACTUAL -

        0x00b85347: cmp $0xd800,%ecx
        0x00b8534d: jl 0x00b85357
        0x00b8534f: cmp $0xdc00,%ecx
        0x00b85355: jl 0x00b8535b ;*if_icmplt
                                              ; -
      java.lang.Character::isHighSurrogate@3 (line 2795)
        0x00b85357: xor %eax,%eax
        0x00b85359: jmp 0x00b85360
        0x00b8535b: mov $0x1,%eax ;*ireturn
                                              ; -
      java.lang.Character::isHighSurrogate@17 (line 2795)
        0x00b85360: add $0x8,%esp
        0x00b85363: pop %ebp
        0x00b85364: test %eax,0x390000 ; {poll_return}
        0x00b8536a: ret


      ---------- BEGIN SOURCE ----------

          public static boolean isHighSurrogate(char ch) {
      // return ch >= MIN_HIGH_SURROGATE && ch <= MAX_HIGH_SURROGATE;
              return ch >= MIN_HIGH_SURROGATE && ch < MAX_HIGH_SURROGATE + 1;
          }

      ---------- END SOURCE ----------

            rbackman Rickard Backman (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: