| Index: third_party/WebKit/Source/build/scripts/templates/MakeNames.cpp.tmpl
|
| diff --git a/third_party/WebKit/Source/build/scripts/templates/MakeNames.cpp.tmpl b/third_party/WebKit/Source/build/scripts/templates/MakeNames.cpp.tmpl
|
| index ed0c03160f41f7ef42c01dc3f783c5c1a13ca419..2889987e7c57729a48b468e122b132a98c7dd274 100644
|
| --- a/third_party/WebKit/Source/build/scripts/templates/MakeNames.cpp.tmpl
|
| +++ b/third_party/WebKit/Source/build/scripts/templates/MakeNames.cpp.tmpl
|
| @@ -27,20 +27,25 @@ const AtomicString& {{entry|symbol}} = reinterpret_cast<AtomicString*>(&{{suffix
|
|
|
| void init{{suffix}}()
|
| {
|
| + const int kMaxNameLength = {{entries|map(attribute='name')|map('length')|max}} + 1;
|
| struct NameEntry {
|
| - const char* name;
|
| + // StringImpl instances are created at |stringImplStorage| in-place.
|
| + // |name| must be placed soon after |stringImplStorage| to match the memory layout requirement of StringImpl.
|
| + char stringImplStorage[sizeof(StringImpl)];
|
| + char name[kMaxNameLength];
|
| unsigned hash;
|
| unsigned char length;
|
| };
|
|
|
| - static const NameEntry kNames[] = {
|
| + static NameEntry kNames[] = {
|
| {% for entry in entries|sort(attribute='name', case_sensitive=True) %}
|
| - { "{{entry|cpp_name}}", {{entry|cpp_name|hash}}, {{entry|cpp_name|length}} },
|
| + { "", "{{entry|cpp_name}}", {{entry|cpp_name|hash}}, {{entry|cpp_name|length}} },
|
| {% endfor %}
|
| };
|
|
|
| for (size_t i = 0; i < WTF_ARRAY_LENGTH(kNames); i++) {
|
| - StringImpl* stringImpl = StringImpl::createStatic(kNames[i].name, kNames[i].length, kNames[i].hash);
|
| + StringImpl* stringImpl = StringImpl::createPreallocatedStatic(kNames[i].stringImplStorage, kNames[i].length, kNames[i].hash);
|
| + ASSERT(reinterpret_cast<char*>(stringImpl + 1) == kNames[i].name);
|
| void* address = reinterpret_cast<AtomicString*>(&{{suffix}}NamesStorage) + i;
|
| new (address) AtomicString(stringImpl);
|
| }
|
|
|