Ignore:
Timestamp:
May 9, 2010, 6:41:07 PM (15 years ago)
Author:
[email protected]
Message:

2010-05-09 Geoffrey Garen <[email protected]>

Reviewed by Oliver Hunt.

Reserve a large-ish initial capacity for Lexer::m_buffer16.

SunSpider says 0.3% faster.

m_buffer16 is used when parsing complex strings -- for example, strings
with escape sequences in them. These kinds of strings can be really long,
and we want to avoid repeatedly copying as we grow m_buffer16.

The net memory cost is quite low, since it's proporitional to source
code we already have in memory, and we throw away m_buffer16 right when
we're done parsing.

  • parser/Lexer.cpp: (JSC::Lexer::Lexer): No need to reserve initial capacity in our constructor, since setCode will be called before we're asked to lex anything. (JSC::Lexer::setCode): Reserve enough space to lex half the source code as a complex string without having to copy. (JSC::Lexer::clear): No need to reserve initial capacity here either, since setCode will be called before we're asked to lex anything.

2010-05-09 Oliver Hunt <[email protected]>

Reviewed by Gavin Barraclough.

REGRESSION(r57955): RegExp literals should not actually be cached, so r57955 should be rolled out.
https://bugs.webkit.org/show_bug.cgi?id=38828

Replace incorrect test for caching regexp literals with ones that tests that they are not cached.

  • fast/js/regexp-literals-are-constants-expected.txt: Removed.
  • fast/js/regexp-literals-are-constants.html: Removed.
  • fast/js/regexp-literals-arent-constants-expected.txt: Added.
  • fast/js/regexp-literals-arent-constants.html: Added.
  • fast/js/script-tests/regexp-literals-are-constants.js: Removed.
  • fast/js/script-tests/regexp-literals-arent-constants.js: Added. (test1): (returnRegExpLiteral): (returnConditionalRegExpLiteral):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/bytecode/CodeBlock.cpp

    r58986 r59064  
    9090}
    9191
     92static UString regexpToSourceString(RegExp* regExp)
     93{
     94    char postfix[5] = { '/', 0, 0, 0, 0 };
     95    int index = 1;
     96    if (regExp->global())
     97        postfix[index++] = 'g';
     98    if (regExp->ignoreCase())
     99        postfix[index++] = 'i';
     100    if (regExp->multiline())
     101        postfix[index] = 'm';
     102
     103    return makeString("/", regExp->pattern(), postfix);
     104}
     105
     106static CString regexpName(int re, RegExp* regexp)
     107{
     108    return makeString(regexpToSourceString(regexp), "(@re", UString::from(re), ")").UTF8String();
     109}
     110
    92111static UString pointerToSourceString(void* p)
    93112{
     
    350369    }
    351370
     371    if (m_rareData && !m_rareData->m_regexps.isEmpty()) {
     372        printf("\nm_regexps:\n");
     373        size_t i = 0;
     374        do {
     375            printf("  re%u = %s\n", static_cast<unsigned>(i), regexpToSourceString(m_rareData->m_regexps[i].get()).ascii());
     376            ++i;
     377        } while (i < m_rareData->m_regexps.size());
     378    }
     379
    352380#if ENABLE(JIT)
    353381    if (!m_globalResolveInfos.isEmpty() || !m_structureStubInfos.isEmpty())
     
    485513            int argc = (++it)->u.operand;
    486514            printf("[%4d] new_array\t %s, %s, %d\n", location, registerName(exec, dst).data(), registerName(exec, argv).data(), argc);
     515            break;
     516        }
     517        case op_new_regexp: {
     518            int r0 = (++it)->u.operand;
     519            int re0 = (++it)->u.operand;
     520            printf("[%4d] new_regexp\t %s, %s\n", location, registerName(exec, r0).data(), regexpName(re0, regexp(re0)).data());
    487521            break;
    488522        }
     
    16961730    if (m_rareData) {
    16971731        m_rareData->m_exceptionHandlers.shrinkToFit();
     1732        m_rareData->m_regexps.shrinkToFit();
    16981733        m_rareData->m_immediateSwitchJumpTables.shrinkToFit();
    16991734        m_rareData->m_characterSwitchJumpTables.shrinkToFit();
Note: See TracChangeset for help on using the changeset viewer.