Skip to content
Permalink
Browse files
Source/JavaScriptCore: RefCounted::deprecatedTurnOffVerifier() should…
… not be deprecated

https://bugs.webkit.org/show_bug.cgi?id=79864

Patch by Filip Pizlo <fpizlo@apple.com> on 2012-02-28
Reviewed by Oliver Hunt.

Removed the word "deprecated" from the name of this method, since this method
should not be deprecated. It works just fine as it is, and there is simply no
alternative to calling this method for many interesting JSC classes.

* parser/SourceProvider.h:
(JSC::SourceProvider::SourceProvider):
* runtime/SymbolTable.h:
(JSC::SharedSymbolTable::SharedSymbolTable):
* wtf/MetaAllocator.cpp:
(WTF::MetaAllocatorHandle::MetaAllocatorHandle):
(WTF::MetaAllocator::allocate):
* wtf/RefCounted.h:
(RefCountedBase):
(WTF::RefCountedBase::turnOffVerifier):

LayoutTests: 'source' property of RegExp instance cannot be ""
https://bugs.webkit.org/show_bug.cgi?id=79938

Reviewed by Oliver Hunt.

15.10.6.4 specifies that RegExp.prototype.toString must return '/' + source + '/',
and also states that the result must be a valid RegularExpressionLiteral. '//' is
not a valid RegularExpressionLiteral (since it is a single line comment), and hence
source cannot ever validly be "". If the source is empty, return a different Pattern
that would match the same thing.

* fast/js/kde/RegExp-expected.txt:
* fast/js/kde/script-tests/RegExp.js:
* fast/regex/script-tests/toString.js:
* fast/regex/toString-expected.txt:
    - Update these tests to check for the correct result.
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T1-expected.txt:
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T2-expected.txt:
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T3-expected.txt:
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T4-expected.txt:
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T5-expected.txt:
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A4_T2-expected.txt:
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A4_T3-expected.txt:
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A4_T5-expected.txt:
    - Check in failing results, these tests are all incorrect.



Canonical link: https://commits.webkit.org/97028@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@109275 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
pizlonator authored and Gavin Barraclough committed Feb 29, 2012
1 parent 4fde1c3 commit 4ea15f76d9c4e5306cd6646dc0904c8550ac9743
@@ -1,3 +1,31 @@
2012-02-29 Gavin Barraclough <barraclough@apple.com>

'source' property of RegExp instance cannot be ""
https://bugs.webkit.org/show_bug.cgi?id=79938

Reviewed by Oliver Hunt.

15.10.6.4 specifies that RegExp.prototype.toString must return '/' + source + '/',
and also states that the result must be a valid RegularExpressionLiteral. '//' is
not a valid RegularExpressionLiteral (since it is a single line comment), and hence
source cannot ever validly be "". If the source is empty, return a different Pattern
that would match the same thing.

* fast/js/kde/RegExp-expected.txt:
* fast/js/kde/script-tests/RegExp.js:
* fast/regex/script-tests/toString.js:
* fast/regex/toString-expected.txt:
- Update these tests to check for the correct result.
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T1-expected.txt:
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T2-expected.txt:
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T3-expected.txt:
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T4-expected.txt:
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A3_T5-expected.txt:
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A4_T2-expected.txt:
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A4_T3-expected.txt:
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A4_T5-expected.txt:
- Check in failing results, these tests are all incorrect.

2012-02-29 Joshua Bell <jsbell@chromium.org>

IndexedDB: Resource leak with IDBObjectStore.openCursor
@@ -3,7 +3,7 @@ KDE JS Test
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS (new RegExp()).source is ''
PASS (new RegExp()).source is '(?:)'
PASS Boolean(new RegExp()) is true
PASS isNaN(Number(new RegExp())) is true
PASS RegExp(/x/).source is 'x'
@@ -1,4 +1,4 @@
shouldBe("(new RegExp()).source", "''");
shouldBe("(new RegExp()).source", "'(?:)'");
shouldBe("Boolean(new RegExp())", "true");
shouldBeTrue("isNaN(Number(new RegExp()))");

@@ -18,8 +18,8 @@ function testLineTerminator(pattern)
}

shouldBe("RegExp('/').source", '"\\\\/"');
shouldBe("RegExp('').source", '""');
shouldBe("RegExp.prototype.source", '""');
shouldBe("RegExp('').source", '"(?:)"');
shouldBe("RegExp.prototype.source", '"(?:)"');

shouldBe("RegExp('/').toString()", '"/\\\\//"');
shouldBe("RegExp('').toString()", '"/(?:)/"');
@@ -53,3 +53,12 @@ shouldBeFalse('testLineTerminator("\\\\u2029");');

shouldBe("RegExp('[/]').source", "'[/]'");
shouldBe("RegExp('\\\\[/]').source", "'\\\\[\\\\/]'");

// See 15.10.6.4
// The first half of this checks that:
// Return the String value formed by concatenating the Strings "/", the
// String value of the source property of this RegExp object, and "/";
// The second half checks that:
// The returned String has the form of a RegularExpressionLiteral that
// evaluates to another RegExp object with the same behaviour as this object.
shouldBe("var o = new RegExp(); o.toString() === '/'+o.source+'/' && eval(o.toString()+'.exec(String())')", '[""]');
@@ -4,8 +4,8 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE


PASS RegExp('/').source is "\\/"
PASS RegExp('').source is ""
PASS RegExp.prototype.source is ""
PASS RegExp('').source is "(?:)"
PASS RegExp.prototype.source is "(?:)"
PASS RegExp('/').toString() is "/\\//"
PASS RegExp('').toString() is "/(?:)/"
PASS RegExp.prototype.toString() is "/(?:)/"
@@ -30,6 +30,7 @@ PASS testLineTerminator("\u2029"); is false
PASS testLineTerminator("\\u2029"); is false
PASS RegExp('[/]').source is '[/]'
PASS RegExp('\\[/]').source is '\\[\\/]'
PASS var o = new RegExp(); o.toString() === '/'+o.source+'/' && eval(o.toString()+'.exec(String())') is [""]
PASS successfullyParsed is true

TEST COMPLETE
@@ -1,6 +1,6 @@
S15.10.4.1_A3_T1

PASS
FAIL SputnikError: #1: __re = new RegExp; __re.source === "". Actual: (?:)

TEST COMPLETE

@@ -1,6 +1,6 @@
S15.10.4.1_A3_T2

PASS
FAIL SputnikError: #1: __re = new RegExp(void 0); __re.source === "". Actual: (?:)

TEST COMPLETE

@@ -1,6 +1,6 @@
S15.10.4.1_A3_T3

PASS
FAIL SputnikError: #1: __re = new RegExp(x); var x; __re.source === "". Actual: (?:)

TEST COMPLETE

@@ -1,6 +1,6 @@
S15.10.4.1_A3_T4

PASS
FAIL SputnikError: #1: __re = new RegExp(undefined); __re.source === "". Actual: (?:)

TEST COMPLETE

@@ -1,6 +1,6 @@
S15.10.4.1_A3_T5

PASS
FAIL SputnikError: #1: __re = new RegExp((function(){})()); __re.source === "". Actual: (?:)

TEST COMPLETE

@@ -1,6 +1,6 @@
S15.10.4.1_A4_T2

PASS
FAIL SputnikError: #1: __re = new RegExp(undefined, undefined); __re.source === "". Actual: (?:)

TEST COMPLETE

@@ -1,6 +1,6 @@
S15.10.4.1_A4_T3

PASS
FAIL SputnikError: #1: __re = new RegExp({}.p, {}.q); __re.source === "". Actual: (?:)

TEST COMPLETE

@@ -1,6 +1,6 @@
S15.10.4.1_A4_T5

PASS
FAIL SputnikError: #1: __re = new RegExp("", (function(){})()); __re.source === "". Actual: (?:)

TEST COMPLETE

@@ -20,6 +20,26 @@
(RefCountedBase):
(WTF::RefCountedBase::turnOffVerifier):

2012-02-29 Gavin Barraclough <barraclough@apple.com>

'source' property of RegExp instance cannot be ""
https://bugs.webkit.org/show_bug.cgi?id=79938

Reviewed by Oliver Hunt.

15.10.6.4 specifies that RegExp.prototype.toString must return '/' + source + '/',
and also states that the result must be a valid RegularExpressionLiteral. '//' is
not a valid RegularExpressionLiteral (since it is a single line comment), and hence
source cannot ever validly be "". If the source is empty, return a different Pattern
that would match the same thing.

* runtime/RegExpObject.cpp:
(JSC::regExpObjectSource):
- Do not return "" if the source is empty, this would lead to invalid behaviour in toString.
* runtime/RegExpPrototype.cpp:
(JSC::regExpProtoFuncToString):
- No need to special case the empty string - this should be being done by 'source'.

2012-02-29 Gavin Barraclough <barraclough@apple.com>

Writable attribute not set correctly when redefining an accessor to a data descriptor
@@ -189,6 +189,14 @@ JSValue regExpObjectSource(ExecState* exec, JSValue slotBase, const Identifier&)
bool inBrackets = false;
bool shouldEscape = false;

// 15.10.6.4 specifies that RegExp.prototype.toString must return '/' + source + '/',
// and also states that the result must be a valid RegularExpressionLiteral. '//' is
// not a valid RegularExpressionLiteral (since it is a single line comment), and hence
// source cannot ever validly be "". If the source is empty, return a different Pattern
// that would match the same thing.
if (!length)
return jsString(exec, "(?:)");

// early return for strings that don't contain a forwards slash and LineTerminator
for (unsigned i = 0; i < length; ++i) {
UChar ch = characters[i];
@@ -155,7 +155,7 @@ EncodedJSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState* exec)
postfix[index] = 'm';
UString source = thisObject->get(exec, exec->propertyNames().source).toString(exec)->value(exec);
// If source is empty, use "/(?:)/" to avoid colliding with comment syntax
return JSValue::encode(jsMakeNontrivialString(exec, "/", source.length() ? source : UString("(?:)"), postfix));
return JSValue::encode(jsMakeNontrivialString(exec, "/", source, postfix));
}

} // namespace JSC

0 comments on commit 4ea15f7

Please sign in to comment.