Ignore:
Timestamp:
Apr 20, 2010, 11:41:20 PM (15 years ago)
Author:
[email protected]
Message:

2010-04-20 Oliver Hunt <[email protected]>

Reviewed by Maciej Stachowiak.

[ES5] RegExp literals are constants that should be persistent across multiple function calls.
https://bugs.webkit.org/show_bug.cgi?id=37908

Dump the separate RegExp constant pool, and just use the standard JS constant pool
in codeblock. This allows us to drop op_new_regexp and all associated code as well.

  • bytecode/CodeBlock.cpp: (JSC::CodeBlock::dump): (JSC::CodeBlock::shrinkToFit):
  • bytecode/CodeBlock.h:
  • bytecode/Opcode.h:
  • bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::emitLoad):
  • bytecompiler/BytecodeGenerator.h:
  • bytecompiler/NodesCodegen.cpp: (JSC::RegExpNode::emitBytecode):
  • interpreter/Interpreter.cpp: (JSC::Interpreter::privateExecute):
  • jit/JIT.cpp: (JSC::JIT::privateCompileMainPass):
  • jit/JIT.h:
  • jit/JITOpcodes.cpp:
  • jit/JITStubs.cpp:
  • jit/JITStubs.h: (JSC::):

2010-04-20 Oliver Hunt <[email protected]>

Reviewed by Maciej Stachowiak.

[ES5] RegExp literals are constants that should be persistent across multiple function calls.
https://bugs.webkit.org/show_bug.cgi?id=37908

Add tests to ensure correct persistence of RegExp literals, and correctly avoid
sharing "identical" regexps used in different places.

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

Legend:

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

    r57054 r57955  
    9090}
    9191
    92 static 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 
    106 static CString regexpName(int re, RegExp* regexp)
    107 {
    108     return makeString(regexpToSourceString(regexp), "(@re", UString::from(re), ")").UTF8String();
    109 }
    110 
    11192static UString pointerToSourceString(void* p)
    11293{
     
    365346    }
    366347
    367     if (m_rareData && !m_rareData->m_regexps.isEmpty()) {
    368         printf("\nm_regexps:\n");
    369         size_t i = 0;
    370         do {
    371             printf("  re%u = %s\n", static_cast<unsigned>(i), regexpToSourceString(m_rareData->m_regexps[i].get()).ascii());
    372             ++i;
    373         } while (i < m_rareData->m_regexps.size());
    374     }
    375 
    376348#if ENABLE(JIT)
    377349    if (!m_globalResolveInfos.isEmpty() || !m_structureStubInfos.isEmpty())
     
    509481            int argc = (++it)->u.operand;
    510482            printf("[%4d] new_array\t %s, %s, %d\n", location, registerName(exec, dst).data(), registerName(exec, argv).data(), argc);
    511             break;
    512         }
    513         case op_new_regexp: {
    514             int r0 = (++it)->u.operand;
    515             int re0 = (++it)->u.operand;
    516             printf("[%4d] new_regexp\t %s, %s\n", location, registerName(exec, r0).data(), regexpName(re0, regexp(re0)).data());
    517483            break;
    518484        }
     
    17081674    if (m_rareData) {
    17091675        m_rareData->m_exceptionHandlers.shrinkToFit();
    1710         m_rareData->m_regexps.shrinkToFit();
    17111676        m_rareData->m_immediateSwitchJumpTables.shrinkToFit();
    17121677        m_rareData->m_characterSwitchJumpTables.shrinkToFit();
Note: See TracChangeset for help on using the changeset viewer.