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

Add IR checks to TestExplicitRangeChecks.java

    XMLWordPrintable

Details

    Description

      The tests in test/hotspot/jtreg/compiler/rangechecks/TestExplicitRangeChecks.java exercise an optimization that folds together two range-check-like comparisons into a single, unsigned one. Currently, the tests check the correctness of the optimization, but do not assert that the optimization actually takes place. This RFE proposes adding such assertions using the IR test framework (for example, check that the optimized code contains the expected number of comparisons or uncommon traps). For example:

          // Should be compiled as a single unsigned comparison
          // 0 <= index < array.length
          @Test
          @IR(counts = {IRNode.RANGE_CHECK_TRAP, "1"})
          @IR(failOn = IRNode.UNSTABLE_IF_TRAP)
          static boolean test1_1(int index, int[] array) {
              if (index < 0 || index >= array.length) {
                  return false;
              }
              return true;
          }

      The tests use jdk.test.whitebox functionality to e.g. assert that some calls to the compiled tests result or do not result in deoptimization. A similar effect could be achieved using functionality provided by the IR test framework, e.g. compiler.lib.ir_framework.TestFramework::assertDeoptimizedByC2(Method m).

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              rcastanedalo Roberto Castaneda Lozano
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: