Ignore:
Timestamp:
Mar 9, 2011, 6:22:50 PM (14 years ago)
Author:
[email protected]
Message:

Bug 56041 - RexExp constructor should only accept flags "gim"
Fix for issues introduced in r80667.

Reviewed by Sam Weinig.

Source/JavaScriptCore:

Invalid flags to a RegExp literal are a late syntax error!

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::addRegExp):

  • Pass a PassRefPtr<RegExp>
  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::addRegExp):
(JSC::BytecodeGenerator::emitNewRegExp):

  • bytecompiler/BytecodeGenerator.h:
    • Pass a PassRefPtr<RegExp>
  • bytecompiler/NodesCodegen.cpp:

(JSC::RegExpNode::emitBytecode):

  • Should not be ASSERTing that the flags are valid - this is a late(er) error.
  • interpreter/Interpreter.cpp:

(JSC::Interpreter::privateExecute):

  • Need to check for error from RegExp constructor.
  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • Need to check for error from RegExp constructor.
  • runtime/RegExp.h:

(JSC::RegExp::isValid):

  • Make isValid check that the regexp was created with valid flags.
  • runtime/RegExpKey.h:
    • Since we'll not create RegExp objects with invalid flags, separate out the deleted value.

LayoutTests:

  • fast/regex/script-tests/parentheses.js:
  • fast/regex/script-tests/pcre-test-1.js:
    • Providing invalid flags to RegExp literals is an error in ES5.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.h

    r80598 r80684  
    500500        FunctionExecutable* functionExpr(int index) { return m_functionExprs[index].get(); }
    501501
    502         unsigned addRegExp(RegExp* r) { createRareDataIfNecessary(); unsigned size = m_rareData->m_regexps.size(); m_rareData->m_regexps.append(r); return size; }
     502        unsigned addRegExp(PassRefPtr<RegExp> r) { createRareDataIfNecessary(); unsigned size = m_rareData->m_regexps.size(); m_rareData->m_regexps.append(r); return size; }
    503503        RegExp* regexp(int index) const { ASSERT(m_rareData); return m_rareData->m_regexps[index].get(); }
    504504
Note: See TracChangeset for help on using the changeset viewer.