8007402: Code cleanup to remove Parfait false positive

Sat, 09 Feb 2013 12:55:09 -0800

author
drchase
date
Sat, 09 Feb 2013 12:55:09 -0800
changeset 4585
2c673161698a
parent 4584
309460dcedf7
child 4586
64d2a0a39954

8007402: Code cleanup to remove Parfait false positive
Summary: add array access range check
Reviewed-by: kvn

src/share/vm/opto/regmask.cpp file | annotate | diff | comparison | revisions
src/share/vm/opto/regmask.hpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/opto/regmask.cpp	Fri Feb 08 15:39:43 2013 -0800
     1.2 +++ b/src/share/vm/opto/regmask.cpp	Sat Feb 09 12:55:09 2013 -0800
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -241,7 +241,8 @@
    1.11        } else {                  // Else its a split-pair case
    1.12          if( bit != _A[i] ) return false; // Found many bits, so fail
    1.13          i++;                    // Skip iteration forward
    1.14 -        if( _A[i] != 1 ) return false; // Require 1 lo bit in next word
    1.15 +        if( i >= RM_SIZE || _A[i] != 1 )
    1.16 +          return false; // Require 1 lo bit in next word
    1.17        }
    1.18      }
    1.19    }
    1.20 @@ -254,7 +255,7 @@
    1.21  // Find the lowest-numbered register set in the mask.  Return the
    1.22  // HIGHEST register number in the set, or BAD if no sets.
    1.23  // Works also for size 1.
    1.24 -OptoReg::Name RegMask::find_first_set(int size) const {
    1.25 +OptoReg::Name RegMask::find_first_set(const int size) const {
    1.26    verify_sets(size);
    1.27    for (int i = 0; i < RM_SIZE; i++) {
    1.28      if (_A[i]) {                // Found some bits
    1.29 @@ -268,7 +269,7 @@
    1.30  
    1.31  //------------------------------clear_to_sets----------------------------------
    1.32  // Clear out partial bits; leave only aligned adjacent bit pairs
    1.33 -void RegMask::clear_to_sets(int size) {
    1.34 +void RegMask::clear_to_sets(const int size) {
    1.35    if (size == 1) return;
    1.36    assert(2 <= size && size <= 8, "update low bits table");
    1.37    assert(is_power_of_2(size), "sanity");
    1.38 @@ -293,7 +294,7 @@
    1.39  
    1.40  //------------------------------smear_to_sets----------------------------------
    1.41  // Smear out partial bits to aligned adjacent bit sets
    1.42 -void RegMask::smear_to_sets(int size) {
    1.43 +void RegMask::smear_to_sets(const int size) {
    1.44    if (size == 1) return;
    1.45    assert(2 <= size && size <= 8, "update low bits table");
    1.46    assert(is_power_of_2(size), "sanity");
    1.47 @@ -318,7 +319,7 @@
    1.48  }
    1.49  
    1.50  //------------------------------is_aligned_set--------------------------------
    1.51 -bool RegMask::is_aligned_sets(int size) const {
    1.52 +bool RegMask::is_aligned_sets(const int size) const {
    1.53    if (size == 1) return true;
    1.54    assert(2 <= size && size <= 8, "update low bits table");
    1.55    assert(is_power_of_2(size), "sanity");
    1.56 @@ -344,7 +345,7 @@
    1.57  //------------------------------is_bound_set-----------------------------------
    1.58  // Return TRUE if the mask contains one adjacent set of bits and no other bits.
    1.59  // Works also for size 1.
    1.60 -int RegMask::is_bound_set(int size) const {
    1.61 +int RegMask::is_bound_set(const int size) const {
    1.62    if( is_AllStack() ) return false;
    1.63    assert(1 <= size && size <= 8, "update low bits table");
    1.64    int bit = -1;                 // Set to hold the one bit allowed
    1.65 @@ -352,7 +353,7 @@
    1.66      if (_A[i] ) {               // Found some bits
    1.67        if (bit != -1)
    1.68         return false;            // Already had bits, so fail
    1.69 -      bit = _A[i] & -_A[i];     // Extract 1 bit from mask
    1.70 +      bit = _A[i] & -_A[i];     // Extract low bit from mask
    1.71        int hi_bit = bit << (size-1); // high bit
    1.72        if (hi_bit != 0) {        // Bit set stays in same word?
    1.73          int set = hi_bit + ((hi_bit-1) & ~(bit-1));
    1.74 @@ -362,12 +363,12 @@
    1.75          if (((-1) & ~(bit-1)) != _A[i])
    1.76            return false;         // Found many bits, so fail
    1.77          i++;                    // Skip iteration forward and check high part
    1.78 -        assert(size <= 8, "update next code");
    1.79          // The lower 24 bits should be 0 since it is split case and size <= 8.
    1.80          int set = bit>>24;
    1.81          set = set & -set; // Remove sign extension.
    1.82          set = (((set << size) - 1) >> 8);
    1.83 -        if (_A[i] != set) return false; // Require 1 lo bit in next word
    1.84 +        if (i >= RM_SIZE || _A[i] != set)
    1.85 +          return false; // Require expected low bits in next word
    1.86        }
    1.87      }
    1.88    }
     2.1 --- a/src/share/vm/opto/regmask.hpp	Fri Feb 08 15:39:43 2013 -0800
     2.2 +++ b/src/share/vm/opto/regmask.hpp	Sat Feb 09 12:55:09 2013 -0800
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     2.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     2.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.8   *
     2.9   * This code is free software; you can redistribute it and/or modify it
    2.10 @@ -225,22 +225,22 @@
    2.11    // Find the lowest-numbered register set in the mask.  Return the
    2.12    // HIGHEST register number in the set, or BAD if no sets.
    2.13    // Assert that the mask contains only bit sets.
    2.14 -  OptoReg::Name find_first_set(int size) const;
    2.15 +  OptoReg::Name find_first_set(const int size) const;
    2.16  
    2.17    // Clear out partial bits; leave only aligned adjacent bit sets of size.
    2.18 -  void clear_to_sets(int size);
    2.19 +  void clear_to_sets(const int size);
    2.20    // Smear out partial bits to aligned adjacent bit sets.
    2.21 -  void smear_to_sets(int size);
    2.22 +  void smear_to_sets(const int size);
    2.23    // Verify that the mask contains only aligned adjacent bit sets
    2.24    void verify_sets(int size) const { assert(is_aligned_sets(size), "mask is not aligned, adjacent sets"); }
    2.25    // Test that the mask contains only aligned adjacent bit sets
    2.26 -  bool is_aligned_sets(int size) const;
    2.27 +  bool is_aligned_sets(const int size) const;
    2.28  
    2.29    // mask is a set of misaligned registers
    2.30    bool is_misaligned_set(int size) const { return (int)Size()==size && !is_aligned_sets(size);}
    2.31  
    2.32    // Test for a single adjacent set
    2.33 -  int is_bound_set(int size) const;
    2.34 +  int is_bound_set(const int size) const;
    2.35  
    2.36    static bool is_vector(uint ireg);
    2.37    static int num_registers(uint ireg);

mercurial