⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 233789 in webkit


Ignore:
Timestamp:
Jul 12, 2018, 5:28:36 PM (8 years ago)
Author:
achristensen@apple.com
Message:

Reduce size of WebCore::URL
​https://bugs.webkit.org/show_bug.cgi?id=186820

Reviewed by Yusuke Suzuki and Youenn Fablet.

Source/WebCore:

We were using 32 bits for the length of the port, which is always between 0 and 5 inclusive
because port numbers are missing or between 0 and 65535. Let's just use 3 bits here.
We were using 32 bits for the length of the scheme, which is usually 3-5 characters and can be
longer for some custom schemes, but I've never seen one more than 20 characters. If we assume
schemes are always less than 64MB, we can save 8 bytes per URL!

No change in behavior, just less memory use!

To restore the IPC encoding to how it was before r221165, I just encode the string and reparse it.

  • platform/URL.cpp:

(WebCore::URL::invalidate):
(WebCore::URL::lastPathComponent const):
(WebCore::URL::port const):
(WebCore::URL::protocolHostAndPort const):
(WebCore::URL::path const):
(WebCore::URL::removePort):
(WebCore::URL::setPort):
(WebCore::URL::setHostAndPort):
(WebCore::URL::setPath):

  • platform/URL.h:

(WebCore::URL::encode const):
(WebCore::URL::decode):
(WebCore::URL::hasPath const):
(WebCore::URL::pathStart const):

  • platform/URLParser.cpp:

(WebCore::URLParser::copyBaseWindowsDriveLetter):
(WebCore::URLParser::urlLengthUntilPart):
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::shouldPopPath):
(WebCore::URLParser::popPath):
(WebCore::URLParser::parse):
(WebCore::URLParser::parsePort):
(WebCore::URLParser::parseHostAndPort):
(WebCore::URLParser::allValuesEqual):
(WebCore::URLParser::internalValuesConsistent):

  • workers/service/server/RegistrationDatabase.cpp:

Increment the service worker registration schema version because of the URL encoding change.

Source/WebKit:

  • NetworkProcess/cache/NetworkCacheStorage.h:

Increment cache version because of URL encoding change.

Tools:

  • TestWebKitAPI/Tests/WebCore/URLParser.cpp:

(TestWebKitAPI::TEST_F):

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r233782 r233789  
     12018-07-12  Alex Christensen  <achristensen@webkit.org>
     2
     3        Reduce size of WebCore::URL
     4        https://bugs.webkit.org/show_bug.cgi?id=186820
     5
     6        Reviewed by Yusuke Suzuki and Youenn Fablet.
     7
     8        We were using 32 bits for the length of the port, which is always between 0 and 5 inclusive
     9        because port numbers are missing or between 0 and 65535.  Let's just use 3 bits here.
     10        We were using 32 bits for the length of the scheme, which is usually 3-5 characters and can be
     11        longer for some custom schemes, but I've never seen one more than 20 characters.  If we assume
     12        schemes are always less than 64MB, we can save 8 bytes per URL!
     13
     14        No change in behavior, just less memory use!
     15       
     16        To restore the IPC encoding to how it was before r221165, I just encode the string and reparse it.
     17
     18        * platform/URL.cpp:
     19        (WebCore::URL::invalidate):
     20        (WebCore::URL::lastPathComponent const):
     21        (WebCore::URL::port const):
     22        (WebCore::URL::protocolHostAndPort const):
     23        (WebCore::URL::path const):
     24        (WebCore::URL::removePort):
     25        (WebCore::URL::setPort):
     26        (WebCore::URL::setHostAndPort):
     27        (WebCore::URL::setPath):
     28        * platform/URL.h:
     29        (WebCore::URL::encode const):
     30        (WebCore::URL::decode):
     31        (WebCore::URL::hasPath const):
     32        (WebCore::URL::pathStart const):
     33        * platform/URLParser.cpp:
     34        (WebCore::URLParser::copyBaseWindowsDriveLetter):
     35        (WebCore::URLParser::urlLengthUntilPart):
     36        (WebCore::URLParser::copyURLPartsUntil):
     37        (WebCore::URLParser::shouldPopPath):
     38        (WebCore::URLParser::popPath):
     39        (WebCore::URLParser::parse):
     40        (WebCore::URLParser::parsePort):
     41        (WebCore::URLParser::parseHostAndPort):
     42        (WebCore::URLParser::allValuesEqual):
     43        (WebCore::URLParser::internalValuesConsistent):
     44        * workers/service/server/RegistrationDatabase.cpp:
     45        Increment the service worker registration schema version because of the URL encoding change.
     46
    1472018-07-12  Youenn Fablet  <youenn@apple.com>
    248
  • trunk/Source/WebCore/platform/URL.cpp

    r233755 r233789  
    8585    m_passwordEnd = 0;
    8686    m_hostEnd = 0;
    87     m_portEnd = 0;
     87    m_portLength = 0;
    8888    m_pathEnd = 0;
    8989    m_pathAfterLastSlash = 0;
    … …  
    145145
    146146    size_t start = m_string.reverseFind('/', end);
    147     if (start < static_cast<unsigned>(m_portEnd))
     147    if (start < static_cast<unsigned>(m_hostEnd + m_portLength))
    148148        return String();
    149149    ++start;
    … …  
    165165std::optional<uint16_t> URL::port() const
    166166{
    167     if (!m_portEnd || m_hostEnd >= m_portEnd - 1)
     167    if (!m_portLength)
    168168        return std::nullopt;
    169169
    … …  
    171171    unsigned number;
    172172    if (m_string.is8Bit())
    173         number = charactersToUIntStrict(m_string.characters8() + m_hostEnd + 1, m_portEnd - m_hostEnd - 1, &ok);
     173        number = charactersToUIntStrict(m_string.characters8() + m_hostEnd + 1, m_portLength - 1, &ok);
    174174    else
    175         number = charactersToUIntStrict(m_string.characters16() + m_hostEnd + 1, m_portEnd - m_hostEnd - 1, &ok);
     175        number = charactersToUIntStrict(m_string.characters16() + m_hostEnd + 1, m_portLength - 1, &ok);
    176176    if (!ok || number > std::numeric_limits<uint16_t>::max())
    177177        return std::nullopt;
    … …  
    188188String URL::protocolHostAndPort() const
    189189{
    190     String result = m_string.substring(0, m_portEnd);
     190    String result = m_string.substring(0, m_hostEnd + m_portLength);
    191191
    192192    if (m_passwordEnd - m_userStart > 0) {
    … …  
    371371String URL::path() const
    372372{
    373     return m_string.substring(m_portEnd, m_pathEnd - m_portEnd);
     373    unsigned portEnd = m_hostEnd + m_portLength;
     374    return m_string.substring(portEnd, m_pathEnd - portEnd);
    374375}
    375376
    … …  
    456457void URL::removePort()
    457458{
    458     if (m_hostEnd == m_portEnd)
    459         return;
    460     URLParser parser(m_string.left(m_hostEnd) + m_string.substring(m_portEnd));
     459    if (!m_portLength)
     460        return;
     461    URLParser parser(makeString(StringView(m_string).left(m_hostEnd), StringView(m_string).substring(m_hostEnd + m_portLength)));
    461462    *this = parser.result();
    462463}
    … …  
    467468        return;
    468469
    469     bool colonNeeded = m_portEnd == m_hostEnd;
     470    bool colonNeeded = !m_portLength;
    470471    unsigned portStart = (colonNeeded ? m_hostEnd : m_hostEnd + 1);
    471472
    472     URLParser parser(makeString(m_string.left(portStart), (colonNeeded ? ":" : ""), String::number(i), m_string.substring(m_portEnd)));
     473    URLParser parser(makeString(StringView(m_string).left(portStart), (colonNeeded ? ":" : ""), String::number(i), StringView(m_string).substring(m_hostEnd + m_portLength)));
    473474    *this = parser.result();
    474475}
    … …  
    510511        builder.append(port);
    511512    }
    512     builder.append(m_string.substring(m_portEnd));
     513    builder.append(StringView(m_string).substring(m_hostEnd + m_portLength));
    513514
    514515    URLParser parser(builder.toString());
    … …  
    659660        return character == '?' || character == '#';
    660661    };
    661     URLParser parser(makeString(StringView(m_string).left(m_portEnd), percentEncodeCharacters(path, questionMarkOrNumberSign), StringView(m_string).substring(m_pathEnd)));
     662    URLParser parser(makeString(StringView(m_string).left(m_hostEnd + m_portLength), percentEncodeCharacters(path, questionMarkOrNumberSign), StringView(m_string).substring(m_pathEnd)));
    662663    *this = parser.result();
    663664}
  • trunk/Source/WebCore/platform/URL.h

    r233755 r233789  
    220220
    221221    String m_string;
    222     bool m_isValid : 1;
    223     bool m_protocolIsInHTTPFamily : 1;
    224     bool m_cannotBeABaseURL : 1;
    225 
    226     unsigned m_schemeEnd;
     222
     223    unsigned m_isValid : 1;
     224    unsigned m_protocolIsInHTTPFamily : 1;
     225    unsigned m_cannotBeABaseURL : 1;
     226
     227    // This is out of order to align the bits better. The port is after the host.
     228    unsigned m_portLength : 3;
     229    static constexpr unsigned maxPortLength = (1 << 3) - 1;
     230
     231    static constexpr unsigned maxSchemeLength = (1 << 26) - 1;
     232    unsigned m_schemeEnd : 26;
    227233    unsigned m_userStart;
    228234    unsigned m_userEnd;
    229235    unsigned m_passwordEnd;
    230236    unsigned m_hostEnd;
    231     unsigned m_portEnd;
    232237    unsigned m_pathAfterLastSlash;
    233238    unsigned m_pathEnd;
    … …  
    235240};
    236241
     242static_assert(sizeof(URL) == sizeof(String) + 8 * sizeof(unsigned), "URL should stay small");
     243
    237244template <class Encoder>
    238245void URL::encode(Encoder& encoder) const
    239246{
    240247    encoder << m_string;
    241     encoder << static_cast<bool>(m_isValid);
    242     if (!m_isValid)
    243         return;
    244     encoder << static_cast<bool>(m_protocolIsInHTTPFamily);
    245     encoder << m_schemeEnd;
    246     encoder << m_userStart;
    247     encoder << m_userEnd;
    248     encoder << m_passwordEnd;
    249     encoder << m_hostEnd;
    250     encoder << m_portEnd;
    251     encoder << m_pathAfterLastSlash;
    252     encoder << m_pathEnd;
    253     encoder << m_queryEnd;
    254248}
    255249
    … …  
    267261std::optional<URL> URL::decode(Decoder& decoder)
    268262{
    269     URL url;
    270     if (!decoder.decode(url.m_string))
     263    String string;
     264    if (!decoder.decode(string))
    271265        return std::nullopt;
    272     bool isValid;
    273     if (!decoder.decode(isValid))
    274         return std::nullopt;
    275     url.m_isValid = isValid;
    276     if (!isValid)
    277         return WTFMove(url);
    278     bool protocolIsInHTTPFamily;
    279     if (!decoder.decode(protocolIsInHTTPFamily))
    280         return std::nullopt;
    281     url.m_protocolIsInHTTPFamily = protocolIsInHTTPFamily;
    282     if (!decoder.decode(url.m_schemeEnd))
    283         return std::nullopt;
    284     if (!decoder.decode(url.m_userStart))
    285         return std::nullopt;
    286     if (!decoder.decode(url.m_userEnd))
    287         return std::nullopt;
    288     if (!decoder.decode(url.m_passwordEnd))
    289         return std::nullopt;
    290     if (!decoder.decode(url.m_hostEnd))
    291         return std::nullopt;
    292     if (!decoder.decode(url.m_portEnd))
    293         return std::nullopt;
    294     if (!decoder.decode(url.m_pathAfterLastSlash))
    295         return std::nullopt;
    296     if (!decoder.decode(url.m_pathEnd))
    297         return std::nullopt;
    298     if (!decoder.decode(url.m_queryEnd))
    299         return std::nullopt;
    300     return WTFMove(url);
     266    return URL(URL(), string);
    301267}
    302268
    … …  
    401367inline bool URL::hasPath() const
    402368{
    403     return m_pathEnd != m_portEnd;
     369    return m_pathEnd != m_hostEnd + m_portLength;
    404370}
    405371
    … …  
    441407inline unsigned URL::pathStart() const
    442408{
    443     return m_portEnd;
     409    return m_hostEnd + m_portLength;
    444410}
    445411
  • trunk/Source/WebCore/platform/URLParser.cpp

    r233755 r233789  
    503503{
    504504    if (base.protocolIs("file")) {
    505         RELEASE_ASSERT(base.m_portEnd < base.m_string.length());
     505        RELEASE_ASSERT(base.m_hostEnd + base.m_portLength < base.m_string.length());
    506506        if (base.m_string.is8Bit()) {
    507507            const LChar* begin = base.m_string.characters8();
    508             CodePointIterator<LChar> c(begin + base.m_portEnd + 1, begin + base.m_string.length());
     508            CodePointIterator<LChar> c(begin + base.m_hostEnd + base.m_portLength + 1, begin + base.m_string.length());
    509509            if (isWindowsDriveLetter(c)) {
    510510                appendWindowsDriveLetter(c);
    … …  
    513513        } else {
    514514            const UChar* begin = base.m_string.characters16();
    515             CodePointIterator<UChar> c(begin + base.m_portEnd + 1, begin + base.m_string.length());
     515            CodePointIterator<UChar> c(begin + base.m_hostEnd + base.m_portLength + 1, begin + base.m_string.length());
    516516            if (isWindowsDriveLetter(c)) {
    517517                appendWindowsDriveLetter(c);
    … …  
    847847        return url.m_pathAfterLastSlash;
    848848    case URLPart::PortEnd:
    849         return url.m_portEnd;
     849        return url.m_hostEnd + url.m_portLength;
    850850    case URLPart::HostEnd:
    851851        return url.m_hostEnd;
    … …  
    899899        FALLTHROUGH;
    900900    case URLPart::PortEnd:
    901         m_url.m_portEnd = base.m_portEnd;
     901        m_url.m_portLength = base.m_portLength;
    902902        FALLTHROUGH;
    903903    case URLPart::HostEnd:
    … …  
    10441044    ASSERT(m_url.m_pathAfterLastSlash <= m_asciiBuffer.size());
    10451045    CodePointIterator<LChar> componentToPop(&m_asciiBuffer[newPathAfterLastSlash], &m_asciiBuffer[0] + m_url.m_pathAfterLastSlash);
    1046     if (newPathAfterLastSlash == m_url.m_portEnd + 1 && isWindowsDriveLetter(componentToPop))
     1046    if (newPathAfterLastSlash == m_url.m_hostEnd + m_url.m_portLength + 1 && isWindowsDriveLetter(componentToPop))
    10471047        return false;
    10481048    return true;
    … …  
    10521052{
    10531053    ASSERT(m_didSeeSyntaxViolation);
    1054     if (m_url.m_pathAfterLastSlash > m_url.m_portEnd + 1) {
     1054    if (m_url.m_pathAfterLastSlash > m_url.m_hostEnd + m_url.m_portLength + 1) {
    10551055        auto newPathAfterLastSlash = m_url.m_pathAfterLastSlash - 1;
    10561056        if (m_asciiBuffer[newPathAfterLastSlash] == '/')
    10571057            newPathAfterLastSlash--;
    1058         while (newPathAfterLastSlash > m_url.m_portEnd && m_asciiBuffer[newPathAfterLastSlash] != '/')
     1058        while (newPathAfterLastSlash > m_url.m_hostEnd + m_url.m_portLength && m_asciiBuffer[newPathAfterLastSlash] != '/')
    10591059            newPathAfterLastSlash--;
    10601060        newPathAfterLastSlash++;
    … …  
    12721272                appendToASCIIBuffer(toASCIILower(*c));
    12731273            } else if (*c == ':') {
    1274                 m_url.m_schemeEnd = currentPosition(c);
     1274                unsigned schemeEnd = currentPosition(c);
     1275                if (schemeEnd > URL::maxSchemeLength) {
     1276                    failure();
     1277                    return;
     1278                }
     1279                m_url.m_schemeEnd = schemeEnd;
    12751280                StringView urlScheme = parsedDataView(0, m_url.m_schemeEnd);
    12761281                appendToASCIIBuffer(':');
    … …  
    13221327                        m_url.m_passwordEnd = m_url.m_userStart;
    13231328                        m_url.m_hostEnd = m_url.m_userStart;
    1324                         m_url.m_portEnd = m_url.m_userStart;
     1329                        m_url.m_portLength = 0;
    13251330                        m_url.m_pathAfterLastSlash = m_url.m_userStart;
    13261331                        m_url.m_cannotBeABaseURL = true;
    … …  
    13961401                m_url.m_passwordEnd = m_url.m_userStart;
    13971402                m_url.m_hostEnd = m_url.m_userStart;
    1398                 m_url.m_portEnd = m_url.m_userStart;
     1403                m_url.m_portLength = 0;
    13991404                m_url.m_pathAfterLastSlash = m_url.m_userStart + 1;
    14001405                state = State::Path;
    … …  
    14521457                copyURLPartsUntil(base, URLPart::PortEnd, c, isUTF8Encoding);
    14531458                appendToASCIIBuffer('/');
    1454                 m_url.m_pathAfterLastSlash = base.m_portEnd + 1;
     1459                m_url.m_pathAfterLastSlash = base.m_hostEnd + base.m_portLength + 1;
    14551460                state = State::Path;
    14561461            }
    … …  
    15211526                        m_url.m_passwordEnd = m_url.m_userEnd;
    15221527                        m_url.m_hostEnd = m_url.m_userEnd;
    1523                         m_url.m_portEnd = m_url.m_userEnd;
     1528                        m_url.m_portLength = 0;
    15241529                        m_url.m_pathAfterLastSlash = m_url.m_userEnd;
    15251530                    } else {
    … …  
    15911596                    m_url.m_passwordEnd = m_url.m_userStart;
    15921597                    m_url.m_hostEnd = m_url.m_userStart;
    1593                     m_url.m_portEnd = m_url.m_userStart;
     1598                    m_url.m_portLength = 0;
    15941599                    m_url.m_pathAfterLastSlash = m_url.m_userStart + 1;
    15951600                    m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
    … …  
    16131618                    m_url.m_passwordEnd = m_url.m_userStart;
    16141619                    m_url.m_hostEnd = m_url.m_userStart;
    1615                     m_url.m_portEnd = m_url.m_userStart;
     1620                    m_url.m_portLength = 0;
    16161621                    m_url.m_pathAfterLastSlash = m_url.m_userStart + 1;
    16171622                    m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
    … …  
    16311636                    m_url.m_passwordEnd = m_url.m_userStart;
    16321637                    m_url.m_hostEnd = m_url.m_userStart;
    1633                     m_url.m_portEnd = m_url.m_userStart;
     1638                    m_url.m_portLength = 0;
    16341639                    m_url.m_pathAfterLastSlash = m_url.m_userStart + 1;
    16351640                    if (isWindowsDriveLetter(c))
    … …  
    16511656                m_url.m_passwordEnd = m_url.m_userStart;
    16521657                m_url.m_hostEnd = m_url.m_userStart;
    1653                 m_url.m_portEnd = m_url.m_userStart;
     1658                m_url.m_portLength = 0;
    16541659                authorityOrHostBegin = c;
    16551660                state = State::FileHost;
    … …  
    16621667            m_url.m_passwordEnd = m_url.m_userStart;
    16631668            m_url.m_hostEnd = m_url.m_userStart;
    1664             m_url.m_portEnd = m_url.m_userStart;
     1669            m_url.m_portLength = 0;
    16651670            if (isWindowsDriveLetter(c)) {
    16661671                appendWindowsDriveLetter(c);
    … …  
    17211726                        m_asciiBuffer.shrink(m_url.m_passwordEnd);
    17221727                        m_url.m_hostEnd = currentPosition(c);
    1723                         m_url.m_portEnd = m_url.m_hostEnd;
     1728                        m_url.m_portLength = 0;
    17241729                    }
    17251730                   
    … …  
    18761881        m_url.m_passwordEnd = m_url.m_userStart;
    18771882        m_url.m_hostEnd = m_url.m_userStart;
    1878         m_url.m_portEnd = m_url.m_userStart;
     1883        m_url.m_portLength = 0;
    18791884        m_url.m_pathAfterLastSlash = m_url.m_userStart + 1;
    18801885        m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
    … …  
    18881893        copyURLPartsUntil(base, URLPart::PortEnd, c, isUTF8Encoding);
    18891894        appendToASCIIBuffer('/');
    1890         m_url.m_pathAfterLastSlash = base.m_portEnd + 1;
     1895        m_url.m_pathAfterLastSlash = m_url.m_hostEnd + m_url.m_portLength + 1;
    18911896        m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
    18921897        m_url.m_queryEnd = m_url.m_pathAfterLastSlash;
    … …  
    18981903        m_url.m_passwordEnd = m_url.m_userStart;
    18991904        m_url.m_hostEnd = m_url.m_userStart;
    1900         m_url.m_portEnd = m_url.m_userStart;
     1905        m_url.m_portLength = 0;
    19011906        m_url.m_pathAfterLastSlash = m_url.m_userStart;
    19021907        m_url.m_pathEnd = m_url.m_userStart;
    … …  
    19151920            m_url.m_passwordEnd = m_url.m_userStart;
    19161921            m_url.m_hostEnd = m_url.m_userStart;
    1917             m_url.m_portEnd = m_url.m_userStart;
     1922            m_url.m_portLength = 0;
    19181923            m_url.m_pathEnd = m_url.m_userStart;
    19191924        } else if (!parseHostAndPort(authorityOrHostBegin)) {
    … …  
    19241929                syntaxViolation(c);
    19251930                appendToASCIIBuffer('/');
    1926                 m_url.m_pathEnd = m_url.m_portEnd + 1;
     1931                m_url.m_pathEnd = m_url.m_hostEnd + m_url.m_portLength + 1;
    19271932            } else
    1928                 m_url.m_pathEnd = m_url.m_portEnd;
     1933                m_url.m_pathEnd = m_url.m_hostEnd + m_url.m_portLength;
    19291934        }
    19301935        m_url.m_pathAfterLastSlash = m_url.m_pathEnd;
    … …  
    19401945            syntaxViolation(c);
    19411946            appendToASCIIBuffer('/');
    1942             m_url.m_pathEnd = m_url.m_portEnd + 1;
     1947            m_url.m_pathEnd = m_url.m_hostEnd + m_url.m_portLength + 1;
    19431948        } else
    1944             m_url.m_pathEnd = m_url.m_portEnd;
     1949            m_url.m_pathEnd = m_url.m_hostEnd + m_url.m_portLength;
    19451950        m_url.m_pathAfterLastSlash = m_url.m_pathEnd;
    19461951        m_url.m_queryEnd = m_url.m_pathEnd;
    … …  
    19581963        m_url.m_passwordEnd = m_url.m_userStart;
    19591964        m_url.m_hostEnd = m_url.m_userStart;
    1960         m_url.m_portEnd = m_url.m_userStart;
     1965        m_url.m_portLength = 0;
    19611966        m_url.m_pathAfterLastSlash = m_url.m_userStart + 1;
    19621967        m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
    … …  
    19711976        m_url.m_passwordEnd = m_url.m_userStart;
    19721977        m_url.m_hostEnd = m_url.m_userStart;
    1973         m_url.m_portEnd = m_url.m_userStart;
     1978        m_url.m_portLength = 0;
    19741979        if (copyBaseWindowsDriveLetter(base)) {
    19751980            appendToASCIIBuffer('/');
    … …  
    20002005            m_url.m_passwordEnd = m_url.m_userStart;
    20012006            m_url.m_hostEnd = m_url.m_userStart;
    2002             m_url.m_portEnd = m_url.m_userStart;
     2007            m_url.m_portLength = 0;
    20032008            m_url.m_pathAfterLastSlash = m_url.m_userStart + 1;
    20042009            m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
    … …  
    20162021            m_asciiBuffer.shrink(m_url.m_passwordEnd);
    20172022            m_url.m_hostEnd = currentPosition(c);
    2018             m_url.m_portEnd = m_url.m_hostEnd;
     2023            m_url.m_portLength = 0;
    20192024        }
    20202025        appendToASCIIBuffer('/');
    2021         m_url.m_pathAfterLastSlash = m_url.m_portEnd + 1;
     2026        m_url.m_pathAfterLastSlash = m_url.m_hostEnd + m_url.m_portLength + 1;
    20222027        m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
    20232028        m_url.m_queryEnd = m_url.m_pathAfterLastSlash;
    … …  
    26022607    uint32_t port = 0;
    26032608    if (UNLIKELY(iterator.atEnd())) {
    2604         m_url.m_portEnd = currentPosition(colonIterator);
     2609        unsigned portLength = currentPosition(colonIterator) - m_url.m_hostEnd;
     2610        RELEASE_ASSERT(portLength <= URL::maxPortLength);
     2611        m_url.m_portLength = portLength;
    26052612        syntaxViolation(colonIterator);
    26062613        return true;
    … …  
    26392646    }
    26402647
    2641     m_url.m_portEnd = currentPosition(iterator);
     2648    unsigned portLength = currentPosition(iterator) - m_url.m_hostEnd;
     2649    RELEASE_ASSERT(portLength <= URL::maxPortLength);
     2650    m_url.m_portLength = portLength;
    26422651    return true;
    26432652}
    … …  
    26652674                }
    26662675                m_url.m_hostEnd = currentPosition(ipv6End);
    2667                 m_url.m_portEnd = m_url.m_hostEnd;
     2676                m_url.m_portLength = 0;
    26682677                return true;
    26692678            }
    … …  
    26882697        m_url.m_hostEnd = currentPosition(iterator);
    26892698        if (iterator.atEnd()) {
    2690             m_url.m_portEnd = currentPosition(iterator);
     2699            m_url.m_portLength = 0;
    26912700            return true;
    26922701        }
    … …  
    27092718            m_url.m_hostEnd = currentPosition(iterator);
    27102719            if (iterator.atEnd()) {
    2711                 m_url.m_portEnd = currentPosition(iterator);
     2720                m_url.m_portLength = 0;
    27122721                return true;
    27132722            }
    … …  
    27282737        if (!hostIterator.atEnd())
    27292738            return parsePort(hostIterator);
    2730         m_url.m_portEnd = currentPosition(iterator);
     2739        unsigned portLength = currentPosition(iterator) - m_url.m_hostEnd;
     2740        RELEASE_ASSERT(portLength <= URL::maxPortLength);
     2741        m_url.m_portLength = portLength;
    27312742        return true;
    27322743    }
    … …  
    27702781        m_url.m_hostEnd = currentPosition(iterator);
    27712782        if (iterator.atEnd()) {
    2772             m_url.m_portEnd = currentPosition(iterator);
     2783            m_url.m_portLength = 0;
    27732784            return true;
    27742785        }
    … …  
    27822793    if (!iterator.atEnd())
    27832794        return parsePort(iterator);
    2784     m_url.m_portEnd = currentPosition(iterator);
     2795    m_url.m_portLength = 0;
    27852796    return true;
    27862797}
    … …  
    28692880bool URLParser::allValuesEqual(const URL& a, const URL& b)
    28702881{
    2871     // FIXME: m_cannotBeABaseURL is not compared because the old URL::parse did not use it,
    2872     // but once we get rid of URL::parse its value should be tested.
    2873     URL_PARSER_LOG("%d %d %d %d %d %d %d %d %d %d %d %s\n%d %d %d %d %d %d %d %d %d %d %d %s",
     2882    URL_PARSER_LOG("%d %d %d %d %d %d %d %d %d %d %d %d %s\n%d %d %d %d %d %d %d %d %d %d %d %d %s",
    28742883        a.m_isValid,
     2884        a.m_cannotBeABaseURL,
    28752885        a.m_protocolIsInHTTPFamily,
    28762886        a.m_schemeEnd,
    … …  
    28792889        a.m_passwordEnd,
    28802890        a.m_hostEnd,
    2881         a.m_portEnd,
     2891        a.m_hostEnd + a.m_portLength,
    28822892        a.m_pathAfterLastSlash,
    28832893        a.m_pathEnd,
    … …  
    28852895        a.m_string.utf8().data(),
    28862896        b.m_isValid,
     2897        b.m_cannotBeABaseURL,
    28872898        b.m_protocolIsInHTTPFamily,
    28882899        b.m_schemeEnd,
    … …  
    28912902        b.m_passwordEnd,
    28922903        b.m_hostEnd,
    2893         b.m_portEnd,
     2904        b.m_hostEnd + b.m_portLength,
    28942905        b.m_pathAfterLastSlash,
    28952906        b.m_pathEnd,
    … …  
    28992910    return a.m_string == b.m_string
    29002911        && a.m_isValid == b.m_isValid
     2912        && a.m_cannotBeABaseURL == b.m_cannotBeABaseURL
    29012913        && a.m_protocolIsInHTTPFamily == b.m_protocolIsInHTTPFamily
    29022914        && a.m_schemeEnd == b.m_schemeEnd
    … …  
    29052917        && a.m_passwordEnd == b.m_passwordEnd
    29062918        && a.m_hostEnd == b.m_hostEnd
    2907         && a.m_portEnd == b.m_portEnd
     2919        && a.m_portLength == b.m_portLength
    29082920        && a.m_pathAfterLastSlash == b.m_pathAfterLastSlash
    29092921        && a.m_pathEnd == b.m_pathEnd
    … …  
    29172929        && url.m_userEnd <= url.m_passwordEnd
    29182930        && url.m_passwordEnd <= url.m_hostEnd
    2919         && url.m_hostEnd <= url.m_portEnd
    2920         && url.m_portEnd <= url.m_pathAfterLastSlash
     2931        && url.m_hostEnd + url.m_portLength <= url.m_pathAfterLastSlash
    29212932        && url.m_pathAfterLastSlash <= url.m_pathEnd
    29222933        && url.m_pathEnd <= url.m_queryEnd
  • trunk/Source/WebCore/workers/service/server/RegistrationDatabase.cpp

    r233122 r233789  
    4949namespace WebCore {
    5050
    51 static const uint64_t schemaVersion = 2;
     51static const uint64_t schemaVersion = 3;
    5252
    5353static const String recordsTableSchema(const String& tableName)
  • trunk/Source/WebKit/ChangeLog

    r233788 r233789  
     12018-07-12  Alex Christensen  <achristensen@webkit.org>
     2
     3        Reduce size of WebCore::URL
     4        https://bugs.webkit.org/show_bug.cgi?id=186820
     5
     6        Reviewed by Yusuke Suzuki and Youenn Fablet.
     7
     8        * NetworkProcess/cache/NetworkCacheStorage.h:
     9        Increment cache version because of URL encoding change.
     10
    1112018-07-12  Chris Dumez  <cdumez@apple.com>
    212
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h

    r232759 r233789  
    109109
    110110    // Incrementing this number will delete all existing cache content for everyone. Do you really need to do it?
    111     static const unsigned version = 12;
     111    static const unsigned version = 13;
    112112#if PLATFORM(MAC)
    113113    /// Allow the last stable version of the cache to co-exist with the latest development one.
  • trunk/Tools/ChangeLog

    r233786 r233789  
     12018-07-12  Alex Christensen  <achristensen@webkit.org>
     2
     3        Reduce size of WebCore::URL
     4        https://bugs.webkit.org/show_bug.cgi?id=186820
     5
     6        Reviewed by Yusuke Suzuki and Youenn Fablet.
     7
     8        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
     9        (TestWebKitAPI::TEST_F):
     10
    1112018-07-12  Brady Eidson  <beidson@apple.com>
    212
  • trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp

    r233755 r233789  
    11801180        {"", "", "", "", 0, "", "", "", "file://:0/path"},
    11811181        {"file", "", "", "", 0, "/path", "", "", "file://:0/path"});
     1182   
     1183    checkURL("http://example.com:0000000000000077", {"http", "", "", "example.com", 77, "/", "", "", "http://example.com:77/"});
     1184    checkURL("http://example.com:0000000000000080", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"});
    11821185}
    11831186
Note: See TracChangeset for help on using the changeset viewer.