| Index: third_party/WebKit/Source/build/scripts/templates/MakeQualifiedNames.cpp.tmpl
|
| diff --git a/third_party/WebKit/Source/build/scripts/templates/MakeQualifiedNames.cpp.tmpl b/third_party/WebKit/Source/build/scripts/templates/MakeQualifiedNames.cpp.tmpl
|
| index 3e32ccde735dcad12ba3ae1893d807df39c066b1..e38706409a910f2cc687c90c60da0f4040cecdc8 100644
|
| --- a/third_party/WebKit/Source/build/scripts/templates/MakeQualifiedNames.cpp.tmpl
|
| +++ b/third_party/WebKit/Source/build/scripts/templates/MakeQualifiedNames.cpp.tmpl
|
| @@ -54,14 +54,6 @@ PassOwnPtr<const QualifiedName*[]> get{{namespace}}Attrs()
|
|
|
| void init()
|
| {
|
| - struct NameEntry {
|
| - const char* name;
|
| - unsigned hash;
|
| - unsigned char length;
|
| - unsigned char isTag;
|
| - unsigned char isAttr;
|
| - };
|
| -
|
| // Use placement new to initialize the globals.
|
| AtomicString {{namespace_prefix}}NS("{{namespace_uri}}", AtomicString::ConstructFromLiteral);
|
|
|
| @@ -69,9 +61,21 @@ void init()
|
| new ((void*)&{{namespace_prefix}}NamespaceURI) AtomicString({{namespace_prefix}}NS);
|
| {% set tagnames = tags|map(attribute='name')|list() %}
|
| {% set attrnames = attrs|map(attribute='name')|list() %}
|
| - static const NameEntry kNames[] = {
|
| + const int kMaxNameLength = {{(tagnames + attrnames)|map('length')|max}} + 1;
|
| + struct NameEntry {
|
| + // 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;
|
| + unsigned char isTag;
|
| + unsigned char isAttr;
|
| + };
|
| +
|
| + static NameEntry kNames[] = {
|
| {% for name, tag_list in (tags + attrs)|groupby('name')|sort(attribute=0, case_sensitive=True) %}
|
| - { "{{name}}", {{name|hash}}, {{name|length}}, {{ (name in tagnames)|int }}, {{ (name in attrnames)|int }} },
|
| + { "", "{{name}}", {{name|hash}}, {{name|length}}, {{ (name in tagnames)|int }}, {{ (name in attrnames)|int }} },
|
| {% endfor %}
|
| };
|
|
|
| @@ -80,7 +84,7 @@ void init()
|
| {% endif %}
|
| size_t attr_i = 0;
|
| 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);
|
| {% if tags %}
|
| if (kNames[i].isTag) {
|
| void* address = reinterpret_cast<{{namespace}}QualifiedName*>(&{{suffix}}TagStorage) + tag_i;
|
|
|