/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 6603011
*
*/
//
// -XX:-Inline is essential to this test so that verification functions
// divi, modi, divl and modl generate "plain" divides.
// -Xcomp -Xbatch are also useful to ensure the full range of
// dividend and divisor combinations are tested
//
class s {
}
// Report verbose messages on failure; turn off to suppress
// too much output with gross numbers of failures.
static final boolean VERBOSE = true;
// Initailize DIVISOR so that it is final in this class.
static final int DIVISOR;
static {
int value = 0;
try {
} catch (Throwable e) {
}
}
// The methods of interest. We want the JIT to compile these
// and convert the divide into a multiply.
if (VERBOSE) {
// Report sign of rem failure
}
// Report range of rem failure
}
}
}
return false;
}
return true;
}
if (VERBOSE) {
// Report sign of rem failure
}
// Report range of rem failure
}
+ dividend);
}
}
return false;
}
return true;
}
public void run() {
// Don't try to divide by zero
if (divisor() == 0) return;
// Range of dividends to check. Try dividends from start to end
// inclusive, as well as variations on those values as shifted
// left.
int start = -1024;
int end = 1024;
// Test int division using a variety of dividends.
int wrong = 0;
int total = 0;
for (int s = 0; s < 32; s += 4) {
total++;
int dividend = i << s;
wrong++;
// Stop on the first failure
// break outerloop;
}
}
}
if (wrong > 0) {
}
// Test long division using a variety of dividends.
wrong = 0;
total = 0;
for (int s = 0; s < 64; s += 4) {
total++;
long dividend = ((long)i) << s;
wrong++;
// Stop on the first failure
// break outerloop;
}
}
}
if (wrong > 0) {
}
}
// Reload this class with the "divisor" property set to the input parameter.
// This allows the JIT to see q.DIVISOR as a final constant, and change
// any divisions or mod operations into multiplies.
r.run();
}
// Test every divisor between -100 and 100.
for (int i = -100; i <= 100; i++) {
test_divisor(i, apploader);
}
// Try a few divisors outside the typical range.
// The values below have been observed in rt.jar.
}
}