Update java.lang.String class size.
In standalone desugar, one of the implemented interface CharSequence has
two lambdas:
lambda$chars$0$CharSequence
lambda$codePoints$1$CharSequence
which are virtual functions.
In D8 Desugar, both of them are now direct methods.
Bug: 69477285
Test: USE_D8_DESUGAR=true m && USE_D8_DESUGAR=false m
Change-Id: I94aaa42e86bd104fc86fa14d1eb45b2e906da5a9
diff --git a/build/art.go b/build/art.go
index 3f598da..58df11c 100644
--- a/build/art.go
+++ b/build/art.go
@@ -103,6 +103,10 @@
asflags = append(asflags, "-DART_MIPS32_CHECK_ALIGNMENT")
}
+ if envTrue(ctx, "USE_D8_DESUGAR") {
+ cflags = append(cflags, "-DUSE_D8_DESUGAR=1")
+ }
+
return cflags, asflags
}
diff --git a/runtime/mirror/string-inl.h b/runtime/mirror/string-inl.h
index 84587c8..24c75ec 100644
--- a/runtime/mirror/string-inl.h
+++ b/runtime/mirror/string-inl.h
@@ -35,7 +35,16 @@
namespace mirror {
inline uint32_t String::ClassSize(PointerSize pointer_size) {
+#ifdef USE_D8_DESUGAR
+ // Two lambdas in CharSequence:
+ // lambda$chars$0$CharSequence
+ // lambda$codePoints$1$CharSequence
+ // which were virtual functions in standalone desugar, becomes
+ // direct functions with D8 desugaring.
+ uint32_t vtable_entries = Object::kVTableLength + 54;
+#else
uint32_t vtable_entries = Object::kVTableLength + 56;
+#endif
return Class::ComputeClassSize(true, vtable_entries, 0, 0, 0, 1, 2, pointer_size);
}