Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: third_party/WebKit/Source/build/scripts/templates/MakeNames.cpp.tmpl

Issue 1405573003: Introduce StringImpl::createPreallocatedStatic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 {% from "macros.tmpl" import license %} 1 {% from "macros.tmpl" import license %}
2 {{ license() }} 2 {{ license() }}
3 3
4 #include "config.h" 4 #include "config.h"
5 5
6 #include "{{namespace}}{{suffix}}Names.h" 6 #include "{{namespace}}{{suffix}}Names.h"
7 7
8 #include "wtf/StdLibExtras.h" 8 #include "wtf/StdLibExtras.h"
9 9
10 // Generated from: 10 // Generated from:
11 {% for entry in in_files|sort %} 11 {% for entry in in_files|sort %}
12 // - {{entry}} 12 // - {{entry}}
13 {% endfor %} 13 {% endfor %}
14 14
15 namespace blink { 15 namespace blink {
16 namespace {{namespace}}Names { 16 namespace {{namespace}}Names {
17 17
18 using namespace WTF; 18 using namespace WTF;
19 19
20 void* {{suffix}}NamesStorage[{{namespace}}{{suffix}}NamesCount * ((sizeof(Atomic String) + sizeof(void *) - 1) / sizeof(void *))]; 20 void* {{suffix}}NamesStorage[{{namespace}}{{suffix}}NamesCount * ((sizeof(Atomic String) + sizeof(void *) - 1) / sizeof(void *))];
21 21
22 {% for entry in entries|sort(attribute='name', case_sensitive=True) %} 22 {% for entry in entries|sort(attribute='name', case_sensitive=True) %}
23 {% filter enable_conditional(entry.Conditional) %} 23 {% filter enable_conditional(entry.Conditional) %}
24 const AtomicString& {{entry|symbol}} = reinterpret_cast<AtomicString*>(&{{suffix }}NamesStorage)[{{loop.index0}}]; 24 const AtomicString& {{entry|symbol}} = reinterpret_cast<AtomicString*>(&{{suffix }}NamesStorage)[{{loop.index0}}];
25 {% endfilter %} 25 {% endfilter %}
26 {% endfor %} 26 {% endfor %}
27 27
28 void init{{suffix}}() 28 void init{{suffix}}()
29 { 29 {
30 const int kMaxNameLength = {{entries|map(attribute='name')|map('length')|max }} + 1;
30 struct NameEntry { 31 struct NameEntry {
31 const char* name; 32 char string_impl_storage[sizeof(StringImpl)];
tkent 2015/10/21 03:19:33 * Need a comment that the layout should be matched
Daniel Bratell 2015/10/21 09:51:25 This looks like it could make the Names array rath
tzik 2015/10/28 14:33:31 Done.
tzik 2015/10/28 14:33:31 |name| needs to be an array instead of char* to ma
33 char name[kMaxNameLength];
32 unsigned hash; 34 unsigned hash;
33 unsigned char length; 35 unsigned char length;
34 }; 36 };
35 37
36 static const NameEntry kNames[] = { 38 static NameEntry Names[] = {
tkent 2015/10/21 03:19:33 You don't need to rename kNames to Names, which do
tzik 2015/10/28 14:33:31 Done.
37 {% for entry in entries|sort(attribute='name', case_sensitive=True) %} 39 {% for entry in entries|sort(attribute='name', case_sensitive=True) %}
38 { "{{entry|cpp_name}}", {{entry|cpp_name|hash}}, {{entry|cpp_name|length }} }, 40 { "", "{{entry|cpp_name}}", {{entry|cpp_name|hash}}, {{entry|cpp_name|le ngth}} },
39 {% endfor %} 41 {% endfor %}
40 }; 42 };
41 43
42 for (size_t i = 0; i < WTF_ARRAY_LENGTH(kNames); i++) { 44 for (size_t i = 0; i < WTF_ARRAY_LENGTH(Names); i++) {
43 StringImpl* stringImpl = StringImpl::createStatic(kNames[i].name, kNames [i].length, kNames[i].hash); 45 StringImpl* stringImpl = StringImpl::createPreallocatedStatic(Names[i].s tring_impl_storage, Names[i].length, Names[i].hash);
44 void* address = reinterpret_cast<AtomicString*>(&{{suffix}}NamesStorage) + i; 46 void* address = reinterpret_cast<AtomicString*>(&{{suffix}}NamesStorage) + i;
45 new (address) AtomicString(stringImpl); 47 new (address) AtomicString(stringImpl);
46 } 48 }
47 } 49 }
48 50
49 } // {{namespace}}Names 51 } // {{namespace}}Names
50 } // namespace blink 52 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698