diff options
author | 2022-11-14 14:03:10 +0000 | |
---|---|---|
committer | 2022-11-15 15:34:39 +0000 | |
commit | e2d1a03f24c7a130a8e5ad1c9245abe781ddb1e8 (patch) | |
tree | 99f6b917cb3b3c1ee0d7513f8b1d5f66f3884723 /test/496-checker-inlining-class-loader | |
parent | 07c68601ddf623a699892ed0dd5ec87b7a05fd02 (diff) |
ART: Change indentation to 4 spaces in run-test shards 95-99.
Created with
for testName in \
`git grep -E '^ public static void main\(String\[\]' \
-- test/*<i>-*/src/Main.java | \
sed '-es/\/src\/Main.java:.*//'`; \
do \
find $testName/ -type f -name *.java | \
xargs sed -E '-es/^(( )+)/\1\1/' --in-place ; \
done
with <i> manually set to 99 down to 95 (stopping when the
change is getting large).
Manually address many long lines and fix other style issues.
Also fix indentation in two files where
https://android-review.googlesource.com/2300941
just updated previously wrong indentation.
Exclude changes to
test/595-profile-saving/src/Main.java
because of a conflict in internal.
Test: testrunner.py --host --optimizing
Test: buildbot-build.sh --target
Change-Id: I02fe676f3983610c0cdda1134aee2476f71bc7ce
Diffstat (limited to 'test/496-checker-inlining-class-loader')
-rw-r--r-- | test/496-checker-inlining-class-loader/src/FirstSeenByMyClassLoader.java | 14 | ||||
-rw-r--r-- | test/496-checker-inlining-class-loader/src/Main.java | 191 |
2 files changed, 103 insertions, 102 deletions
diff --git a/test/496-checker-inlining-class-loader/src/FirstSeenByMyClassLoader.java b/test/496-checker-inlining-class-loader/src/FirstSeenByMyClassLoader.java index e97b4e3391..fe0582e151 100644 --- a/test/496-checker-inlining-class-loader/src/FirstSeenByMyClassLoader.java +++ b/test/496-checker-inlining-class-loader/src/FirstSeenByMyClassLoader.java @@ -15,12 +15,12 @@ */ public class FirstSeenByMyClassLoader { - public static void $inline$bar() { - } + public static void $inline$bar() { + } - public static void $noinline$bar() { - try { - System.out.println("In $noinline$bar"); - } catch (Throwable t) { /* Ignore */ } - } + public static void $noinline$bar() { + try { + System.out.println("In $noinline$bar"); + } catch (Throwable t) { /* Ignore */ } + } } diff --git a/test/496-checker-inlining-class-loader/src/Main.java b/test/496-checker-inlining-class-loader/src/Main.java index 4fe47237f8..feb8fdc56d 100644 --- a/test/496-checker-inlining-class-loader/src/Main.java +++ b/test/496-checker-inlining-class-loader/src/Main.java @@ -20,115 +20,116 @@ import java.util.ArrayList; import java.util.List; class MyClassLoader extends ClassLoader { - MyClassLoader() throws Exception { - super(MyClassLoader.class.getClassLoader()); + MyClassLoader() throws Exception { + super(MyClassLoader.class.getClassLoader()); - // Some magic to get access to the pathList field of BaseDexClassLoader. - ClassLoader loader = getClass().getClassLoader(); - Class<?> baseDexClassLoader = loader.getClass().getSuperclass(); - Field f = baseDexClassLoader.getDeclaredField("pathList"); - f.setAccessible(true); - Object pathList = f.get(loader); + // Some magic to get access to the pathList field of BaseDexClassLoader. + ClassLoader loader = getClass().getClassLoader(); + Class<?> baseDexClassLoader = loader.getClass().getSuperclass(); + Field f = baseDexClassLoader.getDeclaredField("pathList"); + f.setAccessible(true); + Object pathList = f.get(loader); - // Some magic to get access to the dexField field of pathList. - // Need to make a copy of the dex elements since we don't want an app image with pre-resolved - // things. - f = pathList.getClass().getDeclaredField("dexElements"); - f.setAccessible(true); - Object[] dexElements = (Object[]) f.get(pathList); - f = dexElements[0].getClass().getDeclaredField("dexFile"); - f.setAccessible(true); - for (Object element : dexElements) { - Object dexFile = f.get(element); - // Make copy. - Field fileNameField = dexFile.getClass().getDeclaredField("mFileName"); - fileNameField.setAccessible(true); - dexFiles.add(dexFile.getClass().getDeclaredConstructor(String.class).newInstance( - fileNameField.get(dexFile))); + // Some magic to get access to the dexField field of pathList. + // Need to make a copy of the dex elements since we don't want an app image + // with pre-resolved things. + f = pathList.getClass().getDeclaredField("dexElements"); + f.setAccessible(true); + Object[] dexElements = (Object[]) f.get(pathList); + f = dexElements[0].getClass().getDeclaredField("dexFile"); + f.setAccessible(true); + for (Object element : dexElements) { + Object dexFile = f.get(element); + // Make copy. + Field fileNameField = dexFile.getClass().getDeclaredField("mFileName"); + fileNameField.setAccessible(true); + dexFiles.add(dexFile.getClass().getDeclaredConstructor(String.class).newInstance( + fileNameField.get(dexFile))); + } } - } - ArrayList<Object> dexFiles = new ArrayList<Object>(); - Field dexFileField; + ArrayList<Object> dexFiles = new ArrayList<Object>(); + Field dexFileField; - protected Class<?> loadClass(String className, boolean resolve) throws ClassNotFoundException { - // Other classes may also get loaded, ignore those. - if (className.equals("LoadedByMyClassLoader") || className.equals("FirstSeenByMyClassLoader")) { - System.out.println("Request for " + className); - } + protected Class<?> loadClass(String className, boolean resolve) throws ClassNotFoundException { + // Other classes may also get loaded, ignore those. + if (className.equals("LoadedByMyClassLoader") + || className.equals("FirstSeenByMyClassLoader")) { + System.out.println("Request for " + className); + } - // We're only going to handle LoadedByMyClassLoader. - if (className != "LoadedByMyClassLoader") { - return getParent().loadClass(className); - } + // We're only going to handle LoadedByMyClassLoader. + if (className != "LoadedByMyClassLoader") { + return getParent().loadClass(className); + } - // Mimic what DexPathList.findClass is doing. - try { - for (Object dexFile : dexFiles) { - Method method = dexFile.getClass().getDeclaredMethod( - "loadClassBinaryName", String.class, ClassLoader.class, List.class); + // Mimic what DexPathList.findClass is doing. + try { + for (Object dexFile : dexFiles) { + Method method = dexFile.getClass().getDeclaredMethod( + "loadClassBinaryName", String.class, ClassLoader.class, List.class); - if (dexFile != null) { - Class<?> clazz = (Class<?>)method.invoke(dexFile, className, this, null); - if (clazz != null) { - return clazz; - } - } - } - } catch (Exception e) { /* Ignore */ } - return null; - } + if (dexFile != null) { + Class<?> clazz = (Class<?>) method.invoke(dexFile, className, this, null); + if (clazz != null) { + return clazz; + } + } + } + } catch (Exception e) { /* Ignore */ } + return null; + } } class LoadedByMyClassLoader { - /// CHECK-START: void LoadedByMyClassLoader.bar() inliner (before) - /// CHECK: LoadClass class_name:FirstSeenByMyClassLoader - /// CHECK-NEXT: ClinitCheck - /// CHECK-NEXT: InvokeStaticOrDirect - /// CHECK-NEXT: LoadClass class_name:java.lang.System - /// CHECK-NEXT: ClinitCheck - /// CHECK-NEXT: StaticFieldGet - /// CHECK-NEXT: LoadString - /// CHECK-NEXT: NullCheck - /// CHECK-NEXT: InvokeVirtual + /// CHECK-START: void LoadedByMyClassLoader.bar() inliner (before) + /// CHECK: LoadClass class_name:FirstSeenByMyClassLoader + /// CHECK-NEXT: ClinitCheck + /// CHECK-NEXT: InvokeStaticOrDirect + /// CHECK-NEXT: LoadClass class_name:java.lang.System + /// CHECK-NEXT: ClinitCheck + /// CHECK-NEXT: StaticFieldGet + /// CHECK-NEXT: LoadString + /// CHECK-NEXT: NullCheck + /// CHECK-NEXT: InvokeVirtual - /// CHECK-START: void LoadedByMyClassLoader.bar() inliner (after) - /// CHECK: LoadClass class_name:FirstSeenByMyClassLoader - /// CHECK-NEXT: ClinitCheck - /* We inlined FirstSeenByMyClassLoader.$inline$bar */ - /// CHECK-NEXT: LoadClass class_name:java.lang.System - /// CHECK-NEXT: ClinitCheck - /// CHECK-NEXT: StaticFieldGet - /// CHECK-NEXT: LoadString - /// CHECK-NEXT: NullCheck - /// CHECK-NEXT: InvokeVirtual + /// CHECK-START: void LoadedByMyClassLoader.bar() inliner (after) + /// CHECK: LoadClass class_name:FirstSeenByMyClassLoader + /// CHECK-NEXT: ClinitCheck + /* We inlined FirstSeenByMyClassLoader.$inline$bar */ + /// CHECK-NEXT: LoadClass class_name:java.lang.System + /// CHECK-NEXT: ClinitCheck + /// CHECK-NEXT: StaticFieldGet + /// CHECK-NEXT: LoadString + /// CHECK-NEXT: NullCheck + /// CHECK-NEXT: InvokeVirtual - /// CHECK-START: void LoadedByMyClassLoader.bar() register (before) - /* Load and initialize FirstSeenByMyClassLoader */ - /// CHECK: LoadClass class_name:FirstSeenByMyClassLoader gen_clinit_check:true - /* Load and initialize System */ - // There may be HX86ComputeBaseMethodAddress here. - /// CHECK: LoadClass class_name:java.lang.System - // The ClinitCheck may (PIC) or may not (non-PIC) be merged into the LoadClass. - // (The merging checks for environment match but HLoadClass/kBootImageAddress - // used for non-PIC mode does not have an environment at all.) - /// CHECK: StaticFieldGet - // There may be HX86ComputeBaseMethodAddress here. - /// CHECK: LoadString - /// CHECK-NEXT: NullCheck - /// CHECK-NEXT: InvokeVirtual - public static void bar() { - FirstSeenByMyClassLoader.$inline$bar(); - System.out.println("In between the two calls."); - FirstSeenByMyClassLoader.$noinline$bar(); - } + /// CHECK-START: void LoadedByMyClassLoader.bar() register (before) + /* Load and initialize FirstSeenByMyClassLoader */ + /// CHECK: LoadClass class_name:FirstSeenByMyClassLoader gen_clinit_check:true + /* Load and initialize System */ + // There may be HX86ComputeBaseMethodAddress here. + /// CHECK: LoadClass class_name:java.lang.System + // The ClinitCheck may (PIC) or may not (non-PIC) be merged into the LoadClass. + // (The merging checks for environment match but HLoadClass/kBootImageAddress + // used for non-PIC mode does not have an environment at all.) + /// CHECK: StaticFieldGet + // There may be HX86ComputeBaseMethodAddress here. + /// CHECK: LoadString + /// CHECK-NEXT: NullCheck + /// CHECK-NEXT: InvokeVirtual + public static void bar() { + FirstSeenByMyClassLoader.$inline$bar(); + System.out.println("In between the two calls."); + FirstSeenByMyClassLoader.$noinline$bar(); + } } public class Main { - public static void main(String[] args) throws Exception { - MyClassLoader o = new MyClassLoader(); - Class<?> foo = o.loadClass("LoadedByMyClassLoader"); - Method m = foo.getDeclaredMethod("bar"); - m.invoke(null); - } + public static void main(String[] args) throws Exception { + MyClassLoader o = new MyClassLoader(); + Class<?> foo = o.loadClass("LoadedByMyClassLoader"); + Method m = foo.getDeclaredMethod("bar"); + m.invoke(null); + } } |