Rename StaticType's kInstance to instance.

This is more than just a noop: when ANGLE is rolled in Chromium it is
tested by the Android Binary Size trybot. This trybot runs an analysis
pass that checks that any new variable names "kSomthing" is in .rodata
or .data.rel.ro because it helps keep the binary size (and the size of
each new Chromium process) small on Android.

The analysis picks up new usages of StaticType::Helpers::kInstance as a
new constant varaible that isn't in .data.rel.ro or .rodata. My
understanding is that kInstances isn't put in those segments because it
contains a TType that has a "mutable" field so it would be incorrect to
put the variable in a read-only segment.

BUG=chromium:981610

Change-Id: I36e550e066206df3404619f1d012b183cbb72fe4
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1698202
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
This commit is contained in:
Corentin Wallez 2019-07-11 14:56:47 +02:00 коммит произвёл Commit Bot
Родитель 1d672749e7
Коммит 60e2f11eb5
1 изменённых файлов: 8 добавлений и 4 удалений

Просмотреть файл

@ -53,7 +53,7 @@ constexpr StaticMangledName BuildStaticMangledName(TBasicType basicType,
// This "variable" contains the mangled names for every constexpr-generated TType.
// If kMangledNameInstance<B, P, Q, PS, SS> is used anywhere (specifally
// in kInstance, below), this is where the appropriate type will be stored.
// in instance, below), this is where the appropriate type will be stored.
template <TBasicType basicType,
TPrecision precision,
TQualifier qualifier,
@ -67,14 +67,18 @@ static constexpr StaticMangledName kMangledNameInstance =
//
// This "variable" contains every constexpr-generated TType.
// If kInstance<B, P, Q, PS, SS> is used anywhere (specifally
// If instance<B, P, Q, PS, SS> is used anywhere (specifally
// in Get, below), this is where the appropriate type will be stored.
//
// TODO(crbug.com/981610): This is constexpr but doesn't follow the kConstant naming convention
// because TType has a mutable member that prevents it from being in .data.rel.ro and makes the
// Android Binary Size builder complain when ANGLE is rolled in Chromium.
template <TBasicType basicType,
TPrecision precision,
TQualifier qualifier,
unsigned char primarySize,
unsigned char secondarySize>
static constexpr TType kInstance =
static constexpr TType instance =
TType(basicType,
precision,
qualifier,
@ -97,7 +101,7 @@ constexpr const TType *Get()
{
static_assert(1 <= primarySize && primarySize <= 4, "primarySize out of bounds");
static_assert(1 <= secondarySize && secondarySize <= 4, "secondarySize out of bounds");
return &Helpers::kInstance<basicType, precision, qualifier, primarySize, secondarySize>;
return &Helpers::instance<basicType, precision, qualifier, primarySize, secondarySize>;
}
//