Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
REGRESSION(r168256): JSString can get 8-bit flag wrong when re-using …
…AtomicStrings. <https://webkit.org/b/133574> <rdar://problem/18051847> Source/JavaScriptCore: The optimization that resolves JSRopeStrings into an existing AtomicString (to save time and memory by avoiding StringImpl allocation) had a bug that it wasn't copying the 8-bit flag from the AtomicString. This could lead to a situation where a 16-bit StringImpl containing only 8-bit characters is sitting in the AtomicString table, is found by the rope resolution optimization, and gives you a rope that thinks it's all 8-bit, but has a fiber with 16-bit characters. Resolving that rope will then yield incorrect results. This was all caught by an assertion, but very hard to reproduce. Test: js/dopey-rope-with-16-bit-propertyname.html Reviewed by Darin Adler. * runtime/JSString.cpp: (JSC::JSRopeString::resolveRopeToAtomicString): (JSC::JSRopeString::resolveRopeToExistingAtomicString): * runtime/JSString.h: (JSC::JSString::setIs8Bit): (JSC::JSString::toExistingAtomicString): LayoutTests: Add a tests that creates a 16-bit AtomicString with only 8-bit characters, then tiers up into baseline JIT and uses that string as part of a rope-within-a-rope and serializes that rope to get an incorrect concatenation. Reviewed by Darin Adler. * js/dopey-rope-with-16-bit-propertyname-expected.txt: Added. * js/dopey-rope-with-16-bit-propertyname.html: Added. Canonical link: https://commits.webkit.org/153901@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@172727 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Andreas Kling
committed
Aug 18, 2014
1 parent
e7c15f5
commit 1ea2edc68e68799d002066b0b77d9ff4ec5ea595
Showing
6 changed files
with
100 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,10 @@ | ||
Test that a 16-bit AtomicString containing only 8-bit characters doesn't confuse the JIT into thinking it's an 8-bit AtomicString. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS globalRope is 'foo.zest' | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<script src="../resources/js-test-pre.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
|
||
description("Test that a 16-bit AtomicString containing only 8-bit characters doesn't confuse the JIT into thinking it's an 8-bit AtomicString."); | ||
|
||
o = {}; | ||
|
||
stringWithEmoji = "zest😐"; | ||
var test16bit = stringWithEmoji.substring(0, 4); | ||
|
||
o[test16bit] = "this makes it an AtomicString"; | ||
|
||
globalRope = ""; | ||
|
||
function jittable(a, b) { | ||
for (var i = 0; i < 5000; ++i) { | ||
poisonedRope = a + b; | ||
o[poisonedRope] = 1; | ||
globalRope = "foo." + poisonedRope; | ||
} | ||
} | ||
|
||
jittable("ze", "st"); | ||
|
||
shouldBe("globalRope", "'foo.zest'"); | ||
|
||
</script> | ||
<script src="../resources/js-test-post.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters