Skip to content

Commit 24eacfc

Browse files
Cleanups and fixes.
Removed all JVMTI code that uses JNI object handles.
1 parent 3b9bc76 commit 24eacfc

File tree

76 files changed

+729
-5383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+729
-5383
lines changed

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/GCImpl.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
import java.lang.ref.Reference;
3131

32-
import com.oracle.svm.core.jvmti.JvmtiPostEvents;
3332
import org.graalvm.nativeimage.CurrentIsolate;
3433
import org.graalvm.nativeimage.IsolateThread;
3534
import org.graalvm.nativeimage.Platform;
@@ -170,8 +169,6 @@ public void collectionHint(boolean fullGC) {
170169

171170
private void collect(GCCause cause, boolean forceFullGC) {
172171
if (!hasNeverCollectPolicy()) {
173-
JvmtiPostEvents.postGarbageCollectionStart();
174-
JvmtiPostEvents.postGarbageCollectionFinish();
175172
boolean outOfMemory = collectWithoutAllocating(cause, forceFullGC);
176173
if (outOfMemory) {
177174
throw OutOfMemoryUtil.heapSizeExceeded();

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ImageHeapWalker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private static boolean walkPartitionInline(Object firstObject, Object lastObject
126126

127127
@Uninterruptible(reason = "Bridge between uninterruptible and potentially interruptible code.", mayBeInlined = true, calleeMustBe = false)
128128
private static boolean visitObject(ObjectVisitor visitor, Object currentObject) {
129-
return visitor. visitObject(currentObject);
129+
return visitor.visitObject(currentObject);
130130
}
131131

132132
@Uninterruptible(reason = "Bridge between uninterruptible and potentially interruptible code.", mayBeInlined = true, calleeMustBe = false)

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateOptions.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,15 +467,13 @@ public static void updateMaxJavaStackTraceDepth(EconomicMap<OptionKey<?>, Object
467467
@Option(help = "Enable JVM Tool Interface (JVMTI) support.", type = OptionType.User)//
468468
public static final HostedOptionKey<Boolean> JVMTI = new HostedOptionKey<>(false);
469469

470-
// TEMP (chaeubl): we need to support multiple values
471470
@Option(help = "Loads the specified native agent library. " +
472471
"After the library name, a comma-separated list of options specific to the library can be used.", type = OptionType.User)//
473-
public static final RuntimeOptionKey<String> AgentLib = new RuntimeOptionKey<>(null);
472+
public static final RuntimeOptionKey<String> JVMTIAgentLib = new RuntimeOptionKey<>(null);
474473

475-
// TEMP (chaeubl): we need to support multiple values
476474
@Option(help = "Loads the specified native agent library specified by the absolute path name. " +
477475
"After the library path, a comma-separated list of options specific to the library can be used.", type = OptionType.User)//
478-
public static final RuntimeOptionKey<String> AgentPath = new RuntimeOptionKey<>(null);
476+
public static final RuntimeOptionKey<String> JVMTIAgentPath = new RuntimeOptionKey<>(null);
479477

480478
@Option(help = "Alignment of AOT and JIT compiled code in bytes.")//
481479
public static final HostedOptionKey<Integer> CodeAlignment = new HostedOptionKey<>(16);

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/CEntryPointSnippets.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@
3333

3434
import java.util.Map;
3535

36-
import com.oracle.svm.core.jvmti.JvmtiEnvManager;
37-
import com.oracle.svm.core.jvmti.JvmtiManager;
38-
import com.oracle.svm.core.jvmti.JvmtiPostEvents;
3936
import org.graalvm.nativeimage.CurrentIsolate;
4037
import org.graalvm.nativeimage.ImageSingletons;
4138
import org.graalvm.nativeimage.Isolate;
@@ -80,7 +77,6 @@
8077
import com.oracle.svm.core.heap.RestrictHeapAccess;
8178
import com.oracle.svm.core.jdk.PlatformNativeLibrarySupport;
8279
import com.oracle.svm.core.jdk.RuntimeSupport;
83-
import com.oracle.svm.core.jvmti.JvmtiAgents;
8480
import com.oracle.svm.core.log.Log;
8581
import com.oracle.svm.core.option.RuntimeOptionParser;
8682
import com.oracle.svm.core.os.CommittedMemoryProvider;
@@ -402,13 +398,6 @@ private static int initializeIsolateInterruptibly1(CEntryPointCreateIsolateParam
402398
/* Initialize the physical memory size. */
403399
PhysicalMemory.size();
404400

405-
if (SubstrateOptions.JVMTI.getValue()) {
406-
JvmtiAgents.singleton().load();
407-
408-
//JvmtiPostEvents.postVMInit();
409-
JvmtiPostEvents.postVMStart();
410-
}
411-
412401
assert !isolateInitialized;
413402
isolateInitialized = true;
414403

@@ -643,14 +632,6 @@ private static boolean initiateTearDownIsolateInterruptibly() {
643632
}
644633

645634
VMThreads.singleton().threadExit();
646-
647-
if (SubstrateOptions.JVMTI.getValue()) {
648-
JvmtiPostEvents.postVMDeath();
649-
JvmtiManager.freeAllJvmtiClassesUnmanagedMemory();
650-
JvmtiAgents.singleton().unload();
651-
}
652-
653-
654635
return true;
655636
}
656637

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/headers/LibCSupport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import com.oracle.svm.core.memory.NativeMemory;
3535

3636
/** Platform-independent LibC support. Don't use this class directly, use {@link LibC} instead. */
37-
public interface LibCSupport {
37+
public interface LibCSupport {
3838
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
3939
int errno();
4040

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHub.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,6 @@ private ClassRepository getGenericInfo() {
18011801
return companion.getGenericInfo(this);
18021802
}
18031803

1804-
18051804
ClassRepository computeGenericInfo() {
18061805
String genericSignature = getGenericSignature0();
18071806
if (genericSignature == null) {

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/UninterruptibleUtils.java

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -602,21 +602,6 @@ public static int modifiedUTF8Length(java.lang.String string, boolean addNullTer
602602
return result + (addNullTerminator ? 1 : 0);
603603
}
604604

605-
//TODO @dprcci FINISH THAT TłOMORROW
606-
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
607-
public static int modifiedUTF8LengthCharArray(char[] buffer, int bufferLength, boolean addNullTerminator, CharReplacer replacer) {
608-
int result = 0;
609-
for (int index = 0; index < bufferLength; index++) {
610-
char ch = buffer[index];
611-
if (replacer != null) {
612-
ch = replacer.replace(ch);
613-
}
614-
result += modifiedUTF8Length(ch);
615-
}
616-
617-
return result + (addNullTerminator ? 1 : 0);
618-
}
619-
620605
/**
621606
* Writes the encoded {@code string} into the given {@code buffer} using the modified UTF8
622607
* encoding (null characters that are present in the input will be encoded in a way that
@@ -652,29 +637,6 @@ public static Pointer toModifiedUTF8(java.lang.String string, int stringLength,
652637
VMError.guarantee(pos.belowOrEqual(bufferEnd), "Must not write out of bounds.");
653638
return pos;
654639
}
655-
656-
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
657-
public static Pointer toModifiedUTF8FromCharArray(char[] charArray, int endIndex, Pointer buffer, Pointer bufferEnd, boolean addNullTerminator) {
658-
return toModifiedUTF8FromCharArray(charArray, endIndex, buffer, bufferEnd, addNullTerminator, null);
659-
}
660-
661-
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
662-
public static Pointer toModifiedUTF8FromCharArray(char[] charArray, int endIndex, Pointer buffer, Pointer bufferEnd, boolean addNullTerminator, CharReplacer replacer) {
663-
Pointer pos = buffer;
664-
for (int i = 0; i < endIndex; i++) {
665-
char ch = charArray[i];
666-
if (replacer != null) {
667-
ch = replacer.replace(ch);
668-
}
669-
pos = writeModifiedUTF8(pos, ch);
670-
}
671-
if (addNullTerminator) {
672-
pos.writeByte(0, (byte) 0);
673-
pos = pos.add(1);
674-
}
675-
VMError.guarantee(pos.belowOrEqual(bufferEnd), "Must not write out of bounds.");
676-
return pos;
677-
}
678640
}
679641

680642
@FunctionalInterface

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/access/JNIAccessibleField.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
/**
4545
* Information on a field that can be looked up and accessed via JNI.
4646
*/
47-
public final class JNIAccessibleField extends JNIAccessibleMember {
47+
public final class JNIAccessibleField extends JNIAccessibleMember {
4848
/* 10000000...0 */
4949
private static final UnsignedWord ID_STATIC_FLAG = WordFactory.unsigned(-1L).unsignedShiftRight(1).add(1);
5050
/* 01000000...0 */

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/access/JNIAccessibleMethod.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,13 @@ boolean isPublic() {
129129
return Modifier.isPublic(modifiers);
130130
}
131131

132-
boolean isNative() {
132+
public boolean isNative() {
133133
return Modifier.isNative(modifiers);
134134
}
135135

136-
boolean isStatic() {return Modifier.isStatic(modifiers);}
136+
boolean isStatic() {
137+
return Modifier.isStatic(modifiers);
138+
}
137139

138140
@Platforms(HOSTED_ONLY.class)
139141
public void finishBeforeCompilation(EconomicSet<Class<?>> hidingSubclasses, int vtableEntryOffset, CodePointer nonvirtualEntry, PointerBase newObjectEntry, CodePointer callWrapperEntry,

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/access/JNIReflectionDictionary.java

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@
2727
import static com.oracle.svm.core.SubstrateOptions.JNIVerboseLookupErrors;
2828

2929
import java.io.PrintStream;
30-
import java.util.ArrayList;
31-
import java.util.HashSet;
3230
import java.util.Map;
33-
import java.util.Random;
34-
import java.util.Set;
3531
import java.util.function.Function;
3632

3733
import org.graalvm.collections.EconomicMap;
@@ -234,75 +230,6 @@ private JNIAccessibleMethod getDeclaredMethod(Class<?> classObject, JNIAccessibl
234230
return method;
235231
}
236232

237-
public void printall(){
238-
classesByClassObject.getKeys().forEach(System.out::println);
239-
}
240-
// TODO @dprcci REMOVE!
241-
public JNIMethodId getRandomMethodID() {
242-
Iterable<JNIAccessibleClass> accessibleClass = classesByClassObject.getValues();
243-
ArrayList<JNIAccessibleClass> classList = new ArrayList<>();
244-
accessibleClass.forEach(classList::add);
245-
246-
// Get random class
247-
Random random = new Random();
248-
JNIAccessibleClass randomClass = null;
249-
if (!classList.isEmpty()) {
250-
int randomIndex = random.nextInt(classList.size());
251-
randomClass = classList.get(randomIndex);
252-
}
253-
if (randomClass == null) {
254-
return WordFactory.nullPointer();
255-
}
256-
MapCursor<JNIAccessibleMethodDescriptor, JNIAccessibleMethod> cursor = randomClass.getMethods();
257-
if (cursor.advance()) {
258-
return toMethodID(cursor.getValue());
259-
} else {
260-
return WordFactory.nullPointer();
261-
}
262-
}
263-
264-
// TODO @dprcci JVMTI is this correct or should reflection be used? It is assumed the internals
265-
// should not be exposed to the user
266-
public JNIMethodId toMethodID(Class<?> clazz, String methodName) {
267-
//Log.log().string(clazz.getName());
268-
JNIAccessibleClass accessibleClass = classesByClassObject.get(clazz);
269-
if (accessibleClass == null) {
270-
return WordFactory.nullPointer();
271-
}
272-
boolean found = false;
273-
MapCursor<JNIAccessibleMethodDescriptor, JNIAccessibleMethod> cursor = accessibleClass.getMethods();
274-
while (!found && cursor.advance()) {
275-
found = cursor.getKey().getName().equals(methodName);
276-
}
277-
return toMethodID(found ? cursor.getValue() : null);
278-
}
279-
280-
// TODO @dprcci
281-
@Platforms(HOSTED_ONLY.class)
282-
public Set<Class<?>> getRegisteredClasses() {
283-
Set<Class<?>> res = new HashSet<>();
284-
classesByClassObject.getKeys().forEach(res::add);
285-
return res;
286-
}
287-
288-
// TODO @dprcci
289-
public static boolean isMethodNative(JNIMethodId methodId) {
290-
return getMethodByID(methodId).isNative();
291-
}
292-
293-
public boolean isValidMethodIdSlow(JNIMethodId methodId){
294-
Iterable<JNIAccessibleClass> classIterator = classesByClassObject.getValues();
295-
for (JNIAccessibleClass c : classIterator){
296-
MapCursor<JNIAccessibleMethodDescriptor, JNIAccessibleMethod> cursor = c.getMethods();
297-
while(cursor.advance()){
298-
if(toMethodID(cursor.getValue()).equal(methodId)){
299-
return true;
300-
}
301-
}
302-
}
303-
return false;
304-
}
305-
306233
public JNIMethodId getMethodID(Class<?> classObject, CharSequence name, CharSequence signature, boolean isStatic) {
307234
JNIAccessibleMethod method = findMethod(classObject, new JNIAccessibleMethodDescriptor(name, signature), "getMethodID");
308235
boolean match = (method != null && method.isStatic() == isStatic && method.isDiscoverableIn(classObject));

0 commit comments

Comments
 (0)