1# Bytecode profiling in Dynamic languages 2 3## Support in ISA 4 5Each bytecode instruction, that supports profiling, contains additional field - profile index. It denotes index of 6a corresponding profile data in the profile vector. 7 8Currently, it has 2 bytes size, but we can reduce it for small methods, where size of a profiling vector will be less 9than 256 bytes. 10 11## Support in Runtime 12 13For each method, that contains instructions with profiling data, Runtime should allocate profiling vector. 14 15Profiling vector is a plain data of bytes, which content is determined by the language of a given bytecode. Core part 16of Runtime knows nothing about how to interpret the profiling vector. 17 18Profile elements are sorted in descending order, from largest Profiles to smallest. It avoids alignment issues. 19 20Each interpreter handler reads profiling field from bytecode instruction and update corresponding slot in profiling 21vector. 22 23## Support in AOT compilation 24 25Profile information, gathered during run, can be saved into special profile file, that can be specified by option 26`--profile-ouptut`. After VM execution is finished, all profile information will be saved into this file. 27 28Format of a profile file is determined by the language plugin. 29 30AOT compiler accesses this file via runtime interface. CoreVM doesn't implement profiling interface, it must be 31implemented by all language plugins, that supports profiling. 32