Title: [152881] trunk/Source/WTF
- Revision
- 152881
- Author
- [email protected]
- Date
- 2013-07-18 20:24:43 -0700 (Thu, 18 Jul 2013)
Log Message
Little cleaning of StringImpl::lower() and StringImpl::upper() for ARM
https://bugs.webkit.org/show_bug.cgi?id=118831
Reviewed by Gavin Barraclough.
Clean lower() and upper() before trying some optimizations:
-Prefix the code with the empty() case. Otherwise, each descending loop starts with
a check for length == 0.
-Change ored to a 32 bits registers. ARM only has 32 bits registers and access to full word.
To keep the value a UChar, the compiler is adding a bunch of useless value & 0xffff in the loops.
-Change the pointer based loops for index based loops. The compiler does a mighty job at optimizing
those for each architecture. No need to make the code more complex.
-Don't perform the check for int32 unless we need to. The only code limited to int is Unicode::toLower.
* wtf/text/StringImpl.cpp:
(WTF::StringImpl::lower):
(WTF::StringImpl::upper):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (152880 => 152881)
--- trunk/Source/WTF/ChangeLog 2013-07-19 03:04:47 UTC (rev 152880)
+++ trunk/Source/WTF/ChangeLog 2013-07-19 03:24:43 UTC (rev 152881)
@@ -1,3 +1,23 @@
+2013-07-18 Benjamin Poulain <[email protected]>
+
+ Little cleaning of StringImpl::lower() and StringImpl::upper() for ARM
+ https://bugs.webkit.org/show_bug.cgi?id=118831
+
+ Reviewed by Gavin Barraclough.
+
+ Clean lower() and upper() before trying some optimizations:
+ -Prefix the code with the empty() case. Otherwise, each descending loop starts with
+ a check for length == 0.
+ -Change ored to a 32 bits registers. ARM only has 32 bits registers and access to full word.
+ To keep the value a UChar, the compiler is adding a bunch of useless value & 0xffff in the loops.
+ -Change the pointer based loops for index based loops. The compiler does a mighty job at optimizing
+ those for each architecture. No need to make the code more complex.
+ -Don't perform the check for int32 unless we need to. The only code limited to int is Unicode::toLower.
+
+ * wtf/text/StringImpl.cpp:
+ (WTF::StringImpl::lower):
+ (WTF::StringImpl::upper):
+
2013-07-18 Andreas Kling <[email protected]>
CodeBlock::m_argumentValueProfiles wastes a lot of memory.
Modified: trunk/Source/WTF/wtf/text/StringImpl.cpp (152880 => 152881)
--- trunk/Source/WTF/wtf/text/StringImpl.cpp 2013-07-19 03:04:47 UTC (rev 152880)
+++ trunk/Source/WTF/wtf/text/StringImpl.cpp 2013-07-19 03:24:43 UTC (rev 152881)
@@ -389,67 +389,63 @@
{
// Note: This is a hot function in the Dromaeo benchmark, specifically the
// no-op code path up through the first 'return' statement.
-
+
// First scan the string for uppercase and non-ASCII characters:
bool noUpper = true;
- UChar ored = 0;
+ unsigned ored = 0;
if (is8Bit()) {
- const LChar* end = m_data8 + m_length;
- for (const LChar* chp = m_data8; chp != end; ++chp) {
- if (UNLIKELY(isASCIIUpper(*chp)))
+ for (unsigned i = 0; i < m_length; ++i) {
+ LChar character = m_data8[i];
+ if (UNLIKELYisASCIIUpper(character)))
noUpper = false;
- ored |= *chp;
+ ored |= character;
}
// Nothing to do if the string is all ASCII with no uppercase.
if (noUpper && !(ored & ~0x7F))
return this;
- if (m_length > static_cast<unsigned>(numeric_limits<int32_t>::max()))
- CRASH();
- int32_t length = m_length;
-
LChar* data8;
- RefPtr<StringImpl> newImpl = createUninitialized(length, data8);
+ RefPtr<StringImpl> newImpl = createUninitialized(m_length, data8);
if (!(ored & ~0x7F)) {
- for (int32_t i = 0; i < length; ++i)
+ for (unsigned i = 0; i < m_length; ++i)
data8[i] = toASCIILower(m_data8[i]);
return newImpl.release();
}
// Do a slower implementation for cases that include non-ASCII Latin-1 characters.
- for (int32_t i = 0; i < length; ++i)
+ for (unsigned i = 0; i < m_length; ++i)
data8[i] = static_cast<LChar>(Unicode::toLower(m_data8[i]));
return newImpl.release();
}
- const UChar *end = m_data16 + m_length;
- for (const UChar* chp = m_data16; chp != end; ++chp) {
- if (UNLIKELY(isASCIIUpper(*chp)))
+ for (unsigned i = 0; i < m_length; ++i) {
+ UChar character = m_data16[i];
+ if (UNLIKELY(isASCIIUpper(character)))
noUpper = false;
- ored |= *chp;
+ ored |= character;
}
// Nothing to do if the string is all ASCII with no uppercase.
if (noUpper && !(ored & ~0x7F))
return this;
- if (m_length > static_cast<unsigned>(numeric_limits<int32_t>::max()))
- CRASH();
- int32_t length = m_length;
-
if (!(ored & ~0x7F)) {
UChar* data16;
RefPtr<StringImpl> newImpl = createUninitialized(m_length, data16);
- for (int32_t i = 0; i < length; ++i) {
+ for (unsigned i = 0; i < m_length; ++i) {
UChar c = m_data16[i];
data16[i] = toASCIILower(c);
}
return newImpl.release();
}
-
+
+ if (m_length > static_cast<unsigned>(numeric_limits<int32_t>::max()))
+ CRASH();
+ int32_t length = m_length;
+
// Do a slower implementation for cases that include non-ASCII characters.
UChar* data16;
RefPtr<StringImpl> newImpl = createUninitialized(m_length, data16);
@@ -481,7 +477,7 @@
RefPtr<StringImpl> newImpl = createUninitialized(m_length, data8);
// Do a faster loop for the case where all the characters are ASCII.
- LChar ored = 0;
+ unsigned ored = 0;
for (int i = 0; i < length; ++i) {
LChar c = m_data8[i];
ored |= c;
@@ -542,7 +538,7 @@
RefPtr<StringImpl> newImpl = createUninitialized(m_length, data16);
// Do a faster loop for the case where all the characters are ASCII.
- UChar ored = 0;
+ unsigned ored = 0;
for (int i = 0; i < length; ++i) {
UChar c = source16[i];
ored |= c;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes