Java Code Examples for sun.invoke.util.Wrapper#isSubwordOrInt()

The following examples show how to use sun.invoke.util.Wrapper#isSubwordOrInt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InvokerBytecodeGenerator.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Emit a type conversion bytecode casting from "from" to "to".
 */
private void emitPrimCast(Wrapper from, Wrapper to) {
    // Here's how.
    // -   indicates forbidden
    // <-> indicates implicit
    //      to ----> boolean  byte     short    char     int      long     float    double
    // from boolean    <->        -        -        -        -        -        -        -
    //      byte        -       <->       i2s      i2c      <->      i2l      i2f      i2d
    //      short       -       i2b       <->      i2c      <->      i2l      i2f      i2d
    //      char        -       i2b       i2s      <->      <->      i2l      i2f      i2d
    //      int         -       i2b       i2s      i2c      <->      i2l      i2f      i2d
    //      long        -     l2i,i2b   l2i,i2s  l2i,i2c    l2i      <->      l2f      l2d
    //      float       -     f2i,i2b   f2i,i2s  f2i,i2c    f2i      f2l      <->      f2d
    //      double      -     d2i,i2b   d2i,i2s  d2i,i2c    d2i      d2l      d2f      <->
    if (from == to) {
        // no cast required, should be dead code anyway
        return;
    }
    if (from.isSubwordOrInt()) {
        // cast from {byte,short,char,int} to anything
        emitI2X(to);
    } else {
        // cast from {long,float,double} to anything
        if (to.isSubwordOrInt()) {
            // cast to {byte,short,char,int}
            emitX2I(from);
            if (to.bitWidth() < 32) {
                // targets other than int require another conversion
                emitI2X(to);
            }
        } else {
            // cast to {long,float,double} - this is verbose
            boolean error = false;
            switch (from) {
            case LONG:
                switch (to) {
                case FLOAT:   mv.visitInsn(Opcodes.L2F);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.L2D);  break;
                default:      error = true;               break;
                }
                break;
            case FLOAT:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.F2L);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.F2D);  break;
                default:      error = true;               break;
                }
                break;
            case DOUBLE:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.D2L);  break;
                case FLOAT:   mv.visitInsn(Opcodes.D2F);  break;
                default:      error = true;               break;
                }
                break;
            default:
                error = true;
                break;
            }
            if (error) {
                throw new IllegalStateException("unhandled prim cast: " + from + "2" + to);
            }
        }
    }
}
 
Example 2
Source File: InvokerBytecodeGenerator.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Emit a type conversion bytecode casting from "from" to "to".
 */
private void emitPrimCast(Wrapper from, Wrapper to) {
    // Here's how.
    // -   indicates forbidden
    // <-> indicates implicit
    //      to ----> boolean  byte     short    char     int      long     float    double
    // from boolean    <->        -        -        -        -        -        -        -
    //      byte        -       <->       i2s      i2c      <->      i2l      i2f      i2d
    //      short       -       i2b       <->      i2c      <->      i2l      i2f      i2d
    //      char        -       i2b       i2s      <->      <->      i2l      i2f      i2d
    //      int         -       i2b       i2s      i2c      <->      i2l      i2f      i2d
    //      long        -     l2i,i2b   l2i,i2s  l2i,i2c    l2i      <->      l2f      l2d
    //      float       -     f2i,i2b   f2i,i2s  f2i,i2c    f2i      f2l      <->      f2d
    //      double      -     d2i,i2b   d2i,i2s  d2i,i2c    d2i      d2l      d2f      <->
    if (from == to) {
        // no cast required, should be dead code anyway
        return;
    }
    if (from.isSubwordOrInt()) {
        // cast from {byte,short,char,int} to anything
        emitI2X(to);
    } else {
        // cast from {long,float,double} to anything
        if (to.isSubwordOrInt()) {
            // cast to {byte,short,char,int}
            emitX2I(from);
            if (to.bitWidth() < 32) {
                // targets other than int require another conversion
                emitI2X(to);
            }
        } else {
            // cast to {long,float,double} - this is verbose
            boolean error = false;
            switch (from) {
            case LONG:
                switch (to) {
                case FLOAT:   mv.visitInsn(Opcodes.L2F);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.L2D);  break;
                default:      error = true;               break;
                }
                break;
            case FLOAT:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.F2L);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.F2D);  break;
                default:      error = true;               break;
                }
                break;
            case DOUBLE:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.D2L);  break;
                case FLOAT:   mv.visitInsn(Opcodes.D2F);  break;
                default:      error = true;               break;
                }
                break;
            default:
                error = true;
                break;
            }
            if (error) {
                throw new IllegalStateException("unhandled prim cast: " + from + "2" + to);
            }
        }
    }
}
 
Example 3
Source File: InvokerBytecodeGenerator.java    From jdk-1.7-annotated with Apache License 2.0 4 votes vote down vote up
/**
 * Emit a type conversion bytecode casting from "from" to "to".
 */
