Add a way to change the IMT size
Useful for having smaller imts on memory constrainted devices.
Setting ART_IMT_SIZE=x will change the size of the IMT.
(cherry picked from commit 8ee96437f8cd24e1eb0b2adc6cef3346ed4b6a98)
Change-Id: Ia74946ffc57ad32de5a8d60be3412462f19f8076
diff --git a/build/Android.common_build.mk b/build/Android.common_build.mk
index 7d34dae..c6e2b95 100644
--- a/build/Android.common_build.mk
+++ b/build/Android.common_build.mk
@@ -220,6 +220,14 @@
# -Wmissing-declarations \
+
+ifdef ART_IMT_SIZE
+ art_cflags += -DIMT_SIZE=$(ART_IMT_SIZE)
+else
+ # Default is 64
+ art_cflags += -DIMT_SIZE=64
+endif
+
ifeq ($(ART_SMALL_MODE),true)
art_cflags += -DART_SMALL_MODE=1
endif
diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h
index a77972e..56867dd 100644
--- a/runtime/mirror/class.h
+++ b/runtime/mirror/class.h
@@ -29,6 +29,10 @@
#include "read_barrier_option.h"
#include "utils.h"
+#ifndef IMT_SIZE
+#error IMT_SIZE not defined
+#endif
+
namespace art {
struct ClassOffsets;
@@ -58,7 +62,7 @@
// Interface method table size. Increasing this value reduces the chance of two interface methods
// colliding in the interface method table but increases the size of classes that implement
// (non-marker) interfaces.
- static constexpr size_t kImtSize = 64;
+ static constexpr size_t kImtSize = IMT_SIZE;
// imtable entry embedded in class object.
struct MANAGED ImTableEntry {