< prev index next >

test/compiler/rangechecks/TestRangeCheckSmearing.java

Print this page




  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8066103
  27  * @summary C2's range check smearing allows out of bound array accesses
  28  * @library /testlibrary /../../test/lib /compiler/whitebox
  29  * @modules java.base/sun.misc
  30  *          java.management
  31  * @build TestRangeCheckSmearing
  32  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  33  * @run main ClassFileInstaller com.oracle.java.testlibrary.Platform
  34  * @run main/othervm -ea -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
  35  *                   -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestRangeCheckSmearing
  36  *
  37  */
  38 
  39 import java.lang.annotation.*;
  40 import java.lang.reflect.*;
  41 import java.util.*;
  42 import sun.hotspot.WhiteBox;
  43 import sun.hotspot.code.NMethod;
  44 import com.oracle.java.testlibrary.Platform;
  45 
  46 public class TestRangeCheckSmearing {
  47     private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
  48 
  49     @Retention(RetentionPolicy.RUNTIME)
  50     @interface Args { int[] value(); }
  51 
  52     // first range check is i + max of all constants
  53     @Args({0, 8})
  54     static int m1(int[] array, int i, boolean allaccesses) {
  55         int res = 0;
  56         res += array[i+9];
  57         if (allaccesses) {
  58             res += array[i+8];
  59             res += array[i+7];
  60             res += array[i+6];
  61             res += array[i+5];
  62             res += array[i+4];
  63             res += array[i+3];
  64             res += array[i+2];




  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8066103
  27  * @summary C2's range check smearing allows out of bound array accesses
  28  * @library /testlibrary /../../test/lib /compiler/whitebox
  29  * @modules java.base/sun.misc
  30  *          java.management
  31  * @build TestRangeCheckSmearing
  32  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  33  * @run main ClassFileInstaller jdk.test.lib.Platform
  34  * @run main/othervm -ea -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
  35  *                   -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestRangeCheckSmearing
  36  *
  37  */
  38 
  39 import java.lang.annotation.*;
  40 import java.lang.reflect.*;
  41 import java.util.*;
  42 import sun.hotspot.WhiteBox;
  43 import sun.hotspot.code.NMethod;
  44 import jdk.test.lib.Platform;
  45 
  46 public class TestRangeCheckSmearing {
  47     private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
  48 
  49     @Retention(RetentionPolicy.RUNTIME)
  50     @interface Args { int[] value(); }
  51 
  52     // first range check is i + max of all constants
  53     @Args({0, 8})
  54     static int m1(int[] array, int i, boolean allaccesses) {
  55         int res = 0;
  56         res += array[i+9];
  57         if (allaccesses) {
  58             res += array[i+8];
  59             res += array[i+7];
  60             res += array[i+6];
  61             res += array[i+5];
  62             res += array[i+4];
  63             res += array[i+3];
  64             res += array[i+2];


< prev index next >