8202812: [TESTBUG] Open source VM testbase compiler tests

Reviewed-by: kvn, mseledtsov
This commit is contained in:
Igor Ignatyev 2018-06-01 15:48:55 -07:00
parent 4639892e77
commit c4ec887262
467 changed files with 56718 additions and 1 deletions

View file

@ -148,6 +148,9 @@ vmTestbase/nsk/jvmti/IterateThroughHeap/filter-untagged/TestDescription.java 820
vmTestbase/gc/lock/jni/jnilock002/TestDescription.java 8191869,8192647 generic-all
vmTestbase/jit/escape/LockCoarsening/LockCoarsening001/TestDescription.java 8148743 generic-all
vmTestbase/jit/escape/LockCoarsening/LockCoarsening002/TestDescription.java 8079666 generic-all
vmTestbase/vm/mlvm/indy/func/jdi/breakpointOtherStratum/Test.java 8199578 generic-all
vmTestbase/vm/mlvm/indy/func/jdi/breakpoint/Test.java 8199578 generic-all
vmTestbase/vm/mlvm/indy/func/jvmti/redefineClassInBootstrap/TestDescription.java 8013267 generic-all

View file

@ -27,7 +27,7 @@
# It also contains test-suite configuration information.
# The list of keywords supported in this test suite
keys=cte_test jcmd nmt regression gc stress metaspace
keys=cte_test jcmd nmt regression gc stress metaspace headful
groups=TEST.groups

View file

@ -1971,6 +1971,293 @@ vmTestbase_largepages = \
vmTestbase/metaspace/shrink_grow/ShrinkGrowMultiJVM/ShrinkGrowMultiJVM.java \
vmTestbase/metaspace/shrink_grow/CompressedClassSpaceSize/TestDescription.java
# Just-In-Time compiler tests
vmTestbase_vm_compiler = \
vmTestbase/vm/compiler \
vmTestbase/jit \
vmTestbase/vm/jit
vmTestbase_vm_compiler_quick = \
vmTestbase/vm/compiler/jbe/constprop/constprop01/constprop01.java \
vmTestbase/vm/compiler/jbe/constprop/constprop02/constprop02.java \
vmTestbase/vm/compiler/jbe/dead/dead01/dead01.java \
vmTestbase/vm/compiler/jbe/dead/dead02/dead02.java \
vmTestbase/vm/compiler/jbe/dead/dead03/dead03.java \
vmTestbase/vm/compiler/jbe/dead/dead04/dead04.java \
vmTestbase/vm/compiler/jbe/dead/dead05/dead05.java \
vmTestbase/vm/compiler/jbe/dead/dead06/dead06.java \
vmTestbase/vm/compiler/jbe/dead/dead07/dead07.java \
vmTestbase/vm/compiler/jbe/dead/dead08/dead08.java \
vmTestbase/vm/compiler/jbe/dead/dead09/dead09.java \
vmTestbase/vm/compiler/jbe/dead/dead10/dead10.java \
vmTestbase/vm/compiler/jbe/dead/dead11/dead11.java \
vmTestbase/vm/compiler/jbe/dead/dead12/dead12.java \
vmTestbase/vm/compiler/jbe/dead/dead13/dead13.java \
vmTestbase/vm/compiler/jbe/dead/dead14/dead14.java \
vmTestbase/vm/compiler/jbe/dead/dead15/dead15.java \
vmTestbase/vm/compiler/jbe/dead/dead16/dead16.java \
vmTestbase/vm/compiler/jbe/hoist/hoist01/hoist01.java \
vmTestbase/vm/compiler/jbe/hoist/hoist02/hoist02.java \
vmTestbase/vm/compiler/jbe/hoist/hoist03/hoist03.java \
vmTestbase/vm/compiler/jbe/hoist/hoist04/hoist04.java \
vmTestbase/vm/compiler/jbe/subcommon/subcommon01/subcommon01.java \
vmTestbase/vm/compiler/jbe/subcommon/subcommon03/subcommon03.java \
vmTestbase/vm/compiler/jbe/subcommon/subcommon04/subcommon04.java \
vmTestbase/vm/compiler/jbe/subcommon/subcommon05/subcommon05.java \
vmTestbase/vm/compiler/coverage/parentheses/TestDescription.java \
vmTestbase/vm/compiler/optimizations/stringconcat/explicit/Explicit01/cs_disabled/TestDescription.java \
vmTestbase/vm/compiler/optimizations/stringconcat/explicit/Explicit01/cs_enabled/TestDescription.java \
vmTestbase/vm/compiler/optimizations/stringconcat/explicit/Merge01/cs_disabled/TestDescription.java \
vmTestbase/vm/compiler/optimizations/stringconcat/explicit/Merge01/cs_enabled/TestDescription.java \
vmTestbase/vm/compiler/optimizations/stringconcat/implicit/Implicit01/cs_disabled/TestDescription.java \
vmTestbase/vm/compiler/optimizations/stringconcat/implicit/Implicit01/cs_enabled/TestDescription.java \
vmTestbase/vm/compiler/optimizations/stringconcat/implicit/Merge01/cs_disabled/TestDescription.java \
vmTestbase/vm/compiler/optimizations/stringconcat/implicit/Merge01/cs_enabled/TestDescription.java \
vmTestbase/vm/compiler/optimizations/partialpeel/ForWhile/TestDescription.java \
vmTestbase/vm/compiler/optimizations/partialpeel/While/TestDescription.java \
vmTestbase/vm/compiler/optimizations/partialpeel/WhileWhile/TestDescription.java \
vmTestbase/vm/compiler/optimizations/partialpeel/Do/TestDescription.java \
vmTestbase/vm/compiler/complog/uninit/uninit001/uninit001.java \
vmTestbase/vm/compiler/complog/uninit/uninit002/uninit002.java \
vmTestbase/vm/compiler/complog/uninit/uninit003/uninit003.java \
vmTestbase/vm/compiler/complog/uninit/uninit004/uninit004.java \
vmTestbase/vm/compiler/complog/uninit/uninit005/uninit005.java \
vmTestbase/vm/compiler/complog/uninit/uninit006/uninit006.java \
vmTestbase/vm/compiler/complog/uninit/uninit007/uninit007.java \
vmTestbase/vm/compiler/complog/uninit/uninit008/uninit008.java \
vmTestbase/vm/compiler/complog/uninit/uninit009/uninit009.java \
vmTestbase/vm/compiler/complog/uninit/uninit010/uninit010.java \
vmTestbase/vm/compiler/complog/uninit/uninit011/uninit011.java \
vmTestbase/vm/compiler/complog/uninit/uninit012/uninit012.java \
vmTestbase/vm/compiler/complog/uninit/uninit013/uninit013.java \
vmTestbase/jit/Arrays/ArrayBounds/ArrayBounds.java \
vmTestbase/jit/Arrays/ArrayStoreCheck/ArrayStoreCheck.java \
vmTestbase/jit/Arrays/ArrayTests/ArrayTests.java \
vmTestbase/jit/CEETest/CEETest.java \
vmTestbase/jit/CondExpr/CondExpr.java \
vmTestbase/jit/DivTest/DivTest.java \
vmTestbase/jit/ExcOpt/ExcOpt.java \
vmTestbase/jit/FloatingPoint/FPCompare/TestFPBinop/TestFPBinop.java \
vmTestbase/jit/FloatingPoint/gen_math/Filtering/Filtering.java \
vmTestbase/jit/FloatingPoint/gen_math/Loops01/Loops01.java \
vmTestbase/jit/FloatingPoint/gen_math/Loops02/Loops02.java \
vmTestbase/jit/FloatingPoint/gen_math/Loops03/Loops03.java \
vmTestbase/jit/FloatingPoint/gen_math/Loops04/Loops04.java \
vmTestbase/jit/FloatingPoint/gen_math/Loops05/Loops05.java \
vmTestbase/jit/FloatingPoint/gen_math/Loops06/Loops06.java \
vmTestbase/jit/FloatingPoint/gen_math/Loops07/Loops07.java \
vmTestbase/jit/FloatingPoint/gen_math/Matrix_3d/Matrix_3d.java \
vmTestbase/jit/FloatingPoint/gen_math/ShortCircuitTest/ShortCircuitTest.java \
vmTestbase/jit/FloatingPoint/gen_math/Summ/Summ.java \
vmTestbase/jit/PrintProperties/PrintProperties.java \
vmTestbase/jit/PrintThis/PrintThis.java \
vmTestbase/jit/Robert/Robert.java \
vmTestbase/jit/Sleeper/Sleeper.java \
vmTestbase/jit/bounds/bounds.java \
vmTestbase/jit/collapse/collapse.java \
vmTestbase/jit/deoptimization/test01/test01.java \
vmTestbase/jit/deoptimization/test02/test02.java \
vmTestbase/jit/deoptimization/test03/test03.java \
vmTestbase/jit/deoptimization/test04/test04.java \
vmTestbase/jit/deoptimization/test05/test05.java \
vmTestbase/jit/deoptimization/test06/test06.java \
vmTestbase/jit/deoptimization/test07/test07.java \
vmTestbase/jit/deoptimization/test08/test08.java \
vmTestbase/jit/escape/AdaptiveBlocking/AdaptiveBlocking001/AdaptiveBlocking001.java \
vmTestbase/jit/escape/LockElision/MatMul/MatMul.java \
vmTestbase/jit/escape/LockCoarsening/LockCoarsening002/TestDescription.java \
vmTestbase/jit/exception/exception.java \
vmTestbase/jit/graph/cgt0/cgt0.java \
vmTestbase/jit/graph/cgt1/cgt1.java \
vmTestbase/jit/graph/cgt2/cgt2.java \
vmTestbase/jit/graph/cgt3/cgt3.java \
vmTestbase/jit/graph/cgt4/cgt4.java \
vmTestbase/jit/graph/cgt5/cgt5.java \
vmTestbase/jit/graph/cgt6/cgt6.java \
vmTestbase/jit/graph/cgt7/cgt7.java \
vmTestbase/jit/graph/cgt8/cgt8.java \
vmTestbase/jit/graph/cgt9/cgt9.java \
vmTestbase/jit/graph/cgt10/cgt10.java \
vmTestbase/jit/graph/cgt11/cgt11.java \
vmTestbase/jit/init/init01/init01.java \
vmTestbase/jit/init/init02/init02.java \
vmTestbase/jit/inline/inline003/inline003.java \
vmTestbase/jit/inline/inline004/inline004.java \
vmTestbase/jit/inline/inline005/inline005.java \
vmTestbase/jit/inline/inline007/inline007.java \
vmTestbase/jit/misctests/JitBug1/JitBug1.java \
vmTestbase/jit/misctests/Pi/Pi.java \
vmTestbase/jit/misctests/clss14702/clss14702.java \
vmTestbase/jit/misctests/fpustack/GraphApplet.java \
vmTestbase/jit/misctests/putfield00802/putfield00802.java \
vmTestbase/jit/misctests/t5/t5.java \
vmTestbase/jit/overflow/overflow.java \
vmTestbase/jit/regression/b4427606/b4427606.java \
vmTestbase/jit/regression/b4446672/b4446672.java \
vmTestbase/jit/regression/CrashC1/CrashC1.java \
vmTestbase/jit/series/series.java \
vmTestbase/jit/t/t001/t001.java \
vmTestbase/jit/t/t002/t002.java \
vmTestbase/jit/t/t003/t003.java \
vmTestbase/jit/t/t004/t004.java \
vmTestbase/jit/t/t005/t005.java \
vmTestbase/jit/t/t006/t006.java \
vmTestbase/jit/t/t007/t007.java \
vmTestbase/jit/t/t008/t008.java \
vmTestbase/jit/t/t009/t009.java \
vmTestbase/jit/t/t011/t011.java \
vmTestbase/jit/t/t012/t012.java \
vmTestbase/jit/t/t013/t013.java \
vmTestbase/jit/t/t014/t014.java \
vmTestbase/jit/t/t015/t015.java \
vmTestbase/jit/t/t016/t016.java \
vmTestbase/jit/t/t017/t017.java \
vmTestbase/jit/t/t018/t018.java \
vmTestbase/jit/t/t019/t019.java \
vmTestbase/jit/t/t020/t020.java \
vmTestbase/jit/t/t021/t021.java \
vmTestbase/jit/t/t022/t022.java \
vmTestbase/jit/t/t023/t023.java \
vmTestbase/jit/t/t024/t024.java \
vmTestbase/jit/t/t025/t025.java \
vmTestbase/jit/t/t026/t026.java \
vmTestbase/jit/t/t027/t027.java \
vmTestbase/jit/t/t028/t028.java \
vmTestbase/jit/t/t029/t029.java \
vmTestbase/jit/t/t030/t030.java \
vmTestbase/jit/t/t031/t031.java \
vmTestbase/jit/t/t032/t032.java \
vmTestbase/jit/t/t033/t033.java \
vmTestbase/jit/t/t034/t034.java \
vmTestbase/jit/t/t035/t035.java \
vmTestbase/jit/t/t036/t036.java \
vmTestbase/jit/t/t037/t037.java \
vmTestbase/jit/t/t038/t038.java \
vmTestbase/jit/t/t039/t039.java \
vmTestbase/jit/t/t040/t040.java \
vmTestbase/jit/t/t041/t041.java \
vmTestbase/jit/t/t042/t042.java \
vmTestbase/jit/t/t043/t043.java \
vmTestbase/jit/t/t044/t044.java \
vmTestbase/jit/t/t045/t045.java \
vmTestbase/jit/t/t046/t046.java \
vmTestbase/jit/t/t047/t047.java \
vmTestbase/jit/t/t048/t048.java \
vmTestbase/jit/t/t049/t049.java \
vmTestbase/jit/t/t050/t050.java \
vmTestbase/jit/t/t051/t051.java \
vmTestbase/jit/t/t052/t052.java \
vmTestbase/jit/t/t053/t053.java \
vmTestbase/jit/t/t054/t054.java \
vmTestbase/jit/t/t055/t055.java \
vmTestbase/jit/t/t056/t056.java \
vmTestbase/jit/t/t057/t057.java \
vmTestbase/jit/t/t058/t058.java \
vmTestbase/jit/t/t059/t059.java \
vmTestbase/jit/t/t060/t060.java \
vmTestbase/jit/t/t061/t061.java \
vmTestbase/jit/t/t062/t062.java \
vmTestbase/jit/t/t063/t063.java \
vmTestbase/jit/t/t064/t064.java \
vmTestbase/jit/t/t065/t065.java \
vmTestbase/jit/t/t066/t066.java \
vmTestbase/jit/t/t067/t067.java \
vmTestbase/jit/t/t068/t068.java \
vmTestbase/jit/t/t069/t069.java \
vmTestbase/jit/t/t070/t070.java \
vmTestbase/jit/t/t071/t071.java \
vmTestbase/jit/t/t072/t072.java \
vmTestbase/jit/t/t073/t073.java \
vmTestbase/jit/t/t074/t074.java \
vmTestbase/jit/t/t075/t075.java \
vmTestbase/jit/t/t076/t076.java \
vmTestbase/jit/t/t077/t077.java \
vmTestbase/jit/t/t078/t078.java \
vmTestbase/jit/t/t079/t079.java \
vmTestbase/jit/t/t080/t080.java \
vmTestbase/jit/t/t081/t081.java \
vmTestbase/jit/t/t086/t086.java \
vmTestbase/jit/t/t087/t087.java \
vmTestbase/jit/t/t088/t088.java \
vmTestbase/jit/t/t091/t091.java \
vmTestbase/jit/t/t093/t093.java \
vmTestbase/jit/t/t094/t094.java \
vmTestbase/jit/t/t095/t095.java \
vmTestbase/jit/t/t096/t096.java \
vmTestbase/jit/t/t098/t098.java \
vmTestbase/jit/t/t099/t099.java \
vmTestbase/jit/t/t100/t100.java \
vmTestbase/jit/t/t101/t101.java \
vmTestbase/jit/t/t102/t102.java \
vmTestbase/jit/t/t103/t103.java \
vmTestbase/jit/t/t104/t104.java \
vmTestbase/jit/t/t105/t105.java \
vmTestbase/jit/t/t106/t106.java \
vmTestbase/jit/t/t107/t107.java \
vmTestbase/jit/t/t108/TestDescription.java \
vmTestbase/jit/t/t109/TestDescription.java \
vmTestbase/jit/t/t110/TestDescription.java \
vmTestbase/jit/t/t111/TestDescription.java \
vmTestbase/jit/t/t112/TestDescription.java \
vmTestbase/jit/t/t113/TestDescription.java \
vmTestbase/jit/tiered/TestDescription.java \
vmTestbase/jit/verifier/VerifyInitLocal/VerifyInitLocal.java \
vmTestbase/jit/verifier/VerifyMergeStack/VerifyMergeStack.java \
vmTestbase/jit/wide/wide01/wide01.java \
vmTestbase/jit/wide/wide02/wide02.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc1/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc2/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc3/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc4/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc5/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc6/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc7/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc8/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc9/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc10/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc11/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc12/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc13/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc14/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc15/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc16/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc17/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc18/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc19/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc20/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc21/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc22/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc23/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc24/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc25/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc26/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc27/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc28/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc29/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc30/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc31/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc32/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc33/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc34/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc35/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc36/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc37/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc38/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc39/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc40/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc41/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc42/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc43/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc44/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc45/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc46/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc47/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc48/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc49/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc50/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc51/TestDescription.java \
vmTestbase/vm/jit/LongTransitions/nativeFnc52/TestDescription.java
# JSR292 tests (invokedynamic AKA Multi-Language VM AKA Da Vinci Machine)
vmTestbase_vm_mlvm = \
vmTestbase/vm/mlvm

View file

@ -0,0 +1,240 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/Arrays/ArrayBounds.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm jit.Arrays.ArrayBounds.ArrayBounds
*/
package jit.Arrays.ArrayBounds;
/*
SCCS ID : @(#)ArrayBounds.java 1.2 02/07/16
*/
/* The intent of this Java program is to expose Virtual Machines that
make illegal array bounds check removal optimizations. */
/* There are a variety of potential semantic problems with array bounds
checking.
One source of potential bounds-check problems is a compiler that
"hoist"s bounds checks outside of loops. This may either either
because an array access is loop invariant, or because the compiler
is clever enough to determine a loop-invariant "sufficient
condition" that guarantees the safety of the safety of one or more
accesses within the loop.
While this is a good approach, it has a variety of possible
pitfalls:
1) If a hoisted test fails, you can't just raise a bounds-check
exception when the test fails; the loop may have had global
side effects before the exception was supposed to have been
raised. [prematureExceptionTest]
2) A hoisted test may itself generate an exception (such as a
null pointer exception). Again, this must not be reflected
prematurely if the loop has global side effects that should be
observed.
3) An implementation might fail to be conservative enough about
the possible side effects of a method call within the loop.
For example, when an array being accessed within a loop is
accessed as a static or instance variable, then any call must
be assumed to possibly modify the array variable itself (in
the absence of pretty clever proof techniques!) So no hoisted
predicate mentioning the array length (as most will) can be
loop-invariant.
4) In some implementations, the code generated for a bounds-check
implicitly does a null check as well. For example, it may
access an array length field in the object header. On systems
where the 0-th page is protected, this might ensure an OS
signal for a null array pointer. But if a bounds check is
elided, the generated code might only access the null pointer
at a large offset, beyond the protected page, and fail to
produce a null pointer exception.
5) Multi-dimensional arrays are annoying for bounds-check removal.
If a loop over "i" accesses "a[i][j]" (where "j" is invariant in
the loop, then "a[i]" is not loop-invariant; it changes every
iteration. Even if a two-dimensional array were "rectangular"
when a loop begins, nothing guarantees that another thread
won't update some "a[k]" during the loop. If the compiler
hoisted some bounds check comparing "j" to the presumed length
of all the "a[k]", and a shorter array were written to some
"a[k]" during the loop, then we might miss a necessary array
bounds exception.
*/
import nsk.share.TestFailure;
public class ArrayBounds {
private static int global;
private static int[] aplIota(int n) {
int[] a = new int[n];
for (int j = 0; j < n; j++) a[j] = j;
return a;
}
private static int prematureExceptionWork(int[] a, int n) {
global = 0;
int sum = 0;
try {
for (int i = 0; i < n; i++) {
global++; sum += a[i];
}
} catch (ArrayIndexOutOfBoundsException t) {}
return sum;
}
private static void prematureException() {
int[] a = aplIota(10);
int sum = prematureExceptionWork(a, 11);
if (global != 11 || sum != 45) {
throw new TestFailure("Premature exception test failed.");
}
}
private static class Foo {
int[] a;
}
private static int exceptionInHoistedPredWork(Foo f, int n) {
global = 0;
int sum = 0;
try {
for (int i = 0; i < n; i++) {
global++; sum += f.a[i];
}
} catch (NullPointerException t) {}
return sum;
}
private static void exceptionInHoistedPred() {
int sum = exceptionInHoistedPredWork(null, 10);
if (global != 1 || sum != 0) {
throw new TestFailure("Premature exception test failed.");
}
}
private static void changeLength(Foo f, int n) {
int[] a = aplIota(n);
f.a = a;
}
private static int arraySideEffectWork(Foo f, int n) {
int sum = 0;
try {
for (int i = 0; i < n; i++) {
sum += f.a[i];
if (i == 0) changeLength(f, 5);
}
} catch (ArrayIndexOutOfBoundsException t) {}
return sum;
}
private static void arraySideEffect() {
int[] a = aplIota(10);
Foo f = new Foo(); f.a = a;
int sum = arraySideEffectWork(f, 10);
if (sum != 10) {
throw new TestFailure("Array side effect test failed (" + sum + ")");
}
}
private static boolean nullArrayWork(int[] a, int n) {
int sum = 0;
global = 0;
boolean x = false;
try {
for (int i = 0; i < n; i++) {
global++; sum += a[i];
}
} catch (NullPointerException t) {
x = true;
}
return x;
}
private static void nullArray() {
/* 30000 should be larger than most pages sizes! */
if (!nullArrayWork(null, 30000) || global != 1) {
throw new TestFailure("nullArray test failed.");
}
}
private static int[][] aa = new int[10][20];
static {
for (int i = 0; i < 10; i++) aa[i] = aplIota(20);
}
private static class ArrayMutator extends Thread {
int[][] aa; int newN;
ArrayMutator(int[][] aa, int newN) {
super();
this.aa = aa; this.newN = newN;
}
public void run() {
aa[1] = aplIota(newN);
}
}
private static int array2DWork(int[][] aa, int m, int n) {
int sum = 0;
global = 0;
try {
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
global++; sum += aa[i][j];
if (i == 0 && j == 0) {
Thread t = new ArrayMutator(aa, n/2);
try {
t.start();
t.join();
} catch (InterruptedException x) {}
}
}
}
} catch (ArrayIndexOutOfBoundsException t) {}
return sum;
}
private static void array2D() {
int sum = array2DWork(aa, aa.length, aa[0].length);
if (sum != 19*20/2 + 9*10/2 || global != 20 + 10 + 1) {
throw new TestFailure("array2D test failed (sum = " + sum +
"; global = " + global + ")");
}
}
public static void main(String[] args) {
exceptionInHoistedPred();
prematureException();
arraySideEffect();
nullArray();
array2D();
}
}

View file

@ -0,0 +1,66 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
// A simple program checking whether ArrayStoreExceptions are thrown
/*
* @test
*
* @summary converted from VM Testbase jit/Arrays/ArrayStoreCheck.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm jit.Arrays.ArrayStoreCheck.ArrayStoreCheck
*/
package jit.Arrays.ArrayStoreCheck;
import nsk.share.TestFailure;
class A {}
class B extends A {}
public class ArrayStoreCheck {
static void doit(A list[], A element) {
boolean caught = false;
try {
list[0] = element;
} catch (Exception ex) {
caught = true;
}
if (caught) {
System.out.println("Array store check test passed");
} else {
throw new TestFailure("Array store check test failed");
}
}
public static void main(String args[]) {
doit(new B[1], new A());
}
}

View file

@ -0,0 +1,184 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
// srm 961012
// Test if array stores and reads are correct for
// integral types and floating points
/*
* @test
*
* @summary converted from VM Testbase jit/Arrays/ArrayTests.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm jit.Arrays.ArrayTests.ArrayTests
*/
package jit.Arrays.ArrayTests;
import nsk.share.TestFailure;
public class ArrayTests {
int base_array[];
static int the_int_res = 200;
static int the_char_res = 13041864;
static int the_byte_res = -312;
static int n = 400;
ArrayTests() {
base_array = new int [n];
int start_value = n/2;
for (int i=0; i<n; i++) {
base_array[i]= start_value;
start_value--;
}
};
void print() {
for (int i=0; i<base_array.length; i++)
System.out.print(" "+base_array[i]);
// System.out.println("Result is " + the_res);
}
boolean with_chars () {
char char_array[] = new char[n];
int res = 0;
for (int i=0; i<n; i++) {
char_array[i] = (char)base_array[i];
// System.out.print (" " + (int) char_array[i]);
}
for (int i=0; i<n; i++) {
res += (int) char_array[i];
}
System.out.println("chars " + res + " == " + the_char_res);
return (res==the_char_res);
}
boolean with_bytes () {
byte byte_array[] = new byte[n];
int res = 0;
for (int i=0; i<n; i++) {
byte_array[i] = (byte)base_array[i];
}
for (int i=0; i<n; i++) {
res += (int) byte_array[i];
}
System.out.println("bytes " + res + " == " + the_byte_res);
return res==the_byte_res;
}
boolean with_shorts () {
short short_array[] = new short[n];
int res = 0;
for (int i=0; i<n; i++) {
short_array[i] = (short)base_array[i];
}
for (int i=0; i<n; i++) {
res += (int) short_array[i];
}
System.out.println("shorts " + res + " == " + the_int_res);
return res==the_int_res;
}
boolean with_ints () {
int res = 0;
for (int i=0; i<n; i++) {
res += base_array[i];
}
// base_array is integer
return (res==the_int_res);
}
boolean with_longs() {
long long_array[] = new long[n];
int res = 0;
for (int i=0; i<n; i++) {
long_array[i] = (long)base_array[i];
}
for (int i=0; i<n; i++) {
res += (int) long_array[i];
}
System.out.println("longs " + res + " == " + the_int_res);
return res==the_int_res;
}
boolean with_floats () {
float float_array[] = new float[n];
int res = 0;
for (int i=0; i<n; i++) {
float_array[i] = (float)base_array[i];
}
for (int i=0; i<n; i++) {
res += (int) float_array[i];
}
System.out.println("floats " + res + " == " + the_int_res);
return res==the_int_res;
}
boolean with_doubles () {
double double_array[] = new double[n];
int res = 0;
for (int i=0; i<n; i++) {
double_array[i] = (double)base_array[i];
}
for (int i=0; i<n; i++) {
res += (int) double_array[i];
}
System.out.println("doubles " + res + " == " + the_int_res);
return res==the_int_res;
}
void check(String msg, boolean flag) {
if (!flag) {
System.out.println("ERROR in " + msg);
}
}
boolean execute() {
// print();
boolean res = true;
res = res & with_chars(); check("chars",res);
res = res & with_shorts(); check("shorts",res);
res = res & with_bytes(); check("bytes",res);
res = res & with_ints(); check("ints",res);
res = res & with_longs(); check("longs",res);
res = res & with_floats(); check("floats",res);
res = res & with_doubles(); check("doubles",res);
return res;
}
public static void main (String s[]) {
boolean res = true;
ArrayTests at = new ArrayTests();
res = res & at.execute();
if (res) System.out.println("Array read/write testsOK (srm 10/22/96)");
else throw new TestFailure("Error in read/write array tests!");
}
}

View file

@ -0,0 +1,326 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/CEETest.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm jit.CEETest.CEETest
*/
package jit.CEETest;
import java.io.PrintStream;
import nsk.share.TestFailure;
public class CEETest {
public static final long WarmUp = 1500;
public static final long Iterations = 100000;
public static void main(String args[]) {
boolean pass = true;
for (int i=0; ( i < WarmUp ) & pass; i++) {
pass = pass & doInt();
pass = pass & doBoolean();
pass = pass & doByte();
pass = pass & doChar();
pass = pass & doShort();
pass = pass & doLong();
pass = pass & doFloat();
pass = pass & doDouble();
pass = pass & doObject();
pass = pass & doBitOps();
}
long start = System.currentTimeMillis() ;
for (int i=0; i<Iterations & pass; i++) {
pass = pass & doInt();
pass = pass & doBoolean();
pass = pass & doByte();
pass = pass & doChar();
pass = pass & doShort();
pass = pass & doLong();
pass = pass & doFloat();
pass = pass & doDouble();
pass = pass & doObject();
pass = pass & doBitOps();
}
long duration = System.currentTimeMillis() - start;
if (true == pass) {
System.out.println ("CEETest PASSed in " + duration + " ms.");
}
else {
throw new TestFailure("CEETest FAILed in " + duration + " ms.");
}
}
public static boolean doInt () {
int x = 0;
int y = 1;
int a = (x == y) ? x : y;
int b = (x != y) ? y : x;
int c = (x < y) ? y : x;
int d = (x > y) ? x : y;
int e = (x <= y) ? y : x;
int f = (x >= y) ? x : y;
if ( (a != y) ||
(b != y) ||
(c != y) ||
(d != y) ||
(e != y) ||
(f != y) ) {
System.err.println ("doInt() failed");
return false;
}
else {
return true;
}
}
public static boolean doBoolean () {
boolean x = false;
boolean y = !x;
boolean a = (x == y) ? x : y;
boolean b = (x != y) ? y : x;
if ( (a == y) &&
(b == y) ) {
return true;
}
else {
System.err.println ("doBoolean() failed");
return false;
}
}
public static boolean doByte () {
byte x = 0;
byte y = 1;
byte a = (x == y) ? x : y;
byte b = (x != y) ? y : x;
byte c = (x < y) ? y : x;
byte d = (x > y) ? x : y;
byte e = (x <= y) ? y : x;
byte f = (x >= y) ? x : y;
if ( (a != y) ||
(b != y) ||
(c != y) ||
(d != y) ||
(e != y) ||
(f != y) ) {
System.err.println ("doByte() failed");
return false;
}
else {
return true;
}
}
public static boolean doChar () {
char x = 0;
char y = 1;
char a = (x == y) ? x : y;
char b = (x != y) ? y : x;
char c = (x < y) ? y : x;
char d = (x > y) ? x : y;
char e = (x <= y) ? y : x;
char f = (x >= y) ? x : y;
if ( (a == y) &&
(b == y) &&
(c == y) &&
(d == y) &&
(e == y) &&
(f == y) ) {
return true;
}
else {
System.err.println ("doChar() failed");
return false;
}
}
public static boolean doShort () {
short x = 0;
short y = 1;
short a = (x == y) ? x : y;
short b = (x != y) ? y : x;
short c = (x < y) ? y : x;
short d = (x > y) ? x : y;
short e = (x <= y) ? y : x;
short f = (x >= y) ? x : y;
if ( (a != y) ||
(b != y) ||
(c != y) ||
(d != y) ||
(e != y) ||
(f != y) ) {
System.err.println ("doShort() failed");
return false;
}
else {
return true;
}
}
public static boolean doLong () {
long x = 0;
long y = 1;
long a = (x == y) ? x : y;
long b = (x != y) ? y : x;
long c = (x < y) ? y : x;
long d = (x > y) ? x : y;
long e = (x <= y) ? y : x;
long f = (x >= y) ? x : y;
if ( (a == y) &&
(b == y) &&
(c == y) &&
(d == y) &&
(e == y) &&
(f == y) ) {
return true;
}
else {
System.err.println ("doLong() failed");
return false;
}
}
public static boolean doFloat () {
float x = 0.0f;
float y = 1.0f;
float a = (x == y) ? x : y;
float b = (x != y) ? y : x;
float c = (x < y) ? y : x;
float d = (x > y) ? x : y;
float e = (x <= y) ? y : x;
float f = (x >= y) ? x : y;
if ( (a != y) ||
(b != y) ||
(c != y) ||
(d != y) ||
(e != y) ||
(f != y) ) {
System.err.println ("doFloat() failed");
return false;
}
else {
return true;
}
}
public static boolean doDouble () {
double x = 0.0;
double y = 1.0;
double a = (x == y) ? x : y;
double b = (x != y) ? y : x;
double c = (x < y) ? y : x;
double d = (x <= y) ? y : x;
double e = (x > y) ? x : y;
double f = (x >= y) ? x : y;
if ( (a == y) &&
(b == y) &&
(c == y) &&
(d == y) &&
(e == y) &&
(f == y) ) {
return true;
}
else {
System.err.println ("doDouble() failed");
return false;
}
}
public static boolean doObject () {
String x = new String("x");
String y = new String("y");
String a = (x == y) ? x : y;
String b = (x != y) ? y : x;
String c = (x instanceof String) ? y : x;
if ( (a != y) ||
(b != y) ||
(c != y) ) {
System.err.println ("doBoolean() failed");
return false;
}
else {
return true;
}
}
public static boolean doBitOps () {
int x = 0;
int y = 1;
int a = x; a += y;
int b = (x == y) ? x : (x | y);
int c = (x == y) ? x : (x ^ y);
int d = (x == y) ? x : (y & y);
int e = (x == y) ? x : (y % 2);
int f = (x == y) ? x : (2 >> y);
int g = (x == y) ? x : (~-2);
if ( (a == y) &&
(b == y) &&
(c == y) &&
(d == y) &&
(e == y) &&
(f == y) &&
(g == y) ) {
return true;
} else {
System.err.println ("doBoolean() failed");
return false;
}
}
}

View file

@ -0,0 +1,93 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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 the conditional expressions
/*
* @test
*
* @summary converted from VM Testbase jit/CondExpr.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm jit.CondExpr.CondExpr
*/
package jit.CondExpr;
import nsk.share.TestFailure;
public class CondExpr {
public static void trace (String s, int res) {
System.out.println("test result for " + s + " is " + res);
}
public static int test_int1(int arg) { return (arg==10) ? 1 : 2; }
public static int test_int(int arg) { return test_int1(arg) + test_int1(arg+1); }
public static long test_long1(long arg) { return (arg==10) ? 1l : 2l; }
public static int test_long(long arg) { return (int)(test_long1(arg) + test_long1(arg+1)); }
public static float test_float1(float arg) { return (arg==10.0f) ? 1.0f : 2.0f; }
public static int test_float(float arg) { return (int)(test_float1(arg) + test_float1(arg+1)); }
public static double test_double1(double arg) { return (arg==10.0) ? 1.0 : 2.0; }
public static int test_double(double arg) { return (int)(test_double1(arg) + test_double1(arg+1)); }
public static int nested_test_int1(int arg) {
return (arg>1) ? ((arg==10) ? 1 : 2) : ((arg==-10) ? 3: 4);
}
public static int nested_test_int (int arg) {
return (nested_test_int1 (arg) + nested_test_int1 (arg+1) + nested_test_int1 (-arg) + nested_test_int1 (-arg-1)); }
public static void main(String s[]) {
System.out.println ("Testing conditional expressions (srm 10/22)");
boolean correct = true;
int res = 0;
res = test_int(10); trace("test_int", res);
correct = correct & ( res == 3);
res = test_long(10l); trace("test_long", res);
correct = correct & ( res == 3);
res = test_float(10.0f); trace("test_float", res);
correct = correct & ( res == 3);
res = test_double(10.0); trace("test_double", res);
correct = correct & ( res == 3);
res = nested_test_int(10); trace("nested_test_int", res);
correct = correct & ( res == 10);
if (correct) System.out.println("Correct!");
else throw new TestFailure("ERRROR in conditional expressions");
}
}

View file

@ -0,0 +1,65 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
// DivTest.java
// bug-12
/*
* @test
*
* @summary converted from VM Testbase jit/DivTest.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.DivTest.DivTest
* @run driver ExecDriver --java jit.DivTest.DivTest
*/
package jit.DivTest;
import nsk.share.TestFailure;
class DivTest{
static int n;
static boolean test1 (int n1, int n2) {
try {
n = n1 / n2;
System.out.println(n);
return true;
} catch (Exception e) {
System.out.println(e);
return false;
}
}
public static void main(String s[]) {
boolean failed;
failed = test1 (-1, 0);
failed |= !test1 (-1, 0x80000000);
failed |= !test1 (0, -1);
failed |= !test1 (0x80000000, -1);
if (failed)
throw new TestFailure("Test failed");
}
}

View file

@ -0,0 +1,70 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
// tests exception handler inside optimizable loops and around them
/*
* @test
*
* @summary converted from VM Testbase jit/ExcOpt.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm jit.ExcOpt.ExcOpt
*/
package jit.ExcOpt;
import nsk.share.TestFailure;
public class ExcOpt {
static int x;
public static void main (String s[]) {
x = 0;
try {
for (int i = 1; i < 100; i++) {
x += 1;
}
} catch (Exception e) {
x = 0;
}
for (int i=1; i < 100; i++) {
try {
x += 1;
} catch (Exception e) {
x = 0;
}
}
System.out.println("Done " + x);
if (x != 198)
throw new TestFailure("Test failed (x != 198)");
}
}

View file

@ -0,0 +1,416 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/FloatingPoint/FPCompare/TestFPBinop.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm jit.FloatingPoint.FPCompare.TestFPBinop.TestFPBinop
*/
package jit.FloatingPoint.FPCompare.TestFPBinop;
import nsk.share.TestFailure;
import nsk.share.GoldChecker;
/** Test of Floating Point Binary Ops.
** This is intended to be run on a known-correct system and the
** answer compared with the golden answer with diff or equivalent.
*/
public class TestFPBinop {
public static final GoldChecker goldChecker = new GoldChecker( "TestFPBinop" );
static float floatValues [] = {
Float.MIN_VALUE, Float.MAX_VALUE,
-Float.MIN_VALUE, -Float.MAX_VALUE,
-1.0f, 1.0f, -0.0f, 0.0f,
Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY,
Float.NaN
};
static double doubleValues [] = {
Double.MIN_VALUE, Double.MAX_VALUE,
-Double.MIN_VALUE, -Double.MAX_VALUE,
-1.0, 1.0, -0.0, 0.0,
Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY,
Double.NaN
};
static int nValues = floatValues.length;
static float fOne, fZero;
static double dOne, dZero;
/* This is intended to thrwart an optimizing compiler
* from simplifying some of the expressions by using algebraic
* identities. */
static {
fOne = new Integer(1).floatValue();
fZero = new Integer(0).floatValue();
dOne = new Integer(1).doubleValue();
dZero = new Integer(0).doubleValue();
}
static final boolean DEBUG = false;
static String operandType = "";
// static values
static float xs, ys;
static double xS, yS;
/** Test of Floating Point Binary operators.
** The following orthogonal variables need to be tested.
** <ul>
** <li> Data type: float or double
** <li> Operator: +, -, *, /
** <li> Data values: +-normal, +-zero, NaN, +-infinity, +- min, +-max
** <li> Operand: variable, parameter, static, field, array element,
** function reference, expression, explicit constant.
** </ul>
*/
public static void main (String [] args) {
testFloats();
testDoubles();
TestFPBinop.goldChecker.check();
}
static void testFloats() {
for (int i = 0; i < floatValues.length; i++) {
float iVal = floatValues[i];
for (int j = 0; j < floatValues.length; j++) {
float jVal = floatValues[j];
testFloat(iVal, jVal);
}
}
}
static void testDoubles() {
for (int i = 0; i < doubleValues.length; i++) {
double iVal = doubleValues[i];
for (int j = 0; j < doubleValues.length; j++) {
double jVal = doubleValues[j];
testDouble(iVal, jVal);
}
}
}
static void testFloat (float x, float y) {
testFloatP(x, y);
testFloatL(x, y);
testFloatS(x, y);
testFloatF(x, y);
testFloatA(x, y);
testFloatM(x, y);
testFloat1(x, y);
testFloat2(x, y);
testFloat3(x, y);
}
static void testFloatP(float x, float y) {
check(x, y, x + y, "param", "+");
check(x, y, x - y, "param", "-");
check(x, y, x * y, "param", "*");
check(x, y, x / y, "param", "/");
}
static void testFloatL(float x, float y) {
float xl = x;
float yl = y;
check(xl, yl, xl + yl, "local", "+");
check(xl, yl, xl - yl, "local", "-");
check(xl, yl, xl * yl, "local", "*");
check(xl, yl, xl / yl, "local", "/");
}
static void testFloatS(float x, float y) {
xs = x;
ys = y;
check(xs, ys, xs + ys, "static", "+");
check(xs, ys, xs - ys, "static", "-");
check(xs, ys, xs * ys, "static", "*");
check(xs, ys, xs / ys, "static", "/");
}
static void testFloatF(float x, float y) {
FloatObject xo = new FloatObject(x);
FloatObject yo = new FloatObject(y);
check(xo.f, yo.f, xo.f + yo.f, "field", "+");
check(xo.f, yo.f, xo.f - yo.f, "field", "-");
check(xo.f, yo.f, xo.f * yo.f, "field", "*");
check(xo.f, yo.f, xo.f / yo.f, "field", "/");
}
static void testFloatA(float x, float y) {
int i = index(x);
int j = index(y);
float a [] = floatValues;
check(a[i], a[j], a[i] + a[j], "a[i]", "+");
check(a[i], a[j], a[i] - a[j], "a[i]", "-");
check(a[i], a[j], a[i] * a[j], "a[i]", "*");
check(a[i], a[j], a[i] / a[j], "a[i]", "/");
}
static void testFloatM(float x, float y) {
check(i(x), i(y), i(x) + i(y), "f(x)", "+");
check(i(x), i(y), i(x) - i(y), "f(x)", "-");
check(i(x), i(y), i(x) * i(y), "f(x)", "*");
check(i(x), i(y), i(x) / i(y), "f(x)", "/");
}
static void testFloat1(float x, float y) {
float zero = fZero;
float one = fOne;
check(((x + zero) * one), y, ((x + zero) * one) + y, "lExpr", "+");
check(((x + zero) * one), y, ((x + zero) * one) - y, "lExpr", "-");
check(((x + zero) * one), y, ((x + zero) * one) * y, "lExpr", "*");
check(((x + zero) * one), y, ((x + zero) * one) / y, "lExpr", "/");
}
static void testFloat3(float x, float y) {
float zero = fZero;
float one = fOne;
check(((x + zero) * one), (zero + one * y), ((x + zero) * one) + (zero + one * y), "exprs", "+");
check(((x + zero) * one), (zero + one * y), ((x + zero) * one) - (zero + one * y), "exprs", "-");
check(((x + zero) * one), (zero + one * y), ((x + zero) * one) * (zero + one * y), "exprs", "*");
check(((x + zero) * one), (zero + one * y), ((x + zero) * one) / (zero + one * y), "exprs", "/");
}
static void testFloat2(float x, float y) {
float zero = fZero;
float one = fOne;
operandType = "rExpr";
check(x, (zero + one * y), x + (zero + one * y), "rExpr", "+");
check(x, (zero + one * y), x - (zero + one * y), "rExpr", "-");
check(x, (zero + one * y), x * (zero + one * y), "rExpr", "*");
check(x, (zero + one * y), x / (zero + one * y), "rExpr", "/");
}
static void testDouble (double x, double y) {
testDoubleP(x, y);
testDoubleL(x, y);
testDoubleS(x, y);
testDoubleF(x, y);
testDoubleA(x, y);
testDoubleM(x, y);
testDouble1(x, y);
testDouble2(x, y);
testDouble3(x, y);
}
static void testDoubleP (double x, double y) {
check(x, y, x + y, "param", "+");
check(x, y, x - y, "param", "-");
check(x, y, x * y, "param", "*");
check(x, y, x / y, "param", "/");
}
static void testDoubleL (double x, double y) {
double xl = x;
double yl = y;
check(xl, yl, xl + yl, "local", "+");
check(xl, yl, xl - yl, "local", "-");
check(xl, yl, xl * yl, "local", "*");
check(xl, yl, xl / yl, "local", "/");
}
static void testDoubleS (double x, double y) {
xS = x;
yS = y;
check(xS, yS, xS + yS, "static", "+");
check(xS, yS, xS - yS, "static", "-");
check(xS, yS, xS * yS, "static", "*");
check(xS, yS, xS / yS, "static", "/");
}
static void testDoubleF (double x, double y) {
DoubleObject xo = new DoubleObject(x);
DoubleObject yo = new DoubleObject(y);
check(xo.f, yo.f, xo.f + yo.f, "field", "+");
check(xo.f, yo.f, xo.f - yo.f, "field", "-");
check(xo.f, yo.f, xo.f * yo.f, "field", "*");
check(xo.f, yo.f, xo.f / yo.f, "field", "/");
}
static void testDoubleA (double x, double y) {
int i = index(x);
int j = index(y);
double a [] = doubleValues;
check(a[i], a[j], a[i] + a[j], "a[i]", "+");
check(a[i], a[j], a[i] - a[j], "a[i]", "-");
check(a[i], a[j], a[i] * a[j], "a[i]", "*");
check(a[i], a[j], a[i] / a[j], "a[i]", "/");
}
static void testDoubleM (double x, double y) {
check(i(x), i(y), i(x) + i(y), "f(x)", "+");
check(i(x), i(y), i(x) - i(y), "f(x)", "-");
check(i(x), i(y), i(x) * i(y), "f(x)", "*");
check(i(x), i(y), i(x) / i(y), "f(x)", "/");
}
static void testDouble1 (double x, double y) {
double zero = dZero;
double one = dOne;
check(((x + zero) * one), y, ((x + zero) * one) + y, "lExpr", "+");
check(((x + zero) * one), y, ((x + zero) * one) - y, "lExpr", "-");
check(((x + zero) * one), y, ((x + zero) * one) * y, "lExpr", "*");
check(((x + zero) * one), y, ((x + zero) * one) / y, "lExpr", "/");
}
static void testDouble3 (double x, double y) {
double zero = dZero;
double one = dOne;
check(((x + zero) * one), (zero + one * y), ((x + zero) * one) + (zero + one * y), "exprs", "+");
check(((x + zero) * one), (zero + one * y), ((x + zero) * one) - (zero + one * y), "exprs", "-");
check(((x + zero) * one), (zero + one * y), ((x + zero) * one) * (zero + one * y), "exprs", "*");
check(((x + zero) * one), (zero + one * y), ((x + zero) * one) / (zero + one * y), "exprs", "/");
}
static void testDouble2 (double x, double y) {
double zero = dZero;
double one = dOne;
check(x, (zero + one * y), x + (zero + one * y), "rExpr", "+");
check(x, (zero + one * y), x - (zero + one * y), "rExpr", "-");
check(x, (zero + one * y), x * (zero + one * y), "rExpr", "*");
check(x, (zero + one * y), x / (zero + one * y), "rExpr", "/");
}
/* The convoluted coding is intended to prevent inlining */
static float i(float x) {
while (Float.isNaN(x) && Float.floatToIntBits(x) == 0) {
x = 0.0f;
}
return x;
}
static double i(double x) {
while (Double.isNaN(x) && Double.doubleToLongBits(x) == 0L) {
x = 0.0;
}
return x;
}
static int index(float x) {
for (int i = 0; i < floatValues.length; i++) {
if (new Float(x).equals(new Float(floatValues[i])))
return i;
}
throw new TestFailure("ERROR: can't find " + x + " in floatValues.");
}
static int index(double x) {
for (int i = 0; i < doubleValues.length; i++) {
if (new Double(x).equals(new Double(doubleValues[i])))
return i;
}
throw new TestFailure("ERROR: can't find " + x + " in doubleValues.");
}
static void check (float x, float y, float result,
String operands, String operator) {
TestFPBinop.goldChecker.println(x + " " + operator + " " + y +
" = " + result + ", with float " +
operands + " operands");
}
static void check (double x, double y, double result,
String operands, String operator) {
TestFPBinop.goldChecker.println(x + " " + operator + " " + y +
" = " + result + ", with double " +
operands + " operands");
}
}
class FloatObject {
public float f;
public FloatObject(float x) {
f = x;
}
}
class DoubleObject {
public double f;
public DoubleObject(double x) {
f = x;
}
}

View file

@ -0,0 +1,161 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/FloatingPoint/gen_math/Filtering.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.FloatingPoint.gen_math.Filtering.Filtering
* @run driver ExecDriver --java jit.FloatingPoint.gen_math.Filtering.Filtering
*/
package jit.FloatingPoint.gen_math.Filtering;
import nsk.share.TestFailure;
class Filtering
{
static int N = 1000;
static double xx[];
static double yy[];
public static void main (String args[])
{
double Error = 0.0001;
xx = new double[N];
yy = new double[N];
double r1, r2, r3, r4;
double rn = N;
double dx = 1/rn;
double A = 0.5;
double B = 0.75;
for(int i = 0; i < N; i++)
{ r1 = i * dx;
xx[i] = A * Math.sin(3 * r1) + B * Math.cos(3 * r1);
}
Filtering ff;
ff = new Filtering();
double normaX = ff.Norma1(N,xx);
ff.Filter1(N);
double norma1 = ff.Norma1(N,yy);
ff.Filter2(N);
double norma2 = ff.Norma1(N,yy);
ff.Filter3(N);
double norma3 = ff.Norma1(N,yy);
r4 = (norma1 * norma1 + norma2 * norma2 + norma3 * norma3) / 3 ;
r4 = Math.sqrt(r4);
double errrr = Math.abs(r4 - normaX);
ff.Echeck(errrr,Error);
}
public double Norma1(int nn, double uu[])
{
double nor = 0;
double r1 = nn;
double r2;
for(int i = 0; i < nn; i++)
{ r2 = uu[i] * uu[i];
nor = nor + r2;
}
nor = nor / r1;
return nor;
}
public void Filter1 (int nn)
{ yy[0] = xx[0];
yy[nn - 1] = xx[nn - 1];
for(int i = 1; i < nn - 1; i++)
{
yy[i] = 0.5 * (xx[i - 1] + xx[i + 1]);
}
}
public void Filter2 (int nn)
{ yy[0] = xx[0];
yy[nn - 1] = xx[nn - 1];
for(int i = 1; i < nn - 1; i++)
{
yy[i] = 0.25 * (xx[i - 1] + 2 * xx[i] + xx[i + 1]);
}
}
public void Filter3 (int nn)
{ yy[0] = xx[0];
yy[nn - 1] = xx[nn - 1];
yy[1] = 0.5 * (xx[0] + xx[2]);
yy[nn - 2] = 0.5 * (xx[nn - 1] + xx[nn - 3]);
for(int i = 2; i < nn - 2; i++)
{
yy[i] = 0.1 * (xx[i - 2] + 2 * xx[i - 1] + 4 * xx[i] +
2 * xx[i + 1] + xx[i + 2]);
}
}
public void Echeck(double er, double ER)
{
if( er < ER)
System.out.println("test PASS");
else
{
System.out.println("expected error: " + ER);
System.out.println(" found error: " + er);
throw new TestFailure("test FAIL");
}
}
}

View file

@ -0,0 +1,120 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/FloatingPoint/gen_math/Loops01.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.FloatingPoint.gen_math.Loops01.Loops01
* @run driver ExecDriver --java jit.FloatingPoint.gen_math.Loops01.Loops01
*/
package jit.FloatingPoint.gen_math.Loops01;
import nsk.share.TestFailure;
class Loops01
{
static final int N = 500;
public static void main (String args[])
{
double Error = 0.01;
double xx[][];
xx = new double[N][N];
double rn = N;
double dx = 1/rn;
double dy = 1/rn;
double r1, r2, r3, r4, r5;
Loops01 ll;
ll = new Loops01();
for(int i = 0; i < N; i++)
{ for(int j = 0; j < N; j++)
{
r1 = i * dx;
r2 = j * dy;
r3 = Math.sqrt(r1 * r1 + r2 * r2);
r4 = Math.sin(4 * r1) + Math.cos(4 * r2);
r5 = r3 * (2 + r4);
xx[i][j] = r5;
}
}
double norma = ll.Norma(N,xx);
double er = Math.abs(2.5 - norma);
ll.Echeck(er,Error);
}
public double Norma(int nn, double ww[][])
{
double nor = 0;
double r1 = nn;
double r2 = r1 * r1;
double r3;
for(int i = 0; i < nn; i++)
{
for(int j = 0; j < nn; j++)
{ r3 = ww[i][j] * ww[i][j];
nor = nor + r3;
}
}
nor = nor/r2;
return nor;
}
public void Echeck(double er, double ER)
{
if( er < ER)
System.out.println("test PASS");
else
{
System.out.println("expected error: " + ER);
System.out.println(" found error: " + er);
throw new TestFailure("test FAIL");
}
}
}

View file

@ -0,0 +1,95 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/FloatingPoint/gen_math/Loops02.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.FloatingPoint.gen_math.Loops02.Loops02
* @run driver ExecDriver --java jit.FloatingPoint.gen_math.Loops02.Loops02
*/
package jit.FloatingPoint.gen_math.Loops02;
// Test working with loops and random functions.
import nsk.share.TestFailure;
class Loops02
{
static final int N = 300;
public static void main (String args[])
{
double x;
double r1, r2, r3;
double rn = N;
double dx = 1/rn;
double Min_count = rn/2;
Loops02 ll;
ll = new Loops02();
x = 0.5;
int count = 0;
do
{
r1 = Math.random();
r2 = Math.random();
x = x + dx * (r1 - r2);
count++;
} while(x > 0 && x < 1);
ll.Echeck(Min_count,count);
}
public void Echeck(double er, double ER)
{
if( er < ER)
System.out.println("test PASS");
else
{
System.out.println("expected error: " + ER);
System.out.println(" found error: " + er);
throw new TestFailure("test FAIL");
}
}
}

View file

@ -0,0 +1,119 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/FloatingPoint/gen_math/Loops03.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.FloatingPoint.gen_math.Loops03.Loops03
* @run driver ExecDriver --java jit.FloatingPoint.gen_math.Loops03.Loops03
*/
package jit.FloatingPoint.gen_math.Loops03;
import nsk.share.TestFailure;
class Loops03
{
static final int N = 100000;
public static void main (String args[])
{
double x;
double r1, r2, r3, r4, r5, r6, r7;
double Error = 0.001;
Loops03 ll;
ll = new Loops03();
int i = 1;
double sum = 0;
double prod = 1;
while(i < N)
{ r1 = ll.Random_arg(i);
r3 = Math.sin(r1);
r4 = Math.cos(r1);
r5 = r3 * r3 + r4 * r4;
r6 = i + i;
r7 = r6 * r6;
sum = sum + r5/r7;
r2 = ll.Random_arg(i);
r3 = Math.sin(r1);
r4 = Math.cos(r1);
r5 = r3 * r3 + r4 * r4;
r6 = i + i;
r7 = r6 * r6;
prod = prod * (1 + r5/r7);
i++;
}
double er1 = Math.abs(sum - 0.411);
double er2 = Math.abs(prod - 1.465);
double errrr = Math.sqrt(er1 * er1 + er2 * er2);
ll.Echeck(errrr,Error);
}
// method below return double random number in interval
// (0, int nn)
public double Random_arg(int nn)
{
double rr;
rr = Math.random();
double rn = nn;
double ru = rr * rn;
return ru;
}
public void Echeck(double er, double ER)
{
if( er < ER)
System.out.println("test PASS");
else
{
System.out.println("expected error: " + ER);
System.out.println(" found error: " + er);
throw new TestFailure("test FAIL");
}
}
}

View file

@ -0,0 +1,135 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/FloatingPoint/gen_math/Loops04.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.FloatingPoint.gen_math.Loops04.Loops04
* @run driver ExecDriver --java jit.FloatingPoint.gen_math.Loops04.Loops04
*/
package jit.FloatingPoint.gen_math.Loops04;
// Test working with nested loops.
import nsk.share.TestFailure;
class Loops04
{
public static void main (String args[])
{
int N = 25;
double Error = 0.01;
double xx[];
double yy[];
double zz[];
xx = new double[N];
yy = new double[N];
zz = new double[N];
Loops04 ll;
ll = new Loops04();
for(int i = 0; i < N; i++)
{
xx[i] = i;
yy[i] = i + 1;
zz[i] = Math.max(xx[i],yy[i]);
}
double x_max = 0; double x_min = 0;
double y_max = 0; double y_min = 0;
double z_max = 0; double z_min = 0;
for(int i = 1; i< N - 1; i++)
{
xx[i] = 1;
for(int j = 1; j < N - 1; j++)
{
yy[j] = 2;
for(int k = 1; k< N - 1; k++)
{
zz[k] = 3;
for(int n = 1; n < N - 1; n++)
{
xx[i] = 0.5 * (yy[i - 1] + yy[i + 1]);
yy[j] = 0.5 * (zz[j - 1] + zz[j + 1]);
zz[k] = 0.5 * (xx[k - 1] + xx[k + 1]);
x_max = Math.max(x_max, xx[i]);
x_min = Math.min(x_min, xx[i]);
y_max = Math.max(y_max, yy[j]);
y_min = Math.min(y_min, yy[j]);
z_max = Math.max(z_max, zz[k]);
z_min = Math.min(z_min, zz[k]);
}
}
}
}
double xy_max = Math.max(x_max,y_max);
double xy_min = Math.min(x_min,y_min);
double xy_MaxMin = xy_max - xy_min;
System.out.println(xy_MaxMin);
double er = Math.abs(xy_MaxMin - 23.6407);
ll.Echeck(er,Error);
}
public void Echeck(double er, double ER)
{
if( er < ER)
System.out.println("test PASS");
else
{
System.out.println("expected error: " + ER);
System.out.println(" found error: " + er);
throw new TestFailure("test FAIL");
}
}
}

View file

@ -0,0 +1,144 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/FloatingPoint/gen_math/Loops05.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.FloatingPoint.gen_math.Loops05.Loops05
* @run driver ExecDriver --java jit.FloatingPoint.gen_math.Loops05.Loops05
*/
package jit.FloatingPoint.gen_math.Loops05;
import nsk.share.TestFailure;
class Loops05
{
static final int N = 100;
static final double pi = 3.14;
public static void main (String args[])
{
double Error = 0.01;
double xx[][];
xx = new double[N][N];
double x_norma_n, x_norma_0;
double t = 0;
double dt = 0.01;
double tn = 1;
double r1, r2, r3, r4, r5;
Loops05 ll;
ll = new Loops05();
for(int i = 0; i < N; i++)
{ for(int j = 0; j < N; j++)
{
r1 = i * i + j * j;
r2 = N;
r3 = r1/N;
r4 = r3/N;
xx[i][j] = r4;
}
}
x_norma_0 = ll.Norma(N,xx);
while(t < tn)
{
for(int i = 0; i < N; i++)
{
for(int j = 0; j < N; j++)
{
double fff = ll.F_function(t, 0.2, 0.6, 10);
xx[i][j]= xx[i][j] + fff * dt;
}
}
t = t + dt;
}
x_norma_n = ll.Norma(N,xx);
double errrr = Math.abs(x_norma_0 - x_norma_n);
ll.Echeck(errrr,Error);
}
public double F_function(double tt, double t1, double t2, double magn)
{ double fff;
double r1;
r1 = Math.sin(2 * pi * tt / (t2 - t1));
if(tt > t1 && tt < t2) fff = r1 * magn;
else fff = 0;
return fff;
}
public double Norma(int nn, double ww[][])
{
double nor = 0;
double r1 = nn;
double r2 = r1 * r1;
double r3;
for(int i = 0; i < nn; i++)
{
for(int j = 0; j < nn; j++)
{ r3 = ww[i][j] * ww[i][j];
nor = nor + r3;
}
}
nor = nor/r2;
return nor;
}
public void Echeck(double er, double ER)
{
if( er < ER)
System.out.println("test PASS");
else
{
System.out.println("expected error: " + ER);
System.out.println(" found error: " + er);
throw new TestFailure("test FAIL");
}
}
}

View file

@ -0,0 +1,146 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/FloatingPoint/gen_math/Loops06.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.FloatingPoint.gen_math.Loops06.Loops06
* @run driver ExecDriver --java jit.FloatingPoint.gen_math.Loops06.Loops06
*/
package jit.FloatingPoint.gen_math.Loops06;
import nsk.share.TestFailure;
class Loops06
{
static final int N = 20;
static final double pi = 3.14;
public static void main (String args[])
{
double Error = 0.01;
double xx[];
double yy[];
double zz[];
xx = new double[N];
yy = new double[N];
zz = new double[N];
double r1, r2, r3, r4, r5;
double rN = N;
Loops06 ll;
ll = new Loops06();
for(int i = 0; i < N; i++)
{ r1 = i;
xx[i] = Math.sin( 2 * pi * r1 / rN);
}
int i=0;
while( i < N)
{ r2 = i;
yy[i] = xx[i] * Math.sin(r2);
zz[i] = xx[i] * Math.cos(r2);
i++;
}
for( i = 1; i < N - 1; i++)
{
for(int j = 1; j < N - 1; j++)
{ zz[0] = 0;
for(int k = 1; k < N - 1; k++)
{
for(int n = 1; n < N - 1; n++)
{ yy[0] = 0;
for(int m = 1; m < N - 1; m++)
{
for(int l = 1; l < N - 1; l++)
{
xx[i] = xx[i - 1] + xx[i+1];
}
}
}
}
}
}
double norma_x = ll.norma(N,xx);
double norma_y = ll.norma(N,yy);
double norma_z = ll.norma(N,zz);
r5 = norma_x * norma_x + norma_y * norma_y + norma_z * norma_z;
double total_norma = Math.sqrt(r5);
double errrr = Math.abs(total_norma - 0.83);
ll.Echeck(errrr,Error);
}
public double norma(int nn, double ww[])
{
double nor = 0;
double r1 = nn;
double r2 = r1 * r1;
double r3;
for(int i = 0; i < nn; i++)
{
r3 = ww[i] * ww[i];
nor = nor + r3;
}
nor = nor/r2;
nor = Math.sqrt(nor);
return nor;
}
public void Echeck(double er, double ER)
{
if( er < ER)
System.out.println("test PASS");
else
{
System.out.println("expected error: " + ER);
System.out.println(" found error: " + er);
throw new TestFailure("test FAIL");
}
}
}

View file

@ -0,0 +1,121 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/FloatingPoint/gen_math/Loops07.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.FloatingPoint.gen_math.Loops07.Loops07
* @run driver ExecDriver --java jit.FloatingPoint.gen_math.Loops07.Loops07
*/
package jit.FloatingPoint.gen_math.Loops07;
// Test working with nested loops.
// Code is subject to different types of optimization
// and parallelization - empty loops, dead code, etc.
import nsk.share.TestFailure;
class Loops07
{
public static void main (String args[])
{
int N = 8;
double Error = 1;
double r1, r2, r3, r4, r5, r6;
double xx[][];
double z1, z2, z3;
xx = new double[N][N];
Loops07 ll;
ll = new Loops07();
for(int i = 0; i < N; i++)
{
for(int j = 0; j < N; j++)
{
r1 = i * i + j * j;
r2 = Math.sqrt(r1);
r3 = 1 / r2 ;
r4 = i + j ;
r5 = r4 / r3 ;
xx[i][j] = r5;
}
}
// main loop ---------------------------
z1 = 0;
for(int m1 = 0; m1 < N; m1++)
{
for(int m2 = 0; m2 < N; m2++)
{
z1 = z1 - 0.5 * xx[m1][m2];
for(int m3 = 0; m3 < N; m3++)
{
for(int m4 = 0; m4 < N; m4++)
{
z1 = z1 + xx[m3][m4];
for(int m5 = 0; m5 < N; m5++)
{
for(int m6 = 0; m6 < N; m6++)
{
for(int m7 = 0; m7 < N; m7++)
{
z2 = Math.abs(1 + Math.sin(2 + Math.cos(3 +
Math.sqrt(4 - Math.cos(5)))));
}
}
}
}
}
}
}
// ---------------------------------------
double er = Math.abs(184401 - z1);
if( er < Error)
System.out.println("test PASS");
else
throw new TestFailure("test FAIL");
}
}

View file

@ -0,0 +1,123 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/FloatingPoint/gen_math/Matrix_3d.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.FloatingPoint.gen_math.Matrix_3d.Matrix_3d
* @run driver ExecDriver --java jit.FloatingPoint.gen_math.Matrix_3d.Matrix_3d
*/
package jit.FloatingPoint.gen_math.Matrix_3d;
// Test working with 3D matrix.
// There are no data dependences in code.
import nsk.share.TestFailure;
class Matrix_3d
{
public static void main (String args[])
{
int N = 50;
double Error = 0.001;
double r1, r2, r3, r4, r5, r6;
double xxx[][][];
double yyy[][][];
double zzz[][][];
xxx = new double[N][N][N];
yyy = new double[N][N][N];
zzz = new double[N][N][N];
Matrix_3d mm;
mm = new Matrix_3d();
for(int i = 0; i < N; i++)
{
for(int j = 0; j < N; j++)
{
for(int k = 0; k < N; k++)
{
r1 = i;
r2 = Math.sin(r1);
r3 = j;
r4 = Math.cos(r3);
r5 = k;
r6 = Math.sqrt(r5);
xxx[i][j][k] = r6 * (r2 * r2 + r4 * r4);
}
}
}
for(int i = 0; i < N; i++)
{
for(int j = 0; j < N; j++)
{
for(int k = 0; k < N; k++)
{
yyy[i][j][k] = xxx[k][j][i];
zzz[i][j][k] = xxx[k][i][j];
}
}
}
double trace_xxx = mm.trace_matrix(N,xxx);
double trace_yyy = mm.trace_matrix(N,yyy);
double trace_zzz = mm.trace_matrix(N,zzz);
double trace_3d = trace_xxx + trace_yyy + trace_zzz;
double er = Math.abs(105 - trace_3d);
if( er < Error)
System.out.println("test PASS");
else
throw new TestFailure("test FAIL");
}
public double trace_matrix(int nn, double www[][][])
{ double trace = 0;
for(int i = 0; i < nn; i++)
{
trace = trace + www[i][i][i] * www[i][i][i];
}
return Math.sqrt(trace);
}
}

View file

@ -0,0 +1,373 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/FloatingPoint/gen_math/ShortCircuitTest.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm jit.FloatingPoint.gen_math.ShortCircuitTest.ShortCircuitTest
*/
package jit.FloatingPoint.gen_math.ShortCircuitTest;
////////////////////////////////////////////////////////////////////////////////
// A complete set of tests for the binary Java operators {&&, ||, &, |} to
// ensure that (C-style) short circuit evaluation is used where required, and
// also is not used where prohibited. Checks has been constructed carefully to
// be independent of the operators under scrutiny, so that passing these tests
// constitutes validation of those operators.
//
// The exit status is the number of errors found, at most sixteen.
////////////////////////////////////////////////////////////////////////////////
// If the first test below, a check such as
//
// if(t == 2 && f == 0){...
//
// would be inappropriate, since it contains the item under scrutiny, namely
// short circuit evaluation of AND (&&). Avoid it by slightly tedious
// if-then-else statements, and similarly for the rest of the file.
import nsk.share.TestFailure;
public class ShortCircuitTest {
private static int f = 0, t = 0;
// constr
public ShortCircuitTest(){
}
public boolean f(){
f++;
return false;
}
public boolean t(){
t++;
return true;
}
public static void main(String[] args){
ShortCircuitTest s = new ShortCircuitTest();
int errors = 0;
////////////////////////////////////////////////////////////////////////
// &&
f = t = 0;
if(s.t() && s.t()){
if(t == 2){
if(f == 0){
// System.out.println("PASS");
}else{
System.out.println("Short circuit error: true && true");
errors++;
}
}else{
System.out.println("Short circuit error: true && true");
errors++;
}
}else{
System.out.println("Short circuit error: true && true");
errors++;
}
f = t = 0;
if(s.t() && s.f()){
System.out.println("Short circuit error: true && false");
errors++;
}else{
if(t == 1){
if(f == 1){
// System.out.println("PASS");
}else{
System.out.println("Short circuit error: true && false");
errors++;
}
}else{
System.out.println("Short circuit error: true && false");
errors++;
}
}
f = t = 0;
if(s.f() && s.t()){
System.out.println("Short circuit error: false && true");
errors++;
}else{
if(f == 1){
if(t == 0){
// System.out.println("PASS");
}else{
System.out.println("Short circuit error: false && true");
errors++;
}
}else{
System.out.println("Short circuit error: false && true");
errors++;
}
}
f = t = 0;
if(s.f() && s.f()){
System.out.println("Short circuit error: false && false");
errors++;
}else{
if(f == 1){
if(t == 0){
// System.out.println("PASS");
}else{
System.out.println("Short circuit error: false && false");
errors++;
}
}else{
System.out.println("Short circuit error: false && false");
errors++;
}
}
////////////////////////////////////////////////////////////////////////
// ||
f = t = 0;
if(s.t() || s.t()){
if(t == 1){
if(f == 0){
// System.out.println("PASS");
}else{
System.out.println("Short circuit error: true || true");
errors++;
}
}else{
System.out.println("Short circuit error: true || true");
errors++;
}
}else{
System.out.println("Short circuit error: true || true");
errors++;
}
f = t = 0;
if(s.t() || s.f()){
if(t == 1){
if(f == 0){
// System.out.println("PASS");
}else{
System.out.println("Short circuit error: true || false");
errors++;
}
}else{
System.out.println("Short circuit error: true || false");
errors++;
}
}else{
System.out.println("Short circuit error: true || false");
errors++;
}
f = t = 0;
if(s.f() || s.t()){
if(f == 1){
if(t == 1){
// System.out.println("PASS");
}else{
System.out.println("Short circuit error: false || true");
errors++;
}
}else{
System.out.println("Short circuit error: false || true");
errors++;
}
}else{
System.out.println("Short circuit error: false || true");
errors++;
}
f = t = 0;
if(s.f() || s.f()){
System.out.println("Short circuit error: false || false");
errors++;
}else{
if(f == 2){
if(t == 0){
// System.out.println("PASS");
}else{
System.out.println("Short circuit error: false || false");
errors++;
}
}else{
System.out.println("Short circuit error: false || false");
errors++;
}
}
////////////////////////////////////////////////////////////////////////
// &
f = t = 0;
if(s.t() & s.t()){
if(t == 2){
if(f == 0){
// System.out.println("PASS");
}else{
System.out.println("Short circuit error: true & true");
errors++;
}
}else{
System.out.println("Short circuit error: true & true");
errors++;
}
}else{
System.out.println("Short circuit error: true & true");
errors++;
}
f = t = 0;
if(s.t() & s.f()){
System.out.println("Short circuit error: true & false");
errors++;
}else{
if(t == 1){
if(f == 1){
// System.out.println("PASS");
}else{
System.out.println("Short circuit error: true & false");
errors++;
}
}else{
System.out.println("Short circuit error: true & false");
errors++;
}
}
f = t = 0;
if(s.f() & s.t()){
System.out.println("Short circuit error: false & true");
errors++;
}else{
if(f == 1){
if(t == 1){
// System.out.println("PASS");
}else{
System.out.println("Short circuit error: false & true");
errors++;
}
}else{
System.out.println("Short circuit error: false & true");
errors++;
}
}
f = t = 0;
if(s.f() & s.f()){
System.out.println("Short circuit error: false & false");
errors++;
}else{
if(f == 2){
if(t == 0){
// System.out.println("PASS");
}else{
System.out.println("Short circuit error: false & false");
errors++;
}
}else{
System.out.println("Short circuit error: false & false");
errors++;
}
}
////////////////////////////////////////////////////////////////////////
// |
f = t = 0;
if(s.t() | s.t()){
if(t == 2){
if(f == 0){
// System.out.println("PASS");
}else{
System.out.println("Short circuit error: true | true");
errors++;
}
}else{
System.out.println("Short circuit error: true | true");
errors++;
}
}else{
System.out.println("Short circuit error: true | true");
errors++;
}
f = t = 0;
if(s.t() | s.f()){
if(t == 1){
if(f == 1){
// System.out.println("PASS");
}else{
System.out.println("Short circuit error: true | false");
errors++;
}
}else{
System.out.println("Short circuit error: true | false");
errors++;
}
}else{
System.out.println("Short circuit error: true | false");
errors++;
}
f = t = 0;
if(s.f() | s.t()){
if(f == 1){
if(t == 1){
// System.out.println("PASS");
}else{
System.out.println("Short circuit error: false | true");
errors++;
}
}else{
System.out.println("Short circuit error: false | true");
errors++;
}
}else{
System.out.println("Short circuit error: false | true");
errors++;
}
f = t = 0;
if(s.f() | s.f()){
System.out.println("Short circuit error: false | false");
errors++;
}else{
if(f == 2){
if(t == 0){
// System.out.println("PASS");
}else{
System.out.println("Short circuit error: false | false");
errors++;
}
}else{
System.out.println("Short circuit error: false | false");
errors++;
}
}
if (errors > 0)
throw new TestFailure("Test failed: got " + errors + "errors");
}
}

View file

@ -0,0 +1,83 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/FloatingPoint/gen_math/Summ.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.FloatingPoint.gen_math.Summ.Summ
* @run driver ExecDriver --java jit.FloatingPoint.gen_math.Summ.Summ
*/
package jit.FloatingPoint.gen_math.Summ;
// Test on sums/series
import nsk.share.TestFailure;
class Summ
{
public static void main (String args[])
{
double Error = 1.3488e-06;
double A1 = 0.5;
double Decr = 0.5;
int NN = 20;
Summ ss;
ss = new Summ();
double sum_plus = ss.sum1(NN, Decr);
double sum_minus = ss.sum1(NN, -Decr);
double er_plus = 1.0 - sum_plus;
double er_minus = 1.0 - 3.0 * sum_minus;
double er = er_plus * er_plus + er_minus * er_minus;
double er_total = Math.sqrt(er);
if ( er_total < Error )
System.out.println("test PASS");
else
{
System.out.println("expected error - 1.3488e-06");
System.out.println("found - " + er_total);
throw new TestFailure("test FAIL");
}
}
public double sum1(int nn, double decr)
{
double An = 0.5;
double sum = 0.0;
for(int i = 1; i<=nn; i++)
{ sum = sum + An;
An = An * decr;
}
return sum;
}
}

View file

@ -0,0 +1,45 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/PrintProperties.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm jit.PrintProperties.PrintProperties
*/
package jit.PrintProperties;
import nsk.share.TestFailure;
public class PrintProperties {
public static void main(String[] args) {
System.out.println("System properties");
System.getProperties().list(System.out);
}
}

View file

@ -0,0 +1,47 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/PrintThis.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm jit.PrintThis.PrintThis
*/
package jit.PrintThis;
import nsk.share.TestFailure;
public class PrintThis {
static PrintThis hc = new PrintThis();
public static void main (String s[]) {
System.out.println(hc);
}
}

View file

@ -0,0 +1,120 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/Robert.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.Robert.Robert
* @run driver ExecDriver --java jit.Robert.Robert
*/
package jit.Robert;
import java.io.*;
import nsk.share.TestFailure;
class Robert
{
Robert()
throws Exception
{
try{
testSoftwareException();
}
catch (Exception e)
{
throw e;
}
}
static void
testHardwareException()
throws Exception
{
int i = 1; int j = 0; int k = i / j;
System.out.println(k);
}
static void
testSoftwareException()
throws Exception
{
Float f = Float.valueOf("abc");
System.out.println(f);
}
static void
testUserException()
throws Exception
{
throw new IOException();
}
static void
testRethrownException()
throws Exception
{
new Robert();
}
static void
trouble(int choice)
throws Exception
{
if (choice == 2) testSoftwareException();
if (choice == 3) testUserException();
if (choice == 4) testRethrownException();
}
public static void main(String args[])
throws Exception
{
boolean failed = false;
System.out.println("Robert");
for (int i = 2; i <= 4; ++i)
{
System.out.println("test " + i);
try{
trouble(i);
}
catch (Exception e)
{
System.out.println("caught " + e);
e.printStackTrace(System.out);
continue;
}
failed = true;
}
if (failed)
throw new TestFailure("Test failed.");
else
System.out.println("Test passed.");
}
}

View file

@ -0,0 +1,51 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/Sleeper.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.Sleeper.Sleeper
* @run driver ExecDriver --java jit.Sleeper.Sleeper
*/
package jit.Sleeper;
import nsk.share.TestFailure;
class Sleeper {
public static void main(String args[] ) {
System.out.println ("1");
try { Thread.sleep(1000); } catch (InterruptedException e) {}
System.out.println ("2");
try { Thread.sleep(1000); } catch (InterruptedException e) {}
System.out.println ("3");
try { Thread.sleep(1000); } catch (InterruptedException e) {}
System.out.println ("4");
}
}

View file

@ -0,0 +1,63 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/bounds.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.bounds.bounds
* @run driver ExecDriver --java jit.bounds.bounds
*/
package jit.bounds;
// This test makes sure that array bounds checking is enabled
// with the JIT on
import nsk.share.TestFailure;
class bounds {
public static void main(String[] argv) {
int i;
int a[] = new int[2];
int k = 0;
for(i=-1; i<3; i+=1) {
try {
a[i] = i;
} catch(Throwable t) {
k++;
}
}
if (k == 2) {
System.out.println("Test PASSES");
} else {
throw new TestFailure("Test FAILS");
}
}
}

View file

@ -0,0 +1,8 @@
int + test: 72 should equal 72
long + test: 72 should equal 72
double + test: 72.0 should equal 72.0
float + test: 72.0 should equal 72.0
int += test: 72 should equal 72
long += test: 72 should equal 72
double += test: 72.0 should equal 72.0
float += test: 72.0 should equal 72.0

View file

@ -0,0 +1,151 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/collapse.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.collapse.collapse
* @run driver ExecDriver --java jit.collapse.collapse
*/
package jit.collapse;
import nsk.share.TestFailure;
import nsk.share.GoldChecker;
class collapse {
public static final GoldChecker goldChecker = new GoldChecker( "collapse" );
public static void main( String[] argv )
{
int i;
int j=0, k=0;
long lj=0L, lk=0L;
float fj=0.0F, fk=0.0F;
double dj=0.0D, dk=0.0D;
int n = 4;
boolean boolPass = true;
for (i=1; i<n; i++) {
j = j + 6;
j = j + 6;
j = j + 6;
j = j + 6;
}
for (i=1; i<n; i++) {
k = k + 24;
}
boolPass &= j==k;
collapse.goldChecker.println("int + test: "+j+" should equal "+k);
for (i=1; i<n; i++) {
lj = lj + 6L;
lj = lj + 6L;
lj = lj + 6L;
lj = lj + 6L;
}
for (i=1; i<n; i++) {
lk = lk + 24L;
}
boolPass &= lj==lk;
collapse.goldChecker.println("long + test: "+lj+" should equal "+lk);
for (i=1; i<n; i++) {
dj = dj + 6;
dj = dj + 6;
dj = dj + 6;
dj = dj + 6;
}
for (i=1; i<n; i++) {
dk = dk + 24;
}
boolPass &= dj==dk;
collapse.goldChecker.println("double + test: "+dj+" should equal "+dk);
for (i=1; i<n; i++) {
fj = fj + 6;
fj = fj + 6;
fj = fj + 6;
fj = fj + 6;
}
for (i=1; i<n; i++) {
fk = fk + 24;
}
boolPass &= fj==fk;
collapse.goldChecker.println("float + test: "+fj+" should equal "+fk);
j=0; k=0;
lj=0L; lk=0L;
fj=0.0F; fk=0.0F;
dj=0.0D; dk=0.0D;
for (i=1; i<n; i++) {
j += 6;
j += 6;
j += 6;
j += 6;
}
for (i=1; i<n; i++) {
k += 24;
}
boolPass &= j==k;
collapse.goldChecker.println("int += test: "+j+" should equal "+k);
for (i=1; i<n; i++) {
lj += 6;
lj += 6;
lj += 6;
lj += 6;
}
for (i=1; i<n; i++) {
lk += 24;
}
boolPass &= lj==lk;
collapse.goldChecker.println("long += test: "+lj+" should equal "+lk);
for (i=1; i<n; i++) {
dj += 6;
dj += 6;
dj += 6;
dj += 6;
}
for (i=1; i<n; i++) {
dk += 24;
}
boolPass &= dj==dk;
collapse.goldChecker.println("double += test: "+dj+" should equal "+dk);
for (i=1; i<n; i++) {
fj += 6;
fj += 6;
fj += 6;
fj += 6;
}
for (i=1; i<n; i++) {
fk += 24;
}
boolPass &= fj==fk;
collapse.goldChecker.println("float += test: "+fj+" should equal "+fk);
if (!boolPass)
throw new TestFailure("Test failed.");
collapse.goldChecker.check();
}
}

View file

@ -0,0 +1,82 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/deoptimization/test01.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.deoptimization.test01.test01
* @run driver ExecDriver --java jit.deoptimization.test01.test01
*/
package jit.deoptimization.test01;
import nsk.share.TestFailure;
/*
* Simple loop causes the optimizer to deoptimize
* foo methos when an instance of class B is created.
*
* run with the -XX:TraceDeoptimization to observ the result.
*/
class test01 {
public static void main (String[] args) {
A obj = new A();
for (int index = 0; index < 100; index++) {
obj.used_alot();
}
}
}
class A {
protected final int counter = 25000;
protected int count = 0;
public void foo(int index) {
count++;
if (index == counter - 1) {
try {
((B)Class.forName("B").newInstance()).foo(index);
}
catch(Exception e) {
}
}
}
public void used_alot() {
for (int index = 0; index < counter; index++) {
foo(index);
}
}
}
class B extends A {
public void foo(int index) {
count--;
}
};

View file

@ -0,0 +1,83 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/deoptimization/test02.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.deoptimization.test02.test02
* @run driver ExecDriver --java jit.deoptimization.test02.test02
*/
package jit.deoptimization.test02;
import nsk.share.TestFailure;
/*
* Simple loop causes the optimizer to deoptimize
* foo methos when an instance of class B is created.
*
* run with the -XX:TraceDeoptimization to observ the result.
*/
class test02 {
public static void main (String[] args) {
A obj = new A();
for (int index = 0; index < 100; index++) {
obj.used_alot();
}
}
}
class A {
protected final int counter = 25000;
protected int count = 0;
public void foo(int index) {
count++;
if (index == counter - 1) {
try {
((B)Class.forName("B").newInstance()).foo(index);
}
catch(Exception e) {
}
}
}
public synchronized void used_alot() {
for (int index = 0; index < counter; index++) {
foo(index);
}
}
}
class B extends A {
public void foo(int index) {
count--;
}
};

View file

@ -0,0 +1,87 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/deoptimization/test03.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.deoptimization.test03.test03
* @run driver ExecDriver --java jit.deoptimization.test03.test03
*/
package jit.deoptimization.test03;
import nsk.share.TestFailure;
/*
* Simple loop causes the optimizer to deoptimize
* foo methos when an instance of class B is created.
*
* run with the -XX:TraceDeoptimization to observ the result.
*/
class test03 {
public static void main (String[] args) {
A obj = new A();
for (int index = 0; index < 100; index++) {
obj.used_alot();
}
}
}
class A {
protected final int counter = 25000;
protected int count = 0;
public void foo(int index) {
count++;
if (index == counter - 1) {
try {
((B)Class.forName("B").newInstance()).foo(index);
}
catch(Exception e) {
}
}
}
public synchronized void used_alot() {
for (int index = 0; index < counter - 1; index++) {
synchronized (extern_Lock) {
foo(index);
}
}
}
Object extern_Lock = new Object();
}
class B extends A {
public void foo(int index) {
count--;
}
};

View file

@ -0,0 +1,148 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/deoptimization/test04.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.deoptimization.test04.test04
* @run driver ExecDriver --java jit.deoptimization.test04.test04
*/
package jit.deoptimization.test04;
import nsk.share.TestFailure;
/*
*
*/
class test04 {
public static void main (String[] args) {
A obj = new A();
int result = -1;
for (int index = 0; index < 1; index++) {
result += obj.used_alot();
}
if (result != 1) {
throw new TestFailure("result : " + result + " must equal 1");
}
}
}
class A {
protected int count;
public int foo(int index) {
int rv = ++count;
if (index < A.sIndex / 2)
rv = index;
else {
try {
rv = ((A)Class.forName("jit.deoptimization.test04.B").newInstance()).foo(index);
}
catch(Exception e) {
}
}
return rv;
}
public int used_alot() {
int result = 1;
for (int i = 0; i < A.sIndex; i++) {
result = foo(i);
}
return result;
}
protected static final int sIndex = 25000;
}
class B extends A {
public int foo(int index) {
int rv = 0;
int qrtr = A.sIndex / 4;
if (index > 3 * qrtr) {
try {
if (index < A.sIndex - qrtr)
rv = ((B)Class.forName("jit.deoptimization.test04.C").newInstance()).foo(index);
else
rv = ((B)Class.forName("jit.deoptimization.test04.D").newInstance()).foo(index);
}
catch(Exception e) {
}
}
else {
rv = 1;
}
return rv;
}
}
class C extends B {
public C () {
--this.count;
}
public int foo(int index) {
int j = count;
for (int i=0; i<500; i++)
j += used_alot();
return j;
}
public int used_alot() {
int i=1;
int j=4;
int k=i+j;
byte ba[] = new byte[1000];
int ia[] = new int[1000];
return this.count + (ba.length + i + j - k - ia.length);
}
protected int count = 1;
}
class D extends C {
public D () {
super();
this.count+=2;
}
public int foo(int index) {
return super.foo(index);
}
public synchronized int used_alot() {
count += (--count);
return 0;
}
}

View file

@ -0,0 +1,162 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/deoptimization/test05.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.deoptimization.test05.test05
* @run driver ExecDriver --java jit.deoptimization.test05.test05
*/
package jit.deoptimization.test05;
import nsk.share.TestFailure;
/*
*
*/
class test05 {
public static void main (String[] args) {
A obj = new A();
int result = -1;
for (int index = 0; index < 1; index++) {
result += obj.used_alot();
}
if (result != -1) {
throw new TestFailure("result : " + result + " must equal 1");
}
}
}
class A {
protected int count;
public synchronized int foo(int index) {
int rv = ++count;
if (index < A.sIndex / 2)
rv = index;
else {
try {
rv = ((A)Class.forName("jit.deoptimization.test05.B").newInstance()).foo(index);
}
catch(Exception e) {
}
}
return rv;
}
public synchronized int used_alot() {
int result = 1;
for (int i = 0; i < A.sIndex; i++) {
result = foo(i);
}
return result;
}
protected static final int sIndex = 25000;
}
class B extends A {
public synchronized int foo(int index) {
int rv = 0;
int qrtr = A.sIndex / 4;
if (index > 3 * qrtr) {
try {
if (index < A.sIndex - qrtr)
rv = ((B)Class.forName("jit.deoptimization.test05.C").newInstance()).foo(index);
else
rv = ((B)Class.forName("jit.deoptimization.test05.D").newInstance()).foo(index);
}
catch(Exception e) {
}
}
else {
rv = 1;
}
return rv;
}
}
class C extends B {
public C () {
--this.count;
}
public synchronized int foo(int index) {
int j = count;
for (int i=0; i<5000; i++) {
j += used_alot();
if (i==4999) {
try {
j = ((D2)Class.forName("jit.deoptimization.test05.D2").newInstance()).foo(index);
}
catch (Exception e) {}
}
}
return j;
}
public synchronized int used_alot() {
int i=1;
int j=4;
int k=i+j;
byte ba[] = new byte[1000];
int ia[] = new int[1000];
return this.count + (ba.length + i + j - k - ia.length);
}
protected int count = 1;
}
class D extends C {
public D () {
super();
this.count+=2;
}
public int foo(int index) {
return super.foo(index);
}
public synchronized int used_alot() {
count += (--count);
return 0;
}
}
class D2 extends C {
public int foo(int index) {
return 0;
}
}

View file

@ -0,0 +1,154 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/deoptimization/test06.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.deoptimization.test06.test06
* @run driver ExecDriver --java jit.deoptimization.test06.test06
*/
package jit.deoptimization.test06;
import nsk.share.TestFailure;
/*
* Simple recursion that should causes hotspot to deoptimize
* used_alot and A.foo and A.bar methods
* Expected result for the test is: 0
*
* run with the -XX:TraceDeoptimization to observ the result.
*/
class test06 {
public static void main (String[] args) {
A obj = new A();
for (int index = 0; index < 1; index++) {
obj.used_alot();
}
}
}
class A {
static int result = 0;
public int foo(int index, int iter) {
if (index == 0)
return result;
else if (iter <= sIteration / 2) {
result = bar(index) * foo(--index, iter);
} else {
try {
// halfway through the max iterations
// create a B. This should cause the
// used_alot to be deoptimized
// Call b.frame for the remaining part of the recursion
if (b == null)
b = Class.forName("jit.deoptimization.test06.B").newInstance();
result *= ((B)b).foo(index, iter);
} catch (Exception x) {
throw new TestFailure("Class not found: B");
}
}
return result;
}
// Does nothing but it will let be over written in class C, See Below
public int bar(int index) {
synchronized (this) {
for (int i=0; i<5; i++)
index--;
}
return 0;
}
public void used_alot() {
int result = 1;
for (int index = 1; index <= sIteration; index++) {
result *= foo(index, index);
}
if (result != 0) {
throw new TestFailure("Result: " + result);
}
}
protected Object b = null;
protected static final int sIteration = 1000;
}
class B extends A {
// Override foo in order to force deoptimization.
// Also creates and instance of class C in the last
// iteration in order to force A.foo to get deoptimized
// otherwise just do something stupid.
public int foo(int index, int iter) {
// Make sure that this class was created at least
// halfway through the iteration. Simple sanity check
if (iter < sIteration /2) {
throw new TestFailure("class B create to early");
}
if (iter == sIteration) {
try {
result = ((C)(Class.forName("jit.deoptimization.test06.C").newInstance())).foo(index,iter);
result *= ((C)(Class.forName("jit.deoptimization.test06.C").newInstance())).bar(index);
} catch (Exception x) {
throw new TestFailure("Class not found: C");
}
} else {
result = bar(index);
if (index != 0)
result += foo(--index, iter);
}
return result;
}
}
class C extends B {
public int foo(int index, int iter) {
for (int i=0; i<iter; i++)
result = bar(i);
try {
result = ((D)(Class.forName("jit.deoptimization.test06.D").newInstance())).bar(index);
} catch (Exception x) {
throw new TestFailure("Class not found: D");
}
return result;
}
}
class D extends C {
public int bar(int index) {
return 1;
}
}

View file

@ -0,0 +1,155 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/deoptimization/test07.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.deoptimization.test07.test07
* @run driver ExecDriver --java jit.deoptimization.test07.test07
*/
package jit.deoptimization.test07;
import nsk.share.TestFailure;
/*
* Simple recursion that should cause hotspot to deoptimize
* used_alot and A.foo and A.bar methods
* Expected result for the test is: 0
*
* run with the -XX:TraceDeoptimization to observ the result.
*/
class test07 {
public static void main (String[] args) {
A obj = new A();
for (int index = 0; index < 1; index++) {
obj.used_alot();
}
}
}
class A {
static int result = 0;
synchronized public int foo(int index, int iter) {
if (index == 0)
return result;
else if (iter <= sIteration / 2) {
result = bar(index) * foo(--index, iter);
} else {
try {
// halfway through the max iterations
// create a B. This should cause the
// used_alot to be deoptimized
// Call b.frame for the remaining part of the recursion
if (b == null)
b = Class.forName("jit.deoptimization.test07.B").newInstance();
result *= ((B)b).foo(index, iter);
} catch (Exception x) {
throw new TestFailure("Class not found: B");
}
}
return result;
}
// Does nothing but it will let be over written in class C, See Below
synchronized public int bar(int index) {
synchronized (this) {
for (int i=0; i<5; i++)
index--;
}
return 0;
}
synchronized public void used_alot() {
int result = 1;
for (int index = 1; index <= sIteration; index++) {
result *= foo(index, index);
}
if (result != 0) {
throw new TestFailure("Result: " + result);
}
}
protected Object b = null;
protected static final int sIteration = 1000;
}
class B extends A {
// Override foo in order to force deoptimization.
// Also creates and instance of class C in the last
// iteration in order to force A.foo to get deoptimized
// otherwise just do something stupid.
synchronized public int foo(int index, int iter) {
// Make sure that this class was created at least
// halfway through the iteration. Simple sanity check
if (iter < sIteration /2) {
System.out.println ("class B create to early");
System.exit(1);
}
if (iter == sIteration) {
try {
result = ((C)(Class.forName("jit.deoptimization.test07.C").newInstance())).foo(index,iter);
result *= ((C)(Class.forName("jit.deoptimization.test07.C").newInstance())).bar(index);
} catch (Exception x) {
throw new TestFailure("Class not found: C");
}
} else {
result = bar(index);
if (index != 0)
result += foo(--index, iter);
}
return result;
}
}
class C extends B {
synchronized public int foo(int index, int iter) {
for (int i=0; i<iter; i++)
result = bar(i);
try {
result = ((D)(Class.forName("jit.deoptimization.test07.D").newInstance())).bar(index);
} catch (Exception x) {
throw new TestFailure("Class not found: D");
}
return result;
}
}
class D extends C {
synchronized public int bar(int index) {
return 1;
}
}

View file

@ -0,0 +1,175 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/deoptimization/test08.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.deoptimization.test08.test08
* @run driver ExecDriver --java jit.deoptimization.test08.test08
*/
package jit.deoptimization.test08;
import nsk.share.TestFailure;
/*
* Simple recursion that should causes hotspot to deoptimize
* used_alot and A.foo and A.bar methods
* Expected result for the test is: 0
*
* run with the -XX:TraceDeoptimization to observ the result.
*/
class test08 {
public static void main (String[] args) {
A obj = new A();
for (int index = 0; index < 1; index++) {
obj.used_alot();
}
}
}
class A {
static int result = 0;
synchronized public int foo(int index, int iter) {
synchronized (A.a_ext) {
if (index == 0)
return result;
else if (iter <= sIteration / 2) {
result = bar(index) * foo(--index, iter);
} else {
try {
// halfway through the max iterations
// create a B. This should cause the
// used_alot to be deoptimized
// Call b.frame for the remaining part of the recursion
if (b == null)
b = Class.forName("jit.deoptimization.test08.B").newInstance();
result *= ((B)b).foo(index, iter);
} catch (Exception x) {
throw new TestFailure("Class not found: B");
}
}
}
return result;
}
// Does nothing but it will let be over written in class C, See Below
synchronized public int bar(int index) {
synchronized (a_ext) {
for (int i=0; i<5; i++)
index--;
}
return 0;
}
synchronized public void used_alot() {
int result = 1;
synchronized (a_ext) {
for (int index = 1; index <= sIteration; index++) {
result *= foo(index, index);
}
}
if (result != 0) {
System.err.println ("Result: " + result);
System.exit (1);
}
}
protected Object b = null;
protected static final int sIteration = 1000;
protected static final Object a_ext = new Object();
}
class B extends A {
// Override foo in order to force deoptimization.
// Also creates and instance of class C in the last
// iteration in order to force A.foo to get deoptimized
// otherwise just do something stupid.
synchronized public int foo(int index, int iter) {
synchronized (A.a_ext) {
synchronized (B.b_ext) {
// Make sure that this class was created at least
// halfway through the iteration. Simple sanity check
if (iter < sIteration /2) {
System.out.println ("class B create to early");
System.exit(1);
}
if (iter == sIteration) {
try {
result = ((C)(Class.forName("jit.deoptimization.test08.C").newInstance())).foo(index,iter);
result *= ((C)(Class.forName("jit.deoptimization.test08.C").newInstance())).bar(index);
} catch (Exception x) {
throw new TestFailure("Class not found: C");
}
} else {
result = bar(index);
if (index != 0)
result += foo(--index, iter);
}
}
}
return result;
}
protected static final Object b_ext = new Object();
}
class C extends B {
synchronized public int foo(int index, int iter) {
synchronized (A.a_ext) {
synchronized (B.b_ext) {
synchronized (C.c_ext) {
for (int i=0; i<iter; i++) {
result = bar(i);
if (i == iter-2) {
try {
result = ((D)(Class.forName("jit.deoptimization.test08.D").newInstance())).bar(index);
} catch (Exception x) {
throw new TestFailure("Class not found: D");
}
}
}
}
}
}
return result;
}
protected static final Object c_ext = new Object();
}
class D extends C {
synchronized public int bar(int index) {
return 1;
}
}

View file

@ -0,0 +1,604 @@
Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
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.
* common/ArrayBounds
Checks whether the compiler makes incorrect array bounds removal optimizations.
* common/ArrayTests
Checks whether array stores and reads are correct for integral types and floating points.
* common/bounds
Makes sure that array bounds checking is enabled with the JIT on
* common/CEETest
Checks whether comparision operations work properly.
* common/collapse
Checks constatnt propagation facilities of the JIT compiler.
* common/CondExpr
Checks that code for conditional expressions is generated properly.
* common/deoptimization/test01
* common/deoptimization/test02
* common/deoptimization/test03
* common/deoptimization/test04
* common/deoptimization/test05
* common/deoptimization/test06
* common/deoptimization/test07
* common/deoptimization/test08
Check compiler deoptimization facilities.
* common/DivTest
Checks some special cases of divide operation.
* common/exception
This JIT buster test checks to see if a JIT doing register allocation
on a machine with a callees saves ABI for non-volatile registers can
get the exception handling correct. Intel and PowerPC are both such
machines.
* common/exceptiontest
Does exactly the same as common/exception
* common/ExcOpt
Tests exception handler inside optimizable loop and around it.
* common/FPCompare/TestFPBinop
Tests floating point binary operations.
* common/FPCompare/TestFPCompare
Test of floating point comparison.
* common/gen_math/Filtering
* common/gen_math/Loops_1
* common/gen_math/Loops_2
* common/gen_math/Loops_3
* common/gen_math/Loops_4
* common/gen_math/Loops_5
* common/gen_math/Loops_6
* common/gen_math/Loops_7
* common/gen_math/Matrix_3d
* common/gen_math/Summ
These tests check math preciction stuff.
* common/gen_math/ShortCircuitTest
A complete set of tests for the binary Java operators {&&, ||, &, |} to
ensure that (C-style) short circuit evaluation is used where required, and
also is not used where prohibited. Checks has been constructed carefully to
be independent of the operators under scrutiny, so that passing these tests
constitutes validation of those operators.
* common/graph
The test checks the dynamic class creation and method invokation reflection features. A number of threads is created. They call
methods dynamically and recursively. Also, exceptions, thrown from the dynamically called methods are checked.
* common/inittest
Checks correctness of class initialization order.
* common/inittest2
Checks that JIT doesn't perform an initialization of class which is never used.
* common/inline001
This test is valid in JDK 1.1.4 and in prior JDKs. It
ceased to work in JDK 1.2e. The test relied on the JIT
to inline some final methods and to never inline non-final
methods.
* common/inline002
Look for inlined final methods in java.Math. Do this by comparing
execution times against estimates of call overheads for various
method signatures.
The current (08/04/97) list of inlined methods is short:
abs(float)
abs(double)
sqrt(double) [i386 only]
If new methods are inlined or dropped from the list of inlined
codes, record this fact by changing the value of an element of the
array expectInline. This is done in the method result().
This test will fail if the JIT is disabled. There are two modes
of operation. The first is to merely record a pass/fail for each
method tested. This output should be machine independent and
suitable for a golden file.
java -Djava.compiler=sunwjit inline002
The other mode is a report generation mode. It reports the
number of iterations, call overhead in nanoseconds, and a judgement
as to whether a method was inlined or not.
java -Djava.compiler=sunwjit inline002 -report
* common/inline003
* common/inline004
Check inlining of final methods.
* common/inline005
Checks correctness of evaluation order in inlined math functions (?).
* common/inline006
* common/inline007
Checks access to final class fields.
* common/JITSuite
Does exactly the same as common/inittest2
* common/jtest
Does some client-server communications via sockets. Not actually a JIT test!
* common/Linpack
Math presiction test.
* common/loops/arg01
* common/loops/arg03
Fill arrays in a loops and then makes a number of checks (?)
* common/loops/arg04
Checks correctness of interprocedural data flow analysis, tests for recognition of
loop independent dependences between statements in mutually exclusive regions, checks
global data flow analysis.
* common/loops/arg05
Checks loop vectorization stuff.
* common/loops/arg06
Checks statement reordering, loop distribution, partial loop vectorization, recurrence
in the middle of the loop.
* common/loops/arg07
Checks loop interchange, node splitting.
* common/loops/arg08
Checks scalar and array expansion.
* common/loops/arg09
Checks scalar and array expansion, control flow (loop with independent conditional).
* common/loops/arg10
Some control flow-related checks.
* common/loops/dec01
* common/loops/dec02
* common/loops/dec03
* common/loops/dec04
* common/loops/dec05
* common/loops/dec06
* common/loops/dec07
* common/loops/dec08
* common/loops/dec09
* common/loops/dec10
* common/loops/dec11
Some aritmetic operations within loops and a number of comparisions (?).
* common/loops/fuse1
* common/loops/fuse10
* common/loops/fuse101
* common/loops/fuse102
* common/loops/fuse103
* common/loops/fuse105
* common/loops/fuse106
* common/loops/fuse108
* common/loops/fuse11
* common/loops/fuse111
* common/loops/fuse113
* common/loops/fuse116
* common/loops/fuse117
* common/loops/fuse12
* common/loops/fuse13
* common/loops/fuse14
* common/loops/fuse16
* common/loops/fuse17
* common/loops/fuse18
* common/loops/fuse2
* common/loops/fuse3
* common/loops/fuse4
* common/loops/fuse5
* common/loops/fuse6
* common/loops/fuse8
Check correctness of loop fusion.
* common/loops/fuse107
* common/loops/fuse109
* common/loops/fuse15
* common/loops/fuse19
* common/loops/fuse7
* common/loops/fuse9
Construct a number of loops and make some calculations. These tests seems to be
incomplete (incorrectly translated from Fortran).
* common/loops/private1
Single dimensional private array, with no carried dependence in the inner
loop - simple subscripts.
* common/loops/private2
Single dimensional private array, with no carried dependence in the inner
loop - non-simple subscripts (test incomplete).
* common/loops/private3
Single dimensional private array, with no carried dependence
in the inner loop (test incomplete).
* common/loops/private4
Loop with condionals, both arms of the conditional cover the entire array
which is private.
* common/loops/private5
Single dimensional private array, 2 inner loops; all uses of array in the 2nd loop are
covered by defs in the 1st one.
* common/loops/private6
Single dimensional private array; all uses of array in the inner loop are
covered by defs in the outer one.
* common/loops/private7
Single dimensional private array, 3 inner loops; all uses of array in the 3rd loop are
covered by defs in the 1st and 2nd one.
* common/loops/private8
Single dimensional private array, 3 inner loops; the defs of array in the 2nd loop cover
all the defs and uses within loops 2 and 3.
* common/loops/private9
Single dimensional private array, the two loops effectively cover the array.
* common/loops/private10
Single dimensional private array, the two asignments to the array in the inner loop
effectively cover the entire array.
* common/loops/private104
Loop with condionals. Both arms of the conditional cover the entire array.
* common/loops/private105
Single dimensional private array, 2 inner loops; all uses of array in the 2nd loop are
covered by defs in the 1st one.
* common/loops/private107
Single dimensional private array, 3 inner loops; all uses of array in the 3rd loop are
covered by defs in the 1st and 2nd one.
* common/loops/private109
Single dimensional private array, the two loops effectively cover the array.
* common/loops/private11
The two loops each cover disjoint triangular regions of the array. Together they
cover the entire array.
* common/loops/private110
Single dimensional private array, the two asignments to the array in the inner loop
effectively cover the entire array.
* common/loops/private111
The two loops each cover disjoint triangular regions of the array. Together they
cover the entire array.
* common/loops/private112
* common/loops/private113
* common/loops/private12
* common/loops/private13
Private array sections. Even though only a portion of the array is covered by the
definitions, but the uses are covered entirely by the defs in the array.
* common/loops/private117
Single dimensional private array, 2 inner loops; all uses of array in the 2nd loop are
covered by defs in the 1st one.
* common/loops/private118
Two dimensional private array and some loop unrolling made by hand.
* common/loops/private119
Two dimensional private array.
* common/loops/private120
Loop peeling before and after the loop.
* common/loops/private122
Two dimensional private array.
* common/loops/private123
Single dimensional private array; even though not all elements of the array are modified
in the inner loop, and all uses of array are covered.
* common/loops/private124
Two dimensional private array. Loop with condionals; both arms of the conditional cover
the entire array, there are uses in the either arm the are entirely covered.
* common/loops/private125
Two dimensional private array. Loop with condionals; the uses of the array outside the
conditional are not guaranteed to be covered entirely.
* common/loops/private126
Two dimensional array. Here array is not private, as one element is not covered in the loop.
* common/loops/private128
Two and single dimensional arrays.
* common/loops/private130
2 two dimensional and 1 single dimension array.
* common/loops/private133
Single dimensional private array, 2 inner loops.
* common/loops/private14
This is an involved test. The first j loop covers 1..m elements of the
1..n array. Since overindexing is prohibited, the compiler should assume
that 1..m is a subset of 1..n. In the k loop first m uses of the array
a() are covered by defs in the j loop. The next m+1..n iterations of the
loop do not have any uncovered uses. Therefore the array a() ought to be
a private array.
* common/loops/private15
Similar to common/loops/private14, but uses no conditionals.
* common/loops/private17
Single dimensional array, assuming no overindexing.
* common/loops/private18
* common/loops/private19
* common/loops/private20
* common/loops/private22
Single dimensional private array, 3 inner loops.
* common/loops/private21
3 inner loops, the 1st and 2nd loop together cover the entire array, and all the uses
of the array in the 3rd loop are covered.
* common/loops/private23
Private array, even though not all elements of the array are modified in inner loop,
and all uses of the array are covered.
* common/loops/private24
Conditional inside the loop, 2 inner loops in both arms.
* common/loops/private25
Conditional inside the loop, inner loops in both arms and one inner loop after
the conditional.
* common/loops/private26
* common/loops/private27
* common/loops/private28
Single dimensional private array, 3 inner loops.
* common/loops/private29
Single dimensional private array, 2 inner loops.
* common/loops/private30
Conditional inside the loop, inner loops in both arms and one inner loop before
the conditional.
* common/loops/private31
Conditional inside the loop, inner loop in both arms.
* common/loops/private32
2 loops, inner loop inside the 2nd one.
* common/loops/private33
Single dimensional private array, 2 inner loops.
* common/misctests/classes
No test found!
* common/misctests/clss14702
Checks that NullPointerException is thrown.
* common/misctests/FileViewer
Not a JIT test!
* common/misctests/Foo
Does nothing.
* common/misctests/fpustack
Not a JIT test!
* common/misctests/Jdk116JitProblem
The test illustrates a problem with the new JDK 1.1.6 JIT. The JIT compiler
included with JDK 1.1.6 takes forever to compile the transform() method, thereby
hanging up the virtual machine.
* common/misctests/JitBug
Symantec's JIT seems to optimize away important code. The test compiled using
the standard javac, demonstrates a bug in the JIT on NT4/sp3.
* common/misctests/JitBug1
Demonstrates yet another JIT bug.
* common/misctests/JitTest
Tests equals() method.
* common/misctests/NoHeader
Not a JIT test!
* common/misctests/noop
Not a JIT test!
* common/misctests/Pi
Not a JIT test!
* common/misctests/putfield00802
Tests NullPointerException. Should be removed (common/misctests/clss14702 is a better test).
* common/misctests/t5
Not a JIT test!
* common/misctests/testbug
If this test is run under JRE 1.1.6, it gets the following error: "A nonfatal internal
JIT (3.00.039(x)) error 'Unuse_LRU' hasoccu4rred in: 'testbug.dk ([BI)V': Interpreting method."
* common/misctests/whet
Not a JIT test!
* common/misctests/test.java
Not a JIT test!
* common/overflow
Test StackOverflowException.
* common/pat001
Tests arithmetic series.
* common/Peano
Computes factorials by using the Peano axioms only. Not a test!
* common/PrintProperties
* common/PrintThis
Not a JIT test!
* common/Robert
Tests some exception stuff
* common/Sleeper
Not a JIT test!
* common/tXXX
Do some arithmetic operations, but do not actually report results. Should be removed.
* common/testForBugs/4427606/TestDivByZero
Tests correctness of division by zero handling.
* common/testForBugs/4427606/Security
* common/testForBugs/4446672/TestThreadStart.java
Not a JIT test!
* common/testForBugs/CrashC1
Test for bug in C1.
* common/wide
* common/too_wide
Check for intermediate results that are too wide.
* common/TsdCase
performance benchmarks. Not a test!
* common/verifier/VerifyInitLocal
Makes sure verifier allows initialization of local fields.
* common/verifier/VerifyMergeStack
Makes sure verifier fails when two distinct types meet on operand stack.

View file

@ -0,0 +1,205 @@
/*
* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/escape/AdaptiveBlocking/AdaptiveBlocking001.
* VM Testbase keywords: [jit, quick]
* VM Testbase readme:
* This is a basic JIT compiler adaptive blocking test. The test runs 2 threads
* contending for a shared resource. In the first round, the lock is held for
* a short period of time, provoking spinlock-style locking. In the second round,
* the lock is held for a long period of time, provoking blocked locking. The
* described scenario is repeated numRounds (specified by the -numRounds
* parameter) times.
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.escape.AdaptiveBlocking.AdaptiveBlocking001.AdaptiveBlocking001
* @run driver/timeout=300 ExecDriver --java -server -Xcomp -XX:+DoEscapeAnalysis
* jit.escape.AdaptiveBlocking.AdaptiveBlocking001.AdaptiveBlocking001 -numRounds 10
*/
package jit.escape.AdaptiveBlocking.AdaptiveBlocking001;
import nsk.share.TestFailure;
class AdaptiveBlocking001
{
public static int numRounds = 10;
private static Object sharedLock = new Object();
private static boolean lockEntered1;
private static boolean lockEntered2;
private static boolean latentLocks;
private static boolean done;
private static boolean failed;
public static void main( String[] args )
{
System.out.println( "Adaptive blocking test" );
parseArgs( args );
for( int i=0; i < numRounds; ++i )
{
doRound(i, false);
doRound(i, true);
}
if( !failed )
System.out.println( "TEST PASSED" );
else
throw new TestFailure( "TEST FAILED" );
}
private static void parseArgs( String[] args )
{
for( int i=0; i < args.length; ++i )
{
String arg = args[i];
String val;
if( arg.equals( "-numRounds" ) )
{
if( ++i < args.length )
val = args[i];
else
throw new TestFailure( "Need value for '" + arg + "' parameter" );
try {
numRounds = Integer.parseInt( val );
} catch( NumberFormatException e ) {
throw new TestFailure( "Invalid value for '" + arg + "' parameter: " + val );
}
}
else
{
throw new TestFailure( "Invalid argument: " + args );
}
}
}
private static void doRound(int ord, boolean latent_locks)
{
System.out.println( "round #" + ord + ", latent locks: " + (latent_locks ? "yes" : "no") + "..." );
latentLocks = latent_locks;
Thread_1 t1 = new Thread_1();
Thread_2 t2 = new Thread_2();
done = false;
t1.start();
t2.start();
for( int i=0; i < 10; ++i )
{
try {
Thread.sleep( 1000 );
} catch( InterruptedException e ) {
}
if( done )
break;
}
done = true;
try {
t1.join();
t2.join();
} catch( InterruptedException e ) {
}
}
private static class Thread_1 extends Thread
{
public void run()
{
while( !done )
{
synchronized( sharedLock )
{
lockEntered1 = true;
if( lockEntered2 )
{
Fail();
done = true;
break;
}
holdLock();
lockEntered1 = false;
}
}
}
}
private static class Thread_2 extends Thread
{
public void run()
{
while( !done )
{
synchronized( sharedLock )
{
lockEntered2 = true;
if( lockEntered1 )
{
Fail();
done = true;
break;
}
holdLock();
lockEntered2 = false;
}
}
}
}
private static void holdLock()
{
if( latentLocks )
{
try {
Thread.sleep( 500 );
} catch( InterruptedException e ) {
}
}
}
private static void Fail()
{
failed = true;
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,38 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/escape/LockCoarsening/LockCoarsening001.
* VM Testbase keywords: [jit, quarantine]
* VM Testbase comments: JDK-8148743
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.escape.LockCoarsening.LockCoarsening
* @run shell ../run.sh EliminateLocks
*/

View file

@ -0,0 +1,38 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/escape/LockCoarsening/LockCoarsening002.
* VM Testbase keywords: [jit, quick, quarantine]
* VM Testbase comments: JDK-8079666
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.escape.LockCoarsening.LockCoarsening
* @run shell ../run.sh
*/

View file

@ -0,0 +1,68 @@
Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
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.
DESCRIPTION
This is a lock coarsening test. There are 2 threads, trying to acquire a shared
resource. The 1st thread has a number of adjacent lock that are subject to lock
coarsening:
...
synchronized( lock )
{
lock.foo();
}
// (*)
synchronized( lock )
{
lock.foo();
}
...
The test is written in such a way, that thread 2 will acquire the lock, if and
only if thread 1 is somewhere at point (*). Therefore, the fact that lock
coarsening occurred is described by the condition (numAcquiredLocks != 0).
IMPLEMENTATION
The test has one parameter, -eliminateLocks, that tells whether the JVM option
-XX:+EliminateLocks has been specified, so running the test without
-eliminateLocks checks that lock coarsening didn't occur, and running it with
this option check that lock coarsening occurred.
Some hacks have been made to force JIT compile the method doit() (see comments in
the source).
FAILURE ANALYSIS
If test fails try to run it with -XX:+PrintOptoAssembly and -XX:+LogCompilation
to understand if this is a test or product bug.
If compiled code of Thread_1::doit method have lot of locks that surround each
lock.foo() then coarsening did not happen and this is a product bug.
If lock coarsening occurs but not triggered by test then it's a test bug
that should be investigated. One of such problems could be caused if method doit()
was not compiled due to insufficient warm-up iterations. Also there may be a product bug
in compilation.

View file

@ -0,0 +1,80 @@
#!/bin/sh
#
# Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# 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.
#
EXECUTE_CLASS=jit.escape.LockCoarsening.LockCoarsening
JAVA="$TESTJAVA/bin/java"
JAVA_OPTS="-cp $TESTCLASSPATH $TESTJAVAOPTS $TESTVMOPTS"
#
# Run the test in EA mode if -server and -Xcomp JVM options specified
# Set EliminateLocks commandline option to enable -XX:+EliminateLocks
#
if [ "$1" = "EliminateLocks" ]; then
EA_OPTS="-XX:+DoEscapeAnalysis -XX:+EliminateLocks"
TEST_ARGS="$TEST_ARGS -eliminateLocks"
else
EA_OPTS="-XX:-DoEscapeAnalysis -XX:-EliminateLocks"
fi
# Additional VM options
ADD_OPTS="-XX:-TieredCompilation -XX:+IgnoreUnrecognizedVMOptions -XX:-DeoptimizeALot"
echo "Check if EscapeAnalysis is supported"
$JAVA $JAVA_OPTS $EA_OPTS -version
if [ "$?" = 0 ]; then
echo "EA options '$EA_OPTS' are supported"
b1=0
b2=0
for param in $JAVA_OPTS; do
case "$param" in
-server )
b1=1
;;
-Xcomp )
b2=1
;;
esac
done
if [ "$b1$b2" = 11 ]; then
JAVA_OPTS="$JAVA_OPTS $ADD_OPTS $EA_OPTS"
echo "Java options: $JAVA_OPTS"
$JAVA $JAVA_OPTS $EXECUTE_CLASS $TEST_ARGS
exit $?
else
echo "JVM options '-server -Xcomp' not specified"
exit 0
fi
fi
echo "EA not supported, passing test"
exit 0

View file

@ -0,0 +1,676 @@
/*
* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/escape/LockElision/MatMul.
* VM Testbase keywords: [jit, quick]
* VM Testbase readme:
* DESCRIPTION
* The test multiplies 2 matrices, first, by directly calculating matrix product
* elements, and second, by calculating them parallelly in diffenent threads.
* The results are compared then.
* The test, in addition to required locks, introduces locks on local variables or
* variables not escaping from the executing thread, and nests them manifoldly.
* In case of a buggy compiler, during lock elimination some code, required by
* the calulation may be eliminated as well, or the code may be overoptimized in
* some other way, causing difference in the execution results.
* The test has one parameter, -dim, which specifies the dimensions of matrices.
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.escape.LockElision.MatMul.MatMul
* @run driver ExecDriver --java jit.escape.LockElision.MatMul.MatMul -dim 30 -threadCount 10
*/
package jit.escape.LockElision.MatMul;
import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import nsk.share.Consts;
import nsk.share.Log;
import nsk.share.Pair;
import nsk.share.test.StressOptions;
import vm.share.options.Option;
import vm.share.options.OptionSupport;
import vm.share.options.Options;
class MatMul {
@Option(name = "dim", description = "dimension of matrices")
int dim;
@Option(name = "verbose", default_value = "false",
description = "verbose mode")
boolean verbose;
@Option(name = "threadCount", description = "thread count")
int threadCount;
@Options
StressOptions stressOptions = new StressOptions();
private Log log;
public static void main(String[] args) {
MatMul test = new MatMul();
OptionSupport.setup(test, args);
System.exit(Consts.JCK_STATUS_BASE + test.run());
}
public int run() {
log = new Log(System.out, verbose);
log.display("Parallel matrix multiplication test");
Matrix a = Matrix.randomMatrix(dim);
Matrix b = Matrix.randomMatrix(dim);
long t1, t2;
t1 = System.currentTimeMillis();
Matrix serialResult = serialMul(a, b);
t2 = System.currentTimeMillis();
log.display("serial time: " + (t2 - t1) + "ms");
try {
t1 = System.currentTimeMillis();
Matrix parallelResult = parallelMul(a, b,
threadCount * stressOptions.getThreadsFactor());
t2 = System.currentTimeMillis();
log.display("parallel time: " + (t2 - t1) + "ms");
if (!serialResult.equals(parallelResult)) {
log.complain("a = \n" + a);
log.complain("b = \n" + b);
log.complain("serial: a * b = \n" + serialResult);
log.complain("serial: a * b = \n" + parallelResult);
return Consts.TEST_FAILED;
}
return Consts.TEST_PASSED;
} catch (CounterIncorrectStateException e) {
log.complain("incorrect state of counter " + e.counter.name);
log.complain("expected = " + e.counter.expected);
log.complain("actual " + e.counter.state());
return Consts.TEST_FAILED;
}
}
public static int convolution(Seq<Integer> one, Seq<Integer> two) {
int res = 0;
int upperBound = Math.min(one.size(), two.size());
for (int i = 0; i < upperBound; i++) {
res += one.get(i) * two.get(i);
}
return res;
}
/**
* calculate chunked convolutuion of two sequences
* <p/>
* This special version of this method:
* <pre>{@code
* public static int chunkedConvolution(Seq<Integer> one, Seq<Integer> two, int from, int to) {
* int res = 0;
* int upperBound = Math.min(Math.min(one.size(), two.size()), to + 1);
* for (int i = from; i < upperBound; i++) {
* res += one.get(i) * two.get(i);
* }
* return res;
* }}</pre>
* <p/>
* that tries to fool the Lock Elision optimization:
* Most lock objects in these lines are really thread local, so related synchronized blocks (dummy blocks) can be removed.
* But several synchronized blocks (all that protected by Counter instances) are really necessary, and removing them we obtain
* an incorrect result.
*
* @param one
* @param two
* @param from - lower bound of sum
* @param to - upper bound of sum
* @param local - reference ThreadLocal that will be used for calculations
* @param bCounter - Counter instance, need to perfom checks
*/
public static int chunkedConvolutionWithDummy(Seq<Integer> one,
Seq<Integer> two, int from, int to, ThreadLocals local,
Counter bCounter) {
ThreadLocals conv_local1 = new ThreadLocals(local, "conv_local1");
ThreadLocals conv_local2 = new ThreadLocals(conv_local1, "conv_local2");
ThreadLocals conv_local3 = new ThreadLocals(null, "conv_local3");
int res = 0;
synchronized (local) {
local.updateHash();
int upperBound = 0;
synchronized (conv_local1) {
upperBound = local.min(one.size(), two.size());
synchronized (two) {
//int upperBound = Math.min(Math.min(one.size(), two.size()), to + 1) :
upperBound = conv_local1.min(upperBound, to + 1);
synchronized (bCounter) {
bCounter.inc();
}
}
for (int i = from; i < upperBound; i++) {
synchronized (conv_local2) {
conv_local1.updateHash();
int prod = 0;
synchronized (one) {
int t = conv_local2.mult(one.get(i), two.get(i));
synchronized (conv_local3) {
prod = t;
}
//res += one.get(i) * two.get(i)
res = conv_local3.sum(res, prod);
}
}
}
}
return res;
}
}
public boolean productCheck(Matrix a, Matrix b) {
if (a == null || b == null) {
log.complain("null matrix!");
return false;
}
if (a.dim != b.dim) {
log.complain("matrices dimension are differs");
return false;
}
return true;
}
public Matrix serialMul(Matrix a, Matrix b) {
if (!productCheck(a, b)) {
throw new IllegalArgumentException();
}
Matrix result = Matrix.zeroMatrix(a.dim);
for (int i = 0; i < a.dim; i++) {
for (int j = 0; j < a.dim; j++) {
result.set(i, j, convolution(a.row(i), b.column(j)));
}
}
return result;
}
/**
* Parallel multiplication of matrices.
* <p/>
* This special version of this method:
* <pre>{@code
* public Matrix parallelMul1(final Matrix a, final Matrix b, int threadCount) {
* if (!productCheck(a, b)) {
* throw new IllegalArgumentException();
* }
* final int dim = a.dim;
* final Matrix result = Matrix.zeroMatrix(dim);
* <p/>
* ExecutorService threadPool = Executors.newFixedThreadPool(threadCount);
* final CountDownLatch latch = new CountDownLatch(threadCount);
* List<Pair<Integer, Integer>> parts = splitInterval(Pair.of(0, dim - 1), threadCount);
* for (final Pair<Integer, Integer> part : parts) {
* threadPool.submit(new Runnable() {
* @Override
* public void run() {
* for (int i = 0; i < dim; i++) {
* for (int j = 0; j < dim; j++) {
* synchronized (result) {
* int from = part.first;
* int to = part.second;
* result.add(i, j, chunkedConvolution(a.row(i), b.column(j), from, to));
* }
* }
* }
* latch.countDown();
* }
* });
* }
* <p/>
* try {
* latch.await();
* } catch (InterruptedException e) {
* e.printStackTrace();
* }
* threadPool.shutdown();
* return result;
* }}</pre>
* Lines marked with NOP comments need to fool the Lock Elision optimization:
* All lock objects in these lines are really thread local, so related synchronized blocks (dummy blocks) can be removed.
* But several synchronized blocks (that are nested in dummy blocks) are really necessary, and removing them we obtain
* an incorrect result.
*
* @param a first operand
* @param b second operand
* @param threadCount number of threads that will be used for calculations
* @return product of matrices a and b
*/
public Matrix parallelMul(final Matrix a, final Matrix b, int threadCount)
throws CounterIncorrectStateException {
if (!productCheck(a, b)) {
throw new IllegalArgumentException();
}
final int dim = a.dim;
final Matrix result = Matrix.zeroMatrix(dim);
ExecutorService threadPool = Executors.newFixedThreadPool(threadCount);
final CountDownLatch latch = new CountDownLatch(threadCount);
List<Pair<Integer, Integer>> parts = splitInterval(Pair.of(0, dim - 1),
threadCount);
final Counter lCounter1 = new Counter(threadCount, "lCounter1");
final Counter lCounter2 = new Counter(threadCount, "lCounter2");
final Counter lCounter3 = new Counter(threadCount, "lCounter3");
final Counter bCounter1 = new Counter(threadCount * dim * dim,
"bCounter1");
final Counter bCounter2 = new Counter(threadCount * dim * dim,
"bCounter2");
final Counter bCounter3 = new Counter(threadCount * dim * dim,
"bCounter3");
final Counter[] counters = {lCounter1, lCounter2, lCounter3,
bCounter1, bCounter2, bCounter3};
final Map<Pair<Integer, Integer>, ThreadLocals> locals1
= CollectionsUtils.newHashMap();
final Map<Pair<Integer, Integer>, ThreadLocals> locals2
= CollectionsUtils.newHashMap();
final Map<Pair<Integer, Integer>, ThreadLocals> locals3
= CollectionsUtils.newHashMap();
for (final Pair<Integer, Integer> part : parts) {
ThreadLocals local1 = new ThreadLocals(null,
"locals1[" + part + "]");
ThreadLocals local2 = new ThreadLocals(local1,
"locals2[" + part + "]");
ThreadLocals local3 = new ThreadLocals(local2,
"locals3[" + part + "]");
locals1.put(part, local1);
locals2.put(part, local2);
locals3.put(part, local3);
}
for (final Pair<Integer, Integer> part : parts) {
threadPool.submit(new Runnable() {
@Override
public void run() {
ThreadLocals local1 = locals1.get(part);
ThreadLocals local2 = locals2.get(part);
ThreadLocals local3 = locals3.get(part);
ThreadLocals local4 = locals3.get(part);
synchronized (local1) {
local1.updateHash();
synchronized (lCounter1) {
lCounter1.inc();
}
synchronized (lCounter3) {
synchronized (local2) {
local2.updateHash();
lCounter3.inc();
}
}
synchronized (new Object()) {
synchronized (lCounter2) {
lCounter2.inc();
}
for (int i = 0; i < dim; i++) {
for (int j = 0; j < dim; j++) {
synchronized (bCounter1) {
synchronized (new Object()) {
bCounter1.inc();
}
}
synchronized (local3) {
local3.updateHash();
synchronized (bCounter2) {
bCounter2.inc();
}
synchronized (result) {
local1.updateHash();
synchronized (local2) {
local2.updateHash();
int from = part.first;
int to = part.second;
result.add(i, j,
chunkedConvolutionWithDummy(
a.row(i),
b.column(j),
from, to,
local4,
bCounter3));
}
}
}
}
}
}
}
latch.countDown();
}
});
}
try {
latch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
threadPool.shutdown();
for (final Pair<Integer, Integer> part : parts) {
log.display(
"hash for " + part + " = " + locals1.get(part).getHash());
}
for (Counter counter : counters) {
if (!counter.check()) {
throw new CounterIncorrectStateException(counter);
}
}
return result;
}
/**
* Split interval into parts
*
* @param interval - pair than encode bounds of interval
* @param partCount - count of parts
* @return list of pairs than encode bounds of parts
*/
public static List<Pair<Integer, Integer>> splitInterval(
Pair<Integer, Integer> interval, int partCount) {
if (partCount == 0) {
throw new IllegalArgumentException();
}
if (partCount == 1) {
return CollectionsUtils.asList(interval);
}
int intervalSize = interval.second - interval.first + 1;
int partSize = intervalSize / partCount;
List<Pair<Integer, Integer>> init = splitInterval(
Pair.of(interval.first, interval.second - partSize),
partCount - 1);
Pair<Integer, Integer> lastPart = Pair
.of(interval.second - partSize + 1, interval.second);
return CollectionsUtils.append(init, lastPart);
}
public static class Counter {
private int state;
public final int expected;
public final String name;
public void inc() {
state++;
}
public int state() {
return state;
}
public boolean check() {
return state == expected;
}
public Counter(int expected, String name) {
this.expected = expected;
this.name = name;
}
}
private static class CounterIncorrectStateException extends Exception {
public final Counter counter;
public CounterIncorrectStateException(Counter counter) {
this.counter = counter;
}
}
private static abstract class Seq<E> implements Iterable<E> {
@Override
public Iterator<E> iterator() {
return new Iterator<E>() {
private int p = 0;
@Override
public boolean hasNext() {
return p < size();
}
@Override
public E next() {
return get(p++);
}
@Override
public void remove() {
}
};
}
public abstract E get(int i);
public abstract int size();
}
private static class CollectionsUtils {
public static <K, V> Map<K, V> newHashMap() {
return new HashMap<K, V>();
}
public static <E> List<E> newArrayList() {
return new ArrayList<E>();
}
public static <E> List<E> newArrayList(Collection<E> collection) {
return new ArrayList<E>(collection);
}
public static <E> List<E> asList(E e) {
List<E> result = newArrayList();
result.add(e);
return result;
}
public static <E> List<E> append(List<E> init, E last) {
List<E> result = newArrayList(init);
result.add(last);
return result;
}
}
private static class Matrix {
public final int dim;
private int[] coeffs;
private Matrix(int dim) {
this.dim = dim;
this.coeffs = new int[dim * dim];
}
public void set(int i, int j, int value) {
coeffs[i * dim + j] = value;
}
public void add(int i, int j, int value) {
coeffs[i * dim + j] += value;
}
public int get(int i, int j) {
return coeffs[i * dim + j];
}
public Seq<Integer> row(final int i) {
return new Seq<Integer>() {
@Override
public Integer get(int j) {
return Matrix.this.get(i, j);
}
@Override
public int size() {
return Matrix.this.dim;
}
};
}
public Seq<Integer> column(final int j) {
return new Seq<Integer>() {
@Override
public Integer get(int i) {
return Matrix.this.get(i, j);
}
@Override
public int size() {
return Matrix.this.dim;
}
};
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < dim; i++) {
for (int j = 0; j < dim; j++) {
builder.append((j == 0) ? "" : "\t\t");
builder.append(get(i, j));
}
builder.append("\n");
}
return builder.toString();
}
@Override
public boolean equals(Object other) {
if (!(other instanceof Matrix)) {
return false;
}
Matrix b = (Matrix) other;
if (b.dim != this.dim) {
return false;
}
for (int i = 0; i < dim; i++) {
for (int j = 0; j < dim; j++) {
if (this.get(i, j) != b.get(i, j)) {
return false;
}
}
}
return true;
}
private static Random random = new Random();
public static Matrix randomMatrix(int dim) {
Matrix result = new Matrix(dim);
for (int i = 0; i < dim; i++) {
for (int j = 0; j < dim; j++) {
result.set(i, j, random.nextInt(50));
}
}
return result;
}
public static Matrix zeroMatrix(int dim) {
Matrix result = new Matrix(dim);
for (int i = 0; i < dim; i++) {
for (int j = 0; j < dim; j++) {
result.set(i, j, 0);
}
}
return result;
}
}
/**
* All instances of this class will be used in thread local context
*/
private static class ThreadLocals {
private static final int HASH_BOUND = 424242;
private ThreadLocals parent;
private int hash = 42;
public final String name;
public ThreadLocals(ThreadLocals parent, String name) {
this.parent = parent;
this.name = name;
}
public int min(int a, int b) {
updateHash(a + b + 1);
return Math.min(a, b);
}
public int mult(int a, int b) {
updateHash(a + b + 2);
return a * b;
}
public int sum(int a, int b) {
updateHash(a + b + 3);
return a + b;
}
public int updateHash() {
return updateHash(42);
}
public int updateHash(int data) {
hash = (hash + data) % HASH_BOUND;
if (parent != null) {
hash = parent.updateHash(hash) % HASH_BOUND;
}
return hash;
}
public int getHash() {
return hash;
}
}
}

View file

@ -0,0 +1,79 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/exception.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.exception.exception
* @run driver ExecDriver --java jit.exception.exception
*/
package jit.exception;
/*
This JIT buster test checks to see if a JIT doing register allocation
on a machine with a callees saves ABI for non-volatile registers can
get the exception handling correct. Intel and PowerPC are both such
machines. The problem is restoring the correct values of i and j in
the catch block. If i and j are never put into registers, then the
JIT won't have a problem with correctness because the catch block
will load the correct values from memory. If the JIT puts i and j
into registers, then restoring their correct values at the catch
block gets a little bit tougher.
*/
import nsk.share.TestFailure;
class exception {
public static void main(String[] args) {
int i, j;
for (i=0,j=0; i<1000000; i++) {
j=j+1;
j=j+1;
}
try {
int k;
k = div(0);
} catch (Exception e) {
if ((i != 1000000) || (j != 2000000)) {
System.out.println("i=" + i + "(expected 1000000), j = " + j + "(expected 2000000)");
throw new TestFailure("Test FAILS");
} else {
System.out.println("Test PASSES");
}
}
}
static int div(int n) {
int m=15;
m = m/n;
return m;
}
}

View file

@ -0,0 +1,266 @@
/*
* Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package jit.graph;
import java.util.*;
import nsk.share.TestFailure;
import nsk.share.test.StressOptions;
class CGT extends Thread
{
private static StressOptions stressOptions = new StressOptions();
private final static String version = "1.0";
private static String ClistPath = "";
private static long finishTime;
public CGT( String[] args )
{
parse (args);
Globals.initialize(ClistPath);
outputStats (args);
}
public static void main( String[] args )
{
stressOptions.parseCommandLine(args);
CGT jnimt = new CGT(args);
jnimt.start();
}
public void outputStats( String[] args )
{
System.out.println("CGT command line options:");
for (int i=0; i < args.length; ++i )
System.out.println("# " + args[i] );
System.out.println();
System.out.println("CGT parameters");
System.out.println("Seed: " +Globals.RANDOM_SEED);
System.out.println("Number of Threads: " +Globals.NUM_THREADS);
System.out.println("Number of Random Loop iterations: " + Globals.RANDOM_LOOP);
System.out.println("Number of Static Loop iterations: " + Globals.STATIC_LOOP);
System.out.println("Max number of Methods in the Graph: " + Globals.NUM_TEST_CLASSES);
System.out.println("Verbose function calls: " + Globals.VERBOSE);
System.out.println();
}
public void run()
{
finishTime = System.currentTimeMillis() + stressOptions.getTime() * 1000;
for (int i = 0; i< Globals.NUM_THREADS; i++)
new CGTThread("CGT Thread " + i).start();
}
public static boolean shouldFinish()
{
return System.currentTimeMillis() >= finishTime;
}
public void parse (String args[])
{
for (int i = 0; i<args.length; i++)
{
if ((args[i].equalsIgnoreCase("-help")) || (args[i].equalsIgnoreCase("-h")) || (args[i].equalsIgnoreCase("-?")))
{
usage ();
}
else if (args[i].equalsIgnoreCase("-version"))
{
version();
}
else if (args[i].equalsIgnoreCase("-seed"))
{
int argIndex = i+1;
if (argIndex < args.length)
{
try
{
Globals.RANDOM_SEED = Math.abs(Long.parseLong(args[argIndex]));
}
catch (NumberFormatException e)
{
System.out.println("Improper Argument: " + args[i] + " " + args[argIndex]);
usage ();
}
i++;
}
else
{
System.out.println("Improper Argument: " + args[i]);
usage ();
}
}
else if ((args[i].equalsIgnoreCase("-thread")) || (args[i].equalsIgnoreCase("-threads")))
{
int argIndex = i+1;
if (argIndex < args.length)
{
try
{
Globals.NUM_THREADS = Math.abs(Integer.parseInt(args[argIndex])) * stressOptions.getThreadsFactor();
}
catch (NumberFormatException e)
{
System.out.println("Improper Argument: " + args[i] + " " + args[argIndex]);
usage ();
}
if(Globals.NUM_THREADS == 0)
Globals.NUM_THREADS = 1;
i++;
}
else
{
System.out.println("Improper Argument: " + args[i]);
usage ();
}
}
else if (args[i].equalsIgnoreCase("-staticLoop"))
{
int argIndex = i+1;
if (argIndex < args.length)
{
try
{
Globals.STATIC_LOOP = Math.abs(Integer.parseInt(args[argIndex])) * stressOptions.getIterationsFactor();
}
catch (NumberFormatException e)
{
System.out.println("Improper Argument: " + args[i] + " " + args[argIndex]);
usage ();
}
i++;
}
else
{
System.out.println("Improper Argument: " + args[i]);
usage ();
}
}
else if (args[i].equalsIgnoreCase("-randomLoop"))
{
int argIndex = i+1;
if (argIndex < args.length)
{
try
{
Globals.RANDOM_LOOP = Math.abs(Long.parseLong(args[argIndex])) * stressOptions.getIterationsFactor();
}
catch (NumberFormatException e)
{
System.out.println("Improper Argument: " + args[i] + " " + args[argIndex]);
usage ();
}
i++;
}
else
{
System.out.println("Improper Argument: " + args[i]);
usage ();
}
}
else if (args[i].equalsIgnoreCase("-numTestClass"))
{
int argIndex = i+1;
if (argIndex < args.length)
{
try
{
Globals.NUM_TEST_CLASSES = Math.abs(Integer.parseInt(args[argIndex]));
}
catch (NumberFormatException e)
{
System.out.println("Improper Argument: " + args[i] + " " + args[argIndex]);
usage ();
}
i++;
}
else
{
System.out.println("Improper Argument: " + args[i]);
usage ();
}
}
else if (args[i].equalsIgnoreCase("-v") || args[i].equalsIgnoreCase("-verbose"))
{
Globals.VERBOSE = true;
}
else if (args[i].equalsIgnoreCase("-path"))
{
int argIndex = i+1;
if (argIndex < args.length)
{
ClistPath = args[argIndex];
i++;
}
else
{
System.out.println("Improper Argument: " + args[i]);
usage ();
}
}
else if (args[i].startsWith("-stress"))
{
break;
}
else
{
System.out.println("Invalid Argument: " + args[i]);
usage ();
}
}
if (ClistPath.equals(""))
{
System.out.println("class list path not defined");
usage();
}
}
public void usage ()
{
System.out.println("usage: java CGT [options]");
System.out.println(" -help prints out this message");
System.out.println(" -numTestClass # limits the number of \"Test Methods\" to #");
System.out.println(" -randomcLoop # # of random function calls");
System.out.println(" -seed # uses the specified seed rather than the System Time");
System.out.println(" -staticLoop # # of non-random static function calls");
System.out.println(" -threads # # number of test threads, NOTE: no maximum value");
System.out.println(" -version print out the tool version");
System.out.println(" -v -verbose turn on verbose mode");
throw new TestFailure(" -path <path to classlist> required, argument so program can find classes");
}
public void version ()
{
throw new TestFailure("CGT version = " + version);
}
}

View file

@ -0,0 +1,139 @@
/*
* Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package jit.graph;
import java.util.*;
import java.lang.*;
import java.lang.reflect.*;
import nsk.share.TestFailure;
class CGTThread extends Thread
{
private String ThreadName = null;
private Vector Sumation = new Vector(100000);
private Vector IDlist = new Vector(100000);
CGTThread( String name )
{
ThreadName = name;
setName(name);
}
public void run()
{
if (Globals.VERBOSE)
System.out.println("\t\t" + Thread.currentThread().getName() + " started");
Long numFcalls = new Long(Globals.RANDOM_LOOP - 1);
Integer staticFcalls = new Integer(Globals.STATIC_LOOP);
MethodData methodCallStr = Globals.nextRandomMethod();
Globals.addFunctionIDToVector(methodCallStr.id, IDlist);
Throwable invocationExcept = null;
boolean skipVerify = false;
try
{
methodCallStr.nextMethod.invoke(methodCallStr.instance, new Object []{Sumation, IDlist, numFcalls, staticFcalls});
}
catch (IllegalAccessException iax)
{
throw new TestFailure("Illegal Access Exception");
}
catch (InvocationTargetException itx)
{
System.out.println("Invocation Target Exception");
invocationExcept = itx.getTargetException();
System.out.println(invocationExcept);
if (invocationExcept.getClass() == itx.getClass())
{
System.out.println("Processing Exception Invocation Target Exception");
while (invocationExcept.getClass() == itx.getClass())
invocationExcept = ((InvocationTargetException)invocationExcept).getTargetException();
System.out.println(invocationExcept);
}
if (invocationExcept instanceof StackOverflowError)
//StackOverFlow is not a failure
{
System.out.println("Warning: stack overflow: skipping verification...");
skipVerify = true;
}
else if (invocationExcept instanceof OutOfMemoryError)
//OutOfMemoryError is not a failure
{
System.out.println("Warning: test devoured heap ;), skipping verification...");
skipVerify = true;
}
else
{
invocationExcept.printStackTrace();
System.exit(1);
}
}
if( !skipVerify )
verify(Sumation, IDlist);
}
void verify(Vector Sum, Vector ID)
{
long oldsum = 0;
long newsum;
System.out.println(ThreadName + " has begun call stack validation");
if (Sum.size() != ID.size())
{
System.out.println("Vector Length's Do Not Match, VERIFY ERROR");
System.out.println("Thread Name: " + ThreadName);
throw new TestFailure("Sumation Element Count = " + Sum.size() + " ID Element Count = " +ID.size());
}
long vectorSize = Sum.size();
while (!Sum.isEmpty())
{
if (CGT.shouldFinish())
{
System.out.println(Thread.currentThread().getName() + ": skipping verification due to timeout");
return;
}
newsum = ((Long)Sum.firstElement()).longValue();
Sum.removeElementAt(0);
int functionID = ((Integer)ID.firstElement()).intValue();
ID.removeElementAt(0);
if ((newsum - oldsum) != (functionID))
{
System.out.println("Function Call structure invalid, VERIFY ERROR");
System.out.println("Thread Name: " + ThreadName);
System.out.println("Expected = " +(newsum - oldsum) + " Actual = " +functionID);
throw new TestFailure("Test failed.");
// System.exit(1);
}
oldsum = newsum;
}
Globals.decNumThreads();
System.out.println(ThreadName + "'s function call structure validated succesfully ("+vectorSize+" calls validated)");
}
}

View file

@ -0,0 +1,284 @@
/*
* Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package jit.graph;
import java.io.*;
import java.util.*;
import java.lang.*;
import java.lang.reflect.*;
import nsk.share.TestFailure;
public final class Globals
{
// Minimum and Maximum number of threads
public static int NUM_THREADS = 1;
public static long RANDOM_SEED = System.currentTimeMillis();
public static int STATIC_LOOP = 0;
public static int NUM_TEST_CLASSES = 7;
public static long RANDOM_LOOP = 100;
public static boolean VERBOSE = false;
private static Random indexGenerator = null;
//private static TestLoader CGTTestLoader = null;
private static String [] ClassArray = null;
private static Class [] ClassInstanceArray = null;
private static int maxClassIndex = 0;
private static String [] MethodName_Array = null;
private static Method [] MethodInstance_Array = null;
//Should be prime, so that odds of an incorrect verification reduced
public static int [] MethodID_Array = null;
//Number of threads will be reduced as threads finish
public static synchronized void decNumThreads(){NUM_THREADS--;};
public static synchronized void initialize(String testListPath)
{
File td = new File (testListPath);
if (!td.exists())
{
System.err.println("File " + testListPath + " Not found");
System.exit(1);
}
if (!td.isFile())
{
System.err.println(testListPath + " Must be a File");
System.exit(1);
}
BufferedReader classList = null;
try
{
classList = new BufferedReader(new FileReader(td));
}
catch (FileNotFoundException fnfx)
{
System.err.println("Error finding Classlist");
System.exit(1);
}
String line = null;
try
{
line = classList.readLine();
}
catch (IOException iox)
{
System.err.println("Error reading Classlist");
System.exit(1);
}
try
{
maxClassIndex = Math.abs(Integer.parseInt(line));//ClassArray.length;
}
catch (NumberFormatException nfx)
{
System.err.println("Error reading Classlist - first number must be number of methods defined");
System.exit(1);
}
ClassArray = new String [maxClassIndex];
ClassInstanceArray = new Class [maxClassIndex];
MethodName_Array = new String [maxClassIndex];
MethodInstance_Array = new Method [maxClassIndex];
MethodID_Array = new int [maxClassIndex];
int i;
for (i = 0; (i<maxClassIndex) && (line != null); i++)
{
try
{
line = classList.readLine();
}
catch (IOException iox)
{
System.err.println("Error reading ClasslistFile: testListPath");
System.exit(1);
}
StringTokenizer lineTokens = new StringTokenizer(line, "\t ");
if (lineTokens.countTokens() <3)
{
System.out.println("Error reading ClasslistFile: Errored line");
i--;
}
else
{
ClassArray[i] = lineTokens.nextToken();
MethodName_Array[i] =lineTokens.nextToken();
MethodID_Array[i] = Integer.parseInt(lineTokens.nextToken());
}
}
maxClassIndex = i;
indexGenerator = new Random(RANDOM_SEED);
if ((NUM_TEST_CLASSES < ClassArray.length) && (NUM_TEST_CLASSES > 0))
maxClassIndex = NUM_TEST_CLASSES;
else
NUM_TEST_CLASSES = maxClassIndex;
}
//does a binary serach to find the index for the ID of a method
private static int ID_BinSearch(int begin, int end, int ID)
{
if (end < begin)
return(-1);
int mid = (begin + end)/2;
int midvalue = MethodID_Array[mid];
if (ID == midvalue)
return (mid);
else if (ID < midvalue)
return(ID_BinSearch(begin, mid-1, ID));
else
return(ID_BinSearch(mid+1, end, ID));
}
//based off a static index, this function selects the method to be called
public static MethodData returnNextStaticMethod(int Method_ID)
{
//int i = ID_BinSearch(0, MethodID_Array.length - 1, Method_ID);
int i = ID_BinSearch(0, maxClassIndex - 1, Method_ID);
return(nextStaticMethod((i==-1)?0:i));
}
//this function randomly selects the next method to be called by the test class
public static MethodData nextRandomMethod()
{
int i = indexGenerator.nextInt(maxClassIndex);
return(nextStaticMethod(i));
}
private static MethodData nextStaticMethod(int i)
{
Class methodsClass = null;
Method nextMethod = null;
try
{
//methodsClass = CGTTestLoader.findClass(ClassArray[i]);
methodsClass = ClassInstanceArray[i];
if (methodsClass == null)
{
methodsClass = Class.forName(ClassArray[i]);
ClassInstanceArray[i] = methodsClass;
}
nextMethod = MethodInstance_Array[i];
if (nextMethod == null )
{
nextMethod =
methodsClass.getMethod(MethodName_Array[i],
new Class[]{java.util.Vector.class, java.util.Vector.class,
java.lang.Long.class, java.lang.Integer.class});
//sum vector, ID vector, function depth, static function call depth
MethodInstance_Array[i] = nextMethod;
}
}
catch (ClassNotFoundException cnfx)
{
System.out.println("Class: " +ClassArray[i]+ " Not Found");
System.exit(-1);
}
catch (NoSuchMethodException nsmx)
{
System.out.println("Class: " +ClassArray[i]);
System.out.println("Method: " +MethodName_Array[i]+" Not Found");
System.exit(-1);
}
catch (SecurityException sx)
{
System.out.println("Class: " +ClassArray[i]);
System.out.println("Method: " +MethodName_Array[i]);
System.out.println("Security Exception Generated, by above method call");
System.exit(-1);
}
return(new MethodData(ClassArray[i], MethodName_Array[i], methodsClass, nextMethod, MethodID_Array[i]));
}
/*These two functions are used to verify that all function were called in the proper order*/
//called by "parent" function to add childs ID to vector
public static void addFunctionIDToVector(int FunctionIndex, Vector IDVector)
{
IDVector.addElement(new Integer(FunctionIndex));
}
//called by "child" to add Function Index to Vector
public static void appendSumToSumationVector(int FunctionIndex, Vector SummationVector)
{
if (SummationVector.isEmpty())
SummationVector.addElement(new Long(FunctionIndex));
else
SummationVector.addElement(new Long(((Long)SummationVector.lastElement()).longValue() + FunctionIndex));
}
//This function calls a method based off of MethodData
public static void callMethod(MethodData methodCallStr,
Vector summation, Vector ID,
Long numFcalls, Integer staticFcalls)
throws InvocationTargetException
{
if(NUM_THREADS >1)
{
if ((staticFcalls.intValue() + numFcalls.longValue()) %23 == 0)
{
try
{
Thread.sleep(225);
}
catch (InterruptedException ie)
{}
if (VERBOSE)
System.out.println("\t\tCurrentThread:" + Thread.currentThread().getName());
}
}
try
{
methodCallStr.nextMethod.invoke(methodCallStr.instance,
new Object []{summation, ID, numFcalls, staticFcalls});
}
catch (IllegalAccessException iax) //should never happen with a valid testfile
{
throw new TestFailure("Illegal Access Exception");
}
/*
catch (InvocationTargetException itx)
{
itx.printStackTrace();
System.out.println("Invocation Target Exception");
System.exit(1);
}*/
}
}

View file

@ -0,0 +1,56 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package jit.graph;
import java.lang.reflect.*;
import nsk.share.TestFailure;
public final class MethodData
{
public String ClassName;
public String MethodName;
public Class ClassObject;
public Method nextMethod;
public int id;
public Object instance = null;
MethodData(String ClassName, String MethodName, Class ClassObject,Method nextMethod, int id)
{
this.ClassName = ClassName;
this.MethodName = MethodName;
this.nextMethod = nextMethod;
this.id = id;
this.ClassObject = ClassObject;
try
{
this.instance = ClassObject.newInstance();
}
catch (InstantiationException ix)
{
throw new TestFailure("Class: " +ClassName+ " Instantiation Exception");
}
catch (IllegalAccessException iax)
{
throw new TestFailure("Class: " +ClassName+ " Illegal Access Exception");
}
}
}

View file

@ -0,0 +1,133 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package jit.graph;
import nsk.share.TestFailure;
// This class define the tree node.
public class Node
{
public final static int Black = 0; // constants used to define the
public final static int Red = 1; // node color
public final static int Left_son = 2; // constants used to identify
public final static int Right_son = 3;// the node parent and sons.
public final static int Parent = 4;
private int color;
private int key;
private Node L,R,P; // L-left son,R-right son,P-parent
// constructor create a new node the default color is red
// the default appearance (bold) is regular.
// initialize the key field.
public Node(int k)
{
color = Red;
key = k;
L = null;
R = null;
P = null;
}
// constructor for constructing a tree null object, is color
// is black.
public Node()
{
color = Black;
key = -1;
L = null;
R = null;
P = null;
}
// This method set the node key.
public void setKey(int k)
{
key = k;
}
// This method return the node key.
public int getKey()
{
return (key);
}
// This method set the node color.
public void setColor(int c)
{
if (c == Black)
color = Black;
else
if (c == Red)
color = Red;
}
// This method return the node color.
public int getColor()
{
return (color);
}
// This method set the node parent or childs acording to the who
// parameter.
public void setNode(int who,Node n)
{
switch (who)
{
case Left_son:
L = n;
break;
case Right_son:
R = n;
break;
case Parent:
P = n;
break;
}
}
// This method return the node parent or childs acording to the who
// parameter.
public Node getNode(int who)
{
switch (who)
{
case Left_son:
return (L);
case Right_son:
return (R);
case Parent:
return (P);
}
return (null);
}
}

View file

@ -0,0 +1,727 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package jit.graph;
import nsk.share.TestFailure;
//import Node;
// This class defines the tree object.
public class RBTree
{
public final static int maxNodes = 70; // maximum nodes allowed.
public final static int INSERT = 0; // constants indicating
public final static int DELETE = 1; // the current operation
public final static int NOP = 2;
public final static Node treeNull = new Node(); // the tree NULL node.
private Node root;
private int num_of_nodes;
private int height; // The tree heigth ,it is updated
// in each operation.
// since the algorithem is executed in stages I have to remember data
// on the state.
private Node node; // The current operation is being done on it.
private int action;// The operation being performed (insert / delete)
private int stage; // The current stage of execution
// the constructor initialize the object fields.
public RBTree()
{
root = treeNull;
node = treeNull;
num_of_nodes = 0;
height = 0;
action = NOP;
stage = 0;
}
// This method return the root of the tree.
public Node getRoot()
{
return root;
}
// This method return the number of nodes in the tree.
public int getNodes()
{
return num_of_nodes;
}
// This method return the heigth of the tree.
public int getHeight()
{
return height;
}
// This method inserts k into the Red Black Tree
public boolean RBInsert(int k)
{
Thread Pause = new Thread(); // this thread is used for delay
// between the stages.
if (action != NOP) // checking similar to the RB_Insert method
{
System.out.println
("Only one operation can be done at a time.");
return false;
}
if (num_of_nodes == maxNodes)
{
System.out.println
("The maximum nodes allowed is already reached.");
return false;
}
if (Search(k) == treeNull) // Check if there is already node with key k.
{
action = INSERT;
node = new Node(k);
node.setNode(Node.Left_son,treeNull);
node.setNode(Node.Right_son,treeNull);
node.setNode(Node.Parent,treeNull);
stage = 1;
while (stage != 0) // This is the loop that perform all the
{ // operation steps.
InsertStep(); // perform one step
updateHeight(); // update the tree height
}
action = NOP; // set the action to NoOPretion.
return true;
}
else
System.out.println
("Insertion failed. This key already exist.");
return false;
}
// This method deletes the element k from the Red Black tree
public boolean RBDelete(int k)
{
Thread Pause = new Thread(); // this thread is used for delay
// between the stages.
if (action != NOP)
{ // checking like in RB_Delete method
System.out.println
("Only one operation can be done at a time.");
return false;
}
node = Search(k);
if (node != treeNull) // Check if there is a node with key k.
{
action = DELETE;
stage = 1;
while (stage != 0) // this loop perform all the operation
{ // steps.
DeleteStep(); // perform one step
updateHeight(); // update the tree height
}
action = NOP;
return true;
}
else
System.out.println
("Deletion failed. This key doesn't exist.");
return false;
}
// This method perform one step in the insertion operation.
// If perform a step acording to the stage variable.
// I will not explain exactly what each stage do, just that they
// divided to 4 categories:
// 1. inserting a node to the tree.
// 2. marking nodes that will be recolored.
// 3. recoloring nodes.
// 4. rotating right or left.
private void InsertStep()
{
Node Pr,GrPr,Un; // Pr is parent, GrPr is grandparent
// and Un is uncle.
switch (stage)
{
case 1: // Inserting a node to the tree
/*
System.out.println // send a message to the screen
(new String("Inserting ")
.concat(Integer.toString(node.getKey())));
*/
Tree_Insert(); // inserting an element to the tree
break;
case 2: // mid stage that move to algorithem to the
// proper next stage, and send proper message
// to the screen
Pr = node.getNode(Node.Parent);
GrPr = Pr.getNode(Node.Parent);
if (Pr == GrPr.getNode(Node.Left_son))
{
Un = GrPr.getNode(Node.Right_son);
if (Un.getColor() == Node.Red)
{
stage = 3;
}
else
if (node == Pr.getNode(Node.Right_son))
{
node = Pr;
stage = 5;
}
else
{
stage = 6;
}
}
else
{
Un = GrPr.getNode(Node.Left_son);
if (Un.getColor() == Node.Red)
{
stage = 3;
}
else
if (node == Pr.getNode(Node.Left_son))
{
node = Pr;
stage = 5;
}
else
{
stage = 6;
}
}
break;
case 3: // This stage marks node that will be recolored
Pr = node.getNode(Node.Parent);
GrPr = Pr.getNode(Node.Parent);
if (Pr == GrPr.getNode(Node.Left_son))
Un = GrPr.getNode(Node.Right_son);
else
Un = GrPr.getNode(Node.Left_son);
node = GrPr;
stage = 4;
break;
case 4: // this stage recolor marked nodes.
node.setColor(Node.Red);
(node.getNode(Node.Left_son)).setColor(Node.Black);
(node.getNode(Node.Right_son)).setColor(Node.Black);
if ((node == root) ||
((node.getNode(Node.Parent)).getColor() == Node.Black))
if (root.getColor() == Node.Red)
{
stage = 9;
}
else
stage = 0;
else
{
stage = 2;
InsertStep();
}
break;
case 5: // This stage perform rotation operation
Pr = node.getNode(Node.Parent);
if (node == Pr.getNode(Node.Left_son))
Left_Rotate(node);
else
Right_Rotate(node);
stage = 6;
break;
case 6: // This stage marks nodes that will be recolor.
Pr = node.getNode(Node.Parent);
GrPr = Pr.getNode(Node.Parent);
stage = 7;
break;
case 7: // This stage recolor marked nodes.
Pr = node.getNode(Node.Parent);
Pr.setColor(Node.Black);
GrPr = Pr.getNode(Node.Parent);
GrPr.setColor(Node.Red);
stage = 8;
break;
case 8: // This stage perform rotation operation
Pr = node.getNode(Node.Parent);
GrPr = Pr.getNode(Node.Parent);
if (Pr == GrPr.getNode(Node.Left_son))
Right_Rotate(GrPr);
else
Left_Rotate(GrPr);
if (root.getColor() == Node.Red)
{
stage = 9;
}
else
stage = 0;
break;
case 9: // this stage mark the root.
stage = 10;
break;
case 10: // This stage recolor the root.
root.setColor(Node.Black);
stage = 0;
break;
}
}
// This method perform one step in the deletion operation.
// If perform a step acording to the stage variable.
// I will explain exactly what each stage do, just that they
// divided to 4 categories:
// 1. deleting a node from the tree.
// 2. marking nodes that will be recolored.
// 3. recoloring nodes.
// 4. rotating right or left.
public void DeleteStep()
{
Node Pr,Br; // Pr is Parent ,Br is Brother
switch (stage)
{
case 1: // This stage delete a node from the tree.
/*
System.out.println
(new String("Deleting ")
.concat(Integer.toString(node.getKey())));
*/
Tree_Delete();
break;
case 2: // This stage marks a nodes that will be recolored
// or perform other stage.
Pr = node.getNode(Node.Parent);
if (node == Pr.getNode(Node.Left_son))
Br = Pr.getNode(Node.Right_son);
else
Br = Pr.getNode(Node.Left_son);
if (Br.getColor() == Node.Red)
{
stage = 3;
}
else
if (((Br.getNode(Node.Right_son)).getColor() == Node.Black)
&& ((Br.getNode(Node.Left_son)).getColor() == Node.Black))
{
stage = 5;
DeleteStep();
}
else
{
stage = 7;
DeleteStep();
}
break;
case 3: // this stage recolor marked nodes.
Pr = node.getNode(Node.Parent);
if (node == Pr.getNode(Node.Left_son))
{
Br = Pr.getNode(Node.Right_son);
}
else
{
Br = Pr.getNode(Node.Left_son);
}
Br.setColor(Node.Black);
Pr.setColor(Node.Red);
stage = 4;
break;
case 4: // this stage perform rotation operation
Pr = node.getNode(Node.Parent);
if (node == Pr.getNode(Node.Left_son))
{
Left_Rotate(Pr);
Br = Pr.getNode(Node.Right_son);
}
else
{
Right_Rotate(Pr);
Br = Pr.getNode(Node.Left_son);
}
if (((Br.getNode(Node.Right_son)).getColor() == Node.Black)
&& ((Br.getNode(Node.Left_son)).getColor() == Node.Black))
stage = 5;
else
stage = 7;
break;
case 5: // this stage marks nodes that will be recolor.
Pr = node.getNode(Node.Parent);
if (node == Pr.getNode(Node.Left_son))
Br = Pr.getNode(Node.Right_son);
else
Br = Pr.getNode(Node.Left_son);
stage = 6;
break;
case 6: // This stage recolor marked nodes.
Pr = node.getNode(Node.Parent);
if (node == Pr.getNode(Node.Left_son))
Br = Pr.getNode(Node.Right_son);
else
Br = Pr.getNode(Node.Left_son);
Br.setColor(Node.Red);
node = Pr;
if ((node != root) && (node.getColor() == Node.Black))
stage = 2;
else
if (node.getColor() == Node.Red)
{
stage = 13;
}
else
stage = 0;
break;
case 7: // this stage marks nodes that will be recolor
// or perform other stage.
Pr = node.getNode(Node.Parent);
if (node == Pr.getNode(Node.Left_son))
{
Br = Pr.getNode(Node.Right_son);
if ((Br.getNode(Node.Right_son)).getColor() == Node.Black)
{
stage = 8;
}
else
{
stage = 10;
DeleteStep();
}
}
else
{
Br = Pr.getNode(Node.Left_son);
if ((Br.getNode(Node.Left_son)).getColor() == Node.Black)
{
stage = 8;
}
else
{
stage = 10;
DeleteStep();
}
}
break;
case 8: // this stage recolor marked nodes.
Pr = node.getNode(Node.Parent);
if (node == Pr.getNode(Node.Left_son))
{
Br = Pr.getNode(Node.Right_son);
(Br.getNode(Node.Left_son)).setColor(Node.Black);
}
else
{
Br = Pr.getNode(Node.Left_son);
(Br.getNode(Node.Right_son)).setColor(Node.Black);
}
Br.setColor(Node.Red);
stage = 9;
break;
case 9: // this stage perform rotation operation
Pr = node.getNode(Node.Parent);
if (node == Pr.getNode(Node.Left_son))
{
Br = Pr.getNode(Node.Right_son);
Right_Rotate(Br);
}
else
{
Br = Pr.getNode(Node.Left_son);
Left_Rotate(Br);
}
stage = 10;
break;
case 10: // This stage marks node that will be recolor.
Pr = node.getNode(Node.Parent);
if (node == Pr.getNode(Node.Left_son))
{
Br = Pr.getNode(Node.Right_son);
}
else
{
Br = Pr.getNode(Node.Left_son);
}
stage = 11;
break;
case 11: // this stage recolor marked nodes.
Pr = node.getNode(Node.Parent);
if (node == Pr.getNode(Node.Left_son))
{
Br = Pr.getNode(Node.Right_son);
(Br.getNode(Node.Right_son)).setColor(Node.Black);
}
else
{
Br = Pr.getNode(Node.Left_son);
(Br.getNode(Node.Left_son)).setColor(Node.Black);
}
if (Br.getColor() != Pr.getColor())
Br.setColor(Pr.getColor());
if (Pr.getColor() != Node.Black)
Pr.setColor(Node.Black);
stage = 12;
break;
case 12: // this stage perform rotation operation.
Pr = node.getNode(Node.Parent);
if (node == Pr.getNode(Node.Left_son))
Left_Rotate(Pr);
else
Right_Rotate(Pr);
node = root;
if (node.getColor() == Node.Red)
{
stage = 13;
}
else
stage = 0;
break;
case 13: // this stage marks a node that will be recolor
stage = 14;
break;
case 14: // this stage recolor marked node.
node.setColor(Node.Black);
stage = 0;
break;
}
}
// This method insert the node 'node' to the tree.
// it called from the first stage in the InsertStep method.
// we 'dive' from the root to a leaf acording to the node key
// and insert the node in the proper place.
private void Tree_Insert()
{
Node n1,n2;
n1 = root;
n2 = treeNull;
while (n1 != treeNull)
{
n2 = n1;
if (node.getKey() < n1.getKey())
n1 = n1.getNode(Node.Left_son);
else
n1 = n1.getNode(Node.Right_son);
}
node.setNode(Node.Parent,n2);
if (n2 == treeNull)
root = node;
else
{
if (node.getKey() < n2.getKey())
n2.setNode(Node.Left_son,node);
else
n2.setNode(Node.Right_son,node);
}
//Parent.display.drawTree();
// updating the insertion stage.
if ((node == root) ||
((node.getNode(Node.Parent)).getColor() == Node.Black))
if (root.getColor() == Node.Red)
{
stage = 9;
}
else
stage = 0;
else
{
stage = 2;
InsertStep();
}
num_of_nodes++; // increasing the number of nodes
}
// This method delete the node 'node' from the tree.
// it called from the first stage in the DeleteStep method.
// if node has at most one son we just remove it and connect
// his son and parent. If it has 2 sons we delete his successor
// that has at most one son and replace him with the successor.
private void Tree_Delete()
{
Node n1,n2,n3;
if ((node.getNode(Node.Left_son) == treeNull) ||
(node.getNode(Node.Right_son) == treeNull))
n1 = node;
else
n1 = Tree_Successor(node);
if (n1.getNode(node.Left_son) != treeNull)
n2 = n1.getNode(Node.Left_son);
else
n2 = n1.getNode(Node.Right_son);
n3 = n1.getNode(Node.Parent);
n2.setNode(Node.Parent,n3);
if (n3 == treeNull)
root = n2;
else
if (n1 == n3.getNode(Node.Left_son))
n3.setNode(Node.Left_son,n2);
else
n3.setNode(Node.Right_son,n2);
if (n1 != node)
{
node.setKey(n1.getKey());
}
node = n2;
if (n1.getColor() == Node.Black)
if ((node != root) && (node.getColor() == Node.Black))
stage = 2;
else
if (node.getColor() == Node.Red)
stage = 13;
else
stage = 0;
else
stage = 0;
num_of_nodes--; // decrease the number of nodes.
}
// This method return the successor of the node n in the tree.
private Node Tree_Successor(Node n)
{
Node n1;
if (n.getNode(Node.Right_son) != treeNull)
{
n = n.getNode(Node.Right_son);
while (n.getNode(Node.Left_son) != treeNull)
n = n.getNode(Node.Left_son);
return n;
}
n1 = n.getNode(Node.Parent);
while ((n1 != treeNull) && (n == n1.getNode(Node.Right_son)))
{
n = n1;
n1 = n1.getNode(Node.Parent);
}
return n1;
}
// This method perform Left Rotation with n1.
private void Left_Rotate(Node n1)
{
Node n2;
n2 = n1.getNode(Node.Right_son);
n1.setNode(Node.Right_son,n2.getNode(Node.Left_son));
if (n2.getNode(Node.Left_son) != treeNull)
(n2.getNode(Node.Left_son)).setNode(Node.Parent,n1);
n2.setNode(Node.Parent,n1.getNode(Node.Parent));
if (n1.getNode(Node.Parent) == treeNull)
root = n2;
else
if (n1 == (n1.getNode(Node.Parent)).getNode(Node.Left_son))
(n1.getNode(Node.Parent)).setNode(Node.Left_son,n2);
else
(n1.getNode(Node.Parent)).setNode(Node.Right_son,n2);
n2.setNode(Node.Left_son,n1);
n1.setNode(Node.Parent,n2);
}
// This method perform Right Rotation with n1.
private void Right_Rotate(Node n1)
{
Node n2;
n2 = n1.getNode(Node.Left_son);
n1.setNode(Node.Left_son,n2.getNode(Node.Right_son));
if (n2.getNode(Node.Right_son) != treeNull)
(n2.getNode(Node.Right_son)).setNode(Node.Parent,n1);
n2.setNode(Node.Parent,n1.getNode(Node.Parent));
if (n1.getNode(Node.Parent) == treeNull)
root = n2;
else
if (n1 == (n1.getNode(Node.Parent)).getNode(Node.Left_son))
(n1.getNode(Node.Parent)).setNode(Node.Left_son,n2);
else
(n1.getNode(Node.Parent)).setNode(Node.Right_son,n2);
n2.setNode(Node.Right_son,n1);
n1.setNode(Node.Parent,n2);
}
// This method search the tree for a node with key 'key', and
// return the node on success otherwise treeNull.
public Node Search(int key)
{
Node node;
node = root;
while ((node != treeNull) && (key != node.getKey()))
if (key < node.getKey())
node = node.getNode(Node.Left_son);
else
node = node.getNode(Node.Right_son);
return node;
}
// This method update the tree height it uses a recursive method
// findheight.
private void updateHeight()
{
height = 0;
if (root != treeNull)
findHeight(root,1);
}
// This is a recursive method that find a node height.
private void findHeight(Node n,int curr)
{
if (height < curr)
height = curr;
if (n.getNode(Node.Left_son) != treeNull)
findHeight(n.getNode(Node.Left_son),curr+1);
if (n.getNode(Node.Right_son) != treeNull)
findHeight(n.getNode(Node.Right_son),curr+1);
}
}

View file

@ -0,0 +1,44 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/graph/cgt0.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run driver jdk.test.lib.FileInstaller ../data/main.data main.data
* @build jit.graph.*
* @run driver ExecDriver --java
* jit.graph.CGT
* -path main.data
* -numTestClass 1
* -thread 1
* -randomLoop 40
* -staticLoop 40
*/

View file

@ -0,0 +1,44 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/graph/cgt1.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run driver jdk.test.lib.FileInstaller ../data/main.data main.data
* @build jit.graph.*
* @run driver ExecDriver --java
* jit.graph.CGT
* -path main.data
* -numTestClass 2
* -thread 1
* -randomLoop 40
* -staticLoop 40
*/

View file

@ -0,0 +1,44 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/graph/cgt10.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run driver jdk.test.lib.FileInstaller ../data/main.data main.data
* @build jit.graph.*
* @run driver ExecDriver --java
* jit.graph.CGT
* -path main.data
* -numTestClass 11
* -thread 1
* -randomLoop 40
* -staticLoop 40
*/

View file

@ -0,0 +1,44 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/graph/cgt11.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run driver jdk.test.lib.FileInstaller ../data/main.data main.data
* @build jit.graph.*
* @run driver ExecDriver --java
* jit.graph.CGT
* -path main.data
* -numTestClass 12
* -thread 1
* -randomLoop 40
* -staticLoop 40
*/

View file

@ -0,0 +1,44 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/graph/cgt2.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run driver jdk.test.lib.FileInstaller ../data/main.data main.data
* @build jit.graph.*
* @run driver ExecDriver --java
* jit.graph.CGT
* -path main.data
* -numTestClass 3
* -thread 1
* -randomLoop 40
* -staticLoop 40
*/

View file

@ -0,0 +1,44 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/graph/cgt3.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run driver jdk.test.lib.FileInstaller ../data/main.data main.data
* @build jit.graph.*
* @run driver ExecDriver --java
* jit.graph.CGT
* -path main.data
* -numTestClass 4
* -thread 1
* -randomLoop 40
* -staticLoop 40
*/

View file

@ -0,0 +1,44 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/graph/cgt4.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run driver jdk.test.lib.FileInstaller ../data/main.data main.data
* @build jit.graph.*
* @run driver ExecDriver --java
* jit.graph.CGT
* -path main.data
* -numTestClass 5
* -thread 1
* -randomLoop 40
* -staticLoop 40
*/

View file

@ -0,0 +1,44 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/graph/cgt5.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run driver jdk.test.lib.FileInstaller ../data/main.data main.data
* @build jit.graph.*
* @run driver ExecDriver --java
* jit.graph.CGT
* -path main.data
* -numTestClass 6
* -thread 1
* -randomLoop 40
* -staticLoop 40
*/

View file

@ -0,0 +1,44 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/graph/cgt6.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run driver jdk.test.lib.FileInstaller ../data/main.data main.data
* @build jit.graph.*
* @run driver ExecDriver --java
* jit.graph.CGT
* -path main.data
* -numTestClass 7
* -thread 1
* -randomLoop 40
* -staticLoop 40
*/

View file

@ -0,0 +1,44 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/graph/cgt7.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run driver jdk.test.lib.FileInstaller ../data/main.data main.data
* @build jit.graph.*
* @run driver ExecDriver --java
* jit.graph.CGT
* -path main.data
* -numTestClass 8
* -thread 1
* -randomLoop 40
* -staticLoop 40
*/

View file

@ -0,0 +1,44 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/graph/cgt8.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run driver jdk.test.lib.FileInstaller ../data/main.data main.data
* @build jit.graph.*
* @run driver ExecDriver --java
* jit.graph.CGT
* -path main.data
* -numTestClass 9
* -thread 1
* -randomLoop 40
* -staticLoop 40
*/

View file

@ -0,0 +1,44 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/graph/cgt9.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run driver jdk.test.lib.FileInstaller ../data/main.data main.data
* @build jit.graph.*
* @run driver ExecDriver --java
* jit.graph.CGT
* -path main.data
* -numTestClass 10
* -thread 1
* -randomLoop 40
* -staticLoop 40
*/

View file

@ -0,0 +1,13 @@
12
jit.graph.test1 callMe 1
jit.graph.test2 callMe 2
jit.graph.test2 CallCallMe 3
jit.graph.test3 callMe 5
jit.graph.test3 selfRecursion 7
jit.graph.test4 CallCallMe 11
jit.graph.test4 callMe 13
jit.graph.test5 factTest 17
jit.graph.test5 fiboTest 19
jit.graph.test5 combTest 23
jit.graph.test5 pascalTest 29
jit.graph.test6 rbTest 31

View file

@ -0,0 +1,78 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package jit.graph;
import java.util.*;
import java.lang.reflect.*;
import nsk.share.TestFailure;
class test1
{
private final int classID = Globals.MethodID_Array[0];
public void callMe(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
throws InvocationTargetException
{
Globals.appendSumToSumationVector(classID, summation);
if (CGT.shouldFinish())
return;
if (Globals.VERBOSE)
System.out.println("test1.callMe");
if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0))
{
return;
}
MethodData methodCallStr;
Long numFcalls;
Integer staticFcalls;
if (staticFunctionDepth.intValue() > 0)
{
numFcalls = functionDepth;
staticFcalls = new Integer(staticFunctionDepth.intValue()-1);
//methodCallStr = Globals.nextStaticMethod(Globals.getIndexFromID(classID));
methodCallStr = Globals.returnNextStaticMethod(classID);
}
else
{
numFcalls = new Long(functionDepth.longValue() -1);
staticFcalls = staticFunctionDepth;
methodCallStr = Globals.nextRandomMethod();
}
Globals.addFunctionIDToVector(methodCallStr.id, ID);
try {
methodCallStr.nextMethod.invoke(methodCallStr.instance,
new Object []{summation, ID, numFcalls, staticFcalls});
} catch (IllegalAccessException iax) {
throw new TestFailure("Illegal Access Exception");
}
}
}

View file

@ -0,0 +1,145 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package jit.graph;
import java.util.*;
import java.lang.reflect.*;
import nsk.share.TestFailure;
class test2
{
private final int[] MethodID = {Globals.MethodID_Array[1],Globals.MethodID_Array[2]};
public void CallCallMe(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
throws InvocationTargetException
{
Globals.appendSumToSumationVector(MethodID[1], summation);
if (CGT.shouldFinish())
return;
if (Globals.VERBOSE)
System.out.println("test2.CallCallMe");
if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0))
{
return;
}
MethodData methodCallStr;
Long numFcalls;
Integer staticFcalls;
if (staticFunctionDepth.intValue() > 0)
{
numFcalls = functionDepth;
staticFcalls = new Integer(staticFunctionDepth.intValue()-1);
//methodCallStr = Globals.nextStaticMethod(Globals.getIndexFromID(MethodID[1]));
methodCallStr = Globals.returnNextStaticMethod(MethodID[1]);
Globals.addFunctionIDToVector(methodCallStr.id, ID);
}
else
{
numFcalls = new Long(functionDepth.longValue()-1);
staticFcalls = staticFunctionDepth;
Globals.addFunctionIDToVector(MethodID[0], ID);
callMe(summation, ID, numFcalls, staticFcalls);
return;
}
try
{
methodCallStr.nextMethod.invoke(methodCallStr.instance,
new Object []{summation, ID, numFcalls, staticFcalls});
}
catch (IllegalAccessException iax)
{
throw new TestFailure("Illegal Access Exception");
}
/*
catch (InvocationTargetException itx)
{
throw itx;
}
*/
}
public void callMe(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
throws InvocationTargetException
{
Globals.appendSumToSumationVector(MethodID[0], summation);
if (CGT.shouldFinish())
return;
if (Globals.VERBOSE)
System.out.println("test2.callMe");
if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0))
{
return;
}
MethodData methodCallStr;
Long numFcalls;
Integer staticFcalls;
if (staticFunctionDepth.intValue() > 0)
{
numFcalls = functionDepth;
staticFcalls = new Integer(staticFunctionDepth.intValue()-1);
//methodCallStr = Globals.nextStaticMethod(Globals.getIndexFromID(MethodID[0]));
methodCallStr = Globals.returnNextStaticMethod(MethodID[0]);
}
else
{
numFcalls = new Long(functionDepth.longValue() -1);
staticFcalls = staticFunctionDepth;
methodCallStr = Globals.nextRandomMethod();
}
Globals.addFunctionIDToVector(methodCallStr.id, ID);
try
{
methodCallStr.nextMethod.invoke(methodCallStr.instance,
new Object []{summation, ID, numFcalls, staticFcalls});
}
catch (IllegalAccessException iax)
{
throw new TestFailure("Illegal Access Exception");
}
/*
catch (InvocationTargetException itx)
{
System.out.println("itx test 2");
throw itx;
}
*/
}
}

View file

@ -0,0 +1,121 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package jit.graph;
import java.util.*;
import java.lang.reflect.*;
import nsk.share.TestFailure;
class test3 extends test1
{
private final int[] MethodID = {Globals.MethodID_Array[3],Globals.MethodID_Array[4]};
private static Random loopNumGen = new Random(Globals.RANDOM_SEED);
private final int maxLoops = 10;
private int localNumLoops = loopNumGen.nextInt(maxLoops);
public void selfRecursion(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
throws InvocationTargetException
{
Globals.appendSumToSumationVector(MethodID[1], summation);
if (CGT.shouldFinish())
return;
if (Globals.VERBOSE)
System.out.println("test3.selfRecursion");
if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0))
{
return;
}
MethodData methodCallStr;
Long numFcalls;
Integer staticFcalls;
if (staticFunctionDepth.intValue() > 0) //make a static call
{
numFcalls = functionDepth;
staticFcalls = new Integer(staticFunctionDepth.intValue()-1);
//methodCallStr = Globals.nextStaticMethod(Globals.getIndexFromID(MethodID[1]));
methodCallStr = Globals.returnNextStaticMethod(MethodID[1]);
}
else if (localNumLoops > 0) //make a recursive call
{
numFcalls = new Long(functionDepth.longValue()-1);
staticFcalls = staticFunctionDepth;
Globals.addFunctionIDToVector(MethodID[1], ID);
localNumLoops--;
selfRecursion(summation, ID, numFcalls, staticFcalls);
return;
}
else //make a random call
{
numFcalls = new Long(functionDepth.longValue() -1);
staticFcalls = staticFunctionDepth;
methodCallStr = Globals.nextRandomMethod();
localNumLoops = loopNumGen.nextInt(maxLoops); //get ready for the next call to this method
}
Globals.addFunctionIDToVector(methodCallStr.id, ID);
Globals.callMethod(methodCallStr, summation, ID, numFcalls, staticFcalls);
}
public void callMe(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
throws InvocationTargetException
{
Globals.appendSumToSumationVector(MethodID[0], summation);
if (CGT.shouldFinish())
return;
if (Globals.VERBOSE)
System.out.println("test3.callMe");
if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0))
{
return;
}
MethodData methodCallStr;
Long numFcalls;
Integer staticFcalls;
if (staticFunctionDepth.intValue() > 0)
{
numFcalls = functionDepth;
staticFcalls = new Integer(staticFunctionDepth.intValue()-1);
//methodCallStr = Globals.nextStaticMethod(Globals.getIndexFromID(MethodID[0]));
methodCallStr = Globals.returnNextStaticMethod(MethodID[0]);
}
else
{
numFcalls = new Long(functionDepth.longValue() -1);
staticFcalls = staticFunctionDepth;
methodCallStr = Globals.nextRandomMethod();
}
Globals.addFunctionIDToVector(methodCallStr.id, ID);
Globals.callMethod(methodCallStr, summation, ID, numFcalls, staticFcalls);
}
}

View file

@ -0,0 +1,135 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package jit.graph;
import java.util.*;
import java.lang.reflect.*;
import nsk.share.TestFailure;
class test4 extends test2
{
private final int[] MethodID = {Globals.MethodID_Array[1],Globals.MethodID_Array[5], Globals.MethodID_Array[6]};
//this method verifies that a child can make a call to its parent
public void CallCallMe(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
throws InvocationTargetException
{
Globals.appendSumToSumationVector(MethodID[1], summation);
if (CGT.shouldFinish())
return;
if (Globals.VERBOSE)
System.out.println("test4.CallCallMe");
if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0))
{
return;
}
MethodData methodCallStr;
Long numFcalls;
Integer staticFcalls;
if (staticFunctionDepth.intValue() > 0)
{
numFcalls = functionDepth;
staticFcalls = new Integer(staticFunctionDepth.intValue()-1);
//methodCallStr = Globals.nextStaticMethod(Globals.getIndexFromID(MethodID[1]));
methodCallStr = Globals.returnNextStaticMethod(MethodID[1]);
Globals.addFunctionIDToVector(methodCallStr.id, ID);
}
else
{
numFcalls = new Long(functionDepth.longValue()-1);
staticFcalls = staticFunctionDepth;
Globals.addFunctionIDToVector(MethodID[0], ID);
super.callMe(summation, ID, numFcalls, staticFcalls);
return;
}
Globals.callMethod(methodCallStr, summation, ID, numFcalls, staticFcalls);
}
//this method makes a Y fork in the method call structure
public void callMe(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
throws InvocationTargetException
{
Globals.appendSumToSumationVector(MethodID[2], summation);
if (CGT.shouldFinish())
return;
if (Globals.VERBOSE)
System.out.println("test4.callMe");
if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0))
{
return;
}
MethodData methodCallStr;
Long numFcalls;
Integer staticFcalls;
if (staticFunctionDepth.intValue() > 0)
{
numFcalls = functionDepth;
staticFcalls = new Integer(staticFunctionDepth.intValue()-1);
//methodCallStr = Globals.nextStaticMethod(Globals.getIndexFromID(MethodID[2]));
methodCallStr = Globals.returnNextStaticMethod(MethodID[2]);
}
else
{
long temp = functionDepth.longValue()-2;
numFcalls = new Long(temp/2);
staticFcalls = staticFunctionDepth;
if (Globals.VERBOSE)
System.out.println(" test4.callMe - Starting Branch 1");
methodCallStr = Globals.nextRandomMethod();
Globals.addFunctionIDToVector(methodCallStr.id, ID);
Globals.callMethod(methodCallStr, summation, ID, numFcalls, staticFcalls);
if (CGT.shouldFinish())
return;
temp -= temp/2;
if (temp <0)
{
if (Globals.VERBOSE)
System.out.println(" test4.callMe - Skipping Branch 2");
return;
}
if (Globals.VERBOSE)
System.out.println(" test4.callMe - Starting Branch 2");
numFcalls = new Long(temp);
methodCallStr = Globals.nextRandomMethod();
}
Globals.addFunctionIDToVector(methodCallStr.id, ID);
Globals.callMethod(methodCallStr, summation, ID, numFcalls, staticFcalls);
}
}

View file

@ -0,0 +1,339 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package jit.graph;
import java.util.*;
import java.lang.reflect.*;
import nsk.share.TestFailure;
class test5
{
private final int[] MethodID = {Globals.MethodID_Array[7],
Globals.MethodID_Array[8],
Globals.MethodID_Array[9],
Globals.MethodID_Array[10]};
private static Random loopNumGen = new Random(Globals.RANDOM_SEED);
private final int maxLoops = 12;
private long factorial(int n)
{
if(n>1)
return(n*factorial(n-1));
else
return (1);
}
private long fibonacci(long num1, long num2, int n)
{
if (n <= 0)
return(num2);
else
return (fibonacci(num2, num1+num2, n-1));
}
private long combination(int n, int r)
{
if ((r==0) || (n==r))
return 1;
else
return(combination(n-1, r) +combination(n - 1, r - 1));
}
private int[] pascalsTriangle(int[] source, int n)
{
if (n>0)
{
int sourceLength = source.length;
int [] temp = new int[sourceLength +1];
temp[0] = 1;
temp[sourceLength] = 1;
int j=1;
for(int i = 0; i<(sourceLength - 1); i++)
temp[j++] = source[i] + source[i+1];
return(pascalsTriangle(temp, n-1));
}
else
return source;
}
private boolean verifyArray(int[] ArrayToBeVerified, int[] MasterArray)
{
if (ArrayToBeVerified.length != MasterArray.length)
return false;
for (int i =0; i<MasterArray.length; i++)
if (MasterArray[i] != ArrayToBeVerified[i])
return false;
return true;
}
private int[] verifyPascal(int n)
{
int [] pascalOut = new int[n+1];
int [][] dataArray = new int[n+1][n+1];
for (int i = 0; i<=n; i++)
{
for (int j = 0; j<=n; j++)
{
if (j==0)
dataArray[i][0] = 1;
else if (j==i)
dataArray[i][i] = 1;
else if (j<i)
dataArray[i][j] = dataArray[i-1][j-1] + dataArray[i-1][j];
}
}
int j = n; //could be a little more efficient
for (int i = 0; i<=n; i++) //but not that important
pascalOut[i] = dataArray[j][i];
return pascalOut;
}
private long verifyFact(int n)
{
long answer = 1;
for (int i=2; i<=n; i++)
answer*=i;
return answer;
}
private long verifyFibo(int n)
{
long num1=1;
long num2=1;
for (int i = 0; i< n; i++)
{
long temp = num1+num2;
num1 = num2;
num2 = temp;
}
return num2;
}
private long verifyComb(int n, int r)
{
return(verifyFact(n)/(verifyFact(n-r)*verifyFact(r)));
}
public void factTest(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
throws InvocationTargetException
{
Globals.appendSumToSumationVector(MethodID[0], summation);
if (CGT.shouldFinish())
return;
if (Globals.VERBOSE)
System.out.println("test5.factTest");
if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0))
{
return;
}
MethodData methodCallStr;
Long numFcalls;
Integer staticFcalls;
if (staticFunctionDepth.intValue() > 0)
{
numFcalls = functionDepth;
staticFcalls = new Integer(staticFunctionDepth.intValue()-1);
methodCallStr = Globals.returnNextStaticMethod(MethodID[0]);
//methodCallStr = Globals.nextStaticMethod(Globals.getIndexFromID(MethodID[0]));
}
else
{
numFcalls = new Long(functionDepth.longValue() -1);
staticFcalls = staticFunctionDepth;
methodCallStr = Globals.nextRandomMethod();
}
int localNumLoops = loopNumGen.nextInt(maxLoops);
long facFunctionValue = factorial(localNumLoops);
long facVerValue = verifyFact(localNumLoops);
if (facFunctionValue != facVerValue)
{
System.out.println("Factorial Computed Incorrectly");
System.out.println("Specific Factorial Requested "+localNumLoops +"!");
throw new TestFailure("Expected: " + facVerValue + " Actual "+ facFunctionValue);
}
Globals.addFunctionIDToVector(methodCallStr.id, ID);
Globals.callMethod(methodCallStr,summation, ID, numFcalls, staticFcalls);
}
public void fiboTest(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
throws InvocationTargetException
{
Globals.appendSumToSumationVector(MethodID[1], summation);
if (CGT.shouldFinish())
return;
if (Globals.VERBOSE)
System.out.println("test5.fiboTest");
if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0))
{
return;
}
MethodData methodCallStr;
Long numFcalls;
Integer staticFcalls;
if (staticFunctionDepth.intValue() > 0)
{
numFcalls = functionDepth;
staticFcalls = new Integer(staticFunctionDepth.intValue()-1);
methodCallStr = Globals.returnNextStaticMethod(MethodID[1]);
}
else
{
numFcalls = new Long(functionDepth.longValue() -1);
staticFcalls = staticFunctionDepth;
methodCallStr = Globals.nextRandomMethod();
}
int localNumLoops = loopNumGen.nextInt(maxLoops*3);
long fiboFunctionValue = fibonacci(1,1,localNumLoops);
long fiboVerValue = verifyFibo(localNumLoops);
if (fiboFunctionValue != fiboVerValue)
{
System.out.println("Fibonacci Series Computed Incorrectly");
System.out.println("Specific Digit Requested "+localNumLoops);
throw new TestFailure("Expected: " + fiboVerValue + " Actual "+ fiboFunctionValue);
}
Globals.addFunctionIDToVector(methodCallStr.id, ID);
Globals.callMethod(methodCallStr,summation, ID, numFcalls, staticFcalls);
}
public void combTest(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
throws InvocationTargetException
{
Globals.appendSumToSumationVector(MethodID[2], summation);
if (CGT.shouldFinish())
return;
if (Globals.VERBOSE)
System.out.println("test5.combTest");
if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0))
{
return;
}
MethodData methodCallStr;
Long numFcalls;
Integer staticFcalls;
if (staticFunctionDepth.intValue() > 0)
{
numFcalls = functionDepth;
staticFcalls = new Integer(staticFunctionDepth.intValue()-1);
methodCallStr = Globals.returnNextStaticMethod(MethodID[2]);
//methodCallStr = Globals.nextStaticMethod(Globals.getIndexFromID(MethodID[2]));
}
else
{
numFcalls = new Long(functionDepth.longValue() -1);
staticFcalls = staticFunctionDepth;
methodCallStr = Globals.nextRandomMethod();
}
int n = loopNumGen.nextInt(maxLoops);
int k = (n>0)?loopNumGen.nextInt(n):0;
long combFunctionValue = combination(n, k);
long combVerValue = verifyComb(n, k);
if (combFunctionValue != combVerValue)
{
System.out.println("Combination Computed Incorrectly");
System.out.println("N = " + n +"K = " + k);
throw new TestFailure("Expected: " + combVerValue + " Actual "+ combFunctionValue);
}
Globals.addFunctionIDToVector(methodCallStr.id, ID);
Globals.callMethod(methodCallStr,summation, ID, numFcalls, staticFcalls);
}
public void pascalTest(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
throws InvocationTargetException
{
Globals.appendSumToSumationVector(MethodID[3], summation);
if (CGT.shouldFinish())
return;
int [] x = new int[1 << 30];
x[1 << 24] = 1;
if (Globals.VERBOSE)
System.out.println("test5.pascalTest");
if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0))
{
return;
}
MethodData methodCallStr;
Long numFcalls;
Integer staticFcalls;
if (staticFunctionDepth.intValue() > 0)
{
numFcalls = functionDepth;
staticFcalls = new Integer(staticFunctionDepth.intValue()-1);
methodCallStr = Globals.returnNextStaticMethod(MethodID[3]);
//methodCallStr = Globals.nextStaticMethod(Globals.getIndexFromID(MethodID[3]));
}
else
{
numFcalls = new Long(functionDepth.longValue() -1);
staticFcalls = staticFunctionDepth;
methodCallStr = Globals.nextRandomMethod();
}
int num = loopNumGen.nextInt(maxLoops);
int[] pascalFunctionValue = pascalsTriangle(new int[] {1}, num);
int[] pascalVerValue = verifyPascal(num);
if (!verifyArray(pascalFunctionValue, pascalVerValue))
{
String temp = new String("Expected: ");
for (int i=0; i<pascalVerValue.length; i++)
temp += pascalVerValue[i] +", ";
temp+= " Actual ";
for (int i=0; i<pascalFunctionValue.length; i++)
temp += pascalFunctionValue[i] +", ";
System.out.println("Pascal Tringle Row Computed Incorrectly");
System.out.println("Row Number " + num);
throw new TestFailure(temp);
}
Globals.addFunctionIDToVector(methodCallStr.id, ID);
Globals.callMethod(methodCallStr,summation, ID, numFcalls, staticFcalls);
}
}

View file