private void emitPrimCast(char from, char to) {
    // Here's how.
    // -   indicates forbidden
    // <-> indicates implicit
    //      to ----> boolean  byte     short    char     int      long     float    double
    // from boolean    <->        -        -        -        -        -        -        -
    //      byte        -       <->       i2s      i2c      <->      i2l      i2f      i2d
    //      short       -       i2b       <->      i2c      <->      i2l      i2f      i2d
    //      char        -       i2b       i2s      <->      <->      i2l      i2f      i2d
    //      int         -       i2b       i2s      i2c      <->      i2l      i2f      i2d
    //      long        -     l2i,i2b   l2i,i2s  l2i,i2c    l2i      <->      l2f      l2d
    //      float       -     f2i,i2b   f2i,i2s  f2i,i2c    f2i      f2l      <->      f2d
    //      double      -     d2i,i2b   d2i,i2s  d2i,i2c    d2i      d2l      d2f      <->
    if (from == to) {
        // no cast required, should be dead code anyway
        return;
    }
    Wrapper wfrom = Wrapper.forBasicType(from);
    Wrapper wto   = Wrapper.forBasicType(to);
    if (wfrom.isSubwordOrInt()) {
        // cast from {byte,short,char,int} to anything
        emitI2X(to);
    } else {
        // cast from {long,float,double} to anything
        if (wto.isSubwordOrInt()) {
            // cast to {byte,short,char,int}
            emitX2I(from);
            if (wto.bitWidth() < 32) {
                // targets other than int require another conversion
                emitI2X(to);
            }
        } else {
            // cast to {long,float,double} - this is verbose
            boolean error = false;
            switch (from) {
            case 'J':
                     if (to == 'F') { mv.visitInsn(Opcodes.L2F); }
                else if (to == 'D') { mv.visitInsn(Opcodes.L2D); }
                else error = true;
                break;
            case 'F':
                     if (to == 'J') { mv.visitInsn(Opcodes.F2L); }
                else if (to == 'D') { mv.visitInsn(Opcodes.F2D); }
                else error = true;
                break;
            case 'D':
                     if (to == 'J') { mv.visitInsn(Opcodes.D2L); }
                else if (to == 'F') { mv.visitInsn(Opcodes.D2F); }
                else error = true;
                break;
            default:
                error = true;
                break;
            }
            if (error) {
                throw new IllegalStateException("unhandled prim cast: " + from + "2" + to);
            }
        }
    }
}
 
Example 4
Source File: InvokerBytecodeGenerator.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Emit a type conversion bytecode casting from "from" to "to".
 */
private void emitPrimCast(Wrapper from, Wrapper to) {
    // Here's how.
    // -   indicates forbidden
    // <-> indicates implicit
    //      to ----> boolean  byte     short    char     int      long     float    double
    // from boolean    <->        -        -        -        -        -        -        -
    //      byte        -       <->       i2s      i2c      <->      i2l      i2f      i2d
    //      short       -       i2b       <->      i2c      <->      i2l      i2f      i2d
    //      char        -       i2b       i2s      <->      <->      i2l      i2f      i2d
    //      int         -       i2b       i2s      i2c      <->      i2l      i2f      i2d
    //      long        -     l2i,i2b   l2i,i2s  l2i,i2c    l2i      <->      l2f      l2d
    //      float       -     f2i,i2b   f2i,i2s  f2i,i2c    f2i      f2l      <->      f2d
    //      double      -     d2i,i2b   d2i,i2s  d2i,i2c    d2i      d2l      d2f      <->
    if (from == to) {
        // no cast required, should be dead code anyway
        return;
    }
    if (from.isSubwordOrInt()) {
        // cast from {byte,short,char,int} to anything
        emitI2X(to);
    } else {
        // cast from {long,float,double} to anything
        if (to.isSubwordOrInt()) {
            // cast to {byte,short,char,int}
            emitX2I(from);
            if (to.bitWidth() < 32) {
                // targets other than int require another conversion
                emitI2X(to);
            }
        } else {
            // cast to {long,float,double} - this is verbose
            boolean error = false;
            switch (from) {
            case LONG:
                switch (to) {
                case FLOAT:   mv.visitInsn(Opcodes.L2F);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.L2D);  break;
                default:      error = true;               break;
                }
                break;
            case FLOAT:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.F2L);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.F2D);  break;
                default:      error = true;               break;
                }
                break;
            case DOUBLE:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.D2L);  break;
                case FLOAT:   mv.visitInsn(Opcodes.D2F);  break;
                default:      error = true;               break;
                }
                break;
            default:
                error = true;
                break;
            }
            if (error) {
                throw new IllegalStateException("unhandled prim cast: " + from + "2" + to);
            }
        }
    }
}
 
Example 5
Source File: InvokerBytecodeGenerator.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Emit a type conversion bytecode casting from "from" to "to".
 */
