mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.2 KiB
66 lines
1.2 KiB
12 years ago
|
/*
|
||
|
* Large join() needs a valstack check. Even larger joins run
|
||
|
* out of valstack unless the join is done in stages.
|
||
|
*
|
||
|
* These were broken at some point.
|
||
|
*/
|
||
|
|
||
|
/*===
|
||
|
100
|
||
|
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
|
||
|
===*/
|
||
|
|
||
|
/* 100 elements */
|
||
|
tmp = [
|
||
|
0,1,2,3,4,5,6,7,8,9,
|
||
|
0,1,2,3,4,5,6,7,8,9,
|
||
|
0,1,2,3,4,5,6,7,8,9,
|
||
|
0,1,2,3,4,5,6,7,8,9,
|
||
|
0,1,2,3,4,5,6,7,8,9,
|
||
|
0,1,2,3,4,5,6,7,8,9,
|
||
|
0,1,2,3,4,5,6,7,8,9,
|
||
|
0,1,2,3,4,5,6,7,8,9,
|
||
|
0,1,2,3,4,5,6,7,8,9,
|
||
|
0,1,2,3,4,5,6,7,8,9
|
||
|
];
|
||
|
|
||
|
print(tmp.length);
|
||
|
print(tmp.join(''));
|
||
|
|
||
|
/*===
|
||
|
building
|
||
11 years ago
|
1000000
|
||
12 years ago
|
joining
|
||
|
1000000
|
||
11 years ago
|
checking
|
||
|
ok
|
||
12 years ago
|
===*/
|
||
|
|
||
11 years ago
|
/* This was broken at some point: joining happened naively through the
|
||
|
* valstack whose size topped out for large joins.
|
||
12 years ago
|
*/
|
||
|
|
||
|
tmp = [];
|
||
11 years ago
|
var i;
|
||
11 years ago
|
var res;
|
||
11 years ago
|
var limit = 1e6;
|
||
12 years ago
|
|
||
|
print('building');
|
||
11 years ago
|
for (i = 0; i < limit; i++) {
|
||
11 years ago
|
tmp[tmp.length] = String.fromCharCode(i % 65536);
|
||
12 years ago
|
}
|
||
11 years ago
|
print(tmp.length);
|
||
12 years ago
|
|
||
|
print('joining');
|
||
11 years ago
|
res = tmp.join('');
|
||
|
print(res.length);
|
||
|
|
||
|
print('checking');
|
||
11 years ago
|
for (i = 0; i < limit; i++) {
|
||
11 years ago
|
if (res.charCodeAt(i) !== (i % 65536)) {
|
||
|
throw new Error('invalid char at offset ' + i);
|
||
|
}
|
||
|
}
|
||
12 years ago
|
|
||
10 years ago
|
print('ok');
|