@@ -13137,6 +13137,20 @@ add_profile_method (MonoAotCompile *acfg, MonoMethod *m)
1313713137 add_extra_method (acfg , m );
1313813138}
1313913139
13140+ //---------------------------------------------------------------------------------------
13141+ //
13142+ // add_single_profile_method filters MonoMethods to be added for AOT compilation.
13143+ // The filter logic is extracted from add_profile_instances and comments are retained
13144+ // from there.
13145+ //
13146+ // Arguments:
13147+ // * acfg - MonoAotCompiler instance
13148+ // * method - MonoMethod to attempt to add for AOT compilation
13149+ //
13150+ // Return Value:
13151+ // int pertaining whether or not the method was added to be AOT'd
13152+ //
13153+
1314013154static int
1314113155add_single_profile_method (MonoAotCompile * acfg , MonoMethod * method )
1314213156{
@@ -13212,6 +13226,38 @@ typedef enum {
1321213226 FIND_METHOD_TYPE_ENTRY_END ,
1321313227} MibcGroupMethodEntryState ;
1321413228
13229+ //---------------------------------------------------------------------------------------
13230+ //
13231+ // add_mibc_group_method_methods iterates over a mibcGroupMethod MonoMethod to obtain
13232+ // each method/type entry in that group. Each entry begins with LDTOKEN opcode, followed
13233+ // by a series of instructions including another LDTOKEN opcode but excluding a POP opcode
13234+ // ending with a POP opcode to denote the end of the entry. To iterate over entries,
13235+ // a MibcGroupMethodEntryState state is tracked, identifying whether we are looking for
13236+ // an entry starting LDTOKEN opcode or entry ending POP opcode. Each LDTOKEN opcode's
13237+ // argument denotes a methodref or methodspec. Before ultimately adding the entry's method
13238+ // for AOT compilation, checks for the method's class and image are used to skip methods
13239+ // whose class and images cannot be resolved.
13240+ //
13241+ // Sample mibcGroupMethod format
13242+ //
13243+ // Method 'Assemblies_HelloWorld;_1' (#11b) (0x06000001)
13244+ // {
13245+ // IL_0000: ldtoken 0x0A0002B5 // Method/Type Entry token
13246+ // IL_0005: pop
13247+ // }
13248+ //
13249+ // Arguments:
13250+ // * acfg - MonoAotCompiler instance
13251+ // * mibcGroupMethod - MonoMethod representing the group of assemblies that
13252+ // describes each Method/Type entry with the .mibc file
13253+ // * image - MonoImage representing the .mibc file
13254+ // * mibcModuleClass - MonoClass containing the AssemblyDictionary
13255+ // * context - MonoGenericContext of the AssemblyDictionary MonoMethod
13256+ //
13257+ // Return Value:
13258+ // int pertaining to the number of methods added within the mibcGroupMethod
13259+ //
13260+
1321513261static int
1321613262add_mibc_group_method_methods (MonoAotCompile * acfg , MonoMethod * mibcGroupMethod , MonoImage * image , MonoClass * mibcModuleClass , MonoGenericContext * context )
1321713263{
@@ -13257,6 +13303,30 @@ add_mibc_group_method_methods (MonoAotCompile *acfg, MonoMethod *mibcGroupMethod
1325713303 return count ;
1325813304}
1325913305
13306+ //---------------------------------------------------------------------------------------
13307+ //
13308+ // add_mibc_profile_methods is the overarching method that adds methods within a .mibc
13309+ // profile file to be compiled ahead of time. .mibc is a portable executable with
13310+ // methods grouped under mibcGroupMethods, which are summarized within the global
13311+ // function AssemblyDictionary. This method obtains the AssemblyDictionary and iterates
13312+ // over il opcodes and arguments to retrieve mibcGroupMethods and thereafter calls
13313+ // add_mibc_group_method_methods.
13314+ //
13315+ // Sample AssemblyDictionary format
13316+ //
13317+ // Method 'AssemblyDictionary' (#2f67) (0x06000006)
13318+ // {
13319+ // IL_0000: ldstr 0x70000001
13320+ // IL_0005: ldtoken 0x06000001 // mibcGroupMethod
13321+ // IL_000a: pop
13322+ // ...
13323+ // }
13324+ //
13325+ // Arguments:
13326+ // * acfg - MonoAotCompiler instance
13327+ // * filename - the .mibc profile file containing the methods to AOT compile
13328+ //
13329+
1326013330static void
1326113331add_mibc_profile_methods (MonoAotCompile * acfg , char * filename )
1326213332{
0 commit comments