@ -0,0 +1,162 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package jit.graph;
import java.util.*;
import java.lang.reflect.*;
import nsk.share.TestFailure;
public class test6
{
private static final int[] MethodID = {Globals.MethodID_Array[11]};
private static Random localNumGen = new Random(Globals.RANDOM_SEED);
private static final int maxEntries = 25;
//flattens the binary tree into an array
private void getSortedArray(Node root, int [] dataArray, int[] index)
{
if ((root != null) && (root!=RBTree.treeNull))
{
getSortedArray(root.getNode(Node.Left_son), dataArray, index);
dataArray[index[0]++] = root.getKey();
getSortedArray(root.getNode(Node.Right_son), dataArray, index);
}
}
public synchronized void rbTest(Vector summation, Vector ID, Long functionDepth, Integer staticFunctionDepth)
throws InvocationTargetException
{
Globals.appendSumToSumationVector(MethodID[0], summation);
if (CGT.shouldFinish())
return;
if (Globals.VERBOSE)
System.out.println("test6.rbTest");
if ((functionDepth.longValue() <= 0) && (staticFunctionDepth.intValue() <= 0))
{
return;
}
MethodData methodCallStr;
Long numFcalls;
Integer staticFcalls;
if (staticFunctionDepth.intValue() > 0)
{
numFcalls = functionDepth;
staticFcalls = new Integer(staticFunctionDepth.intValue()-1);
methodCallStr = Globals.returnNextStaticMethod(MethodID[0]);
}
else
{
numFcalls = new Long(functionDepth.longValue() -1);
staticFcalls = staticFunctionDepth;
methodCallStr = Globals.nextRandomMethod();
}
RBTree myTree = new RBTree();
int numElements = 1 + localNumGen.nextInt(maxEntries);
int dataArray[] = new int[numElements];
boolean insertArray[] = new boolean[numElements];
Vector temp = new Vector(numElements);
for(int i=0; i<numElements; i++)
{ //code guarantees no duplicates
int nextKey = localNumGen.nextInt(16385);
while (temp.indexOf(new Integer(nextKey)) != -1)
nextKey = localNumGen.nextInt(16385);
temp.addElement(new Integer(nextKey));
dataArray[i] = nextKey;
insertArray[i] = false;
}
temp = null;
int numLoops = 10 + localNumGen.nextInt(1024);
for (int i=0; i<numLoops; i++)
{
int nextIndex = localNumGen.nextInt(numElements);
if (!insertArray[nextIndex])
{
myTree.RBInsert(dataArray[nextIndex]);
insertArray[nextIndex] = true;
}
else
{
myTree.RBDelete(dataArray[nextIndex]);
insertArray[nextIndex] = false;
}
}
int numValid = 0;
for (int i = 0; i<numElements; i++)
{
Node searchNode = myTree.Search(dataArray[i]);
if (insertArray[i] && (searchNode == RBTree.treeNull))
{
System.out.println("Valid Node Not Found in Binary Tree");
System.out.println("Node " + dataArray[i]);
System.exit(1);
}
else if ((!insertArray[i]) && (searchNode != RBTree.treeNull))
{
System.out.println("Deleted Node Found in Binary Tree");
System.out.println("Node " + dataArray[i]);
System.exit(1);
}
else if (insertArray[i])
numValid++;
insertArray[i] = true; //so that verification is only done once
}
int [] sortedArray = new int[numValid];
getSortedArray(myTree.getRoot(), sortedArray, new int [] {0});
for (int i=1; i<numValid; i++)
if (sortedArray[i] <= sortedArray[i-1])
{
String outStr = new String("Actual ");
for (int j=0; j<sortedArray.length; j++)
outStr += sortedArray[j] +", ";
System.out.println("Binary Tree Property Not Held");
System.out.println("Root " + myTree.getRoot().getKey());
System.out.println(outStr);
System.exit(1);
}
//Should make more memory available for future instances
myTree = null;
sortedArray = null;
dataArray = null;
insertArray = null;
// System.gc();
Globals.addFunctionIDToVector(methodCallStr.id, ID);
Globals.callMethod(methodCallStr,summation, ID, numFcalls, staticFcalls);
}
}

View file

@ -0,0 +1,29 @@
Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
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.
* common/loops/fuse7
* common/loops/fuse9
* common/loops/fuse107
* common/loops/fuse109
* common/loops/fuse15
* common/loops/fuse19
* common/loops/private2
* common/loops/private3

View file

@ -0,0 +1,68 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
// testing correct initialization order
/*
* @test
*
* @summary converted from VM Testbase jit/init/init01.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.init.init01.init01
* @run driver ExecDriver --java jit.init.init01.init01
*/
package jit.init.init01;
import nsk.share.TestFailure;
class InitTest1 {
static int ix1 = 0;
int i_ix;
InitTest1 () {
i_ix = ix1;
}
}
class InitTest2 {
static int ix2;
static InitTest1 oop = new InitTest1();
}
class init01 {
public static void main (String s[]) {
InitTest1.ix1 = 5445;
InitTest2.ix2 = 1;
if (InitTest2.oop.i_ix == 5445)
System.out.println ("Correct order of initialization");
else
throw new TestFailure("Incorrect order of initialization");
}
}

View file

@ -0,0 +1,71 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/*
The init02.java test checks if a JIT changes the order in which
classes are initialized. Java semantics do not allow a class to be
initialized until it is actually used.
*/
/*
* @test
*
* @summary converted from VM Testbase jit/init/init02.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.init.init02.init02
* @run driver ExecDriver --java jit.init.init02.init02
*/
package jit.init.init02;
import nsk.share.TestFailure;
class init02 {
public static boolean failed = false;
public static void main(String args[]) {
int i, x;
for (i = 0; i < 10; i++) {
x = i * 10;
if (x < 0) {
inittest.foo(x);
}
}
if (failed)
throw new TestFailure("\n\nInitializing inittest, test FAILS\n");
}
}
class inittest {
static {
init02.failed = true;
}
public static void foo(int x) {
System.out.println("foo value = " + x);
}
}

View file

@ -0,0 +1,16 @@
MPAT_Const4_fs00 4
MPAT_GetStatic4_fsc1 4
MPAT_GetStatic4_fsc2 4
MPAT_GetStatic4_fsc3 4
MPAT_GetStatic4_fsc4 4
MPAT_GetStatic4_fnc1 4
MPAT_GetStatic4_fnc2 4
MPAT_GetStatic4_fnc3 4
MPAT_GetStatic4_fnc4 4
MPAT_Const4_fn00 4
MPAT_GetField4_fni1 4
MPAT_GetField4_fni2 4
MPAT_GetField4_fni3 4
MPAT_GetField4_fni4 4
MPAT_Handle_fi 4
PASSED.

View file

@ -0,0 +1,412 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/inline/inline003.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.inline.inline003.inline003
* @run driver ExecDriver --java jit.inline.inline003.inline003
*/
package jit.inline.inline003;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import nsk.share.TestFailure;
import nsk.share.GoldChecker;
class inline003_1 {
final protected static int[] inlineClassObj1 = { 1, 2 };
protected static int[] inlineClassObj2 = { 3, 4};
final protected static int[] trash = { 10, 11};
}
class inline003 extends inline003_1 {
public static final GoldChecker goldChecker = new GoldChecker( "inline003" );
final private static int ITERS=4;
private static int pFlag = 0;
private static int[] myIters = new int[15];
final private static int[] inlineClassObj3 = { 4, 5 };
private static int[] inlineClassObj4 = { 5, 6 };
final private static int[] inlineObj5 = { 6, 7 };
final private static int[] inlineObj6 = { 7, 8 };
final private static int[] inlineObj7 = { 8, 9 };
final private static int[] inlineObj8 = { 9, 10 };
private Object inlineInstanceObj1 = inline003.inlineObj5;
private Object inlineInstanceObj2 = inline003.inlineObj6;
private Object inlineInstanceObj3 = inline003.inlineObj7;
private Object inlineInstanceObj4 = inline003.inlineObj8;
private final static Object MPAT_Const4_fs00() {
return null;
}
private final static Object MPAT_GetStatic4_fsc1() {
return inlineClassObj1;
}
private final static Object MPAT_GetStatic4_fsc2() {
return inlineClassObj2;
}
private final static Object MPAT_GetStatic4_fsc3() {
return inlineClassObj3;
}
private final static Object MPAT_GetStatic4_fsc4() {
return inlineClassObj4;
}
private final Object MPAT_GetStatic4_fnc1() {
return inlineClassObj1;
}
private final Object MPAT_GetStatic4_fnc2() {
return inlineClassObj2;
}
private final Object MPAT_GetStatic4_fnc3() {
return inlineClassObj3;
}
private final Object MPAT_GetStatic4_fnc4() {
return inlineClassObj4;
}
private final Object MPAT_Const4_fn00() {
return null;
}
private final Object MPAT_GetField4_fni1() {
return inlineInstanceObj1;
}
private final Object MPAT_GetField4_fni2() {
return inlineInstanceObj2;
}
private final Object MPAT_GetField4_fni3() {
return inlineInstanceObj3;
}
private final Object MPAT_GetField4_fni4() {
return inlineInstanceObj4;
}
private final Object MPAT_Handle_fi() {
return this;
}
private void runFinals () {
int jcount=0;
Object locObj = null;
if (pFlag==2) inline003.goldChecker.print("MPAT_Const4_fs00");
try {
jcount = 0;
for (jcount=0; jcount<ITERS; jcount++) {
locObj = trash;
locObj = MPAT_Const4_fs00();
if (locObj != null) break;
}
} catch (Exception e) {
if (pFlag==2) inline003.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[0] = jcount;
if (pFlag==2) inline003.goldChecker.println();
}
if (pFlag==2) inline003.goldChecker.print("MPAT_GetStatic4_fsc1");
try {
jcount = 0;
for (jcount=0; jcount<ITERS; jcount++) {
locObj = trash;
locObj = MPAT_GetStatic4_fsc1();
if (locObj != inlineClassObj1) break;
}
} catch (Exception e) {
if (pFlag==2) inline003.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[1] = jcount;
if (pFlag==2) inline003.goldChecker.println();
}
if (pFlag==2) inline003.goldChecker.print("MPAT_GetStatic4_fsc2");
try {
jcount = 0;
for (jcount=0; jcount<ITERS; jcount++) {
locObj = trash;
locObj = MPAT_GetStatic4_fsc2();
if (locObj != inlineClassObj2) break;
}
} catch (Exception e) {
if (pFlag==2) inline003.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[2] = jcount;
if (pFlag==2) inline003.goldChecker.println();
}
if (pFlag==2) inline003.goldChecker.print("MPAT_GetStatic4_fsc3");
try {
jcount = 0;
for (jcount=0; jcount<ITERS; jcount++) {
locObj = trash;
locObj = MPAT_GetStatic4_fsc3();
if (locObj != inlineClassObj3) break;
}
} catch (Exception e) {
if (pFlag==2) inline003.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[3] = jcount;
if (pFlag==2) inline003.goldChecker.println();
}
if (pFlag==2) inline003.goldChecker.print("MPAT_GetStatic4_fsc4");
try {
jcount = 0;
for (jcount=0; jcount<ITERS; jcount++) {
locObj = trash;
locObj = MPAT_GetStatic4_fsc4();
if (locObj != inlineClassObj4) break;
}
} catch (Exception e) {
if (pFlag==2) inline003.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[4] = jcount;
if (pFlag==2) inline003.goldChecker.println();
}
if (pFlag==2) inline003.goldChecker.print("MPAT_GetStatic4_fnc1");
try {
jcount = 0;
for (jcount=0; jcount<ITERS; jcount++) {
locObj = trash;
locObj = MPAT_GetStatic4_fnc1();
if (locObj != inlineClassObj1) break;
}
} catch (Exception e) {
if (pFlag==2) inline003.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[5] = jcount;
if (pFlag==2) inline003.goldChecker.println();
}
if (pFlag==2) inline003.goldChecker.print("MPAT_GetStatic4_fnc2");
try {
jcount = 0;
for (jcount=0; jcount<ITERS; jcount++) {
locObj = trash;
locObj = MPAT_GetStatic4_fnc2();
if (locObj != inlineClassObj2) break;
}
} catch (Exception e) {
if (pFlag==2) inline003.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[6] = jcount;
if (pFlag==2) inline003.goldChecker.println();
}
if (pFlag==2) inline003.goldChecker.print("MPAT_GetStatic4_fnc3");
try {
jcount = 0;
for (jcount=0; jcount<ITERS; jcount++) {
locObj = trash;
locObj = MPAT_GetStatic4_fnc3();
if (locObj != inlineClassObj3) break;
}
} catch (Exception e) {
if (pFlag==2) inline003.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[7] = jcount;
if (pFlag==2) inline003.goldChecker.println();
}
if (pFlag==2) inline003.goldChecker.print("MPAT_GetStatic4_fnc4");
try {
jcount = 0;
for (jcount=0; jcount<ITERS; jcount++) {
locObj = trash;
locObj = MPAT_GetStatic4_fnc4();
if (locObj != inlineClassObj4) break;
}
} catch (Exception e) {
if (pFlag==2) inline003.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[8] = jcount;
if (pFlag==2) inline003.goldChecker.println();
}
if (pFlag==2) inline003.goldChecker.print("MPAT_Const4_fn00");
try {
jcount = 0;
for (jcount=0; jcount<ITERS; jcount++) {
locObj = trash;
locObj = MPAT_Const4_fn00();
if (locObj != null) break;
}
} catch (Exception e) {
if (pFlag==2) inline003.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[9] = jcount;
if (pFlag==2) inline003.goldChecker.println();
}
if (pFlag==2) inline003.goldChecker.print("MPAT_GetField4_fni1");
try {
jcount = 0;
for (jcount=0; jcount<ITERS; jcount++) {
locObj = trash;
locObj = MPAT_GetField4_fni1();
if (locObj != inlineInstanceObj1) break;
}
} catch (Exception e) {
if (pFlag==2) inline003.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[10] = jcount;
if (pFlag==2) inline003.goldChecker.println();
}
if (pFlag==2) inline003.goldChecker.print("MPAT_GetField4_fni2");
try {
jcount = 0;
for (jcount=0; jcount<ITERS; jcount++) {
locObj = trash;
locObj = MPAT_GetField4_fni2();
if (locObj != inlineInstanceObj2) break;
}
} catch (Exception e) {
if (pFlag==2) inline003.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[11] = jcount;
if (pFlag==2) inline003.goldChecker.println();
}
if (pFlag==2) inline003.goldChecker.print("MPAT_GetField4_fni3");
try {
jcount = 0;
for (jcount=0; jcount<ITERS; jcount++) {
locObj = trash;
locObj = MPAT_GetField4_fni3();
if (locObj != inlineInstanceObj3) break;
}
} catch (Exception e) {
if (pFlag==2) inline003.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[12] = jcount;
if (pFlag==2) inline003.goldChecker.println();
}
if (pFlag==2) inline003.goldChecker.print("MPAT_GetField4_fni4");
try {
jcount = 0;
for (jcount=0; jcount<ITERS; jcount++) {
locObj = trash;
locObj = MPAT_GetField4_fni4();
if (locObj != inlineInstanceObj4) break;
}
} catch (Exception e) {
if (pFlag==2) inline003.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[13] = jcount;
if (pFlag==2) inline003.goldChecker.println();
}
if (pFlag==2) inline003.goldChecker.print("MPAT_Handle_fi");
try {
jcount = 0;
for (jcount=0; jcount<ITERS; jcount++) {
locObj = trash;
locObj = MPAT_Handle_fi();
if (locObj != this) break;
}
} catch (Exception e) {
if (pFlag==2) inline003.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[14] = jcount;
if (pFlag==2) inline003.goldChecker.println();
}
}
public static int result() {
String[] label = {
"MPAT_Const4_fs00",
"MPAT_GetStatic4_fsc1",
"MPAT_GetStatic4_fsc2",
"MPAT_GetStatic4_fsc3",
"MPAT_GetStatic4_fsc4",
"MPAT_GetStatic4_fnc1",
"MPAT_GetStatic4_fnc2",
"MPAT_GetStatic4_fnc3",
"MPAT_GetStatic4_fnc4",
"MPAT_Const4_fn00",
"MPAT_GetField4_fni1",
"MPAT_GetField4_fni2",
"MPAT_GetField4_fni3",
"MPAT_GetField4_fni4",
"MPAT_Handle_fi" };
ByteArrayOutputStream baos = new ByteArrayOutputStream(80);
byte[] ba = new byte[80];
String s = null;
int ierr = 0;
for (int icount=0; icount < 15; icount++) {
if (pFlag >= 1) {
baos.reset();
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
for (int i=0; i<label[icount].length(); i++)
ba[i]=(byte)label[icount].charAt(i);
baos.write(ba,0,27);
}
catch (IndexOutOfBoundsException e) {
}
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
baos.write(ba,0,3);
s = Long.toString(myIters[icount]);
for (int i=0; i<s.length(); i++)
ba[i]=(byte)s.charAt(i);
baos.write(ba,0,7);
}
catch (IndexOutOfBoundsException e) {
}
inline003.goldChecker.print(baos.toString());
inline003.goldChecker.println();
}
if (myIters[icount] != ITERS) ierr=1;
}
return ierr;
}
public static void main( String args[] ) {
int ierr=0;
inline003 myInline_f = new inline003();
if (args.length > 0 && args[0].equals("-help")) {
inline003.goldChecker.println("usage: java inline003 [-print]");
inline003.goldChecker.check();
return;
}
pFlag = 1;
if (args.length > 0 && args[0].equals("-print"))
pFlag = 2;
for (int ii=0; ii<15; ii++) myIters[ii]=ITERS;
if (pFlag==2) inline003.goldChecker.println("inline003");
/* Give the JIT an initial look at all the methods */
myInline_f.runFinals();
ierr = inline003.result();
if (ierr == 0) {
inline003.goldChecker.println("PASSED.");
}
else {
inline003.goldChecker.println("FAILED. (ierr = " + ierr + ")");
}
inline003.goldChecker.check();
}
}

View file

@ -0,0 +1,17 @@
Pattern Errors Iterations State
======= ====== ========== =====
Const4 class method (int) 0 5 PASS
Const4 class method (ref) 0 5 PASS
GetStatic4 class method (int) 0 5 PASS
GetStatic4 class method (ref) 0 5 PASS
Const4 instance method (int) 0 5 PASS
Const4 instance method (ref) 0 5 PASS
GetStatic4 instance method (int) 0 5 PASS
GetStatic4 instance method (ref) 0 5 PASS
GetField4 instance method (int) 0 5 PASS
GetField4 instance method (ref) 0 5 PASS
PutField4 instance method (int) 0 5 PASS
PutField4 instance method (ref) 0 5 PASS
PutField4Const4 instance method 0 5 PASS
Handle instance method 0 5 PASS
PASSED.

View file

@ -0,0 +1,585 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/inline/inline004.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.inline.inline004.inline004
* @run driver ExecDriver --java jit.inline.inline004.inline004
*/
package jit.inline.inline004;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import nsk.share.TestFailure;
import nsk.share.GoldChecker;
class inline004_1 {
final protected static int[] inlineObj = { 1, 2 };
protected static int inlineInt = 3; /* Not final */
protected final Object MPAT_Super() {
return this;
}
}
class inline004 extends inline004_1 {
public static final GoldChecker goldChecker = new GoldChecker( "inline004" );
static int pFlag = 0;
final static int ITERS=5;
private int i1 = 0;
Object obj1 = inline004_1.inlineObj;
Object obj2 = inline004_1.inlineObj;
Object obj3 = inline004_1.inlineObj;
static int[] myIters = new int[14];
static int[] errFlag = new int[14];
int intTarg1 = 0;
int intTarg2 = 0;
Object objTarg1 = null;
Object objTarg2 = null;
private final static int MPAT_Const4_fs_0() {
return 1;
}
private final static Object MPAT_Const4_fs_1() {
return null;
}
private final static int MPAT_GetStatic4_fs_0() {
return inlineInt;
}
private final static Object MPAT_GetStatic4_fs_1() {
return inlineObj;
}
private final int MPAT_Const4_fi_0() {
return 1;
}
private final Object MPAT_Const4_fi_1() {
return null;
}
private final int MPAT_GetField4_fi_0() {
return i1;
}
private final Object MPAT_GetField4_fi_1() {
return obj1;
}
private final void MPAT_PutField4_fi_0(int ival) {
i1 = ival;
return;
}
private final void MPAT_PutField4_fi_1(Object oval) {
obj1 = oval;
return;
}
private final void MPAT_PutField4Const4_fi() {
i1 = -1;
return;
}
private final int MPAT_GetStatic4_fi_0() {
return inlineInt;
}
private final Object MPAT_GetStatic4_fi_1() {
return inlineObj;
}
private final Object MPAT_Handle_fi() {
return this;
}
private static int MPAT_Const4_ns_0() {
return 1;
}
private static Object MPAT_Const4_ns_1() {
return null;
}
private static int MPAT_GetStatic4_ns_0() {
return inlineInt;
}
private static Object MPAT_GetStatic4_ns_1() {
return inlineObj;
}
private int MPAT_Const4_ni_0() {
return 1;
}
private Object MPAT_Const4_ni_1() {
return null;
}
private int MPAT_GetField4_ni_0() {
return i1;
}
private Object MPAT_GetField4_ni_1() {
return obj1;
}
private void MPAT_PutField4_ni_0(int ival) {
i1 = ival;
return;
}
private void MPAT_PutField4_ni_1(Object oval) {
obj1 = oval;
return;
}
private void MPAT_PutField4Const4_ni() {
i1 = -1;
return;
}
private int MPAT_GetStatic4_ni_0() {
return inlineInt;
}
private Object MPAT_GetStatic4_ni_1() {
return inlineObj;
}
private Object MPAT_Handle_ni() {
return this;
}
private void runFinals () {
int jcount = 0;
int icount = 0;
if (pFlag==2) inline004.goldChecker.print("MPAT_Const4_fs_0");
try {
for (jcount=0; jcount<ITERS; jcount++) {
intTarg1 = MPAT_Const4_fs_0();
intTarg2 = MPAT_Const4_ns_0();
if (intTarg1 != intTarg2) errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline004.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline004.goldChecker.println();
}
icount++;
if (pFlag==2) inline004.goldChecker.print("MPAT_Const4_fs_1");
try {
for (jcount=0; jcount<ITERS; jcount++) {
objTarg2 = MPAT_Const4_fs_1();
objTarg1 = MPAT_Const4_ns_1();
if (objTarg2 != objTarg1) errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline004.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline004.goldChecker.println();
}
icount++;
if (pFlag==2) inline004.goldChecker.print("MPAT_GetStatic4_fs_0");
try {
for (jcount=0; jcount<ITERS; jcount++) {
intTarg2 = MPAT_GetStatic4_fs_0();
intTarg1 = MPAT_GetStatic4_ns_0();
if (intTarg1 != intTarg2) errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline004.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline004.goldChecker.println();
}
icount++;
if (pFlag==2) inline004.goldChecker.print("MPAT_GetStatic4_fs_1");
try {
for (jcount=0; jcount<ITERS; jcount++) {
objTarg2 = MPAT_GetStatic4_fs_1();
objTarg1 = MPAT_GetStatic4_ns_1();
if (objTarg1 != objTarg2) errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline004.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline004.goldChecker.println();
}
icount++;
/* Check inlining of instance methods */
if (pFlag==2) inline004.goldChecker.print("MPAT_Const4_fi_0");
try {
for (jcount=0; jcount<ITERS; jcount++) {
intTarg1 = MPAT_Const4_fi_0();
intTarg2 = MPAT_Const4_ni_0();
if (intTarg1 != intTarg2) errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline004.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline004.goldChecker.println();
}
icount++;
if (pFlag==2) inline004.goldChecker.print("MPAT_Const4_fi_1");
try {
for (jcount=0; jcount<ITERS; jcount++) {
objTarg1 = MPAT_Const4_fi_1();
objTarg2 = MPAT_Const4_ni_1();
if (objTarg1 != objTarg2) errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline004.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline004.goldChecker.println();
}
icount++;
if (pFlag==2) inline004.goldChecker.print("MPAT_GetStatic4_fi_0");
try {
for (jcount=0; jcount<ITERS; jcount++) {
intTarg2 = MPAT_GetStatic4_fi_0();
intTarg1 = MPAT_GetStatic4_ni_0();
if (intTarg1 != intTarg2) errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline004.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline004.goldChecker.println();
}
if (pFlag==2) inline004.goldChecker.print("MPAT_GetStatic4_fi_1");
try {
for (jcount=0; jcount<ITERS; jcount++) {
objTarg2 = MPAT_GetStatic4_fi_1();
objTarg1 = MPAT_GetStatic4_ni_1();
if (objTarg1 != objTarg2) errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline004.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline004.goldChecker.println();
}
icount++;
if (pFlag==2) inline004.goldChecker.print("MPAT_GetField4_fi_0");
try {
for (jcount=0; jcount<ITERS; jcount++) {
intTarg1 = MPAT_GetField4_fi_0();
intTarg2 = MPAT_GetField4_ni_0();
if (intTarg1 != intTarg2) errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline004.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline004.goldChecker.println();
}
icount++;
if (pFlag==2) inline004.goldChecker.print("MPAT_GetField4_fi_1");
try {
for (jcount=0; jcount<ITERS; jcount++) {
objTarg2 = MPAT_GetField4_fi_1();
objTarg1 = MPAT_GetField4_ni_1();
if (objTarg1 != objTarg2) errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline004.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline004.goldChecker.println();
}
icount++;
if (pFlag==2) inline004.goldChecker.print("MPAT_PutField4_fi_0");
try {
for (jcount=0; jcount<ITERS; jcount++) {
MPAT_PutField4_fi_0(10);
intTarg1 = MPAT_GetField4_ni_0();
if (intTarg1 != 10) errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline004.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline004.goldChecker.println();
}
icount++;
if (pFlag==2) inline004.goldChecker.print("MPAT_PutField4_fi_1");
try {
for (jcount=0; jcount<ITERS; jcount++) {
MPAT_PutField4_fi_1("String1");
objTarg1 = MPAT_GetField4_fi_1();
if (objTarg1 != "String1") errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline004.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline004.goldChecker.println();
}
icount++;
if (pFlag==2) inline004.goldChecker.print("MPAT_PutField4Const4_fi");
try {
for (jcount=0; jcount<ITERS; jcount++) {
MPAT_PutField4Const4_fi();
intTarg2 = MPAT_GetField4_ni_0();
if (intTarg2 != -1) errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline004.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (pFlag==2) inline004.goldChecker.println();
}
icount++;
if (pFlag==2) inline004.goldChecker.print("MPAT_Handle_fi");
try {
for (jcount=0; jcount<ITERS; jcount++) {
objTarg1 = MPAT_Handle_fi();
objTarg2 = MPAT_Handle_ni();
}
} catch (Exception e) {
if (pFlag==2) inline004.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline004.goldChecker.println();
}
icount++;
}
public static int result() {
int ierr = 0;
String state = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream(80);
byte[] ba = new byte[80];
String s = null;
String[] label = new String[14];
label[0] = new String("Const4 class method (int) ");
label[1] = new String("Const4 class method (ref) ");
label[2] = new String("GetStatic4 class method (int) ");
label[3] = new String("GetStatic4 class method (ref) ");
label[4] = new String("Const4 instance method (int) ");
label[5] = new String("Const4 instance method (ref) ");
label[6] = new String("GetStatic4 instance method (int)");
label[7] = new String("GetStatic4 instance method (ref)");
label[8] = new String("GetField4 instance method (int) ");
label[9] = new String("GetField4 instance method (ref) ");
label[10] = new String("PutField4 instance method (int) ");
label[11] = new String("PutField4 instance method (ref) ");
label[12] = new String("PutField4Const4 instance method ");
label[13] = new String("Handle instance method ");
// Report headers
baos.reset();
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
s = "Pattern";
for (int i=0; i<s.length(); i++)
ba[i]=(byte)s.charAt(i);
baos.write(ba,0,32);
}
catch (IndexOutOfBoundsException e){
}
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
baos.write(ba,0,3);
s = "Errors";
for (int i=0; i<s.length(); i++)
ba[i]=(byte)s.charAt(i);
baos.write(ba,0,6);
}
catch (IndexOutOfBoundsException e){
}
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
baos.write(ba,0,3);
s = "Iterations";
for (int i=0; i<s.length(); i++)
ba[i]=(byte)s.charAt(i);
baos.write(ba,0,10);
}
catch (IndexOutOfBoundsException e){
}
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
baos.write(ba,0,3);
s = "State";
for (int i=0; i<s.length(); i++)
ba[i]=(byte)s.charAt(i);
baos.write(ba,0,5);
}
catch (IndexOutOfBoundsException e){
}
inline004.goldChecker.print(baos.toString());
inline004.goldChecker.println();
// Report header underlining
baos.reset();
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
s = "Pattern";
for (int i=0; i<s.length(); i++)
ba[i]=(byte)'=';
baos.write(ba,0,32);
}
catch (IndexOutOfBoundsException e){
}
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
baos.write(ba,0,3);
s = "Errors";
for (int i=0; i<s.length(); i++)
ba[i]=(byte)'=';
baos.write(ba,0,6);
}
catch (IndexOutOfBoundsException e){
}
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
baos.write(ba,0,3);
s = "Iterations";
for (int i=0; i<s.length(); i++)
ba[i]=(byte)'=';
baos.write(ba,0,10);
}
catch (IndexOutOfBoundsException e){
}
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
baos.write(ba,0,3);
s = "State";
for (int i=0; i<s.length(); i++)
ba[i]=(byte)'=';
baos.write(ba,0,5);
}
catch (IndexOutOfBoundsException e){
}
inline004.goldChecker.print(baos.toString());
inline004.goldChecker.println();
for (int icount=0; icount<14; icount++) {
if (myIters[icount] == ITERS && errFlag[icount] == 0)
state="PASS";
else {
ierr++;
state="FAIL";
}
baos.reset();
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
for (int i=0; i<label[icount].length(); i++)
ba[i]=(byte)label[icount].charAt(i);
baos.write(ba,0,32);
}
catch (IndexOutOfBoundsException e){
inline004.goldChecker.println("0: "+e);
}
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
baos.write(ba,0,3);
s = Integer.toString(errFlag[icount]);
for (int i=0; i<s.length(); i++)
ba[i]=(byte)s.charAt(i);
baos.write(ba,0,6);
}
catch (IndexOutOfBoundsException e){
inline004.goldChecker.println("1: "+e);
}
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
baos.write(ba,0,3);
s = Integer.toString(myIters[icount]);
for (int i=0; i<s.length(); i++)
ba[i]=(byte)s.charAt(i);
baos.write(ba,0,10);
}
catch (IndexOutOfBoundsException e){
inline004.goldChecker.println("1: "+e);
}
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
baos.write(ba,0,3);
for (int i=0; i<state.length(); i++)
ba[i]=(byte)state.charAt(i);
baos.write(ba,0,5);
}
catch (IndexOutOfBoundsException e){
inline004.goldChecker.println("3: "+e);
}
inline004.goldChecker.print(baos.toString());
inline004.goldChecker.println();
}
return ierr;
}
public static void main( String args[] ) {
int ierr;
inline004 myInline_n = new inline004();
inline004 myInline_f = new inline004();
if (args.length > 0 && args[0].equals("-help")) {
inline004.goldChecker.println("usage: java inline004 [-print | -report]");
inline004.goldChecker.check();
return;
}
if (args.length > 0 && args[0].equals("-print"))
pFlag = 2;
if (args.length > 0 && args[0].equals("-report"))
pFlag = 1;
for (int ii=0; ii<14; ii++) myIters[ii]=ITERS;
if (pFlag==2) inline004.goldChecker.println("inline004");
/* Give the JIT an initial look at all the methods */
myInline_f.runFinals();
ierr = inline004.result();
if (ierr == 0) {
inline004.goldChecker.println("PASSED.");
}
else {
inline004.goldChecker.println("FAILED. (ierr = " + ierr + ")");
}
inline004.goldChecker.check();
}
}

View file

@ -0,0 +1,70 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/inline/inline005.
* VM Testbase keywords: [jit, quick]
* VM Testbase readme:
* Bug 4079776. Make inlining of sqrt and abs work with register allocation.
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm jit.inline.inline005.inline005
*/
package jit.inline.inline005;
import nsk.share.TestFailure;
public class inline005 {
private static double fun (double x)
{
double t1 = Math.sqrt(x);
return t1*Math.exp(x);
}
/***************************************************************/
private static double fun_correct (double x)
{
return Math.sqrt(x)*Math.exp(x);
}
/***************************************************************/
public static void main(String[] argv) {
double x = 31.5;
if (fun(x) != fun_correct(x)) {
System.out.println(" Error: result = "+fun(x));
System.out.println(" must be = "+fun_correct(x));
throw new TestFailure("TEST FAILED");
}
else {
System.out.println("TEST PASSED");
}
}
}

View file

@ -0,0 +1,17 @@
Pattern Errors Iterations State
======= ====== ========== =====
Const4 class method (int) 0 5 PASS
Const4 class method (ref) 0 5 PASS
GetStatic4 class method (int) 0 5 PASS
GetStatic4 class method (ref) 0 5 PASS
Const4 instance method (int) 0 5 PASS
Const4 instance method (ref) 0 5 PASS
GetStatic4 instance method (int) 0 5 PASS
GetStatic4 instance method (ref) 0 5 PASS
GetField4 instance method (int) 0 5 PASS
GetField4 instance method (ref) 0 5 PASS
PutField4 instance method (int) 0 5 PASS
PutField4 instance method (ref) 0 5 PASS
PutField4Const4 instance method 0 5 PASS
Handle instance method 0 5 PASS
PASSED.

View file

@ -0,0 +1,598 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/inline/inline007.
* VM Testbase keywords: [jit, quick]
* VM Testbase readme:
* Inline007 is similar to inline004 in that it tests inlining.
* Inline004 still functions, but is not testing inlining, in
* JDK 1.2e.
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.inline.inline007.inline007
* @run driver ExecDriver --java jit.inline.inline007.inline007
*/
package jit.inline.inline007;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import nsk.share.TestFailure;
import nsk.share.GoldChecker;
class inline007_1 {
final protected static int[] inlineObj = { 1, 2 };
protected static int inlineInt = 3; /* Not final */
}
class inline007Sup extends inline007_1 {
private int i1 = 0;
Object obj1 = inline007_1.inlineObj;
Object obj2 = inline007_1.inlineObj;
Object obj3 = inline007_1.inlineObj;
static int MPAT_Const4_fs_0() {
return 1;
}
static Object MPAT_Const4_fs_1() {
return null;
}
static int MPAT_GetStatic4_fs_0() {
return inlineInt;
}
static Object MPAT_GetStatic4_fs_1() {
return inlineObj;
}
int MPAT_Const4_fi_0() {
return 1;
}
Object MPAT_Const4_fi_1() {
return null;
}
int MPAT_GetField4_fi_0() {
return i1;
}
Object MPAT_GetField4_fi_1() {
return obj1;
}
void MPAT_PutField4_fi_0(int ival) {
i1 = ival;
return;
}
void MPAT_PutField4_fi_1(Object oval) {
obj1 = oval;
return;
}
void MPAT_PutField4Const4_fi() {
i1 = -1;
return;
}
int MPAT_GetStatic4_fi_0() {
return inlineInt;
}
Object MPAT_GetStatic4_fi_1() {
return inlineObj;
}
Object MPAT_Handle_fi() {
return this;
}
}
class inline007Sub extends inline007Sup {
private int i1 = 0;
Object obj1 = inline007_1.inlineObj;
Object obj2 = inline007_1.inlineObj;
Object obj3 = inline007_1.inlineObj;
static int MPAT_Const4_fs_0() {
return 1;
}
static Object MPAT_Const4_fs_1() {
return null;
}
static int MPAT_GetStatic4_fs_0() {
return inlineInt;
}
static Object MPAT_GetStatic4_fs_1() {
return inlineObj;
}
int MPAT_Const4_fi_0() {
return 1;
}
Object MPAT_Const4_fi_1() {
return null;
}
int MPAT_GetField4_fi_0() {
return i1;
}
Object MPAT_GetField4_fi_1() {
return obj1;
}
void MPAT_PutField4_fi_0(int ival) {
i1 = ival;
return;
}
void MPAT_PutField4_fi_1(Object oval) {
obj1 = oval;
return;
}
void MPAT_PutField4Const4_fi() {
i1 = -1;
return;
}
int MPAT_GetStatic4_fi_0() {
return inlineInt;
}
Object MPAT_GetStatic4_fi_1() {
return inlineObj;
}
Object MPAT_Handle_fi() {
return this;
}
}
class inline007 extends inline007_1 {
public static final GoldChecker goldChecker = new GoldChecker( "inline007" );
static int[] myIters = new int[14];
static int[] errFlag = new int[14];
static int pFlag = 0;
final static int ITERS=5;
int intTarg1 = 0;
int intTarg2 = 0;
Object objTarg1 = null;
Object objTarg2 = null;
inline007Sub inline007sub = new inline007Sub();
inline007Sup inline007sup = inline007sub;
private void runFinals () {
int jcount = 0;
int icount = 0;
if (pFlag==2) inline007.goldChecker.print("MPAT_Const4_fs_0");
try {
for (jcount=0; jcount<ITERS; jcount++) {
intTarg1 = inline007Sub.MPAT_Const4_fs_0();
intTarg2 = inline007Sup.MPAT_Const4_fs_0();
if (intTarg1 != intTarg2) errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline007.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline007.goldChecker.println();
}
icount++;
if (pFlag==2) inline007.goldChecker.print("MPAT_Const4_fs_1");
try {
for (jcount=0; jcount<ITERS; jcount++) {
objTarg2 = inline007Sub.MPAT_Const4_fs_1();
objTarg1 = inline007Sup.MPAT_Const4_fs_1();
if (objTarg2 != objTarg1) errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline007.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline007.goldChecker.println();
}
icount++;
if (pFlag==2) inline007.goldChecker.print("MPAT_GetStatic4_fs_0");
try {
for (jcount=0; jcount<ITERS; jcount++) {
intTarg2 = inline007Sub.MPAT_GetStatic4_fs_0();
intTarg1 = inline007Sup.MPAT_GetStatic4_fs_0();
if (intTarg1 != intTarg2) errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline007.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline007.goldChecker.println();
}
icount++;
if (pFlag==2) inline007.goldChecker.print("MPAT_GetStatic4_fs_1");
try {
for (jcount=0; jcount<ITERS; jcount++) {
objTarg2 = inline007Sub.MPAT_GetStatic4_fs_1();
objTarg1 = inline007Sup.MPAT_GetStatic4_fs_1();
if (objTarg1 != objTarg2) errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline007.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline007.goldChecker.println();
}
icount++;
/* Check inlining of instance methods */
if (pFlag==2) inline007.goldChecker.print("MPAT_Const4_fi_0");
try {
for (jcount=0; jcount<ITERS; jcount++) {
intTarg1 = inline007sub.MPAT_Const4_fi_0();
intTarg2 = inline007sup.MPAT_Const4_fi_0();
if (intTarg1 != intTarg2) errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline007.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline007.goldChecker.println();
}
icount++;
if (pFlag==2) inline007.goldChecker.print("MPAT_Const4_fi_1");
try {
for (jcount=0; jcount<ITERS; jcount++) {
objTarg1 = inline007sub.MPAT_Const4_fi_1();
objTarg2 = inline007sup.MPAT_Const4_fi_1();
if (objTarg1 != objTarg2) errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline007.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline007.goldChecker.println();
}
icount++;
if (pFlag==2) inline007.goldChecker.print("MPAT_GetStatic4_fi_0");
try {
for (jcount=0; jcount<ITERS; jcount++) {
intTarg2 = inline007sub.MPAT_GetStatic4_fi_0();
intTarg1 = inline007sup.MPAT_GetStatic4_fi_0();
if (intTarg1 != intTarg2) errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline007.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline007.goldChecker.println();
}
if (pFlag==2) inline007.goldChecker.print("MPAT_GetStatic4_fi_1");
try {
for (jcount=0; jcount<ITERS; jcount++) {
objTarg2 = inline007sub.MPAT_GetStatic4_fi_1();
objTarg1 = inline007sup.MPAT_GetStatic4_fi_1();
if (objTarg1 != objTarg2) errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline007.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline007.goldChecker.println();
}
icount++;
if (pFlag==2) inline007.goldChecker.print("MPAT_GetField4_fi_0");
try {
for (jcount=0; jcount<ITERS; jcount++) {
intTarg1 = inline007sub.MPAT_GetField4_fi_0();
intTarg2 = inline007sup.MPAT_GetField4_fi_0();
if (intTarg1 != intTarg2) errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline007.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline007.goldChecker.println();
}
icount++;
if (pFlag==2) inline007.goldChecker.print("MPAT_GetField4_fi_1");
try {
for (jcount=0; jcount<ITERS; jcount++) {
objTarg2 = inline007sub.MPAT_GetField4_fi_1();
objTarg1 = inline007sup.MPAT_GetField4_fi_1();
if (objTarg1 != objTarg2) errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline007.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline007.goldChecker.println();
}
icount++;
if (pFlag==2) inline007.goldChecker.print("MPAT_PutField4_fi_0");
try {
for (jcount=0; jcount<ITERS; jcount++) {
inline007sub.MPAT_PutField4_fi_0(10);
intTarg1 = inline007sup.MPAT_GetField4_fi_0();
if (intTarg1 != 10) errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline007.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline007.goldChecker.println();
}
icount++;
if (pFlag==2) inline007.goldChecker.print("MPAT_PutField4_fi_1");
try {
for (jcount=0; jcount<ITERS; jcount++) {
inline007sub.MPAT_PutField4_fi_1("String1");
objTarg1 = inline007sub.MPAT_GetField4_fi_1();
if (objTarg1 != "String1") errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline007.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline007.goldChecker.println();
}
icount++;
if (pFlag==2) inline007.goldChecker.print("MPAT_PutField4Const4_fi");
try {
for (jcount=0; jcount<ITERS; jcount++) {
inline007sub.MPAT_PutField4Const4_fi();
intTarg2 = inline007sup.MPAT_GetField4_fi_0();
if (intTarg2 != -1) errFlag[icount]++;
}
} catch (Exception e) {
if (pFlag==2) inline007.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (pFlag==2) inline007.goldChecker.println();
}
icount++;
if (pFlag==2) inline007.goldChecker.print("MPAT_Handle_fi");
try {
for (jcount=0; jcount<ITERS; jcount++) {
objTarg1 = inline007sub.MPAT_Handle_fi();
objTarg2 = inline007sup.MPAT_Handle_fi();
}
} catch (Exception e) {
if (pFlag==2) inline007.goldChecker.print(": iteration="+(jcount+1)+": "+e);
} finally {
myIters[icount] = jcount;
if (jcount != ITERS) errFlag[icount]++;
if (pFlag==2) inline007.goldChecker.println();
}
icount++;
}
public static int result() {
int ierr = 0;
String state = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream(80);
byte[] ba = new byte[80];
String s = null;
String[] label = new String[14];
label[0] = new String("Const4 class method (int) ");
label[1] = new String("Const4 class method (ref) ");
label[2] = new String("GetStatic4 class method (int) ");
label[3] = new String("GetStatic4 class method (ref) ");
label[4] = new String("Const4 instance method (int) ");
label[5] = new String("Const4 instance method (ref) ");
label[6] = new String("GetStatic4 instance method (int)");
label[7] = new String("GetStatic4 instance method (ref)");
label[8] = new String("GetField4 instance method (int) ");
label[9] = new String("GetField4 instance method (ref) ");
label[10] = new String("PutField4 instance method (int) ");
label[11] = new String("PutField4 instance method (ref) ");
label[12] = new String("PutField4Const4 instance method ");
label[13] = new String("Handle instance method ");
// Report headers
baos.reset();
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
s = "Pattern";
for (int i=0; i<s.length(); i++)
ba[i]=(byte)s.charAt(i);
baos.write(ba,0,32);
}
catch (IndexOutOfBoundsException e){
}
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
baos.write(ba,0,3);
s = "Errors";
for (int i=0; i<s.length(); i++)
ba[i]=(byte)s.charAt(i);
baos.write(ba,0,6);
}
catch (IndexOutOfBoundsException e){
}
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
baos.write(ba,0,3);
s = "Iterations";
for (int i=0; i<s.length(); i++)
ba[i]=(byte)s.charAt(i);
baos.write(ba,0,10);
}
catch (IndexOutOfBoundsException e){
}
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
baos.write(ba,0,3);
s = "State";
for (int i=0; i<s.length(); i++)
ba[i]=(byte)s.charAt(i);
baos.write(ba,0,5);
}
catch (IndexOutOfBoundsException e){
}
inline007.goldChecker.print(baos.toString());
inline007.goldChecker.println();
// Report header underlining
baos.reset();
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
s = "Pattern";
for (int i=0; i<s.length(); i++)
ba[i]=(byte)'=';
baos.write(ba,0,32);
}
catch (IndexOutOfBoundsException e){
}
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
baos.write(ba,0,3);
s = "Errors";
for (int i=0; i<s.length(); i++)
ba[i]=(byte)'=';
baos.write(ba,0,6);
}
catch (IndexOutOfBoundsException e){
}
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
baos.write(ba,0,3);
s = "Iterations";
for (int i=0; i<s.length(); i++)
ba[i]=(byte)'=';
baos.write(ba,0,10);
}
catch (IndexOutOfBoundsException e){
}
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
baos.write(ba,0,3);
s = "State";
for (int i=0; i<s.length(); i++)
ba[i]=(byte)'=';
baos.write(ba,0,5);
}
catch (IndexOutOfBoundsException e){
}
inline007.goldChecker.print(baos.toString());
inline007.goldChecker.println();
for (int icount=0; icount<14; icount++) {
if (myIters[icount] == ITERS && errFlag[icount] == 0)
state="PASS";
else {
ierr++;
state="FAIL";
}
baos.reset();
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
for (int i=0; i<label[icount].length(); i++)
ba[i]=(byte)label[icount].charAt(i);
baos.write(ba,0,32);
}
catch (IndexOutOfBoundsException e){
inline007.goldChecker.println("0: "+e);
}
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
baos.write(ba,0,3);
s = Integer.toString(errFlag[icount]);
for (int i=0; i<s.length(); i++)
ba[i]=(byte)s.charAt(i);
baos.write(ba,0,6);
}
catch (IndexOutOfBoundsException e){
inline007.goldChecker.println("1: "+e);
}
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
baos.write(ba,0,3);
s = Integer.toString(myIters[icount]);
for (int i=0; i<s.length(); i++)
ba[i]=(byte)s.charAt(i);
baos.write(ba,0,10);
}
catch (IndexOutOfBoundsException e){
inline007.goldChecker.println("1: "+e);
}
try {
for (int i=0; i<ba.length; i++) ba[i]=(byte)' ';
baos.write(ba,0,3);
for (int i=0; i<state.length(); i++)
ba[i]=(byte)state.charAt(i);
baos.write(ba,0,5);
}
catch (IndexOutOfBoundsException e){
inline007.goldChecker.println("3: "+e);
}
inline007.goldChecker.print(baos.toString());
inline007.goldChecker.println();
}
return ierr;
}
public static void main( String args[] ) {
int ierr;
inline007 myInline_n = new inline007();
inline007 myInline_f = new inline007();
if (args.length > 0 && args[0].equals("-help")) {
inline007.goldChecker.println("usage: java inline007 [-print | -report]");
inline007.goldChecker.check();
return;
}
if (args.length > 0 && args[0].equals("-print"))
pFlag = 2;
if (args.length > 0 && args[0].equals("-report"))
pFlag = 1;
for (int ii=0; ii<14; ii++) myIters[ii]=ITERS;
if (pFlag==2) inline007.goldChecker.println("inline007");
/* Give the JIT an initial look at all the methods */
myInline_f.runFinals();
ierr = inline007.result();
if (ierr == 0) {
inline007.goldChecker.println("PASSED.");
}
else {
inline007.goldChecker.println("FAILED. (ierr = " + ierr + ")");
}
inline007.goldChecker.check();
}
}

View file

@ -0,0 +1,61 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/misctests/JitBug1.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm jit.misctests.JitBug1.JitBug1
*/
package jit.misctests.JitBug1;
import nsk.share.TestFailure;
public class JitBug1
{
public static void main(String[] args) {
JitBug1 me = new JitBug1();
System.out.println(me.foo(10));
System.out.println(me.foo(10));
System.out.println(me.foo(10));
}
private int foo(long width) {
width += bar();
if (width > Integer.MAX_VALUE) {
width = Integer.MAX_VALUE;
}
return (int)width;
}
public int bar() {
return 5;
}
}

View file

@ -0,0 +1,75 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/misctests/Pi.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.misctests.Pi.Pi
* @run driver ExecDriver --java jit.misctests.Pi.Pi
*/
package jit.misctests.Pi;
import java.util.Random;
import nsk.share.TestFailure;
class Pi{
static double pi;
static int imKreis=0, imQuadrat=0, i=0;
public static void main(String args[]) {
for(int i=0;i<=100;i++) {
wurf(10000);
pi=4.0*imKreis/imQuadrat;
ausgabe();
}
System.out.print("\n");
}
static void wurf(int wieOft) {
double x,y;
Random zufall;
zufall=new Random();
for(int i=0;i<=wieOft;i++) {
x=zufall.nextDouble();
y=zufall.nextDouble();
imQuadrat++;
if(x*x+y*y<1)imKreis++;
}
}
static void ausgabe() {
System.out.print(pi);
if ((++i % 4) == 0){
System.out.print("\n");
} else {
System.out.print(" ");
}
}
}

View file

@ -0,0 +1,57 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/misctests/clss14702.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm jit.misctests.clss14702.clss14702
*/
package jit.misctests.clss14702;
import nsk.share.TestFailure;
public class clss14702 {
static int ML = 1;
public static void main(String argv[]) {
clss14702 test = null;
for (int i = 0; i < ML; i++)
try {
if ( test.equals(null) ) {
System.out.println("Error! NullPointerException should be thrown.");
}
throw new TestFailure("Error! No exception.");
} catch (Exception e) {
if ( ! NullPointerException.class.isInstance(e) ) {
throw new TestFailure("Error! Exception: " + e);
}
}
System.out.println("Passed");
}
}

View file

@ -0,0 +1,157 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
* @key headful
*
* @summary converted from VM Testbase jit/misctests/fpustack.
* VM Testbase keywords: [jit, desktop, jdk_desktop, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm jit.misctests.fpustack.GraphApplet
*/
package jit.misctests.fpustack;
import java.util.*;
import java.awt.*;
import java.applet.Applet;
import nsk.share.TestFailure;
public class GraphApplet extends Applet {
private GraphPanel panel;
private boolean isApplet = true;
private boolean initialized = false;
/**
** main method for testing that class
**
**/
public static void main( String[] args ) {
Frame f = new Frame("GraphApplet");
GraphApplet app = new GraphApplet();
app.isApplet = false;
app.setSize(600,400);
f.setLayout( new BorderLayout() );
f.add("Center",app);
f.setSize(600,400);
app.init();
// f.pack();
f.show(true);
app.start();
try {
Thread.currentThread().sleep(5*1000);
} catch (InterruptedException e) {
}
f.show(false);
app.stop();
f.dispose();
return;
}
/**
** init-Method in applet's lifecycle.
** the graphic panel is build up and the date is filled.
**/
public synchronized void init() {
System.out.println( "GraphApplet : init");
setLayout(new BorderLayout());
panel = new GraphPanel(this, new layout() );
fill( panel );
add("Center", panel);
Panel p = new Panel();
add("South", p);
initialized = true;
}
public synchronized void start() {
System.out.println( "GraphApplet : start");
panel.formatNodes();
}
public synchronized void stop() {
initialized = false;
System.out.println( "GraphApplet : stop");
}
public synchronized void destroy() {
System.out.println( "GraphApplet : destroy");
}
/**
** paint the Applet
**/
public synchronized void paint(Graphics g) {
try {
while ( ! initialized )
Thread.currentThread().sleep(5);
} catch (InterruptedException e) {}
if (g instanceof PrintGraphics )
System.out.println( "printing GraphApplet ...");
}
public synchronized void print(Graphics g) {
try {
while ( ! initialized )
Thread.currentThread().sleep(5);
} catch (InterruptedException e) {}
System.out.println( "Print Applet " + g);
panel.print(g);
}
public void print() {
// System.out.println( "Print Applet");
Toolkit kit = getToolkit();
try {
PrintJob job = kit.getPrintJob( new Frame("x"), "PrintableFrame print job",
null);
// do the printing if the user didn't cancel the print job
if (job != null) {
Graphics g = job.getGraphics();
printAll(g); // not paint(g)
g.dispose(); // finish with this page
job.end(); // finish with the PrintJob
}
} catch (Exception ex) {
System.out.println( "print exception " + ex);
}
}
/**
**
** @param panel the container for nodes
**
**/
private void
fill( GraphPanel panel ) {
panel.addNodes("Node1", "Node2", "Node3" );
}
}

View file

@ -0,0 +1,111 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package jit.misctests.fpustack;
import java.util.*;
import java.awt.*;
import java.applet.Applet;
import nsk.share.TestFailure;
public class GraphPanel extends Panel {
private Panel graph; // the container
private ilayout layout = null; // the strategy
private int nodesN; // number of nodes
private Node nodes[] = new Node[200]; // nodes container
/**
** constructor
**
** @param Panel the container
** @param layout a strategy to layout the nodes
**
**/
GraphPanel(Panel graph, layout ls ) {
this.graph = graph;
layout = ls;
}
/**
** add a node via label text.
**
** @param lbl the label
** @return the index of the node in array nodes[]
**
**/
public int addNode(String lbl) {
Node n = new Node();
if (nodesN > 0) {
n.x = nodes[nodesN-1].x + 30;
n.y = nodes[nodesN-1].y + 30;
}
n.lbl = lbl;
nodes[nodesN] = n;
return nodesN++;
}
/**
** add a node via label text.
**
** @param lbl the label
** @return the index of the node in array nodes[]
**
**/
public void addNodes(String lb1, String lb2, String lb3) {
addNode(lb1);
addNode(lb2);
addNode(lb3);
}
/**
** layout the nodes on the panel. the layout is used
**
**
**/
public synchronized void formatNodes( ) {
// format nodes
FontMetrics fm = getFontMetrics(getFont());
Dimension d = getSize();
Node[] ns = new Node[ nodesN ];
System.arraycopy(nodes, 0, ns, 0, nodesN);
layout.formatNodes( ns, d, fm );
}
}

View file

@ -0,0 +1,34 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package jit.misctests.fpustack;
import nsk.share.TestFailure;
public class Node {
double x = 0.0;
double y = 0.0;
String lbl;
}

View file

@ -0,0 +1,33 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package jit.misctests.fpustack;
import java.util.*;
import java.awt.*;
import nsk.share.TestFailure;
interface ilayout {
public void formatNodes( Node[] n, Dimension d, FontMetrics fm );
}

View file

@ -0,0 +1,46 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package jit.misctests.fpustack;
import java.util.*;
import java.awt.*;
import java.applet.Applet;
import nsk.share.TestFailure;
public class layout implements ilayout {
public void formatNodes( Node[] nodes, Dimension d, FontMetrics fm ) {
int h = d.height/2 - 10 ;
double alpha = -Math.PI/2;
for ( int j = 0; j < nodes.length; j++) {
Node n = nodes[j];
int w = d.width/2 - fm.stringWidth( n.lbl )/2;
n.x = d.width/2 + (int)(w*Math.cos( alpha ));
n.y = d.height/2 + (int)(h*Math.sin( alpha ));
alpha += 2*Math.PI/nodes.length;
}
}
}

View file

@ -0,0 +1,59 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/misctests/putfield00802.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm jit.misctests.putfield00802.putfield00802
*/
package jit.misctests.putfield00802;
import java.io.PrintStream;
import nsk.share.TestFailure;
public class putfield00802 {
public double dou_v;
public static putfield00802 always_null;
public static void main(String args[]) {
System.exit(run(args, System.out) + 95/*STATUS_TEMP*/);
}
public static int run(String args[], PrintStream out) {
try {
always_null.dou_v = 17.0;
//int i = 1; // (1)
} catch (NullPointerException e) { // (2)
return 0/*STATUS_PASSED*/;
}
return 2/*STATUS_FAILED*/;
}
}

View file

@ -0,0 +1,79 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/misctests/t5.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.misctests.t5.t5
* @run driver ExecDriver --java jit.misctests.t5.t5
*/
package jit.misctests.t5;
import nsk.share.TestFailure;
class t5
{
public static void main (String [] args)
{
byte[] data = new byte[16];
//foo (data, 0, 16, data, 0);
foo();
}
public static int FF (int a, int b, int c, int d, int x, int s, int ac)
{
return (((a += ((b & c) | (~b & d)) + x + ac) << s) | (a >>> (32-s))
+ b);
}
//static void foo (byte[] data, int off, int len, byte[] to, int pos)
static void foo ()
{
System.out.println ("Starting foo ...");
int[] W = new int[16];
int a = 0x67452301;
int b = 0xefcdab89;
int c = 0x98badcfe;
int d = 0x10325476;
for (int i = 0; i < 16; i++) {
a = FF (a, b, c, d, W[0], 7, 0xd76aa478);
d = FF (d, a, b, c, W[1], 12, 0xe8c7b756);
c = FF (c, d, a, b, W[2], 17, 0x242070db);
b = FF (b, c, d, a, W[3], 22, 0xc1bdceee);
a = FF (a, b, c, d, W[4], 7, 0xf57c0faf);
d = FF (d, a, b, c, W[5], 12, 0x4787c62a);
c = FF (c, d, a, b, W[6], 17, 0xa8304613);
b = FF (b, c, d, a, W[7], 22, 0xfd469501);
}
System.out.println ("foo ended.");
}
}

View file

@ -0,0 +1,38 @@
Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
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.
* common/jtest
* common/misctests/FileViewer
* common/misctests/Foo
* common/misctests/fpustack
* common/misctests/NoHeader
* common/misctests/noop
* common/misctests/Pi
* common/misctests/t5
* common/misctests/whet
* common/misctests/test.java
* common/Peano
* common/PrintProperties
* common/PrintThis
* common/Sleeper
* common/testForBugs/4427606/Security
* common/testForBugs/4446672/TestThreadStart.java
* common/TsdCase

View file

@ -0,0 +1,56 @@
Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
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.
* common/deoptimization/test01
* common/deoptimization/test02
* common/deoptimization/test03
* common/deoptimization/test04
* common/deoptimization/test05
* common/deoptimization/test06
* common/deoptimization/test07
* common/deoptimization/test08
* common/DivTest
* common/ExcOpt
* common/FPCompare/TestFPBinop
* common/FPCompare/TestFPCompare
* common/loops/arg06
* common/loops/arg07
* common/loops/arg08
* common/loops/arg09
* common/loops/arg10
* common/loops/dec01
* common/loops/dec06
* common/loops/dec07
* common/loops/dec08
* common/loops/dec09
* common/loops/dec10
* common/loops/dec11
* common/loops/fuse7
* common/loops/fuse9
* common/loops/fuse107
* common/loops/fuse109
* common/loops/fuse15
* common/loops/fuse19
* common/loops/private2
* common/loops/private3
* common/Peano
* common/tXXX
* common/TsdCase

View file

@ -0,0 +1,67 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/overflow.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @build jit.overflow.overflow
* @run driver ExecDriver --java jit.overflow.overflow
*/
package jit.overflow;
/*
This test checks if a JIT can still detect stack overflow. Method
invocation overhead is expensive in Java and improving it is a
nobel cause for a JIT. JITs just have to be careful that they
don't loose some error handling ability in doing so.
*/
import java.lang.*;
import nsk.share.TestFailure;
class overflow {
public static void main(String[] args) {
try {
recurse(1);
} catch (StackOverflowError e) {
System.out.println("Test PASSES");
return;
}
throw new TestFailure("Test FAILED");
}
static int recurse(int n) {
if (n != 0) {
return recurse(n+1);
}
return 0;
}
}

View file

@ -0,0 +1,48 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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
*
* @summary converted from VM Testbase jit/regression/CrashC1.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm jit.regression.CrashC1.CrashC1
*/
package jit.regression.CrashC1;
import nsk.share.TestFailure;
public class CrashC1 {
public long alignUp(long size, long alignment) {
return (size + alignment - 1) & ~(alignment - 1);
}
public static void main(String[] args) {
new CrashC1().alignUp(8, 8);
}
}

View file

@ -0,0 +1,90 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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 4427606
*
* @summary converted from VM Testbase jit/regression/b4427606.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm jit.regression.b4427606.b4427606
*/
package jit.regression.b4427606;
import nsk.share.TestFailure;
/*
* This is a reproducible case for a few bugs reported in merlin.
* mainly: 4427606
*/
public class b4427606 {
private static final int NUM_ITERATIONS = 1000000;
public static void main(String[] args) {
new b4427606().run();
}
public void run() {
new DivByZero().start();
new NeverDivByZero().start();
}
class DivByZero extends Thread {
public void run() {
long source = 1L;
long iter = NUM_ITERATIONS;
while (--iter > 0) {
try {
long ignore = source % zero;
throw new RuntimeException("Should Not Reach Here....");
} catch (java.lang.ArithmeticException ax) {
} catch (RuntimeException rx) {
rx.printStackTrace();
throw new TestFailure("Test failed.");
}
}
}
}
class NeverDivByZero extends Thread {
public void run() {
long source = 1L;
long iter = NUM_ITERATIONS;
while (--iter > 0) {
try {
long ignore = source % notzero;
} catch (java.lang.ArithmeticException ax) {
ax.printStackTrace();
throw new TestFailure("Test failed.");
}
}
}
}
long zero = 0;
long notzero = 10;
}

View file

@ -0,0 +1,92 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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 4446672
*
* @summary converted from VM Testbase jit/regression/b4446672.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm jit.regression.b4446672.b4446672
*/
package jit.regression.b4446672;
import nsk.share.TestFailure;
public class b4446672 {
public static void main(String[] args) {
new b4446672().run();
}
private void run() {
new GCThread().start();
new TestThreadStarter().start();
while (!gcing) Thread.yield();
while (!starting) Thread.yield();
done = true;
while (!testing) Thread.yield();
}
class TestThread extends Thread {
public void run() {
System.out.println ("TestThread.");
testing = true;
}
}
class TestThreadStarter extends Thread {
public void run() {
System.out.println ("TestThreadStarter.");
starting=true;
testThread.start();
}
}
class GCThread extends Thread {
public void run() {
System.out.println ("GCThread run.");
synchronized (testThread) {
System.out.println ("GCThread synchronized.");
while (!done) {
gcing=true;
yield();
System.gc();
}
}
System.out.println ("GCThread done.");
}
}
TestThread testThread = new TestThread();
boolean done = false;
boolean gcing = false;
boolean testing = false;
boolean starting = false;
}

View file

@ -0,0 +1,45 @@
Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
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.
* common/exception
* common/inline001
* common/inline002
* common/JITSuite
* common/jtest
* common/misctests/classes
* common/misctests/FileViewer
* common/misctests/Foo
* common/misctests/fpustack
* common/misctests/NoHeader
* common/misctests/noop
* common/misctests/Pi
* common/misctests/putfield00802
* common/misctests/t5
* common/misctests/whet
* common/misctests/test.java
* common/Peano
* common/PrintProperties
* common/PrintThis
* common/Sleeper
* common/tXXX
* common/testForBugs/4427606/Security
* common/testForBugs/4446672/TestThreadStart.java
* common/TsdCase

View file

@ -0,0 +1,8 @@
1: 0
2: 0
3: 0
4: 0
5: 0.0
6: 0.0
7: 0.0
8: 0.0

Some files were not shown because too many files have changed in this diff Show more