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

JIT confused parameter's type after inlining

    Details

    • Subcomponent:
    • Resolved In Build:
      11
    • CPU:
      sparc
    • OS:
      solaris_7

      Description

      Problem
      -------
      When calling a method with with a certain number/type of parameters, the JIT can confuse the object's type ('Class').
      This occurs while trying to inline the method. Disabling the JIT or simply preventing this method from being inlined removes the problem.
      The problem does not occur with Java2 SDK 1.3.
      This corruption can be seen by using either "parm.getClass()" or "instanceof".
      The test-case supplied shows the parameter changing from a byte[] to another user defined class. It will reproduce with byte[] changed to java.lang.Object implying not array specific.
      Removing any of the method parameters will remove the problem as will removing seemingly irrelevant code sections.


      Code Example
      ------------
      import java.util.Vector;

      public class JIT2 {
          public static void main(String [] args) {
              InstructionToDebit mj = new InstructionToDebit();

              for (int i=0;i<6;i++) {
                  mj.processMessage();
              }
          }
      }

      class InstructionToDebit {
          long myLong;

          Object o1, o2, o3, o4;

          byte[] tknListHash;
          TokenList trCopyTokens;

          InstructionToDebit() {
              tknListHash = new byte[16];
          }

          void processMessage() {
              Object v;

              try {
                  trCopyTokens = null;
                  trCopyTokens = new TokenList();

                  System.err.println("RUNNING MESSAGE");
                  System.err.println("BEFORE> " + tknListHash.getClass());

                  sendCheckAuthorisation(tknListHash,
                          myLong,
                          myLong,
                          o1,
                          o2,
                          o3,
                          o4,
                          trCopyTokens.getTrustThreshold());

                  System.err.println("AFTER> " + tknListHash.getClass());
                  System.err.println("RUNNING MESSAGE .. done");

              } catch (Exception e) {
                  e.printStackTrace();
              }

          }

          void sendCheckAuthorisation(byte[] bob,
                  long l1,
                  long l2,
                  Object o1,
                  Object o2,
                  Object o3,
                  Object o4,
                  short trustThreshold) {

              Object ob = (Object) bob;
              if (ob instanceof byte[]) {
                  System.err.println("************ NO ERROR ***************");
                  System.err.println("DURING> " + ob.getClass());
                  System.err.println("************ NO ERROR ***************");
              } else {
                  System.err.println("************ ERROR ***************");
                  System.err.println("DURING> " + ob.getClass());
                  System.err.println("************ ERROR ***************");

              }
          }
      }

      class TokenList {
          Vector tknList= new Vector();

          TokenList() {
              TokenWrapper trTkn= new TokenWrapper();
              tknList.add(trTkn);
          }

          TokenWrapper get() {
              Object y = new Object();

              return (TokenWrapper) tknList.get(0);
          }

          short getTrustThreshold() {
              TokenWrapper tkn = get();
              return(tkn.getTrustThreshold());
          }
      }

      class TokenWrapper {
          TokenRec tkn = null;

          TokenWrapper() {
              tkn = new TokenRec();
          }

          short getTrustThreshold() {
              return tkn.getTrustThreshold();
          }
      }

      class TokenRec {
          short trustThreshold = 0;

          TokenRec () {
          }

          short getTrustThreshold () {
              return trustThreshold;
          }
      }


      To Reproduce
      ------------
      Compile and run with 1.2 JDK (tested with 1.2.2_05a).

      Error output is:
      ===
      rupertk@starbucks (/share/calls/36057806/Test/Mods): java JIT2
      RUNNING MESSAGE
      BEFORE> class [B
      ************ NO ERROR ***************
      DURING> class [B
      ************ NO ERROR ***************
      AFTER> class [B
      RUNNING MESSAGE .. done
      RUNNING MESSAGE
      BEFORE> class [B
      ************ NO ERROR ***************
      DURING> class [B
      ************ NO ERROR ***************
      AFTER> class [B
      RUNNING MESSAGE .. done
      RUNNING MESSAGE
      BEFORE> class [B
      ************ NO ERROR ***************
      DURING> class [B
      ************ NO ERROR ***************
      AFTER> class [B
      RUNNING MESSAGE .. done
      RUNNING MESSAGE
      BEFORE> class [B
      ************ NO ERROR ***************
      DURING> class [B
      ************ NO ERROR ***************
      AFTER> class [B
      RUNNING MESSAGE .. done
      RUNNING MESSAGE
      BEFORE> class [B
      ************ ERROR ***************
      DURING> class TokenRec
      ************ ERROR ***************
      AFTER> class [B
      RUNNING MESSAGE .. done
      RUNNING MESSAGE
      BEFORE> class [B
      ************ ERROR ***************
      DURING> class TokenRec
      ************ ERROR ***************
      AFTER> class [B
      RUNNING MESSAGE .. done
      ===

      Problem not happening when no "* ERROR *" lines appear (only "* NO ERROR *").


      Other Related Information
      -------------------------
      Original code had access modifiers - removed these - no change.
      Tried changing names of "getTrustThreshold" to different name per class - no change.
      Tried removing other code that should be irrelevant - error vanishes.
      Changed other classes that seem to be space fillers (eg. Non-referenced "Vector v" that needs to be present) to java.lang.Object to prove irrelevance.


        Attachments

          Activity

            People

            • Assignee:
              chrisphi Chris Phillips
              Reporter:
              duke J. Duke (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: