- optimized Regexp.prototype.exec

- optimized String.prototype.replace
- optimized 'arguments' object creation
- optimized access to non strict 'arguments' elements
This commit is contained in:
Fabrice Bellard
2025-11-22 11:00:50 +01:00
parent 7ab23413b8
commit 9f11034a5a
3 changed files with 568 additions and 312 deletions

View File

@@ -1,4 +1,4 @@
- micro optimizations (15% faster on bench-v8)
- micro optimizations (30% faster on bench-v8)
- added resizable array buffers
- added ArrayBuffer.prototype.transfer
- added the Iterator object and methods

820
quickjs.c

File diff suppressed because it is too large Load Diff

View File

@@ -547,6 +547,43 @@ function typed_array_write(n)
return len * n;
}
function arguments_test()
{
return arguments[0] + arguments[1] + arguments[2];
}
function arguments_read(n)
{
sum = 0;
for(j = 0; j < n; j++) {
sum += arguments_test(j, j, j);
sum += arguments_test(j, j, j);
sum += arguments_test(j, j, j);
sum += arguments_test(j, j, j);
}
global_res = sum;
return n * 4;
}
function arguments_strict_test()
{
"use strict";
return arguments[0] + arguments[1] + arguments[2];
}
function arguments_strict_read(n)
{
sum = 0;
for(j = 0; j < n; j++) {
sum += arguments_strict_test(j, j, j);
sum += arguments_strict_test(j, j, j);
sum += arguments_strict_test(j, j, j);
sum += arguments_strict_test(j, j, j);
}
global_res = sum;
return n * 4;
}
var global_var0;
function global_read(n)
@@ -944,6 +981,18 @@ function regexp_utf16(n)
return n * 1000;
}
function regexp_replace(n)
{
var i, j, r, s;
s = "the quick abc brown fox jumped abc over the lazy dog"
for(j = 0; j < n; j++) {
for(i = 0; i < 1000; i++)
r = s.replace(/abc /g, "-");
global_res = r;
}
return n * 1000;
}
function string_length(n)
{
var str, sum, j;
@@ -1408,6 +1457,8 @@ function main(argc, argv, g)
array_pop,
typed_array_read,
typed_array_write,
arguments_read,
arguments_strict_read,
global_read,
global_write,
global_write_strict,
@@ -1431,6 +1482,7 @@ function main(argc, argv, g)
math_min,
regexp_ascii,
regexp_utf16,
regexp_replace,
string_length,
string_build1,
string_build1x,