private void emitPrimCast(Wrapper from, Wrapper to) {
    // Here's how.
    // -   indicates forbidden
    // <-> indicates implicit
    //      to ----> boolean  byte     short    char     int      long     float    double
    // from boolean    <->        -        -        -        -        -        -        -
    //      byte        -       <->       i2s      i2c      <->      i2l      i2f      i2d
    //      short       -       i2b       <->      i2c      <->      i2l      i2f      i2d
    //      char        -       i2b       i2s      <->      <->      i2l      i2f      i2d
    //      int         -       i2b       i2s      i2c      <->      i2l      i2f      i2d
    //      long        -     l2i,i2b   l2i,i2s  l2i,i2c    l2i      <->      l2f      l2d
    //      float       -     f2i,i2b   f2i,i2s  f2i,i2c    f2i      f2l      <->      f2d
    //      double      -     d2i,i2b   d2i,i2s  d2i,i2c    d2i      d2l      d2f      <->
    if (from == to) {
        // no cast required, should be dead code anyway
        return;
    }
    if (from.isSubwordOrInt()) {
        // cast from {byte,short,char,int} to anything
        emitI2X(to);
    } else {
        // cast from {long,float,double} to anything
        if (to.isSubwordOrInt()) {
            // cast to {byte,short,char,int}
            emitX2I(from);
            if (to.bitWidth() < 32) {
                // targets other than int require another conversion
                emitI2X(to);
            }
        } else {
            // cast to {long,float,double} - this is verbose
            boolean error = false;
            switch (from) {
            case LONG:
                switch (to) {
                case FLOAT:   mv.visitInsn(Opcodes.L2F);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.L2D);  break;
                default:      error = true;               break;
                }
                break;
            case FLOAT:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.F2L);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.F2D);  break;
                default:      error = true;               break;
                }
                break;
            case DOUBLE:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.D2L);  break;
                case FLOAT:   mv.visitInsn(Opcodes.D2F);  break;
                default:      error = true;               break;
                }
                break;
            default:
                error = true;
                break;
            }
            if (error) {
                throw new IllegalStateException("unhandled prim cast: " + from + "2" + to);
            }
        }
    }
}
 
Example 6
Source File: InvokerBytecodeGenerator.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Emit a type conversion bytecode casting from "from" to "to".
 */
private void emitPrimCast(char from, char to) {
    // Here's how.
    // -   indicates forbidden
    // <-> indicates implicit
    //      to ----> boolean  byte     short    char     int      long     float    double
    // from boolean    <->        -        -        -        -        -        -        -
    //      byte        -       <->       i2s      i2c      <->      i2l      i2f      i2d
    //      short       -       i2b       <->      i2c      <->      i2l      i2f      i2d
    //      char        -       i2b       i2s      <->      <->      i2l      i2f      i2d
    //      int         -       i2b       i2s      i2c      <->      i2l      i2f      i2d
    //      long        -     l2i,i2b   l2i,i2s  l2i,i2c    l2i      <->      l2f      l2d
    //      float       -     f2i,i2b   f2i,i2s  f2i,i2c    f2i      f2l      <->      f2d
    //      double      -     d2i,i2b   d2i,i2s  d2i,i2c    d2i      d2l      d2f      <->
    if (from == to) {
        // no cast required, should be dead code anyway
        return;
    }
    Wrapper wfrom = Wrapper.forBasicType(from);
    Wrapper wto   = Wrapper.forBasicType(to);
    if (wfrom.isSubwordOrInt()) {
        // cast from {byte,short,char,int} to anything
        emitI2X(to);
    } else {
        // cast from {long,float,double} to anything
        if (wto.isSubwordOrInt()) {
            // cast to {byte,short,char,int}
            emitX2I(from);
            if (wto.bitWidth() < 32) {
                // targets other than int require another conversion
                emitI2X(to);
            }
        } else {
            // cast to {long,float,double} - this is verbose
            boolean error = false;
            switch (from) {
            case 'J':
                     if (to == 'F') { mv.visitInsn(Opcodes.L2F); }
                else if (to == 'D') { mv.visitInsn(Opcodes.L2D); }
                else error = true;
                break;
            case 'F':
                     if (to == 'J') { mv.visitInsn(Opcodes.F2L); }
                else if (to == 'D') { mv.visitInsn(Opcodes.F2D); }
                else error = true;
                break;
            case 'D':
                     if (to == 'J') { mv.visitInsn(Opcodes.D2L); }
                else if (to == 'F') { mv.visitInsn(Opcodes.D2F); }
                else error = true;
                break;
            default:
                error = true;
                break;
            }
            if (error) {
                throw new IllegalStateException("unhandled prim cast: " + from + "2" + to);
            }
        }
    }
}
 
Example 7
Source File: InvokerBytecodeGenerator.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Emit a type conversion bytecode casting from "from" to "to".
 */
private void emitPrimCast(char from, char to) {
    // Here's how.
    // -   indicates forbidden
    // <-> indicates implicit
    //      to ----> boolean  byte     short    char     int      long     float    double
    // from boolean    <->        -        -        -        -        -        -        -
    //      byte        -       <->       i2s      i2c      <->      i2l      i2f      i2d
    //      short       -       i2b       <->      i2c      <->      i2l      i2f      i2d
    //      char        -       i2b       i2s      <->      <->      i2l      i2f      i2d
    //      int         -       i2b       i2s      i2c      <->      i2l      i2f      i2d
    //      long        -     l2i,i2b   l2i,i2s  l2i,i2c    l2i      <->      l2f      l2d
    //      float       -     f2i,i2b   f2i,i2s  f2i,i2c    f2i      f2l      <->      f2d
    //      double      -     d2i,i2b   d2i,i2s  d2i,i2c    d2i      d2l      d2f      <->
    if (from == to) {
        // no cast required, should be dead code anyway
        return;
    }
    Wrapper wfrom = Wrapper.forBasicType(from);
    Wrapper wto   = Wrapper.forBasicType(to);
    if (wfrom.isSubwordOrInt()) {
        // cast from {byte,short,char,int} to anything
        emitI2X(to);
    } else {
        // cast from {long,float,double} to anything
        if (wto.isSubwordOrInt()) {
            // cast to {byte,short,char,int}
            emitX2I(from);
            if (wto.bitWidth() < 32) {
                // targets other than int require another conversion
                emitI2X(to);
            }
        } else {
            // cast to {long,float,double} - this is verbose
            boolean error = false;
            switch (from) {
            case 'J':
                     if (to == 'F') { mv.visitInsn(Opcodes.L2F); }
                else if (to == 'D') { mv.visitInsn(Opcodes.L2D); }
                else error = true;
                break;
            case 'F':
                     if (to == 'J') { mv.visitInsn(Opcodes.F2L); }
                else if (to == 'D') { mv.visitInsn(Opcodes.F2D); }
                else error = true;
                break;
            case 'D':
                     if (to == 'J') { mv.visitInsn(Opcodes.D2L); }
                else if (to == 'F') { mv.visitInsn(Opcodes.D2F); }
                else error = true;
                break;
            default:
                error = true;
                break;
            }
            if (error) {
                throw new IllegalStateException("unhandled prim cast: " + from + "2" + to);
            }
        }
    }
}
 
Example 8
Source File: InvokerBytecodeGenerator.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Emit a type conversion bytecode casting from "from" to "to".
 */
private void emitPrimCast(Wrapper from, Wrapper to) {
    // Here's how.
    // -   indicates forbidden
    // <-> indicates implicit
    //      to ----> boolean  byte     short    char     int      long     float    double
    // from boolean    <->        -        -        -        -        -        -        -
    //      byte        -       <->       i2s      i2c      <->      i2l      i2f      i2d
    //      short       -       i2b       <->      i2c      <->      i2l      i2f      i2d
    //      char        -       i2b       i2s      <->      <->      i2l      i2f      i2d
    //      int         -       i2b       i2s      i2c      <->      i2l      i2f      i2d
    //      long        -     l2i,i2b   l2i,i2s  l2i,i2c    l2i      <->      l2f      l2d
    //      float       -     f2i,i2b   f2i,i2s  f2i,i2c    f2i      f2l      <->      f2d
    //      double      -     d2i,i2b   d2i,i2s  d2i,i2c    d2i      d2l      d2f      <->
    if (from == to) {
        // no cast required, should be dead code anyway
        return;
    }
    if (from.isSubwordOrInt()) {
        // cast from {byte,short,char,int} to anything
        emitI2X(to);
    } else {
        // cast from {long,float,double} to anything
        if (to.isSubwordOrInt()) {
            // cast to {byte,short,char,int}
            emitX2I(from);
            if (to.bitWidth() < 32) {
                // targets other than int require another conversion
                emitI2X(to);
            }
        } else {
            // cast to {long,float,double} - this is verbose
            boolean error = false;
            switch (from) {
            case LONG:
                switch (to) {
                case FLOAT:   mv.visitInsn(Opcodes.L2F);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.L2D);  break;
                default:      error = true;               break;
                }
                break;
            case FLOAT:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.F2L);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.F2D);  break;
                default:      error = true;               break;
                }
                break;
            case DOUBLE:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.D2L);  break;
                case FLOAT:   mv.visitInsn(Opcodes.D2F);  break;
                default:      error = true;               break;
                }
                break;
            default:
                error = true;
                break;
            }
            if (error) {
                throw new IllegalStateException("unhandled prim cast: " + from + "2" + to);
            }
        }
    }
}
 
Example 9
Source File: InvokerBytecodeGenerator.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
/**
 * Emit a type conversion bytecode casting from "from" to "to".
 */
private void emitPrimCast(Wrapper from, Wrapper to) {
    // Here's how.
    // -   indicates forbidden
    // <-> indicates implicit
    //      to ----> boolean  byte     short    char     int      long     float    double
    // from boolean    <->        -        -        -        -        -        -        -
    //      byte        -       <->       i2s      i2c      <->      i2l      i2f      i2d
    //      short       -       i2b       <->      i2c      <->      i2l      i2f      i2d
    //      char        -       i2b       i2s      <->      <->      i2l      i2f      i2d
    //      int         -       i2b       i2s      i2c      <->      i2l      i2f      i2d
    //      long        -     l2i,i2b   l2i,i2s  l2i,i2c    l2i      <->      l2f      l2d
    //      float       -     f2i,i2b   f2i,i2s  f2i,i2c    f2i      f2l      <->      f2d
    //      double      -     d2i,i2b   d2i,i2s  d2i,i2c    d2i      d2l      d2f      <->
    if (from == to) {
        // no cast required, should be dead code anyway
        return;
    }
    if (from.isSubwordOrInt()) {
        // cast from {byte,short,char,int} to anything
        emitI2X(to);
    } else {
        // cast from {long,float,double} to anything
        if (to.isSubwordOrInt()) {
            // cast to {byte,short,char,int}
            emitX2I(from);
            if (to.bitWidth() < 32) {
                // targets other than int require another conversion
                emitI2X(to);
            }
        } else {
            // cast to {long,float,double} - this is verbose
            boolean error = false;
            switch (from) {
            case LONG:
                switch (to) {
                case FLOAT:   mv.visitInsn(Opcodes.L2F);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.L2D);  break;
                default:      error = true;               break;
                }
                break;
            case FLOAT:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.F2L);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.F2D);  break;
                default:      error = true;               break;
                }
                break;
            case DOUBLE:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.D2L);  break;
                case FLOAT:   mv.visitInsn(Opcodes.D2F);  break;
                default:      error = true;               break;
                }
                break;
            default:
                error = true;
                break;
            }
            if (error) {
                throw new IllegalStateException("unhandled prim cast: " + from + "2" + to);
            }
        }
    }
}
 
Example 10
Source File: InvokerBytecodeGenerator.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Emit a type conversion bytecode casting from "from" to "to".
 */
private void emitPrimCast(Wrapper from, Wrapper to) {
    // Here's how.
    // -   indicates forbidden
    // <-> indicates implicit
    //      to ----> boolean  byte     short    char     int      long     float    double
    // from boolean    <->        -        -        -        -        -        -        -
    //      byte        -       <->       i2s      i2c      <->      i2l      i2f      i2d
    //      short       -       i2b       <->      i2c      <->      i2l      i2f      i2d
    //      char        -       i2b       i2s      <->      <->      i2l      i2f      i2d
    //      int         -       i2b       i2s      i2c      <->      i2l      i2f      i2d
    //      long        -     l2i,i2b   l2i,i2s  l2i,i2c    l2i      <->      l2f      l2d
    //      float       -     f2i,i2b   f2i,i2s  f2i,i2c    f2i      f2l      <->      f2d
    //      double      -     d2i,i2b   d2i,i2s  d2i,i2c    d2i      d2l      d2f      <->
    if (from == to) {
        // no cast required, should be dead code anyway
        return;
    }
    if (from.isSubwordOrInt()) {
        // cast from {byte,short,char,int} to anything
        emitI2X(to);
    } else {
        // cast from {long,float,double} to anything
        if (to.isSubwordOrInt()) {
            // cast to {byte,short,char,int}
            emitX2I(from);
            if (to.bitWidth() < 32) {
                // targets other than int require another conversion
                emitI2X(to);
            }
        } else {
            // cast to {long,float,double} - this is verbose
            boolean error = false;
            switch (from) {
            case LONG:
                switch (to) {
                case FLOAT:   mv.visitInsn(Opcodes.L2F);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.L2D);  break;
                default:      error = true;               break;
                }
                break;
            case FLOAT:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.F2L);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.F2D);  break;
                default:      error = true;               break;
                }
                break;
            case DOUBLE:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.D2L);  break;
                case FLOAT:   mv.visitInsn(Opcodes.D2F);  break;
                default:      error = true;               break;
                }
                break;
            default:
                error = true;
                break;
            }
            if (error) {
                throw new IllegalStateException("unhandled prim cast: " + from + "2" + to);
            }
        }
    }
}
 
Example 11
Source File: InvokerBytecodeGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Emit a type conversion bytecode casting from "from" to "to".
 */
private void emitPrimCast(Wrapper from, Wrapper to) {
    // Here's how.
    // -   indicates forbidden
    // <-> indicates implicit
    //      to ----> boolean  byte     short    char     int      long     float    double
    // from boolean    <->        -        -        -        -        -        -        -
    //      byte        -       <->       i2s      i2c      <->      i2l      i2f      i2d
    //      short       -       i2b       <->      i2c      <->      i2l      i2f      i2d
    //      char        -       i2b       i2s      <->      <->      i2l      i2f      i2d
    //      int         -       i2b       i2s      i2c      <->      i2l      i2f      i2d
    //      long        -     l2i,i2b   l2i,i2s  l2i,i2c    l2i      <->      l2f      l2d
    //      float       -     f2i,i2b   f2i,i2s  f2i,i2c    f2i      f2l      <->      f2d
    //      double      -     d2i,i2b   d2i,i2s  d2i,i2c    d2i      d2l      d2f      <->
    if (from == to) {
        // no cast required, should be dead code anyway
        return;
    }
    if (from.isSubwordOrInt()) {
        // cast from {byte,short,char,int} to anything
        emitI2X(to);
    } else {
        // cast from {long,float,double} to anything
        if (to.isSubwordOrInt()) {
            // cast to {byte,short,char,int}
            emitX2I(from);
            if (to.bitWidth() < 32) {
                // targets other than int require another conversion
                emitI2X(to);
            }
        } else {
            // cast to {long,float,double} - this is verbose
            boolean error = false;
            switch (from) {
            case LONG:
                switch (to) {
                case FLOAT:   mv.visitInsn(Opcodes.L2F);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.L2D);  break;
                default:      error = true;               break;
                }
                break;
            case FLOAT:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.F2L);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.F2D);  break;
                default:      error = true;               break;
                }
                break;
            case DOUBLE:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.D2L);  break;
                case FLOAT:   mv.visitInsn(Opcodes.D2F);  break;
                default:      error = true;               break;
                }
                break;
            default:
                error = true;
                break;
            }
            if (error) {
                throw new IllegalStateException("unhandled prim cast: " + from + "2" + to);
            }
        }
    }
}
 
Example 12
Source File: InvokerBytecodeGenerator.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Emit a type conversion bytecode casting from "from" to "to".
 */
