Skip to content

Commit b2416b6

Browse files
committedJul 13, 2021
8269281: java/foreign/Test{Down,Up}call.java time out
Reviewed-by: jvernee
1 parent bd95c0c commit b2416b6

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed
 

‎test/jdk/java/foreign/CallGeneratorHelper.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public class CallGeneratorHelper extends NativeTestHelper {
4747

4848
static SegmentAllocator IMPLICIT_ALLOCATOR = (size, align) -> MemorySegment.allocateNative(size, align, ResourceScope.newImplicitScope());
4949

50+
static final int SAMPLE_FACTOR = Integer.parseInt((String)System.getProperties().getOrDefault("generator.sample.factor", "-1"));
51+
5052
static final int MAX_FIELDS = 3;
5153
static final int MAX_PARAMS = 3;
5254
static final int CHUNK_SIZE = 600;
@@ -199,15 +201,19 @@ public static Object[][] functions() {
199201
int count = functions;
200202
int fCode = functions++ / CHUNK_SIZE;
201203
String fName = String.format("f%d_%s_%s_%s", fCode, retCode, sigCode, structCode);
202-
downcalls.add(new Object[] { count, fName, r, ptypes, fields });
204+
if (SAMPLE_FACTOR == -1 || (count % SAMPLE_FACTOR) == 0) {
205+
downcalls.add(new Object[]{count, fName, r, ptypes, fields});
206+
}
203207
}
204208
}
205209
} else {
206210
String structCode = sigCode(List.<StructFieldType>of());
207211
int count = functions;
208212
int fCode = functions++ / CHUNK_SIZE;
209213
String fName = String.format("f%d_%s_%s_%s", fCode, retCode, sigCode, structCode);
210-
downcalls.add(new Object[] { count, fName, r, ptypes, List.of() });
214+
if (SAMPLE_FACTOR == -1 || (count % SAMPLE_FACTOR) == 0) {
215+
downcalls.add(new Object[]{count, fName, r, ptypes, List.of()});
216+
}
211217
}
212218
}
213219
}

‎test/jdk/java/foreign/TestDowncall.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* @build NativeTestHelper CallGeneratorHelper TestDowncall
3030
*
3131
* @run testng/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies
32-
* --enable-native-access=ALL-UNNAMED
32+
* --enable-native-access=ALL-UNNAMED -Dgenerator.sample.factor=17
3333
* TestDowncall
3434
*/
3535

@@ -94,9 +94,6 @@ public void testDowncallNoScope(int count, String fName, Ret ret, List<ParamType
9494
FunctionDescriptor descriptor = function(ret, paramTypes, fields);
9595
Object[] args = makeArgs(paramTypes, fields, checks);
9696
boolean needsScope = mt.returnType().equals(MemorySegment.class);
97-
if (count % 100 == 0) {
98-
System.gc();
99-
}
10097
Object res = doCall(addr, IMPLICIT_ALLOCATOR, mt, descriptor, args);
10198
if (ret == Ret.NON_VOID) {
10299
checks.forEach(c -> c.accept(res));

‎test/jdk/java/foreign/TestUpcall.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* @build NativeTestHelper CallGeneratorHelper TestUpcall
3030
*
3131
* @run testng/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies
32-
* --enable-native-access=ALL-UNNAMED
32+
* --enable-native-access=ALL-UNNAMED -Dgenerator.sample.factor=17
3333
* TestUpcall
3434
*/
3535

@@ -41,7 +41,6 @@
4141
import jdk.incubator.foreign.MemorySegment;
4242

4343
import jdk.incubator.foreign.ResourceScope;
44-
import jdk.incubator.foreign.SegmentAllocator;
4544
import org.testng.annotations.BeforeClass;
4645
import org.testng.annotations.Test;
4746

@@ -115,9 +114,6 @@ public void testUpcallsNoScope(int count, String fName, Ret ret, List<ParamType>
115114
MethodHandle mh = abi.downcallHandle(addr, IMPLICIT_ALLOCATOR, mtype, function(ret, paramTypes, fields));
116115
Object[] args = makeArgs(ResourceScope.newImplicitScope(), ret, paramTypes, fields, returnChecks, argChecks);
117116
Object[] callArgs = args;
118-
if (count % 100 == 0) {
119-
System.gc();
120-
}
121117
Object res = mh.invokeWithArguments(callArgs);
122118
argChecks.forEach(c -> c.accept(args));
123119
if (ret == Ret.NON_VOID) {

0 commit comments

Comments
 (0)
Failed to load comments.