Introduce compilation / loading hooks to the PaletteHooks interface.
Test: m
Bug: 162715919
Bug: 134558686
Change-Id: Ib355daeb8fb7ea06798e1374322a5c5d8e038c85
diff --git a/libartpalette/include/palette/palette_hooks.h b/libartpalette/include/palette/palette_hooks.h
index 2f5e3bd..14e7b3f 100644
--- a/libartpalette/include/palette/palette_hooks.h
+++ b/libartpalette/include/palette/palette_hooks.h
@@ -25,15 +25,37 @@
// Functions provided by the Palette Hooks object, called by ART.
typedef struct paletteHooksInterface_ {
- // TODO: add functions. Currently only one field to ensure the struct has a
- // size.
- void* empty;
+ // Notify the Hooks object that dex2oat is starting compilation of the given
+ // `source_fd` dex/apk/zip file, and will generate .art/.oat/.vdex files with
+ // the given file descriptors.
+ void (*NotifyStartDex2oatCompilation)(int source_fd, int art_fd, int oat_fd, int vdex_fd);
+
+ // Notify the Hooks object that dex2oat has ended compilation of the given
+ // `source_fd` dex/apk/zip file, and has written the contents into the given file descriptors.
+ void (*NotifyEndDex2oatCompilation)(int source_fd, int art_fd, int oat_fd, int vdex_fd);
+
+ // Notify the Hooks object that the runtime is loading a dex file.
+ void (*NotifyDexFileLoaded)(const char* path);
+
+ // Notify the Hooks object that the runtime is loading a .oat file.
+ void (*NotifyOatFileLoaded)(const char* path);
} paletteHooksInterface;
struct PaletteHooks {
const struct paletteHooksInterface_* functions;
#ifdef __cplusplus
- // TODO: Add member functions.
+ void NotifyStartDex2oatCompilation(int source_fd, int art_fd, int oat_fd, int vdex_fd) {
+ return functions->NotifyStartDex2oatCompilation(source_fd, art_fd, oat_fd, vdex_fd);
+ }
+ void NotifyEndDex2oatCompilation(int source_fd, int art_fd, int oat_fd, int vdex_fd) {
+ return functions->NotifyEndDex2oatCompilation(source_fd, art_fd, oat_fd, vdex_fd);
+ }
+ void NotifyDexFileLoaded(const char* path) {
+ return functions->NotifyDexFileLoaded(path);
+ }
+ void NotifyOatFileLoaded(const char* path) {
+ return functions->NotifyOatFileLoaded(path);
+ }
#endif
};