Skip to content

Commit f5101cb

Browse files
Cleanups and fixes.
Removed all JVMTI code that uses JNI object handles.
1 parent 6bb1798 commit f5101cb

File tree

87 files changed

+790
-5390
lines changed

Some content is hidden

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

87 files changed

+790
-5390
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
@@ -31,7 +31,6 @@
3131

3232
import java.lang.ref.Reference;
3333

34-
import com.oracle.svm.core.jvmti.JvmtiPostEvents;
3534
import org.graalvm.nativeimage.CurrentIsolate;
3635
import org.graalvm.nativeimage.IsolateThread;
3736
import org.graalvm.nativeimage.Platform;
@@ -178,8 +177,6 @@ public void collectionHint(boolean fullGC) {
178177

179178
private void collect(GCCause cause, boolean forceFullGC) {
180179
if (!hasNeverCollectPolicy()) {
181-
JvmtiPostEvents.postGarbageCollectionStart();
182-
JvmtiPostEvents.postGarbageCollectionFinish();
183180
boolean outOfMemory = collectWithoutAllocating(cause, forceFullGC);
184181
if (outOfMemory) {
185182
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
@@ -127,7 +127,7 @@ private static boolean walkPartitionInline(Object firstObject, Object lastObject
127127

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

133133
@AlwaysInline("de-virtualize calls to ObjectReferenceVisitor")

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
@@ -634,15 +634,13 @@ public static void updateMaxJavaStackTraceDepth(EconomicMap<OptionKey<?>, Object
634634
@Option(help = "Enable JVM Tool Interface (JVMTI) support.", type = OptionType.User)//
635635
public static final HostedOptionKey<Boolean> JVMTI = new HostedOptionKey<>(false);
636636

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

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

647645
@Option(help = "Alignment of AOT and JIT compiled code in bytes.")//
648646
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
@@ -32,9 +32,6 @@
3232

3333
import java.util.Map;
3434

35-
import com.oracle.svm.core.jvmti.JvmtiEnvManager;
36-
import com.oracle.svm.core.jvmti.JvmtiManager;
37-
import com.oracle.svm.core.jvmti.JvmtiPostEvents;
3835
import org.graalvm.nativeimage.CurrentIsolate;
3936
import org.graalvm.nativeimage.ImageSingletons;
4037
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;
@@ -400,13 +396,6 @@ private static int initializeIsolateInterruptibly1(CEntryPointCreateIsolateParam
400396
/* Adjust stack overflow boundary of main thread. */
401397
StackOverflowCheck.singleton().updateStackOverflowBoundary();
402398

403-
if (SubstrateOptions.JVMTI.getValue()) {
404-
JvmtiAgents.singleton().load();
405-
406-
//JvmtiPostEvents.postVMInit();
407-
JvmtiPostEvents.postVMStart();
408-
}
409-
410399
assert !isolateInitialized;
411400
isolateInitialized = true;
412401

@@ -637,14 +626,6 @@ private static boolean initiateTearDownIsolateInterruptibly() {
637626
}
638627

639628
VMThreads.singleton().threadExit();
640-
641-
if (SubstrateOptions.JVMTI.getValue()) {
642-
JvmtiPostEvents.postVMDeath();
643-
JvmtiManager.freeAllJvmtiClassesUnmanagedMemory();
644-
JvmtiAgents.singleton().unload();
645-
}
646-
647-
648629
return true;
649630
}
650631

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
@@ -1843,7 +1843,6 @@ private ClassRepository getGenericInfo() {
18431843
return companion.getGenericInfo(this);
18441844
}
18451845

1846-
18471846
ClassRepository computeGenericInfo() {
18481847
String genericSignature = getGenericSignature0();
18491848
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
@@ -605,21 +605,6 @@ public static int modifiedUTF8Length(java.lang.String string, boolean addNullTer
605605
return result + (addNullTerminator ? 1 : 0);
606606
}
607607

608-
//TODO @dprcci FINISH THAT TłOMORROW
609-
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
610-
public static int modifiedUTF8LengthCharArray(char[] buffer, int bufferLength, boolean addNullTerminator, CharReplacer replacer) {
611-
int result = 0;
612-
for (int index = 0; index < bufferLength; index++) {
613-
char ch = buffer[index];
614-
if (replacer != null) {
615-
ch = replacer.replace(ch);
616-
}
617-
result += modifiedUTF8Length(ch);
618-
}
619-
620-
return result + (addNullTerminator ? 1 : 0);
621-
}
622-
623608
/**
624609
* Writes the encoded {@code string} into the given {@code buffer} using the modified UTF8
625610
* encoding (null characters that are present in the input will be encoded in a way that
@@ -656,29 +641,6 @@ public static Pointer toModifiedUTF8(java.lang.String string, int stringLength,
656641
return pos;
657642
}
658643

659-
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
660-
public static Pointer toModifiedUTF8FromCharArray(char[] charArray, int endIndex, Pointer buffer, Pointer bufferEnd, boolean addNullTerminator) {
661-
return toModifiedUTF8FromCharArray(charArray, endIndex, buffer, bufferEnd, addNullTerminator, null);
662-
}
663-
664-
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
665-
public static Pointer toModifiedUTF8FromCharArray(char[] charArray, int endIndex, Pointer buffer, Pointer bufferEnd, boolean addNullTerminator, CharReplacer replacer) {
666-
Pointer pos = buffer;
667-
for (int i = 0; i < endIndex; i++) {
668-
char ch = charArray[i];
669-
if (replacer != null) {
670-
ch = replacer.replace(ch);
671-
}
672-
pos = writeModifiedUTF8(pos, ch);
673-
}
674-
if (addNullTerminator) {
675-
pos.writeByte(0, (byte) 0);
676-
pos = pos.add(1);
677-
}
678-
VMError.guarantee(pos.belowOrEqual(bufferEnd), "Must not write out of bounds.");
679-
return pos;
680-
}
681-
682644
/**
683645
* Returns a character from a string at {@code index} position based on the encoding format.
684646
*/

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
@@ -157,11 +157,13 @@ boolean isPublic() {
157157
return Modifier.isPublic(modifiers);
158158
}
159159

160-
boolean isNative() {
160+
public boolean isNative() {
161161
return Modifier.isNative(modifiers);
162162
}
163163

164-
boolean isStatic() {return Modifier.isStatic(modifiers);}
164+
boolean isStatic() {
165+
return Modifier.isStatic(modifiers);
166+
}
165167

166168
@Platforms(HOSTED_ONLY.class)
167169
public void finishBeforeCompilation(EconomicSet<Class<?>> hidingSubclasses, int vtableOffsetEntry, int interfaceTypeIDEntry, CodePointer nonvirtualEntry, PointerBase newObjectEntry,

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
@@ -28,11 +28,7 @@
2828
import static com.oracle.svm.core.SubstrateOptions.JNIVerboseLookupErrors;
2929

3030
import java.io.PrintStream;
31-
import java.util.ArrayList;
32-
import java.util.HashSet;
3331
import java.util.Map;
34-
import java.util.Random;
35-
import java.util.Set;
3632
import java.util.function.Function;
3733

3834
import org.graalvm.collections.EconomicMap;
@@ -255,75 +251,6 @@ private JNIAccessibleMethod getDeclaredMethod(Class<?> classObject, JNIAccessibl
255251
return method;
256252
}
257253

258-
public void printall(){
259-
classesByClassObject.getKeys().forEach(System.out::println);
260-
}
261-
// TODO @dprcci REMOVE!
262-
public JNIMethodId getRandomMethodID() {
263-
Iterable<JNIAccessibleClass> accessibleClass = classesByClassObject.getValues();
264-
ArrayList<JNIAccessibleClass> classList = new ArrayList<>();
265-
accessibleClass.forEach(classList::add);
266-
267-
// Get random class
268-
Random random = new Random();
269-
JNIAccessibleClass randomClass = null;
270-
if (!classList.isEmpty()) {
271-
int randomIndex = random.nextInt(classList.size());
272-
randomClass = classList.get(randomIndex);
273-
}
274-
if (randomClass == null) {
275-
return WordFactory.nullPointer();
276-
}
277-
MapCursor<JNIAccessibleMethodDescriptor, JNIAccessibleMethod> cursor = randomClass.getMethods();
278-
if (cursor.advance()) {
279-
return toMethodID(cursor.getValue());
280-
} else {
281-
return WordFactory.nullPointer();
282-
}
283-
}
284-
285-
// TODO @dprcci JVMTI is this correct or should reflection be used? It is assumed the internals
286-
// should not be exposed to the user
287-
public JNIMethodId toMethodID(Class<?> clazz, String methodName) {
288-
//Log.log().string(clazz.getName());
289-
JNIAccessibleClass accessibleClass = classesByClassObject.get(clazz);
290-
if (accessibleClass == null) {
291-
return WordFactory.nullPointer();
292-
}
293-
boolean found = false;
294-
MapCursor<JNIAccessibleMethodDescriptor, JNIAccessibleMethod> cursor = accessibleClass.getMethods();
295-
while (!found && cursor.advance()) {
296-
found = cursor.getKey().getName().equals(methodName);
297-
}
298-
return toMethodID(found ? cursor.getValue() : null);
299-
}
300-
301-
// TODO @dprcci
302-
@Platforms(HOSTED_ONLY.class)
303-
public Set<Class<?>> getRegisteredClasses() {
304-
Set<Class<?>> res = new HashSet<>();
305-
classesByClassObject.getKeys().forEach(res::add);
306-
return res;
307-
}
308-
309-
// TODO @dprcci
310-
public static boolean isMethodNative(JNIMethodId methodId) {
311-
return getMethodByID(methodId).isNative();
312-
}
313-
314-
public boolean isValidMethodIdSlow(JNIMethodId methodId){
315-
Iterable<JNIAccessibleClass> classIterator = classesByClassObject.getValues();
316-
for (JNIAccessibleClass c : classIterator){
317-
MapCursor<JNIAccessibleMethodDescriptor, JNIAccessibleMethod> cursor = c.getMethods();
318-
while(cursor.advance()){
319-
if(toMethodID(cursor.getValue()).equal(methodId)){
320-
return true;
321-
}
322-
}
323-
}
324-
return false;
325-
}
326-
327254
public JNIMethodId getMethodID(Class<?> classObject, CharSequence name, CharSequence signature, boolean isStatic) {
328255
JNIAccessibleMethod method = findMethod(classObject, new JNIAccessibleMethodDescriptor(name, signature), "getMethodID");
329256
method = checkMethod(method, classObject, name, signature);

0 commit comments

Comments
 (0)