From f935f49c67edd4c377dffb3df3f9e47346f96bf2 Mon Sep 17 00:00:00 2001 From: "commit-queue@webkit.org" Date: Wed, 24 Jun 2015 13:09:46 +0000 Subject: [PATCH] Unreviewed, rolling out r185906. https://bugs.webkit.org/show_bug.cgi?id=146276 MSVC doesn't yet provide a const-qualified std::array::size(), failing to compile the static_assert (Requested by zdobersek on #webkit). Reverted changeset: "Improve the source code generated by make_names.pl" https://bugs.webkit.org/show_bug.cgi?id=146208 http://trac.webkit.org/changeset/185906 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@185907 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WTF/ChangeLog | 15 ++++ Source/WTF/wtf/text/StringImpl.h | 2 +- Source/WebCore/ChangeLog | 15 ++++ Source/WebCore/bindings/scripts/StaticString.pm | 36 +++----- Source/WebCore/dom/make_names.pl | 105 +++++++++++++----------- 5 files changed, 97 insertions(+), 76 deletions(-) diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog index 4d7aa40..f4d10d9 100644 --- a/Source/WTF/ChangeLog +++ b/Source/WTF/ChangeLog @@ -1,3 +1,18 @@ +2015-06-24 Commit Queue + + Unreviewed, rolling out r185906. + https://bugs.webkit.org/show_bug.cgi?id=146276 + + MSVC doesn't yet provide a const-qualified std::array::size(), failing to compile the static_assert (Requested by + zdobersek on #webkit). + + Reverted changeset: + + "Improve the source code generated by make_names.pl" + https://bugs.webkit.org/show_bug.cgi?id=146208 + http://trac.webkit.org/changeset/185906 + 2015-06-24 Zan Dobersek Improve the source code generated by make_names.pl diff --git a/Source/WTF/wtf/text/StringImpl.h b/Source/WTF/wtf/text/StringImpl.h index 669393d..0223c96 100644 --- a/Source/WTF/wtf/text/StringImpl.h +++ b/Source/WTF/wtf/text/StringImpl.h @@ -901,7 +901,7 @@ public: }; #ifndef NDEBUG - void assertHashIsCorrect() const + void assertHashIsCorrect() { ASSERT(hasHash()); ASSERT(existingHash() == StringHasher::computeHashAndMaskTop8Bits(characters8(), length())); diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 92fabc1..b613542 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,18 @@ +2015-06-24 Commit Queue + + Unreviewed, rolling out r185906. + https://bugs.webkit.org/show_bug.cgi?id=146276 + + MSVC doesn't yet provide a const-qualified std::array::size(), failing to compile the static_assert (Requested by + zdobersek on #webkit). + + Reverted changeset: + + "Improve the source code generated by make_names.pl" + https://bugs.webkit.org/show_bug.cgi?id=146208 + http://trac.webkit.org/changeset/185906 + 2015-06-24 Zan Dobersek Improve the source code generated by make_names.pl diff --git a/Source/WebCore/bindings/scripts/StaticString.pm b/Source/WebCore/bindings/scripts/StaticString.pm index 6162666..6da10eb 100644 --- a/Source/WebCore/bindings/scripts/StaticString.pm +++ b/Source/WebCore/bindings/scripts/StaticString.pm @@ -26,7 +26,7 @@ package StaticString; use strict; use Hasher; -sub GenerateStringData($) +sub GenerateStrings($) { my $stringsRef = shift; my %strings = %$stringsRef; @@ -37,34 +37,20 @@ sub GenerateStringData($) push(@result, "static const LChar ${name}String8[] = \"$strings{$name}\";\n"); } - return join "", @result; -} - -sub GenerateASCIILiteral($$) -{ - my $name = shift; - my $value = shift; - - my $length = length($value); - my $hash = Hasher::GenerateHashValue($value); - return "{ StaticASCIILiteral::s_initialRefCount, $length, ${name}String8, StaticASCIILiteral::s_initialFlags | (${hash} << StaticASCIILiteral::s_hashShift) }"; -} - -sub GenerateStrings($) -{ - my $stringsRef = shift; - my %strings = %$stringsRef; - - my @result = (); - - push(@result, GenerateStringData($stringsRef)); push(@result, "\n"); for my $name (sort keys %strings) { my $value = $strings{$name}; - push(@result, "static StaticASCIILiteral ${name}Data = "); - push(@result, GenerateASCIILiteral($name, $strings{$name})); - push(@result, ";\n"); + my $length = length($value); + my $hash = Hasher::GenerateHashValue($value); + push(@result, <\n"; - print F "#include \n\n"; + print F "#include \n"; print F "namespace WebCore {\n\n"; print F "namespace ${namespace}Names {\n\n"; - print F "using namespace $usedNamespace;\n"; - print F "using StaticASCIILiteral = StringImpl::StaticASCIILiteral;\n\n"; + print F "using namespace $usedNamespace;\n\n"; } sub printInit @@ -600,6 +598,8 @@ print F "\nvoid init() return; initialized = true; + // Use placement new to initialize the globals. + AtomicString::init(); "; } @@ -762,15 +762,37 @@ sub printNamesCppFile print F "WEBCORE_EXPORT DEFINE_GLOBAL(AtomicString, ${lowercaseNamespacePrefix}NamespaceURI)\n\n"; - print F StaticString::GenerateStringData(\%allStrings); - print F "\n"; + print F StaticString::GenerateStrings(\%allStrings); if (keys %allTags) { - printStaticData($F, \%allTags, "Tag", $parameters{namespace}, "$parameters{namespace}QualifiedName"); + print F "// Tags\n"; + for my $name (sort keys %allTags) { + print F "WEBCORE_EXPORT DEFINE_GLOBAL($parameters{namespace}QualifiedName, ", $name, "Tag)\n"; + } + + print F "\n\nconst WebCore::$parameters{namespace}QualifiedName* const* get$parameters{namespace}Tags()\n"; + print F "{\n static const WebCore::$parameters{namespace}QualifiedName* const $parameters{namespace}Tags[] = {\n"; + for my $name (sort keys %allTags) { + print F " reinterpret_cast(&${name}Tag),\n"; + } + print F " };\n"; + print F " return $parameters{namespace}Tags;\n"; + print F "}\n"; } if (keys %allAttrs) { - printStaticData($F, \%allAttrs, "Attr", $parameters{namespace}, "QualifiedName"); + print F "\n// Attributes\n"; + for my $name (sort keys %allAttrs) { + print F "WEBCORE_EXPORT DEFINE_GLOBAL(QualifiedName, ", $name, "Attr)\n"; + } + print F "\n\nconst WebCore::QualifiedName* const* get$parameters{namespace}Attrs()\n"; + print F "{\n static const WebCore::QualifiedName* const $parameters{namespace}Attrs[] = {\n"; + for my $name (sort keys %allAttrs) { + print F " reinterpret_cast(&${name}Attr),\n"; + } + print F " };\n"; + print F " return $parameters{namespace}Attrs;\n"; + print F "}\n"; } printInit($F, 0); @@ -779,15 +801,16 @@ sub printNamesCppFile print(F " // Namespace\n"); print(F " new (NotNull, (void*)&${lowercaseNamespacePrefix}NamespaceURI) AtomicString(${lowercaseNamespacePrefix}NS);\n"); + print(F "\n"); + print F StaticString::GenerateStringAsserts(\%allStrings); if (keys %allTags) { my $tagsNamespace = $parameters{tagsNullNamespace} ? "nullAtom" : "${lowercaseNamespacePrefix}NS"; - printQualifiedNameCreation($F, "Tags", $parameters{namespace}, "$parameters{namespace}QualifiedName", $tagsNamespace); + printDefinitions($F, \%allTags, "tags", $tagsNamespace); } - if (keys %allAttrs) { my $attrsNamespace = $parameters{attrsNullNamespace} ? "nullAtom" : "${lowercaseNamespacePrefix}NS"; - printQualifiedNameCreation($F, "Attrs", $parameters{namespace}, "QualifiedName", $attrsNamespace); + printDefinitions($F, \%allAttrs, "attributes", $attrsNamespace); } print F "}\n\n} }\n\n"; @@ -870,56 +893,38 @@ sub printConditionalElementIncludes } } -sub printStaticData +sub printDefinitions { - my ($F, $namesRef, $type, $namespace, $qualifiedNameType) = @_; + my ($F, $namesRef, $type, $namespaceURI) = @_; - my $nameCount = scalar(keys %$namesRef); - - print F "// $type\n"; - for my $name (sort keys %$namesRef) { - print F "WEBCORE_EXPORT DEFINE_GLOBAL($qualifiedNameType, ${name}${type})\n"; - } + my $shortCamelType = ucfirst(substr(substr($type, 0, -1), 0, 4)); + my $capitalizedType = ucfirst($type); + +print F < ${namespace}${type}s = { {\n"; - for my $name (sort keys %$namesRef) { - print F " reinterpret_cast(&${name}${type}),\n"; - } - print F "} };\n\n"; + struct ${capitalizedType}TableEntry { + void* targetAddress; + StringImpl& name; + }; - print F "static const std::array ${namespace}${type}sLiterals = { {\n"; + static const ${capitalizedType}TableEntry ${type}Table[] = { +END +; for my $name (sort keys %$namesRef) { - print F " ", StaticString::GenerateASCIILiteral($name, valueForName($name)), ",\n"; + print F " { (void*)&$name$shortCamelType, *reinterpret_cast(&${name}Data) },\n"; } - print F "} };\n\n"; - - print F "const $qualifiedNameType* const* get${namespace}${type}s()\n"; - print F "{\n"; - print F " return ${namespace}${type}s.data();\n"; - print F "}\n"; -} - -sub printQualifiedNameCreation -{ - my ($F, $type, $namespace, $qualifiedNameType, $namespaceURI) = @_; - print F "\n"; - print F " static_assert(${namespace}${type}.size() == ${namespace}${type}Literals.size(), \"Arrays match in size\");\n"; - print F " for (size_t i = 0; i < ${namespace}${type}.size(); ++i) {\n"; - print F "#ifndef NDEBUG\n"; - print F " reinterpret_cast(${namespace}${type}Literals[i]).assertHashIsCorrect();\n"; - print F "#endif\n"; +print F <(const_cast<$qualifiedNameType*>(${namespace}${type}\[i\])),\n"; - print F " reinterpret_cast(const_cast(&${namespace}${type}Literals\[i\])));\n"; + print F " createQualifiedName(${type}Table[i].targetAddress, &${type}Table[i].name);\n"; } else { - print F " createQualifiedName(reinterpret_cast(const_cast<$qualifiedNameType*>(${namespace}${type}\[i\])),\n"; - print F " reinterpret_cast(const_cast(&${namespace}${type}Literals\[i\])), $namespaceURI);\n"; + print F " createQualifiedName(${type}Table[i].targetAddress, &${type}Table[i].name, $namespaceURI);\n"; } - - print F " }\n"; } ## ElementFactory routines -- 1.8.3.1