WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch for landing
bug-112831-20130320142743.patch (text/plain), 25.38 KB, created by
Adam Barth
on 2013-03-20 14:31:54 PDT
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Adam Barth
Created:
2013-03-20 14:31:54 PDT
Size:
25.38 KB
patch
obsolete
>Subversion Revision: 146365 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index 2203ff825bfb45b70ff324c767e86518efef2310..0f346f196d4f6e3d6d894d006165f3a545fa2d37 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,17 @@ >+2013-03-20 Adam Barth <abarth@webkit.org> >+ >+ HTMLNames should construct strings at compile time >+ https://bugs.webkit.org/show_bug.cgi?id=112831 >+ >+ Reviewed by Darin Adler. >+ >+ * wtf/text/StringImpl.h: >+ (StringImpl): >+ (StaticASCIILiteral): >+ - This struct lets us construct StringImpl objects at compile time. >+ (WTF::StringImpl::assertValidHash): >+ - This function lets us sanity check StringImpl objects created from StaticData. >+ > 2013-03-20 JungJik Lee <jungjik.lee@samsung.com> > > [EFL] Disable REQUEST_ANIMATION_FRAME_TIMER to render a new animation frame. >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 2da15ed2dfdfd9ecdccf957638e2eaafe9074b00..04c55a7b2f4849202067337f22f6a5702e7c32e6 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,32 @@ >+2013-03-20 Adam Barth <abarth@webkit.org> >+ >+ HTMLNames should construct strings at compile time >+ https://bugs.webkit.org/show_bug.cgi?id=112831 >+ >+ Reviewed by Darin Adler. >+ >+ This patch teaches make_names how to construct strings at compile time, >+ eliminating a large number of startup mallocs. >+ >+ * WebCore.gyp/WebCore.gyp: >+ * WebCore.gyp/scripts/action_makenames.py: >+ - Teach the Chromium build how to deal with Perl modules. >+ * bindings/scripts/StaticString.pm: Added. >+ - A Perl module for constructing static strings. >+ (GenerateStrings): >+ (GenerateValidateStrings): >+ * dom/QualifiedName.cpp: >+ (WebCore::createQualifiedName): >+ - createQualifiedName now takes an already-constructed StringImpl >+ object. >+ * dom/QualifiedName.h: >+ * dom/make_names.pl: >+ (valueForName): >+ (namesToStrings): >+ (printNamesCppFile): >+ (printDefinitions): >+ - Teach make_names how to use StaticString.pm. >+ > 2013-03-20 Michael Pruett <michael@68k.org> > > [V8] Simplify implementation of EnforceRange conversions >diff --git a/Source/WTF/wtf/text/StringImpl.h b/Source/WTF/wtf/text/StringImpl.h >index f1eb67178b25cd9d81d1f220ed382cf63ba99193..333a55ae95ede74013fec38cb6c70c8245c170f0 100644 >--- a/Source/WTF/wtf/text/StringImpl.h >+++ b/Source/WTF/wtf/text/StringImpl.h >@@ -772,6 +772,32 @@ private: > #ifdef STRING_STATS > WTF_EXPORTDATA static StringStats m_stringStats; > #endif >+ >+public: >+ struct StaticASCIILiteral { >+ // These member variables must match the layout of StringImpl. >+ unsigned m_refCount; >+ unsigned m_length; >+ const LChar* m_data8; >+ void* m_buffer; >+ unsigned m_hashAndFlags; >+ >+ // These values mimic ConstructFromLiteral. >+ static const unsigned s_initialRefCount = s_refCountIncrement; >+ static const unsigned s_initialFlags = s_hashFlag8BitBuffer | BufferInternal | s_hashFlagHasTerminatingNullCharacter; >+ static const unsigned s_hashShift = s_flagCount; >+ }; >+ >+#ifndef NDEBUG >+ void assertHashIsCorrect() >+ { >+ ASSERT(hasHash()); >+ ASSERT(existingHash() == StringHasher::computeHashAndMaskTop8Bits(characters8(), length())); >+ } >+#endif >+ >+private: >+ // These member variables must match the layout of StaticASCIILiteral. > unsigned m_refCount; > unsigned m_length; > union { >@@ -789,6 +815,8 @@ private: > mutable unsigned m_hashAndFlags; > }; > >+COMPILE_ASSERT(sizeof(StringImpl) == sizeof(StringImpl::StaticASCIILiteral), StringImpl_should_match_its_StaticASCIILiteral); >+ > template <> > ALWAYS_INLINE const LChar* StringImpl::getCharacters<LChar>() const { return characters8(); } > >diff --git a/Source/WebCore/DerivedSources.make b/Source/WebCore/DerivedSources.make >index 759b4f08df20e50487f85d72642f23acbe14b29b..0e1de73fb11cc2eec0017ec225d1e9cac5e27c74 100644 >--- a/Source/WebCore/DerivedSources.make >+++ b/Source/WebCore/DerivedSources.make >@@ -826,7 +826,7 @@ UserAgentStyleSheets.h : css/make-css-file-arrays.pl bindings/scripts/preprocess > > # -------- > >-WebKitFontFamilyNames.cpp WebKitFontFamilyNames.h : dom/make_names.pl css/WebKitFontFamilyNames.in >+WebKitFontFamilyNames.cpp WebKitFontFamilyNames.h : bindings/scripts/Hasher.pm bindings/scripts/StaticString.pm dom/make_names.pl css/WebKitFontFamilyNames.in > perl -I $(WebCore)/bindings/scripts $< --fonts $(WebCore)/css/WebKitFontFamilyNames.in > > # HTML tag and attribute names >@@ -873,22 +873,22 @@ endif > > ifdef HTML_FLAGS > >-HTMLElementFactory.cpp HTMLNames.cpp : dom/make_names.pl html/HTMLTagNames.in html/HTMLAttributeNames.in >+HTMLElementFactory.cpp HTMLNames.cpp : bindings/scripts/Hasher.pm bindings/scripts/StaticString.pm dom/make_names.pl html/HTMLTagNames.in html/HTMLAttributeNames.in > perl -I $(WebCore)/bindings/scripts $< --tags $(WebCore)/html/HTMLTagNames.in --attrs $(WebCore)/html/HTMLAttributeNames.in --factory --wrapperFactory --extraDefines "$(HTML_FLAGS)" > > else > >-HTMLElementFactory.cpp HTMLNames.cpp : dom/make_names.pl html/HTMLTagNames.in html/HTMLAttributeNames.in >+HTMLElementFactory.cpp HTMLNames.cpp : bindings/scripts/Hasher.pm bindings/scripts/StaticString.pm dom/make_names.pl html/HTMLTagNames.in html/HTMLAttributeNames.in > perl -I $(WebCore)/bindings/scripts $< --tags $(WebCore)/html/HTMLTagNames.in --attrs $(WebCore)/html/HTMLAttributeNames.in --factory --wrapperFactory > > endif > > JSHTMLElementWrapperFactory.cpp : HTMLNames.cpp > >-XMLNSNames.cpp : dom/make_names.pl xml/xmlnsattrs.in >+XMLNSNames.cpp : bindings/scripts/Hasher.pm bindings/scripts/StaticString.pm dom/make_names.pl xml/xmlnsattrs.in > perl -I $(WebCore)/bindings/scripts $< --attrs $(WebCore)/xml/xmlnsattrs.in > >-XMLNames.cpp : dom/make_names.pl xml/xmlattrs.in >+XMLNames.cpp : bindings/scripts/Hasher.pm bindings/scripts/StaticString.pm dom/make_names.pl xml/xmlattrs.in > perl -I $(WebCore)/bindings/scripts $< --attrs $(WebCore)/xml/xmlattrs.in > > # -------- >@@ -907,18 +907,18 @@ endif > > ifdef SVG_FLAGS > >-SVGElementFactory.cpp SVGNames.cpp : dom/make_names.pl svg/svgtags.in svg/svgattrs.in >+SVGElementFactory.cpp SVGNames.cpp : bindings/scripts/Hasher.pm bindings/scripts/StaticString.pm dom/make_names.pl svg/svgtags.in svg/svgattrs.in > perl -I $(WebCore)/bindings/scripts $< --tags $(WebCore)/svg/svgtags.in --attrs $(WebCore)/svg/svgattrs.in --extraDefines "$(SVG_FLAGS)" --factory --wrapperFactory > else > >-SVGElementFactory.cpp SVGNames.cpp : dom/make_names.pl svg/svgtags.in svg/svgattrs.in >+SVGElementFactory.cpp SVGNames.cpp : bindings/scripts/Hasher.pm bindings/scripts/StaticString.pm dom/make_names.pl svg/svgtags.in svg/svgattrs.in > perl -I $(WebCore)/bindings/scripts $< --tags $(WebCore)/svg/svgtags.in --attrs $(WebCore)/svg/svgattrs.in --factory --wrapperFactory > > endif > > JSSVGElementWrapperFactory.cpp : SVGNames.cpp > >-XLinkNames.cpp : dom/make_names.pl svg/xlinkattrs.in >+XLinkNames.cpp : bindings/scripts/Hasher.pm bindings/scripts/StaticString.pm dom/make_names.pl svg/xlinkattrs.in > perl -I $(WebCore)/bindings/scripts $< --attrs $(WebCore)/svg/xlinkattrs.in > > # -------- >@@ -938,7 +938,7 @@ ExceptionCodeDescription.cpp ExceptionCodeDescription.h ExceptionHeaders.h Excep > > # MathML tag and attribute names, and element factory > >-MathMLElementFactory.cpp MathMLNames.cpp : dom/make_names.pl mathml/mathtags.in mathml/mathattrs.in >+MathMLElementFactory.cpp MathMLNames.cpp : bindings/scripts/Hasher.pm bindings/scripts/StaticString.pm dom/make_names.pl mathml/mathtags.in mathml/mathattrs.in > perl -I $(WebCore)/bindings/scripts $< --tags $(WebCore)/mathml/mathtags.in --attrs $(WebCore)/mathml/mathattrs.in --factory --wrapperFactory > > # -------- >diff --git a/Source/WebCore/GNUmakefile.am b/Source/WebCore/GNUmakefile.am >index 0ba557d584e7a347c0840b9219080261850b75ae..6714485100083b2de123513a8d95068c752ac252 100644 >--- a/Source/WebCore/GNUmakefile.am >+++ b/Source/WebCore/GNUmakefile.am >@@ -145,7 +145,7 @@ $(GENSOURCES_WEBCORE)/XPathGrammar.cpp: $(WebCore)/xml/XPathGrammar.y > # MathML tag and attribute names, and element factory > DerivedSources/WebCore/MathMLElementFactory.h: DerivedSources/WebCore/MathMLElementFactory.cpp > DerivedSources/WebCore/MathMLNames.h: DerivedSources/WebCore/MathMLNames.cpp >-DerivedSources/WebCore/MathMLElementFactory.cpp DerivedSources/WebCore/MathMLNames.cpp: $(WebCore)/dom/make_names.pl $(WebCore)/mathml/mathtags.in $(WebCore)/mathml/mathattrs.in >+DerivedSources/WebCore/MathMLElementFactory.cpp DerivedSources/WebCore/MathMLNames.cpp: $(WebCore)/bindings/scripts/Hasher.pm $(WebCore)/bindings/scripts/StaticString.pm $(WebCore)/dom/make_names.pl $(WebCore)/mathml/mathtags.in $(WebCore)/mathml/mathattrs.in > $(AM_V_GEN)$(PERL) -I$(WebCore)/bindings/scripts $< --tags $(WebCore)/mathml/mathtags.in --attrs $(WebCore)/mathml/mathattrs.in --factory --wrapperFactory --outputDir "$(GENSOURCES_WEBCORE)" > > # ---- >@@ -190,13 +190,13 @@ endif # END_ENABLE_SVG > # SVG tag and attribute names (need to pass an extra flag if svg experimental features are enabled) > DerivedSources/WebCore/SVGNames.cpp: DerivedSources/WebCore/SVGElementFactory.cpp > DerivedSources/WebCore/JSSVGElementWrapperFactory.cpp: DerivedSources/WebCore/SVGElementFactory.cpp >-DerivedSources/WebCore/SVGElementFactory.cpp: $(WebCore)/dom/make_names.pl $(WebCore)/svg/svgtags.in $(WebCore)/svg/svgattrs.in >+DerivedSources/WebCore/SVGElementFactory.cpp: $(WebCore)/bindings/scripts/Hasher.pm $(WebCore)/bindings/scripts/StaticString.pm $(WebCore)/dom/make_names.pl $(WebCore)/svg/svgtags.in $(WebCore)/svg/svgattrs.in > $(AM_V_GEN)$(PERL) -I$(WebCore)/bindings/scripts $< --tags $(WebCore)/svg/svgtags.in --attrs $(WebCore)/svg/svgattrs.in --extraDefines "$(feature_defines)" --factory --wrapperFactory --outputDir "$(GENSOURCES_WEBCORE)" > > # end SVG Features > > DerivedSources/WebCore/XLinkNames.h: DerivedSources/WebCore/XLinkNames.cpp >-DerivedSources/WebCore/XLinkNames.cpp : $(WebCore)/dom/make_names.pl $(WebCore)/svg/xlinkattrs.in >+DerivedSources/WebCore/XLinkNames.cpp : $(WebCore)/bindings/scripts/Hasher.pm $(WebCore)/bindings/scripts/StaticString.pm $(WebCore)/dom/make_names.pl $(WebCore)/svg/xlinkattrs.in > $(AM_V_GEN)$(PERL) -I$(WebCore)/bindings/scripts $< --attrs $(WebCore)/svg/xlinkattrs.in --outputDir "$(GENSOURCES_WEBCORE)" > > if USE_TEXTURE_MAPPER_CAIRO >@@ -293,7 +293,7 @@ DerivedSources/WebCore/UserAgentStyleSheets.h: $(WebCore)/css/make-css-file-arra > $(AM_V_GEN)$(PERL) -I$(WebCore)/bindings/scripts $< --defines "$(feature_defines)" $@ DerivedSources/WebCore/UserAgentStyleSheetsData.cpp $(USER_AGENT_STYLE_SHEETS) > > DerivedSources/WebCore/WebKitFontFamilyNames.cpp: DerivedSources/WebCore/WebKitFontFamilyNames.h >-DerivedSources/WebCore/WebKitFontFamilyNames.h: $(WebCore)/dom/make_names.pl $(WebCore)/css/WebKitFontFamilyNames.in >+DerivedSources/WebCore/WebKitFontFamilyNames.h: $(WebCore)/bindings/scripts/Hasher.pm $(WebCore)/bindings/scripts/StaticString.pm $(WebCore)/dom/make_names.pl $(WebCore)/css/WebKitFontFamilyNames.in > $(AM_V_GEN)$(PERL) -I$(WebCore)/bindings/scripts $< --fonts $(WebCore)/css/WebKitFontFamilyNames.in --outputDir "$(GENSOURCES_WEBCORE)" > > >@@ -302,14 +302,14 @@ DerivedSources/WebCore/JSHTMLElementWrapperFactory.cpp: DerivedSources/WebCore/H > DerivedSources/WebCore/HTMLElementFactory.cpp: DerivedSources/WebCore/HTMLElementFactory.h > DerivedSources/WebCore/HTMLElementFactory.h: DerivedSources/WebCore/HTMLNames.cpp > DerivedSources/WebCore/HTMLNames.cpp: DerivedSources/WebCore/HTMLNames.h >-DerivedSources/WebCore/HTMLNames.h: $(WebCore)/dom/make_names.pl $(WebCore)/html/HTMLTagNames.in $(WebCore)/html/HTMLAttributeNames.in >+DerivedSources/WebCore/HTMLNames.h: $(WebCore)/bindings/scripts/Hasher.pm $(WebCore)/bindings/scripts/StaticString.pm $(WebCore)/dom/make_names.pl $(WebCore)/html/HTMLTagNames.in $(WebCore)/html/HTMLAttributeNames.in > $(AM_V_GEN)$(PERL) -I$(WebCore)/bindings/scripts $< --tags $(WebCore)/html/HTMLTagNames.in --attrs $(WebCore)/html/HTMLAttributeNames.in --extraDefines "$(feature_defines)" --factory --wrapperFactory --outputDir "$(GENSOURCES_WEBCORE)" > > >-DerivedSources/WebCore/XMLNSNames.cpp DerivedSources/WebCore/XMLNSNames.h: $(WebCore)/dom/make_names.pl $(WebCore)/xml/xmlnsattrs.in >+DerivedSources/WebCore/XMLNSNames.cpp DerivedSources/WebCore/XMLNSNames.h: $(WebCore)/bindings/scripts/Hasher.pm $(WebCore)/bindings/scripts/StaticString.pm $(WebCore)/dom/make_names.pl $(WebCore)/xml/xmlnsattrs.in > $(AM_V_GEN)$(PERL) -I$(WebCore)/bindings/scripts $< --attrs $(WebCore)/xml/xmlnsattrs.in --outputDir "$(GENSOURCES_WEBCORE)" > >-DerivedSources/WebCore/XMLNames.cpp DerivedSources/WebCore/XMLNames.h: $(WebCore)/dom/make_names.pl $(WebCore)/xml/xmlattrs.in >+DerivedSources/WebCore/XMLNames.cpp DerivedSources/WebCore/XMLNames.h: $(WebCore)/bindings/scripts/Hasher.pm $(WebCore)/bindings/scripts/StaticString.pm $(WebCore)/dom/make_names.pl $(WebCore)/xml/xmlattrs.in > $(AM_V_GEN)$(PERL) -I$(WebCore)/bindings/scripts $< --attrs $(WebCore)/xml/xmlattrs.in --outputDir "$(GENSOURCES_WEBCORE)" > > DerivedSources/WebCore/EventFactory.cpp DerivedSources/WebCore/EventHeaders.h DerivedSources/WebCore/EventInterfaces.h: $(WebCore)/dom/make_event_factory.pl $(WebCore)/dom/EventNames.in >diff --git a/Source/WebCore/WebCore.gyp/WebCore.gyp b/Source/WebCore/WebCore.gyp/WebCore.gyp >index d3e91826912e426d410476b1808422c26769bdd9..e62e633fbb57ffda3b339b53a0c133ac093a9505 100644 >--- a/Source/WebCore/WebCore.gyp/WebCore.gyp >+++ b/Source/WebCore/WebCore.gyp/WebCore.gyp >@@ -746,6 +746,8 @@ > { > 'action_name': 'HTMLNames', > 'inputs': [ >+ '../bindings/scripts/Hasher.pm', >+ '../bindings/scripts/StaticString.pm', > '../dom/make_names.pl', > '../html/HTMLTagNames.in', > '../html/HTMLAttributeNames.in', >@@ -773,6 +775,8 @@ > { > 'action_name': 'WebKitFontFamilyNames', > 'inputs': [ >+ '../bindings/scripts/Hasher.pm', >+ '../bindings/scripts/StaticString.pm', > '../dom/make_names.pl', > '../css/WebKitFontFamilyNames.in', > ], >@@ -794,6 +798,8 @@ > { > 'action_name': 'SVGNames', > 'inputs': [ >+ '../bindings/scripts/Hasher.pm', >+ '../bindings/scripts/StaticString.pm', > '../dom/make_names.pl', > '../svg/svgtags.in', > '../svg/svgattrs.in', >@@ -882,6 +888,8 @@ > { > 'action_name': 'MathMLNames', > 'inputs': [ >+ '../bindings/scripts/Hasher.pm', >+ '../bindings/scripts/StaticString.pm', > '../dom/make_names.pl', > '../mathml/mathtags.in', > '../mathml/mathattrs.in', >@@ -1016,6 +1024,8 @@ > { > 'action_name': 'XLinkNames', > 'inputs': [ >+ '../bindings/scripts/Hasher.pm', >+ '../bindings/scripts/StaticString.pm', > '../dom/make_names.pl', > '../svg/xlinkattrs.in', > ], >@@ -1037,6 +1047,8 @@ > { > 'action_name': 'XMLNSNames', > 'inputs': [ >+ '../bindings/scripts/Hasher.pm', >+ '../bindings/scripts/StaticString.pm', > '../dom/make_names.pl', > '../xml/xmlnsattrs.in', > ], >@@ -1058,6 +1070,8 @@ > { > 'action_name': 'XMLNames', > 'inputs': [ >+ '../bindings/scripts/Hasher.pm', >+ '../bindings/scripts/StaticString.pm', > '../dom/make_names.pl', > '../xml/xmlattrs.in', > ], >diff --git a/Source/WebCore/WebCore.gyp/scripts/action_makenames.py b/Source/WebCore/WebCore.gyp/scripts/action_makenames.py >index a1a410f1ea50c31542ead51bd3ae046e1c5ec193..813b8641963666e62bdf8279e0ae8afd58a1226a 100644 >--- a/Source/WebCore/WebCore.gyp/scripts/action_makenames.py >+++ b/Source/WebCore/WebCore.gyp/scripts/action_makenames.py >@@ -131,6 +131,8 @@ def main(args): > eventsInput = inputAbsPosix > elif inputBasename.endswith('Names.in'): > options.append(inputAbsPosix) >+ elif inputBasename.endswith('.pm'): >+ continue > else: > assert False > >diff --git a/Source/WebCore/bindings/scripts/StaticString.pm b/Source/WebCore/bindings/scripts/StaticString.pm >new file mode 100644 >index 0000000000000000000000000000000000000000..a10e3c82f6aa7ef6e86f55a5620d4125b55c66d8 >--- /dev/null >+++ b/Source/WebCore/bindings/scripts/StaticString.pm >@@ -0,0 +1,87 @@ >+# Copyright (C) 2013 Google, Inc. All Rights Reserved. >+# >+# Redistribution and use in source and binary forms, with or without >+# modification, are permitted provided that the following conditions >+# are met: >+# 1. Redistributions of source code must retain the above copyright >+# notice, this list of conditions and the following disclaimer. >+# 2. Redistributions in binary form must reproduce the above copyright >+# notice, this list of conditions and the following disclaimer in the >+# documentation and/or other materials provided with the distribution. >+# >+# THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ >+package StaticString; >+ >+use strict; >+use Hasher; >+ >+sub GenerateStrings($) >+{ >+ my $stringsRef = shift; >+ my %strings = %$stringsRef; >+ >+ my @result = (); >+ >+ while ( my ($name, $value) = each %strings ) { >+ push(@result, "static const LChar ${name}String8[] = \"${value}\";\n"); >+ } >+ >+ push(@result, "\n"); >+ >+ while ( my ($name, $value) = each %strings ) { >+ my $length = length($value); >+ my $hash = Hasher::GenerateHashValue($value); >+ push(@result, <<END); >+static StringImpl::StaticASCIILiteral ${name}Data = { >+ StringImpl::StaticASCIILiteral::s_initialRefCount, >+ $length, >+ ${name}String8, >+ 0, >+ StringImpl::StaticASCIILiteral::s_initialFlags | (${hash} << StringImpl::StaticASCIILiteral::s_hashShift) >+}; >+END >+ } >+ >+ push(@result, "\n"); >+ >+ while ( my ($name, $value) = each %strings ) { >+ push(@result, "static StringImpl* ${name}Impl = reinterpret_cast<StringImpl*>(&${name}Data);\n"); >+ } >+ >+ push(@result, "\n"); >+ >+ return join "", @result; >+} >+ >+sub GenerateStringAsserts($) >+{ >+ my $stringsRef = shift; >+ my %strings = %$stringsRef; >+ >+ my @result = (); >+ >+ push(@result, "#ifndef NDEBUG\n"); >+ >+ while ( my ($name, $value) = each %strings ) { >+ push(@result, " ${name}Impl->assertHashIsCorrect();\n"); >+ } >+ >+ push(@result, "#endif // NDEBUG\n"); >+ >+ push(@result, "\n"); >+ >+ return join "", @result; >+} >+ >+1; >diff --git a/Source/WebCore/dom/QualifiedName.cpp b/Source/WebCore/dom/QualifiedName.cpp >index de60bfb07e12298dbaff1fac778d4ea5d3bbd581..b9d51eb457d7f9a4caff64aa8369714ad49b845d 100644 >--- a/Source/WebCore/dom/QualifiedName.cpp >+++ b/Source/WebCore/dom/QualifiedName.cpp >@@ -172,16 +172,14 @@ unsigned QualifiedName::QualifiedNameImpl::computeHash() const > return hashComponents(components); > } > >-void createQualifiedName(void* targetAddress, const char* name, unsigned nameLength, const AtomicString& nameNamespace) >+void createQualifiedName(void* targetAddress, StringImpl* name, const AtomicString& nameNamespace) > { >- AtomicString atomicName(name, nameLength, AtomicString::ConstructFromLiteral); >- new (reinterpret_cast<void*>(targetAddress)) QualifiedName(nullAtom, atomicName, nameNamespace); >+ new (reinterpret_cast<void*>(targetAddress)) QualifiedName(nullAtom, AtomicString(name), nameNamespace); > } > >-void createQualifiedName(void* targetAddress, const char* name, unsigned nameLength) >+void createQualifiedName(void* targetAddress, StringImpl* name) > { >- AtomicString atomicName(name, nameLength, AtomicString::ConstructFromLiteral); >- new (reinterpret_cast<void*>(targetAddress)) QualifiedName(nullAtom, atomicName, nullAtom); >+ new (reinterpret_cast<void*>(targetAddress)) QualifiedName(nullAtom, AtomicString(name), nullAtom); > } > > } >diff --git a/Source/WebCore/dom/QualifiedName.h b/Source/WebCore/dom/QualifiedName.h >index c3cd29fdecabcad720373c5750a9486d3f9f102d..38673154a67f16684d3b44f5d599e697de86d8cd 100644 >--- a/Source/WebCore/dom/QualifiedName.h >+++ b/Source/WebCore/dom/QualifiedName.h >@@ -144,8 +144,8 @@ struct QualifiedNameHash { > static const bool safeToCompareToEmptyOrDeleted = false; > }; > >-void createQualifiedName(void* targetAddress, const char* name, unsigned nameLength); >-void createQualifiedName(void* targetAddress, const char* name, unsigned nameLength, const AtomicString& nameNamespace); >+void createQualifiedName(void* targetAddress, StringImpl* name); >+void createQualifiedName(void* targetAddress, StringImpl* name, const AtomicString& nameNamespace); > > } > >diff --git a/Source/WebCore/dom/make_names.pl b/Source/WebCore/dom/make_names.pl >index b9103e54fe177ff3c1588c213d0a3197fe38f00f..017027527f3b27f5e1621880b215cfeaf6f3a727 100755 >--- a/Source/WebCore/dom/make_names.pl >+++ b/Source/WebCore/dom/make_names.pl >@@ -31,6 +31,7 @@ > > use strict; > >+use StaticString; > use Config; > use Getopt::Long; > use File::Path; >@@ -54,6 +55,7 @@ my %enabledTags = (); > my %enabledAttrs = (); > my %allTags = (); > my %allAttrs = (); >+my %allStrings = (); > my %parameters = (); > my $extraDefines = 0; > my $initDefaults = 1; >@@ -115,14 +117,19 @@ if (length($fontNamesIn)) { > printLicenseHeader($F); > printCppHead($F, "CSS", $familyNamesFileBase, "WTF"); > >+ print F StaticString::GenerateStrings(\%parameters); >+ > while ( my ($name, $identifier) = each %parameters ) { > print F "DEFINE_GLOBAL(AtomicString, $name)\n"; > } > > printInit($F, 0); > >+ print F "\n"; >+ print F StaticString::GenerateStringAsserts(\%parameters); >+ > while ( my ($name, $identifier) = each %parameters ) { >- print F " new ((void*)&$name) AtomicString(\"$identifier\");\n"; >+ print F " new ((void*)&$name) AtomicString(${name}Impl);\n"; > } > > print F "}\n}\n}\n"; >@@ -135,11 +142,13 @@ die "You must specify at least one of --tags <file> or --attrs <file>" unless (l > if (length($tagsFile)) { > %allTags = %{readTags($tagsFile, 0)}; > %enabledTags = %{readTags($tagsFile, 1)}; >+ namesToStrings(\%allTags, \%allStrings); > } > > if (length($attrsFile)) { > %allAttrs = %{readAttrs($attrsFile, 0)}; > %enabledAttrs = %{readAttrs($attrsFile, 1)}; >+ namesToStrings(\%allAttrs, \%allStrings); > } > > die "You must specify a namespace (e.g. SVG) for <namespace>Names.h" unless $parameters{namespace}; >@@ -212,6 +221,31 @@ sub defaultInterfaceName > > ### Parsing handlers > >+sub valueForName >+{ >+ my $name = shift; >+ my $value = $extensionAttrs{$name}; >+ >+ if (!$value) { >+ $value = $name; >+ $value =~ s/_/-/g; >+ } >+ >+ return $value; >+} >+ >+sub namesToStrings >+{ >+ my $namesRef = shift; >+ my $stringsRef = shift; >+ >+ my %names = %$namesRef; >+ >+ for my $name (keys %names) { >+ $stringsRef->{$name} = valueForName($name); >+ } >+} >+ > sub tagsHandler > { > my ($tag, $property, $value) = @_; >@@ -636,6 +670,8 @@ sub printNamesCppFile > > print F "DEFINE_GLOBAL(AtomicString, ${lowerNamespace}NamespaceURI)\n\n"; > >+ print F StaticString::GenerateStrings(\%allStrings); >+ > if (keys %allTags) { > print F "// Tags\n"; > for my $name (sort keys %allTags) { >@@ -672,7 +708,10 @@ sub printNamesCppFile > print(F " AtomicString ${lowerNamespace}NS(\"$parameters{namespaceURI}\", AtomicString::ConstructFromLiteral);\n\n"); > > print(F " // Namespace\n"); >- print(F " new ((void*)&${lowerNamespace}NamespaceURI) AtomicString(${lowerNamespace}NS);\n\n"); >+ print(F " new ((void*)&${lowerNamespace}NamespaceURI) AtomicString(${lowerNamespace}NS);\n"); >+ print(F "\n"); >+ print F StaticString::GenerateStringAsserts(\%allStrings); >+ > if (keys %allTags) { > my $tagsNamespace = $parameters{tagsNullNamespace} ? "nullAtom" : "${lowerNamespace}NS"; > printDefinitions($F, \%allTags, "tags", $tagsNamespace); >@@ -774,17 +813,11 @@ sub printDefinitions > print F " // " . ucfirst($type) . "\n"; > > for my $name (sort keys %$namesRef) { >- my $realName = $extensionAttrs{$name}; >- if (!$realName) { >- $realName = $name; >- $realName =~ s/_/-/g; >- } >- > # To generate less code in init(), the common case of nullAtom for the namespace, we call createQualifiedName() without passing $namespaceURI. > if ($namespaceURI eq "nullAtom") { >- print F " createQualifiedName((void*)&$name","${shortCamelType}, \"$realName\", ", length $realName ,");\n"; >+ print F " createQualifiedName((void*)&$name","${shortCamelType}, ${name}Impl);\n"; > } else { >- print F " createQualifiedName((void*)&$name","${shortCamelType}, \"$realName\", ", length $realName ,", $namespaceURI);\n"; >+ print F " createQualifiedName((void*)&$name","${shortCamelType}, ${name}Impl, $namespaceURI);\n"; > } > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 112831
:
194104
|
194121
|
194125
|
194134
|
194202
|
194209