private void emitPrimCast(Wrapper from, Wrapper to) {
    // Here's how.
    // -   indicates forbidden
    // <-> indicates implicit
    //      to ----> boolean  byte     short    char     int      long     float    double
    // from boolean    <->        -        -        -        -        -        -        -
    //      byte        -       <->       i2s      i2c      <->      i2l      i2f      i2d
    //      short       -       i2b       <->      i2c      <->      i2l      i2f      i2d
    //      char        -       i2b       i2s      <->      <->      i2l      i2f      i2d
    //      int         -       i2b       i2s      i2c      <->      i2l      i2f      i2d
    //      long        -     l2i,i2b   l2i,i2s  l2i,i2c    l2i      <->      l2f      l2d
    //      float       -     f2i,i2b   f2i,i2s  f2i,i2c    f2i      f2l      <->      f2d
    //      double      -     d2i,i2b   d2i,i2s  d2i,i2c    d2i      d2l      d2f      <->
    if (from == to) {
        // no cast required, should be dead code anyway
        return;
    }
    if (from.isSubwordOrInt()) {
        // cast from {byte,short,char,int} to anything
        emitI2X(to);
    } else {
        // cast from {long,float,double} to anything
        if (to.isSubwordOrInt()) {
            // cast to {byte,short,char,int}
            emitX2I(from);
            if (to.bitWidth() < 32) {
                // targets other than int require another conversion
                emitI2X(to);
            }
        } else {
            // cast to {long,float,double} - this is verbose
            boolean error = false;
            switch (from) {
            case LONG:
                switch (to) {
                case FLOAT:   mv.visitInsn(Opcodes.L2F);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.L2D);  break;
                default:      error = true;               break;
                }
                break;
            case FLOAT:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.F2L);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.F2D);  break;
                default:      error = true;               break;
                }
                break;
            case DOUBLE:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.D2L);  break;
                case FLOAT:   mv.visitInsn(Opcodes.D2F);  break;
                default:      error = true;               break;
                }
                break;
            default:
                error = true;
                break;
            }
            if (error) {
                throw new IllegalStateException("unhandled prim cast: " + from + "2" + to);
            }
        }
    }
}
 
Example 13
Source File: InvokerBytecodeGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Emit a type conversion bytecode casting from "from" to "to".
 */
private void emitPrimCast(Wrapper from, Wrapper to) {
    // Here's how.
    // -   indicates forbidden
    // <-> indicates implicit
    //      to ----> boolean  byte     short    char     int      long     float    double
    // from boolean    <->        -        -        -        -        -        -        -
    //      byte        -       <->       i2s      i2c      <->      i2l      i2f      i2d
    //      short       -       i2b       <->      i2c      <->      i2l      i2f      i2d
    //      char        -       i2b       i2s      <->      <->      i2l      i2f      i2d
    //      int         -       i2b       i2s      i2c      <->      i2l      i2f      i2d
    //      long        -     l2i,i2b   l2i,i2s  l2i,i2c    l2i      <->      l2f      l2d
    //      float       -     f2i,i2b   f2i,i2s  f2i,i2c    f2i      f2l      <->      f2d
    //      double      -     d2i,i2b   d2i,i2s  d2i,i2c    d2i      d2l      d2f      <->
    if (from == to) {
        // no cast required, should be dead code anyway
        return;
    }
    if (from.isSubwordOrInt()) {
        // cast from {byte,short,char,int} to anything
        emitI2X(to);
    } else {
        // cast from {long,float,double} to anything
        if (to.isSubwordOrInt()) {
            // cast to {byte,short,char,int}
            emitX2I(from);
            if (to.bitWidth() < 32) {
                // targets other than int require another conversion
                emitI2X(to);
            }
        } else {
            // cast to {long,float,double} - this is verbose
            boolean error = false;
            switch (from) {
            case LONG:
                switch (to) {
                case FLOAT:   mv.visitInsn(Opcodes.L2F);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.L2D);  break;
                default:      error = true;               break;
                }
                break;
            case FLOAT:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.F2L);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.F2D);  break;
                default:      error = true;               break;
                }
                break;
            case DOUBLE:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.D2L);  break;
                case FLOAT:   mv.visitInsn(Opcodes.D2F);  break;
                default:      error = true;               break;
                }
                break;
            default:
                error = true;
                break;
            }
            if (error) {
                throw new IllegalStateException("unhandled prim cast: " + from + "2" + to);
            }
        }
    }
}
 
Example 14
Source File: InvokerBytecodeGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Emit a type conversion bytecode casting from "from" to "to".
 */
