Uploaded image for project: 'JikesRVM'
  1. JikesRVM
  2. RVM-267

unsafe peephole optimization of if (x instanceof C)


    • Type: Bug
    • Status: Open
    • Priority: Low
    • Resolution: Unresolved
    • Affects Version/s: 2.9.1,, 2.9.0
    • Fix Version/s: 1000
    • Component/s: Compiler: Optimizing
    • Labels:


      See sourceforge tracker https://sourceforge.net/tracker/index.php?func=detail&aid=1147079&group_id=128805&atid=712768 for full history.

      The crux of the problem is shown by the following example:

      For example if someone happened to write Java code (or if we
      did some partial CSE on instanceof operations that resulted
      in code) like:

      boolean flag = x instanceof C
      if (flag)

      { ... }
      if (flag) { ... }

      The peephole optimization in OPT_DynamicTypeCheck isn't
      checking to see if the register defined by the instanceof
      operation has multiple uses before deciding to expand it in
      a way that results in the register not being defined to have
      a value.

      As noted in OPT_DynamicTypeCheck, what we really should be
      doing is having OPT_Simple which has def/use chains built
      look to transform the result of an instanceof whose only use
      is an IFCMP into an IF_INSTANCEOF operator. Then
      OPT_DynamicTypeCheck could simply apply this optimization to
      IF_INSTANCEOF and not try to do its own peephole optimization.

      Alternatively (instead of IF_INSTANCEOF) it might be cleaner
      (require less changes to branch optimizations, etc) to add
      an INSTANCEOF and NOT_INSTANCEOF cases to
      OPT_ConditionOperand and rewrite
      t100 = x instanceof C
      ifcmp (t100 != 0)

      ifcmp (x instanceof C)

        Gliffy Diagrams



            There are no comments yet on this issue.


              • Assignee:
                dgrove David Grove
              • Votes:
                0 Vote for this issue
                0 Start watching this issue


                • Created: