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.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@80684 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/runtime/RegExpKey.h b/Source/JavaScriptCore/runtime/RegExpKey.h
index 756fabc..b4847f9 100644
--- a/Source/JavaScriptCore/runtime/RegExpKey.h
+++ b/Source/JavaScriptCore/runtime/RegExpKey.h
@@ -38,7 +38,8 @@
     FlagGlobal = 1,
     FlagIgnoreCase = 2,
     FlagMultiline = 4,
-    InvalidFlags = 8
+    InvalidFlags = 8,
+    DeletedValueFlags = -1
 };
 
 struct RegExpKey {
@@ -102,8 +103,8 @@
 };
 
 template<> struct HashTraits<JSC::RegExpKey> : GenericHashTraits<JSC::RegExpKey> {
-    static void constructDeletedValue(JSC::RegExpKey& slot) { slot.flagsValue = JSC::InvalidFlags; }
-    static bool isDeletedValue(const JSC::RegExpKey& value) { return value.flagsValue == JSC::InvalidFlags; }
+    static void constructDeletedValue(JSC::RegExpKey& slot) { slot.flagsValue = JSC::DeletedValueFlags; }
+    static bool isDeletedValue(const JSC::RegExpKey& value) { return value.flagsValue == JSC::DeletedValueFlags; }
 };
 } // namespace WTF