8269281: java/foreign/Test{Down,Up}call.java time out
Reviewed-by: jvernee
This commit is contained in:
parent
bd95c0c9e0
commit
b2416b60fb
@ -47,6 +47,8 @@ public class CallGeneratorHelper extends NativeTestHelper {
|
||||
|
||||
static SegmentAllocator IMPLICIT_ALLOCATOR = (size, align) -> MemorySegment.allocateNative(size, align, ResourceScope.newImplicitScope());
|
||||
|
||||
static final int SAMPLE_FACTOR = Integer.parseInt((String)System.getProperties().getOrDefault("generator.sample.factor", "-1"));
|
||||
|
||||
static final int MAX_FIELDS = 3;
|
||||
static final int MAX_PARAMS = 3;
|
||||
static final int CHUNK_SIZE = 600;
|
||||
@ -199,7 +201,9 @@ public class CallGeneratorHelper extends NativeTestHelper {
|
||||
int count = functions;
|
||||
int fCode = functions++ / CHUNK_SIZE;
|
||||
String fName = String.format("f%d_%s_%s_%s", fCode, retCode, sigCode, structCode);
|
||||
downcalls.add(new Object[] { count, fName, r, ptypes, fields });
|
||||
if (SAMPLE_FACTOR == -1 || (count % SAMPLE_FACTOR) == 0) {
|
||||
downcalls.add(new Object[]{count, fName, r, ptypes, fields});
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -207,7 +211,9 @@ public class CallGeneratorHelper extends NativeTestHelper {
|
||||
int count = functions;
|
||||
int fCode = functions++ / CHUNK_SIZE;
|
||||
String fName = String.format("f%d_%s_%s_%s", fCode, retCode, sigCode, structCode);
|
||||
downcalls.add(new Object[] { count, fName, r, ptypes, List.of() });
|
||||
if (SAMPLE_FACTOR == -1 || (count % SAMPLE_FACTOR) == 0) {
|
||||
downcalls.add(new Object[]{count, fName, r, ptypes, List.of()});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
* @build NativeTestHelper CallGeneratorHelper TestDowncall
|
||||
*
|
||||
* @run testng/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies
|
||||
* --enable-native-access=ALL-UNNAMED
|
||||
* --enable-native-access=ALL-UNNAMED -Dgenerator.sample.factor=17
|
||||
* TestDowncall
|
||||
*/
|
||||
|
||||
@ -94,9 +94,6 @@ public class TestDowncall extends CallGeneratorHelper {
|
||||
FunctionDescriptor descriptor = function(ret, paramTypes, fields);
|
||||
Object[] args = makeArgs(paramTypes, fields, checks);
|
||||
boolean needsScope = mt.returnType().equals(MemorySegment.class);
|
||||
if (count % 100 == 0) {
|
||||
System.gc();
|
||||
}
|
||||
Object res = doCall(addr, IMPLICIT_ALLOCATOR, mt, descriptor, args);
|
||||
if (ret == Ret.NON_VOID) {
|
||||
checks.forEach(c -> c.accept(res));
|
||||
|
@ -29,7 +29,7 @@
|
||||
* @build NativeTestHelper CallGeneratorHelper TestUpcall
|
||||
*
|
||||
* @run testng/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies
|
||||
* --enable-native-access=ALL-UNNAMED
|
||||
* --enable-native-access=ALL-UNNAMED -Dgenerator.sample.factor=17
|
||||
* TestUpcall
|
||||
*/
|
||||
|
||||
@ -41,7 +41,6 @@ import jdk.incubator.foreign.MemoryLayout;
|
||||
import jdk.incubator.foreign.MemorySegment;
|
||||
|
||||
import jdk.incubator.foreign.ResourceScope;
|
||||
import jdk.incubator.foreign.SegmentAllocator;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -115,9 +114,6 @@ public class TestUpcall extends CallGeneratorHelper {
|
||||
MethodHandle mh = abi.downcallHandle(addr, IMPLICIT_ALLOCATOR, mtype, function(ret, paramTypes, fields));
|
||||
Object[] args = makeArgs(ResourceScope.newImplicitScope(), ret, paramTypes, fields, returnChecks, argChecks);
|
||||
Object[] callArgs = args;
|
||||
if (count % 100 == 0) {
|
||||
System.gc();
|
||||
}
|
||||
Object res = mh.invokeWithArguments(callArgs);
|
||||
argChecks.forEach(c -> c.accept(args));
|
||||
if (ret == Ret.NON_VOID) {
|
||||
|
Loading…
Reference in New Issue
Block a user