Bug 1041469 part 3 - Remove toLatin1 shell function, update tests. r=luke

This commit is contained in:
Jan de Mooij 2014-07-22 14:52:14 +02:00
parent db2a3ccf95
commit 458f1fc31c
33 changed files with 167 additions and 128 deletions

View File

@ -6,7 +6,6 @@ if (!isAsmJSCompilationAvailable() || !isCachingEnabled())
// Test Latin1 and TwoByte PropertyName serialization.
// Latin1
toLatin1("funName"); // Latin1 atom.
var body1 = "'use asm'; function funName() { return 42 } return funName";
var m = new Function(body1);
assertEq(isAsmJSModule(m), true);

View File

@ -1,6 +1,7 @@
// Reflect.parse Latin1
var ast = Reflect.parse(toLatin1("function f() { return 3; }"));
var ast = Reflect.parse("function f() { return 3; }");
assertEq(ast.body[0].id.name, "f");
assertEq(isLatin1(ast.body[0].id.name), true);
// Reflect.parse TwoByte
var ast = Reflect.parse("function f\u1200() { return 3; }");
@ -28,7 +29,6 @@ assertEq(o.toSource(), "({prop:((11)), prop:((11))})");
load(libdir + 'bytecode-cache.js');
// Latin1 string constant
toLatin1("string123");
test = "'string123';";
evalWithCache(test, { assertEqBytecode: true, assertEqResult : true });

View File

@ -1,6 +1,6 @@
assertEq(isLatin1("Foo123\u1200"), false);
s = toLatin1("Foo123");
s = "Foo123";
assertEq(isLatin1(s), true);
function testEq(s) {
@ -23,7 +23,6 @@ function testEq(s) {
}
s = "foo01\u00c7";
s = toLatin1(s);
testEq(s);
testEq(s);
@ -34,8 +33,8 @@ function testConcat() {
// Following tests create fat inline strings.
assertEq(concat("abc", "def"), "abcdef");
var s1 = toLatin1("ABC");
var s2 = toLatin1("DEF");
var s1 = "ABC";
var s2 = "DEF";
assertEq(concat(s1, s2), "ABCDEF");
assertEq(concat(s1, "GHI\u0580"), "ABCGHI\u0580");
assertEq(concat("GHI\u0580", s2), "GHI\u0580DEF");
@ -44,7 +43,7 @@ function testConcat() {
assertEq(isLatin1(s2), true);
// Create a Latin1 rope.
var s3 = toLatin1("0123456789012345678901234567890123456789");
var s3 = "0123456789012345678901234567890123456789";
var rope = concat(s1, s3);
assertEq(isLatin1(rope), true);
assertEq(rope, "ABC0123456789012345678901234567890123456789");
@ -64,7 +63,7 @@ function testConcat() {
assertEq(isLatin1(rope), false);
// Build a Latin1 rope with left-most string an extensible string.
var s4 = toLatin1("adsfasdfjkasdfkjasdfasasdfasdf");
var s4 = "adsfasdfjkasdfkjasdfasasdfasdf";
for (var i=0; i<5; i++) {
s4 = concat(s4, s1);
assertEq(s4 === ".".repeat(s4.length), false); // Flatten rope.
@ -84,8 +83,8 @@ function testFlattenDependent() {
}
// Create some latin1 strings.
var s1 = toLatin1("Foo0123456789bar012345---");
var s2 = toLatin1("Foo0123456789bar012345+++");
var s1 = "Foo0123456789bar012345---";
var s2 = "Foo0123456789bar012345+++";
assertEq(isLatin1(s1), true);
assertEq(isLatin1(s2), true);

View File

@ -1,8 +1,8 @@
function test() {
var arr = [
toLatin1("abc"),
toLatin1("abcd"),
toLatin1("123\u00ff")
"abc",
"abcd",
"123\u00ff"
];
for (var i = 0; i < arr.length; i++) {
for (var j = 0; j < arr.length; j++) {

View File

@ -1,5 +1,5 @@
function test(s) {
var lat1 = toLatin1(s);
function test(lat1) {
assertEq(isLatin1(lat1), true);
var twoByte = "\u1200" + lat1;
twoByte.indexOf("X"); // Flatten.

View File

@ -1,5 +1,3 @@
var s = toLatin1("someName");
// Latin1
function f(someName) {
someName();

View File

@ -1,5 +1,5 @@
function testSubstrLatin1() {
var s1 = toLatin1("abcdefghijklmnopqrstuvwxyz12345678900000a");
var s1 = "abcdefghijklmnopqrstuvwxyz12345678900000a";
// Static strings.
assertEq(s1.substr(s1.length - 1), "a");
@ -51,7 +51,7 @@ function testSubstrTwoByte() {
testSubstrTwoByte();
function testSubstring() {
var s1 = toLatin1("abcdefghijklmnopqrstuvwxyz123456789000ab");
var s1 = "abcdefghijklmnopqrstuvwxyz123456789000ab";
var s2 = s1.substring(1, 8);
assertEq(isLatin1(s2), true);
assertEq(s2, "bcdefgh");
@ -62,7 +62,7 @@ function testSubstring() {
testSubstring();
function testSlice() {
var s1 = toLatin1("abcdefghijklmnopqrstuvwxyz123456789000ABC");
var s1 = "abcdefghijklmnopqrstuvwxyz123456789000ABC";
var s2 = s1.slice(1, 8);
assertEq(isLatin1(s2), true);
assertEq(s2, "bcdefgh");
@ -76,7 +76,8 @@ function testUndepend() {
// Latin1
var s = "abcdefg".repeat(7);
s.indexOf("def"); // flatten
s = toLatin1(s);
assertEq(isLatin1(s), true);
var dep = s.substr(7);
var res = dep.replace(/abcdef/g, ""); // StrReplaceRegexpRemove undepends.
assertEq(res, "gggggg");

View File

@ -1,7 +1,13 @@
// Latin1
s = toLatin1("a%2b%20def%00A0");
assertEq(decodeURI(s), "a%2b def\x00A0");
assertEq(decodeURIComponent(s), "a+ def\x00A0");
s = "a%2b%20def%00A0";
res = decodeURI(s);
assertEq(res, "a%2b def\x00A0");
assertEq(isLatin1(res), true);
res = decodeURIComponent(s);
assertEq(res, "a+ def\x00A0");
assertEq(isLatin1(res), true);
// TwoByte
s += "\u1200";
@ -10,7 +16,7 @@ assertEq(decodeURIComponent(s), "a+ def\x00A0\u1200");
// Latin1 malformed
try {
decodeURI(toLatin1("abc%80"));
decodeURI("abc%80");
assertEq(0, 1);
} catch(e) {
assertEq(e instanceof URIError, true);
@ -25,12 +31,22 @@ try {
}
// Latin1
assertEq(encodeURI(toLatin1("a%2b def\x00A0")), "a%252b%20def%00A0");
assertEq(encodeURIComponent(toLatin1("a+ def\x00A0")), "a%2B%20def%00A0");
res = encodeURI("a%2b def\x00A0");
assertEq(res, "a%252b%20def%00A0");
assertEq(isLatin1(res), true);
res = encodeURIComponent("a+ def\x00A0");
assertEq(res, "a%2B%20def%00A0");
assertEq(isLatin1(res), true);
// TwoByte
assertEq(encodeURI("a%2b def\x00A0\u1200"), "a%252b%20def%00A0%E1%88%80");
assertEq(encodeURIComponent("a+ def\x00A0\u1200"), "a%2B%20def%00A0%E1%88%80");
res = encodeURI("a%2b def\x00A0\u1200");
assertEq(res, "a%252b%20def%00A0%E1%88%80");
assertEq(isLatin1(res), true);
res = encodeURIComponent("a+ def\x00A0\u1200");
assertEq(res, "a%2B%20def%00A0%E1%88%80");
assertEq(isLatin1(res), true);
// TwoByte malformed
try {

View File

@ -1,8 +1,10 @@
// Latin1
s = toLatin1("a%2b%20def%00A0");
assertEq(unescape(s), "a+ def\x00A0");
s = "a%2b%20def%00A0";
res = unescape(s);
assertEq(res, "a+ def\x00A0");
assertEq(isLatin1(res), true);
s = toLatin1("a%2b%20def%00A0%u1200");
s = "a%2b%20def%00A0%u1200";
assertEq(unescape(s), "a+ def\x00A0\u1200");
// TwoByte
@ -10,9 +12,13 @@ s += "\u1200";
assertEq(unescape(s), "a+ def\x00A0\u1200\u1200");
// Latin1
s = toLatin1("abc \u00ff");
assertEq(escape(s), "abc%20%FF");
s = "abc \u00ff";
res = escape(s);
assertEq(res, "abc%20%FF");
assertEq(isLatin1(res), true);
// TwoByte
s += "\u1200";
assertEq(escape(s), "abc%20%FF%u1200");
res = escape(s);
assertEq(res, "abc%20%FF%u1200");
assertEq(isLatin1(res), true);

View File

@ -3,7 +3,7 @@ function f(s) {
var z = eval(s);
assertEq(z, 8);
}
var s = toLatin1("x + y");
var s = "x + y";
f(s); // Latin1
f(s);
f("x + y;/*\u1200*/"); // TwoByte

View File

@ -1,8 +1,8 @@
function test() {
var arg1TwoByte = "arg1\u1200";
var arg2Latin1 = toLatin1("arg2");
var arg2Latin1 = "arg2";
var bodyLatin1 = toLatin1("return arg2 * 3");
var bodyLatin1 = "return arg2 * 3";
var f = Function(arg1TwoByte, arg2Latin1, bodyLatin1);
assertEq(f(10, 20), 60);

View File

@ -1,21 +1,21 @@
function test() {
var arr = new Int8Array(400);
var idx = toLatin1("384");
var idx = "384";
arr[idx] = 9;
assertEq(arr[idx], 9);
arr[idx] = 10;
assertEq(arr[384], 10);
idx = toLatin1("512");
idx = "512";
assertEq(arr[idx], undefined);
assertEq(arr[toLatin1("byteLength")], 400);
assertEq(arr[(() => "byteLength")()], 400);
var o = {};
Object.defineProperty(o, idx, {value: 123});
assertEq(o[512], 123);
var propLatin1 = toLatin1("foobar");
var propLatin1 = "foobar";
o[propLatin1] = 3;
assertEq(o.foobar, 3);

View File

@ -1,3 +1,7 @@
function toLatin1(s) {
assertEq(isLatin1(s), true);
return s;
}
function testLastIndexOf() {
var s1 = toLatin1("abcdefgh123456\u0081defg");
var s2 = toLatin1("456\u0081de");

View File

@ -1,9 +1,9 @@
function testCharCodeAt() {
var s = toLatin1("abcdefghijklm1234567891000");
var s = "abcdefghijklm1234567891000";
for (var i=0; i<10; i++)
assertEq(s.charCodeAt(i), 97 + i);
var rope = s + toLatin1("blah");
var rope = s + "blah";
assertEq(rope.charCodeAt(s.length + 3), 104);
rope = s + "Foo987";
@ -16,12 +16,12 @@ function testCharCodeAt() {
testCharCodeAt();
function testCharAt() {
var s = toLatin1("abcdefghijklm100000002345");
var s = "abcdefghijklm100000002345";
assertEq(s.charAt(0), "a");
assertEq(s.charAt(s.length-1), "5");
assertEq(s.charAt(s.length), "");
var rope = s + toLatin1("abcZYX");
var rope = s + "abcZYX";
assertEq(rope.charAt(s.length + 3), "Z");
rope = s + "Foo987";
@ -41,7 +41,7 @@ function testIndex(s) {
assertEq(rope[7], "\u0512");
}
var s = toLatin1("abcdefghijklm123456");
var s = "abcdefghijklm123456";
testIndex(s);
testIndex(s);
testIndex(s);

View File

@ -1,10 +1,20 @@
function toLatin1(s) {
assertEq(isLatin1(s), true);
return s;
}
var arrLatin1 = [toLatin1("abc1"), toLatin1("abc\u00A0")];
assertEq(arrLatin1.join(toLatin1("sep\u00ff")), "abc1sep\xFFabc\xA0");
var res = arrLatin1.join(toLatin1("sep\u00ff"));
assertEq(res, "abc1sep\xFFabc\xA0");
assertEq(isLatin1(res), true);
var arrTwoByte = [toLatin1("abc2"), "def\u1200"];
assertEq(arrTwoByte.join(toLatin1("sep\u00fe")), "abc2sep\xFEdef\u1200");
assertEq(arrLatin1.join(toLatin1("-")), "abc1-abc\xA0");
res = arrLatin1.join(toLatin1("-"));
assertEq(res, "abc1-abc\xA0");
assertEq(isLatin1(res), true);
assertEq(arrTwoByte.join(toLatin1("7")), "abc27def\u1200");
assertEq(arrLatin1.join("\u1200"), "abc1\u1200abc\xA0");

View File

@ -1,6 +1,7 @@
function testBasic() {
// Latin1
var s = toLatin1('[1, 2, "foo", "bar\\r\\n", {"xyz": 3}, [1, 2, 3]]');
var s = '[1, 2, "foo", "bar\\r\\n", {"xyz": 3}, [1, 2, 3]]';
assertEq(isLatin1(s), true);
assertEq(JSON.stringify(JSON.parse(s)), '[1,2,"foo","bar\\r\\n",{"xyz":3},[1,2,3]]');
// TwoByte
@ -13,7 +14,7 @@ function testErrorPos() {
// Make sure the error location is calculated correctly.
// Latin1
var s = toLatin1('[1, \n2,');
var s = '[1, \n2,';
try {
JSON.parse(s);
assertEq(0, 1);
@ -35,8 +36,9 @@ testErrorPos();
function testEvalHack() {
// Latin1
var arr = eval(toLatin1("[1, 2, 3, \"abc\"]"));
var arr = eval("[1, 2, 3, \"abc\"]");
assertEq(JSON.stringify(arr), '[1,2,3,"abc"]');
assertEq(isLatin1(JSON.stringify(arr)), true);
// TwoByte
arr = eval("[1, 2, 3, \"abc\u1200\"]");
@ -46,7 +48,7 @@ testEvalHack();
function testEvalHackNotJSON() {
// Latin1
var arr = eval(toLatin1("[]; var q; [1, 2, 3, \"abc\"]"));
var arr = eval("[]; var q; [1, 2, 3, \"abc\"]");
assertEq(JSON.stringify(arr), '[1,2,3,"abc"]');
// TwoByte
@ -65,8 +67,10 @@ testEvalHackNotJSON();
function testQuote() {
// Latin1
var s = toLatin1("abc--\x05-'\"-\n-\u00ff++");
assertEq(JSON.stringify(s), '"abc--\\u0005-\'\\"-\\n-\xFF++"');
var s = "abc--\x05-'\"-\n-\u00ff++";
var res = JSON.stringify(s);
assertEq(res, '"abc--\\u0005-\'\\"-\\n-\xFF++"');
assertEq(isLatin1(res), true);
// TwoByte
s += "\uAAAA";

View File

@ -1,6 +1,3 @@
if (!isLatin1("foo")) //TODO: remove this when removing latin1 flag
quit();
function assertLatin1(s) {
assertEq(isLatin1(s), true, "String: " + s);
}

View File

@ -1,5 +1,8 @@
var s1 = toLatin1("abcdefg12345");
var s2 = toLatin1('foo"bar');
var s1 = "abcdefg12345";
var s2 = 'foo"bar';
assertEq(isLatin1(s1), true);
assertEq(isLatin1(s2), true);
function test() {
assertEq(s1.valueOf(), s1);

View File

@ -1,3 +1,7 @@
function toLatin1(s) {
assertEq(isLatin1(s), true);
return s;
}
function testParseInt() {
// Latin1
assertEq(parseInt(toLatin1("12345abc")), 12345);

View File

@ -1,7 +1,11 @@
var s = toLatin1('Abc1234"\'\t987\u00ff');
var s = 'Abc1234"\'\t987\u00ff';
assertEq(isLatin1(s), true);
assertEq(s.toSource(), '(new String("Abc1234\\"\'\\t987\\xFF"))');
assertEq(s.quote(), '"Abc1234\\"\'\\t987\\xFF"');
var res = s.quote();
assertEq(res, '"Abc1234\\"\'\\t987\\xFF"');
assertEq(isLatin1(res), true);
s = 'Abc1234"\'\t\u1200987\u00ff';
assertEq(isLatin1(s), false);
assertEq(s.toSource(), '(new String("Abc1234\\"\'\\t\\u1200987\\xFF"))');
assertEq(s.quote(), '"Abc1234\\"\'\\t\\u1200987\\xFF"');

View File

@ -1,3 +1,8 @@
function toLatin1(s) {
assertEq(isLatin1(s), true);
return s;
}
// Latin1
var re = new RegExp(toLatin1("foo[bB]a\\r"), toLatin1("im"));
assertEq(isLatin1(re.source), true);

View File

@ -1,3 +1,7 @@
function toLatin1(s) {
assertEq(isLatin1(s), true);
return s;
}
function testDollarReplacement() {
// Latin1 input, pat and replacement
var s = toLatin1("Foobarbaz123");
@ -7,6 +11,7 @@ function testDollarReplacement() {
assertEq(s.replace(pat, toLatin1("A$`A")), "FooAFooAbaz123");
assertEq(s.replace(pat, toLatin1("A$&A")), "FooAbarAbaz123");
assertEq(s.replace(pat, toLatin1("A$'A")), "FooAbaz123Abaz123");
assertEq(isLatin1(s.replace(pat, "A$'A")), true);
// Latin1 input and pat, TwoByte replacement
assertEq(s.replace(pat, "A\u1200"), "FooA\u1200baz123");
@ -43,13 +48,20 @@ testDollarReplacement();
function testRegExp() {
var s = toLatin1("Foobar123bar234");
assertEq(s.replace(/bar\d\d/, "456"), "Foo4563bar234");
var res = s.replace(/bar\d\d/, "456");
assertEq(res, "Foo4563bar234");
assertEq(isLatin1(res), true);
// Latin1 input and replacement
var re1 = /bar\d\d/;
res = s.replace(re1, toLatin1("789"));
assertEq(res, "Foo7893bar234");
assertEq(isLatin1(res), true);
var re2 = /bar\d\d/g;
assertEq(s.replace(re1, toLatin1("789")), "Foo7893bar234");
assertEq(s.replace(re2, toLatin1("789\u00ff")), "Foo789\u00ff3789\u00ff4");
res = s.replace(re2, toLatin1("789\u00ff"));
assertEq(res, "Foo789\u00ff3789\u00ff4");
assertEq(isLatin1(res), true);
// Latin1 input, TwoByte replacement
assertEq(s.replace(re1, "789\u1200"), "Foo789\u12003bar234");
@ -75,6 +87,7 @@ function testRegExpDollar() {
assertEq(s.replace(re1, toLatin1("--$&--")), "Foo--bar12--3bar2345");
assertEq(s.replace(re2, toLatin1("--$'\u00ff--")), "Foo--3bar2345\xFF--3--45\xFF--45");
assertEq(s.replace(re2, toLatin1("--$`--")), "Foo--Foo--3--Foobar123--45");
assertEq(isLatin1(s.replace(re2, toLatin1("--$`--"))), true);
// Latin1 input, TwoByte replacement
assertEq(s.replace(re1, "\u1200$$"), "Foo\u1200$3bar2345");
@ -100,7 +113,9 @@ function testFlattenPattern() {
var s = "abcdef[g]abc";
// Latin1 pattern
assertEq(s.replace(toLatin1("def[g]"), "--$&--", "gi"), "abc--def[g]--abc");
var res = s.replace(toLatin1("def[g]"), "--$&--", "gi");
assertEq(res, "abc--def[g]--abc");
assertEq(isLatin1(res), true);
// TwoByte pattern
s = "abcdef[g]\u1200abc";
@ -111,10 +126,14 @@ testFlattenPattern();
function testReplaceEmpty() {
// Latin1
var s = toLatin1("--abcdefghijkl--abcdefghijkl--abcdefghijkl--abcdefghijkl");
assertEq(s.replace(/abcd[eE]/g, ""), "--fghijkl--fghijkl--fghijkl--fghijkl");
var res = s.replace(/abcd[eE]/g, "");
assertEq(res, "--fghijkl--fghijkl--fghijkl--fghijkl");
assertEq(isLatin1(res), true);
s = "--abcdEf--";
assertEq(s.replace(/abcd[eE]/g, ""), "--f--");
res = s.replace(/abcd[eE]/g, "");
assertEq(res, "--f--");
assertEq(isLatin1(res), true);
// TwoByte
s = "--abcdefghijkl--abcdefghijkl--abcdefghijkl--abcdefghijkl\u1200";

View File

@ -1,3 +1,7 @@
function toLatin1(s) {
assertEq(isLatin1(s), true);
return s;
}
function testSearchFlat() {
var s1 = toLatin1("fooBar12345");
var s2 = toLatin1("Bar1");

View File

@ -1,19 +1,22 @@
// Latin1
var s = toLatin1("abcdef,g,,");
var res = s.split(toLatin1(","));
var s = "abcdef,g,,";
var res = s.split(",");
assertEq(res[0], "abcdef");
assertEq(isLatin1(res[0]), true);
assertEq(res[1], "g");
assertEq(res[2], "");
assertEq(res[3], "");
s = toLatin1("abcdef,gh,,");
s = "abcdef,gh,,";
res = s.split("\u1200");
assertEq(res[0], "abcdef,gh,,");
assertEq(isLatin1(res[0]), true);
// TwoByte
s = "abcdef\u1200\u1200,g,,";
res = s.split(",");
assertEq(res[0], "abcdef\u1200\u1200");
assertEq(isLatin1(res[0]), false);
assertEq(res[1], "g");
assertEq(res[2], "");
assertEq(res[3], "");

View File

@ -1,3 +1,7 @@
function toLatin1(s) {
assertEq(isLatin1(s), true);
return s;
}
function testStartsWith() {
var s1 = toLatin1("abc\u0099def");
var s2 = toLatin1("abc\u0099d");

View File

@ -1,9 +1,9 @@
// Latin1
var s = deserialize(serialize(toLatin1("foo123\u00EE")));
var s = deserialize(serialize("foo123\u00EE"));
assertEq(s, "foo123\u00EE");
assertEq(isLatin1(s), true);
var o = deserialize(serialize(new String(toLatin1("foo\u00EE"))));
var o = deserialize(serialize(new String("foo\u00EE")));
assertEq(typeof o, "object");
assertEq(o.valueOf(), "foo\u00EE");
assertEq(isLatin1(o.valueOf()), true);

View File

@ -1,5 +1,6 @@
function testToLowerCase() {
var s1 = toLatin1("abcdefgABCDEFGH 123456");
var s1 = "abcdefgABCDEFGH 123456";
assertEq(isLatin1(s1), true);
// Latin1
var s2 = s1.toLowerCase();
@ -26,7 +27,8 @@ function testToLowerCase() {
testToLowerCase();
function testToUpperCase() {
var s1 = toLatin1("abcdefgABCDEFGH 12345");
var s1 = "abcdefgABCDEFGH 12345";
assertEq(isLatin1(s1), true);
// Latin1
var s2 = s1.toUpperCase();
@ -44,7 +46,7 @@ function testToUpperCase() {
// Tricky case: Latin1 character \u00FF maps to \u0178, a
// non-Latin1 character.
s1 = toLatin1("ABC\u00FF");
s1 = "ABC\u00FF";
assertEq(isLatin1(s1), true);
s2 = s1.toUpperCase();
assertEq(isLatin1(s2), false);

View File

@ -1,3 +1,7 @@
function toLatin1(s) {
assertEq(isLatin1(s), true);
return s;
}
function testToNumber() {
// Latin1
assertEq(+toLatin1("12345.6"), 12345.6);

View File

@ -1,6 +1,7 @@
function test() {
// Latin1
var s = toLatin1(" \r\t\n\u00A0foo 123\t \r\n\u00A0");
var s = " \r\t\n\u00A0foo 123\t \r\n\u00A0";
assertEq(isLatin1(s), true);
var res = s.trim();
assertEq(isLatin1(res), true);
@ -14,7 +15,7 @@ function test() {
assertEq(isLatin1(res), true);
assertEq(res, " \r\t\n\u00A0foo 123");
res = toLatin1("foo 1234").trim();
res = "foo 1234".trim();
assertEq(isLatin1(res), true);
assertEq(res, "foo 1234");

View File

@ -4515,26 +4515,6 @@ IsLatin1(JSContext *cx, unsigned argc, Value *vp)
return true;
}
static bool
ToLatin1(JSContext *cx, unsigned argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
if (!args.get(0).isString() || !args[0].toString()->isLinear()) {
args.rval().setUndefined();
return true;
}
if (args[0].toString()->hasLatin1Chars()) {
args.rval().set(args[0]);
return true;
}
JSLinearString *s = &args[0].toString()->asLinear();
s->debugUnsafeConvertToLatin1();
args.rval().setString(s);
return true;
}
static const JSFunctionSpecWithHelp shell_functions[] = {
JS_FN_HELP("version", Version, 0, 0,
"version([number])",
@ -4970,10 +4950,6 @@ static const JSFunctionSpecWithHelp fuzzing_unsafe_functions[] = {
"untrap(fun[, pc])",
" Remove a trap."),
JS_FN_HELP("toLatin1", ToLatin1, 1, 0,
"toLatin1(s)",
" Convert the string's characters to Latin1."),
JS_FN_HELP("withSourceHook", WithSourceHook, 1, 0,
"withSourceHook(hook, fun)",
" Set this JS runtime's lazy source retrieval hook (that is, the hook\n"

View File

@ -14,7 +14,7 @@ TBPL_FLAGS = [
[], # no flags, normal baseline and ion
['--ion-eager', '--ion-offthread-compile=off'], # implies --baseline-eager
['--ion-eager', '--ion-offthread-compile=off', '--ion-check-range-analysis', '--no-sse3'],
['--baseline-eager', '--latin1-strings'],
['--baseline-eager'],
['--baseline-eager', '--no-fpu'],
['--no-baseline', '--no-ion'],
]

View File

@ -150,27 +150,6 @@ JSString::equals(const char *s)
}
#endif /* DEBUG */
void
JSLinearString::debugUnsafeConvertToLatin1()
{
// Temporary helper function to test changes for bug 998392.
MOZ_ASSERT(hasTwoByteChars());
MOZ_ASSERT(!hasBase());
size_t len = length();
const jschar *twoByteChars = rawTwoByteChars();
Latin1Char *latin1Chars = (Latin1Char *)twoByteChars;
for (size_t i = 0; i < len; i++) {
MOZ_ASSERT((twoByteChars[i] & 0xff00) == 0);
latin1Chars[i] = Latin1Char(twoByteChars[i]);
}
latin1Chars[len] = '\0';
d.u1.flags |= LATIN1_CHARS_BIT;
}
template <typename CharT>
static MOZ_ALWAYS_INLINE bool
AllocChars(ThreadSafeContext *maybecx, size_t length, CharT **chars, size_t *capacity)

View File

@ -649,9 +649,6 @@ class JSLinearString : public JSString
JS::AutoCheckCannotGC nogc;
return hasLatin1Chars() ? latin1Chars(nogc)[index] : twoByteChars(nogc)[index];
}
/* Temporary, unsafe helper function for bug 998392. Don't use for anything else. */
void debugUnsafeConvertToLatin1();
};
JS_STATIC_ASSERT(sizeof(JSLinearString) == sizeof(JSString));