private void emitPrimCast(Wrapper from, Wrapper to) {
    // Here's how.
    // -   indicates forbidden
    // <-> indicates implicit
    //      to ----> boolean  byte     short    char     int      long     float    double
    // from boolean    <->        -        -        -        -        -        -        -
    //      byte        -       <->       i2s      i2c      <->      i2l      i2f      i2d
    //      short       -       i2b       <->      i2c      <->      i2l      i2f      i2d
    //      char        -       i2b       i2s      <->      <->      i2l      i2f      i2d
    //      int         -       i2b       i2s      i2c      <->      i2l      i2f      i2d
    //      long        -     l2i,i2b   l2i,i2s  l2i,i2c    l2i      <->      l2f      l2d
    //      float       -     f2i,i2b   f2i,i2s  f2i,i2c    f2i      f2l      <->      f2d
    //      double      -     d2i,i2b   d2i,i2s  d2i,i2c    d2i      d2l      d2f      <->
    if (from == to) {
        // no cast required, should be dead code anyway
        return;
    }
    if (from.isSubwordOrInt()) {
        // cast from {byte,short,char,int} to anything
        emitI2X(to);
    } else {
        // cast from {long,float,double} to anything
        if (to.isSubwordOrInt()) {
            // cast to {byte,short,char,int}
            emitX2I(from);
            if (to.bitWidth() < 32) {
                // targets other than int require another conversion
                emitI2X(to);
            }
        } else {
            // cast to {long,float,double} - this is verbose
            boolean error = false;
            switch (from) {
            case LONG:
                switch (to) {
                case FLOAT:   mv.visitInsn(Opcodes.L2F);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.L2D);  break;
                default:      error = true;               break;
                }
                break;
            case FLOAT:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.F2L);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.F2D);  break;
                default:      error = true;               break;
                }
                break;
            case DOUBLE:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.D2L);  break;
                case FLOAT:   mv.visitInsn(Opcodes.D2F);  break;
                default:      error = true;               break;
                }
                break;
            default:
                error = true;
                break;
            }
            if (error) {
                throw new IllegalStateException("unhandled prim cast: " + from + "2" + to);
            }
        }
    }
}
 
Example 15
Source File: InvokerBytecodeGenerator.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Emit a type conversion bytecode casting from "from" to "to".
 */
private void emitPrimCast(Wrapper from, Wrapper to) {
    // Here's how.
    // -   indicates forbidden
    // <-> indicates implicit
    //      to ----> boolean  byte     short    char     int      long     float    double
    // from boolean    <->        -        -        -        -        -        -        -
    //      byte        -       <->       i2s      i2c      <->      i2l      i2f      i2d
    //      short       -       i2b       <->      i2c      <->      i2l      i2f      i2d
    //      char        -       i2b       i2s      <->      <->      i2l      i2f      i2d
    //      int         -       i2b       i2s      i2c      <->      i2l      i2f      i2d
    //      long        -     l2i,i2b   l2i,i2s  l2i,i2c    l2i      <->      l2f      l2d
    //      float       -     f2i,i2b   f2i,i2s  f2i,i2c    f2i      f2l      <->      f2d
    //      double      -     d2i,i2b   d2i,i2s  d2i,i2c    d2i      d2l      d2f      <->
    if (from == to) {
        // no cast required, should be dead code anyway
        return;
    }
    if (from.isSubwordOrInt()) {
        // cast from {byte,short,char,int} to anything
        emitI2X(to);
    } else {
        // cast from {long,float,double} to anything
        if (to.isSubwordOrInt()) {
            // cast to {byte,short,char,int}
            emitX2I(from);
            if (to.bitWidth() < 32) {
                // targets other than int require another conversion
                emitI2X(to);
            }
        } else {
            // cast to {long,float,double} - this is verbose
            boolean error = false;
            switch (from) {
            case LONG:
                switch (to) {
                case FLOAT:   mv.visitInsn(Opcodes.L2F);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.L2D);  break;
                default:      error = true;               break;
                }
                break;
            case FLOAT:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.F2L);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.F2D);  break;
                default:      error = true;               break;
                }
                break;
            case DOUBLE:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.D2L);  break;
                case FLOAT:   mv.visitInsn(Opcodes.D2F);  break;
                default:      error = true;               break;
                }
                break;
            default:
                error = true;
                break;
            }
            if (error) {
                throw new IllegalStateException("unhandled prim cast: " + from + "2" + to);
            }
        }
    }
}
 
Example 16
Source File: InvokerBytecodeGenerator.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Emit a type conversion bytecode casting from "from" to "to".
 */
private void emitPrimCast(Wrapper from, Wrapper to) {
    // Here's how.
    // -   indicates forbidden
    // <-> indicates implicit
    //      to ----> boolean  byte     short    char     int      long     float    double
    // from boolean    <->        -        -        -        -        -        -        -
    //      byte        -       <->       i2s      i2c      <->      i2l      i2f      i2d
    //      short       -       i2b       <->      i2c      <->      i2l      i2f      i2d
    //      char        -       i2b       i2s      <->      <->      i2l      i2f      i2d
    //      int         -       i2b       i2s      i2c      <->      i2l      i2f      i2d
    //      long        -     l2i,i2b   l2i,i2s  l2i,i2c    l2i      <->      l2f      l2d
    //      float       -     f2i,i2b   f2i,i2s  f2i,i2c    f2i      f2l      <->      f2d
    //      double      -     d2i,i2b   d2i,i2s  d2i,i2c    d2i      d2l      d2f      <->
    if (from == to) {
        // no cast required, should be dead code anyway
        return;
    }
    if (from.isSubwordOrInt()) {
        // cast from {byte,short,char,int} to anything
        emitI2X(to);
    } else {
        // cast from {long,float,double} to anything
        if (to.isSubwordOrInt()) {
            // cast to {byte,short,char,int}
            emitX2I(from);
            if (to.bitWidth() < 32) {
                // targets other than int require another conversion
                emitI2X(to);
            }
        } else {
            // cast to {long,float,double} - this is verbose
            boolean error = false;
            switch (from) {
            case LONG:
                switch (to) {
                case FLOAT:   mv.visitInsn(Opcodes.L2F);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.L2D);  break;
                default:      error = true;               break;
                }
                break;
            case FLOAT:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.F2L);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.F2D);  break;
                default:      error = true;               break;
                }
                break;
            case DOUBLE:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.D2L);  break;
                case FLOAT:   mv.visitInsn(Opcodes.D2F);  break;
                default:      error = true;               break;
                }
                break;
            default:
                error = true;
                break;
            }
            if (error) {
                throw new IllegalStateException("unhandled prim cast: " + from + "2" + to);
            }
        }
    }
}
 
Example 17
Source File: InvokerBytecodeGenerator.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Emit a type conversion bytecode casting from "from" to "to".
 */
private void emitPrimCast(Wrapper from, Wrapper to) {
    // Here's how.
    // -   indicates forbidden
    // <-> indicates implicit
    //      to ----> boolean  byte     short    char     int      long     float    double
    // from boolean    <->        -        -        -        -        -        -        -
    //      byte        -       <->       i2s      i2c      <->      i2l      i2f      i2d
    //      short       -       i2b       <->      i2c      <->      i2l      i2f      i2d
    //      char        -       i2b       i2s      <->      <->      i2l      i2f      i2d
    //      int         -       i2b       i2s      i2c      <->      i2l      i2f      i2d
    //      long        -     l2i,i2b   l2i,i2s  l2i,i2c    l2i      <->      l2f      l2d
    //      float       -     f2i,i2b   f2i,i2s  f2i,i2c    f2i      f2l      <->      f2d
    //      double      -     d2i,i2b   d2i,i2s  d2i,i2c    d2i      d2l      d2f      <->
    if (from == to) {
        // no cast required, should be dead code anyway
        return;
    }
    if (from.isSubwordOrInt()) {
        // cast from {byte,short,char,int} to anything
        emitI2X(to);
    } else {
        // cast from {long,float,double} to anything
        if (to.isSubwordOrInt()) {
            // cast to {byte,short,char,int}
            emitX2I(from);
            if (to.bitWidth() < 32) {
                // targets other than int require another conversion
                emitI2X(to);
            }
        } else {
            // cast to {long,float,double} - this is verbose
            boolean error = false;
            switch (from) {
            case LONG:
                switch (to) {
                case FLOAT:   mv.visitInsn(Opcodes.L2F);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.L2D);  break;
                default:      error = true;               break;
                }
                break;
            case FLOAT:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.F2L);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.F2D);  break;
                default:      error = true;               break;
                }
                break;
            case DOUBLE:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.D2L);  break;
                case FLOAT:   mv.visitInsn(Opcodes.D2F);  break;
                default:      error = true;               break;
                }
                break;
            default:
                error = true;
                break;
            }
            if (error) {
                throw new IllegalStateException("unhandled prim cast: " + from + "2" + to);
            }
        }
    }
}
 
Example 18
Source File: InvokerBytecodeGenerator.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Emit a type conversion bytecode casting from "from" to "to".
 */
private void emitPrimCast(Wrapper from, Wrapper to) {
    // Here's how.
    // -   indicates forbidden
    // <-> indicates implicit
    //      to ----> boolean  byte     short    char     int      long     float    double
    // from boolean    <->        -        -        -        -        -        -        -
    //      byte        -       <->       i2s      i2c      <->      i2l      i2f      i2d
    //      short       -       i2b       <->      i2c      <->      i2l      i2f      i2d
    //      char        -       i2b       i2s      <->      <->      i2l      i2f      i2d
    //      int         -       i2b       i2s      i2c      <->      i2l      i2f      i2d
    //      long        -     l2i,i2b   l2i,i2s  l2i,i2c    l2i      <->      l2f      l2d
    //      float       -     f2i,i2b   f2i,i2s  f2i,i2c    f2i      f2l      <->      f2d
    //      double      -     d2i,i2b   d2i,i2s  d2i,i2c    d2i      d2l      d2f      <->
    if (from == to) {
        // no cast required, should be dead code anyway
        return;
    }
    if (from.isSubwordOrInt()) {
        // cast from {byte,short,char,int} to anything
        emitI2X(to);
    } else {
        // cast from {long,float,double} to anything
        if (to.isSubwordOrInt()) {
            // cast to {byte,short,char,int}
            emitX2I(from);
            if (to.bitWidth() < 32) {
                // targets other than int require another conversion
                emitI2X(to);
            }
        } else {
            // cast to {long,float,double} - this is verbose
            boolean error = false;
            switch (from) {
            case LONG:
                switch (to) {
                case FLOAT:   mv.visitInsn(Opcodes.L2F);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.L2D);  break;
                default:      error = true;               break;
                }
                break;
            case FLOAT:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.F2L);  break;
                case DOUBLE:  mv.visitInsn(Opcodes.F2D);  break;
                default:      error = true;               break;
                }
                break;
            case DOUBLE:
                switch (to) {
                case LONG :   mv.visitInsn(Opcodes.D2L);  break;
                case FLOAT:   mv.visitInsn(Opcodes.D2F);  break;
                default:      error = true;               break;
                }
                break;
            default:
                error = true;
                break;
            }
            if (error) {
                throw new IllegalStateException("unhandled prim cast: " + from + "2" + to);
            }
        }
    }
}