1 // Copyright (C) 2017 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 //
16 // Lists several combinations of Classes X Methods X Hotness:
17 //
18 // Class A-C:
19 //   - Ensure method hotness overrides sorting by class_def_idx
20 //
21 // Method m_a : m_c
22 //   - Ensure method hotness overrides sorting by method_id
23 //
24 // Method m_a$Hot$Enum$Bits
25 //   - $X$Y$Z is an encoding of MethodHotness flags ($[Hot]$[Startup]$[Poststartup])
26 //   - The method name encoding matches the `profile` hotness.
27 //   - Check all variations of the bits to make sure it sorts by hotness correctly.
28 //
29 
30 class A {
31   // Note that every method has unique dex code (by using a unique string literal).
32   // This is to prevent dex/oat code deduping. Deduped methods do not get distinct bins.
m_a$$$()33   void m_a$$$() { System.out.println("Don't dedupe me! A::m_a$$$"); }
m_a$Hot$$()34   void m_a$Hot$$() { System.out.println("Don't dedupe me! A::m_a$Hot$$"); }
m_a$$Startup$()35   void m_a$$Startup$() { System.out.println("Don't dedupe me! A::m_a$$Startup$"); }
m_a$Hot$Startup$()36   void m_a$Hot$Startup$() { System.out.println("Don't dedupe me! A::m_a$Hot$Startup$"); }
m_a$$$Poststartup()37   void m_a$$$Poststartup() { System.out.println("Don't dedupe me! A::m_a$$$Poststartup"); }
m_a$Hot$$Poststartup()38   void m_a$Hot$$Poststartup() { System.out.println("Don't dedupe me! A::m_a$Hot$$Poststartup"); }
m_a$$Startup$Poststartup()39   void m_a$$Startup$Poststartup() { System.out.println("Don't dedupe me! A::m_a$$Startup$Poststartup"); }
m_a$Hot$Startup$Poststartup()40   void m_a$Hot$Startup$Poststartup() { System.out.println("Don't dedupe me! A::m_a$Hot$Startup$Poststartup"); }
m_b$$$()41   void m_b$$$() { System.out.println("Don't dedupe me! A::m_b$$$"); }
m_b$Hot$$()42   void m_b$Hot$$() { System.out.println("Don't dedupe me! A::m_b$Hot$$"); }
m_b$$Startup$()43   void m_b$$Startup$() { System.out.println("Don't dedupe me! A::m_b$$Startup$"); }
m_b$Hot$Startup$()44   void m_b$Hot$Startup$() { System.out.println("Don't dedupe me! A::m_b$Hot$Startup$"); }
m_b$$$Poststartup()45   void m_b$$$Poststartup() { System.out.println("Don't dedupe me! A::m_b$$$Poststartup"); }
m_b$Hot$$Poststartup()46   void m_b$Hot$$Poststartup() { System.out.println("Don't dedupe me! A::m_b$Hot$$Poststartup"); }
m_b$$Startup$Poststartup()47   void m_b$$Startup$Poststartup() { System.out.println("Don't dedupe me! A::m_b$$Startup$Poststartup"); }
m_b$Hot$Startup$Poststartup()48   void m_b$Hot$Startup$Poststartup() { System.out.println("Don't dedupe me! A::m_b$Hot$Startup$Poststartup"); }
m_c$$$()49   void m_c$$$() { System.out.println("Don't dedupe me! A::m_c$$$"); }
m_c$Hot$$()50   void m_c$Hot$$() { System.out.println("Don't dedupe me! A::m_c$Hot$$"); }
m_c$$Startup$()51   void m_c$$Startup$() { System.out.println("Don't dedupe me! A::m_c$$Startup$"); }
m_c$Hot$Startup$()52   void m_c$Hot$Startup$() { System.out.println("Don't dedupe me! A::m_c$Hot$Startup$"); }
m_c$$$Poststartup()53   void m_c$$$Poststartup() { System.out.println("Don't dedupe me! A::m_c$$$Poststartup"); }
m_c$Hot$$Poststartup()54   void m_c$Hot$$Poststartup() { System.out.println("Don't dedupe me! A::m_c$Hot$$Poststartup"); }
m_c$$Startup$Poststartup()55   void m_c$$Startup$Poststartup() { System.out.println("Don't dedupe me! A::m_c$$Startup$Poststartup"); }
m_c$Hot$Startup$Poststartup()56   void m_c$Hot$Startup$Poststartup() { System.out.println("Don't dedupe me! A::m_c$Hot$Startup$Poststartup"); }
57 }
58 class B {
m_a$$$()59   void m_a$$$() { System.out.println("Don't dedupe me! B::m_a$$$"); }
m_a$Hot$$()60   void m_a$Hot$$() { System.out.println("Don't dedupe me! B::m_a$Hot$$"); }
m_a$$Startup$()61   void m_a$$Startup$() { System.out.println("Don't dedupe me! B::m_a$$Startup$"); }
m_a$Hot$Startup$()62   void m_a$Hot$Startup$() { System.out.println("Don't dedupe me! B::m_a$Hot$Startup$"); }
m_a$$$Poststartup()63   void m_a$$$Poststartup() { System.out.println("Don't dedupe me! B::m_a$$$Poststartup"); }
m_a$Hot$$Poststartup()64   void m_a$Hot$$Poststartup() { System.out.println("Don't dedupe me! B::m_a$Hot$$Poststartup"); }
m_a$$Startup$Poststartup()65   void m_a$$Startup$Poststartup() { System.out.println("Don't dedupe me! B::m_a$$Startup$Poststartup"); }
m_a$Hot$Startup$Poststartup()66   void m_a$Hot$Startup$Poststartup() { System.out.println("Don't dedupe me! B::m_a$Hot$Startup$Poststartup"); }
m_b$$$()67   void m_b$$$() { System.out.println("Don't dedupe me! B::m_b$$$"); }
m_b$Hot$$()68   void m_b$Hot$$() { System.out.println("Don't dedupe me! B::m_b$Hot$$"); }
m_b$$Startup$()69   void m_b$$Startup$() { System.out.println("Don't dedupe me! B::m_b$$Startup$"); }
m_b$Hot$Startup$()70   void m_b$Hot$Startup$() { System.out.println("Don't dedupe me! B::m_b$Hot$Startup$"); }
m_b$$$Poststartup()71   void m_b$$$Poststartup() { System.out.println("Don't dedupe me! B::m_b$$$Poststartup"); }
m_b$Hot$$Poststartup()72   void m_b$Hot$$Poststartup() { System.out.println("Don't dedupe me! B::m_b$Hot$$Poststartup"); }
m_b$$Startup$Poststartup()73   void m_b$$Startup$Poststartup() { System.out.println("Don't dedupe me! B::m_b$$Startup$Poststartup"); }
m_b$Hot$Startup$Poststartup()74   void m_b$Hot$Startup$Poststartup() { System.out.println("Don't dedupe me! B::m_b$Hot$Startup$Poststartup"); }
m_c$$$()75   void m_c$$$() { System.out.println("Don't dedupe me! B::m_c$$$"); }
m_c$Hot$$()76   void m_c$Hot$$() { System.out.println("Don't dedupe me! B::m_c$Hot$$"); }
m_c$$Startup$()77   void m_c$$Startup$() { System.out.println("Don't dedupe me! B::m_c$$Startup$"); }
m_c$Hot$Startup$()78   void m_c$Hot$Startup$() { System.out.println("Don't dedupe me! B::m_c$Hot$Startup$"); }
m_c$$$Poststartup()79   void m_c$$$Poststartup() { System.out.println("Don't dedupe me! B::m_c$$$Poststartup"); }
m_c$Hot$$Poststartup()80   void m_c$Hot$$Poststartup() { System.out.println("Don't dedupe me! B::m_c$Hot$$Poststartup"); }
m_c$$Startup$Poststartup()81   void m_c$$Startup$Poststartup() { System.out.println("Don't dedupe me! B::m_c$$Startup$Poststartup"); }
m_c$Hot$Startup$Poststartup()82   void m_c$Hot$Startup$Poststartup() { System.out.println("Don't dedupe me! B::m_c$Hot$Startup$Poststartup"); }
83 }
84 class C {
m_a$$$()85   void m_a$$$() { System.out.println("Don't dedupe me! C::m_a$$$"); }
m_a$Hot$$()86   void m_a$Hot$$() { System.out.println("Don't dedupe me! C::m_a$Hot$$"); }
m_a$$Startup$()87   void m_a$$Startup$() { System.out.println("Don't dedupe me! C::m_a$$Startup$"); }
m_a$Hot$Startup$()88   void m_a$Hot$Startup$() { System.out.println("Don't dedupe me! C::m_a$Hot$Startup$"); }
m_a$$$Poststartup()89   void m_a$$$Poststartup() { System.out.println("Don't dedupe me! C::m_a$$$Poststartup"); }
m_a$Hot$$Poststartup()90   void m_a$Hot$$Poststartup() { System.out.println("Don't dedupe me! C::m_a$Hot$$Poststartup"); }
m_a$$Startup$Poststartup()91   void m_a$$Startup$Poststartup() { System.out.println("Don't dedupe me! C::m_a$$Startup$Poststartup"); }
m_a$Hot$Startup$Poststartup()92   void m_a$Hot$Startup$Poststartup() { System.out.println("Don't dedupe me! C::m_a$Hot$Startup$Poststartup"); }
m_b$$$()93   void m_b$$$() { System.out.println("Don't dedupe me! C::m_b$$$"); }
m_b$Hot$$()94   void m_b$Hot$$() { System.out.println("Don't dedupe me! C::m_b$Hot$$"); }
m_b$$Startup$()95   void m_b$$Startup$() { System.out.println("Don't dedupe me! C::m_b$$Startup$"); }
m_b$Hot$Startup$()96   void m_b$Hot$Startup$() { System.out.println("Don't dedupe me! C::m_b$Hot$Startup$"); }
m_b$$$Poststartup()97   void m_b$$$Poststartup() { System.out.println("Don't dedupe me! C::m_b$$$Poststartup"); }
m_b$Hot$$Poststartup()98   void m_b$Hot$$Poststartup() { System.out.println("Don't dedupe me! C::m_b$Hot$$Poststartup"); }
m_b$$Startup$Poststartup()99   void m_b$$Startup$Poststartup() { System.out.println("Don't dedupe me! C::m_b$$Startup$Poststartup"); }
m_b$Hot$Startup$Poststartup()100   void m_b$Hot$Startup$Poststartup() { System.out.println("Don't dedupe me! C::m_b$Hot$Startup$Poststartup"); }
m_c$$$()101   void m_c$$$() { System.out.println("Don't dedupe me! C::m_c$$$"); }
m_c$Hot$$()102   void m_c$Hot$$() { System.out.println("Don't dedupe me! C::m_c$Hot$$"); }
m_c$$Startup$()103   void m_c$$Startup$() { System.out.println("Don't dedupe me! C::m_c$$Startup$"); }
m_c$Hot$Startup$()104   void m_c$Hot$Startup$() { System.out.println("Don't dedupe me! C::m_c$Hot$Startup$"); }
m_c$$$Poststartup()105   void m_c$$$Poststartup() { System.out.println("Don't dedupe me! C::m_c$$$Poststartup"); }
m_c$Hot$$Poststartup()106   void m_c$Hot$$Poststartup() { System.out.println("Don't dedupe me! C::m_c$Hot$$Poststartup"); }
m_c$$Startup$Poststartup()107   void m_c$$Startup$Poststartup() { System.out.println("Don't dedupe me! C::m_c$$Startup$Poststartup"); }
m_c$Hot$Startup$Poststartup()108   void m_c$Hot$Startup$Poststartup() { System.out.println("Don't dedupe me! C::m_c$Hot$Startup$Poststartup"); }
109 }
110