Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Feature JsArray #1746

Closed
wants to merge 1 commit into from
Closed

Conversation

HalidOdat
Copy link
Member

This PR introduces a new API for JavaScript builtin objects in Rust (such as Array, Map, Proxy, etc). Rather than just expose the raw builtin functions as discussed here #1692 (though having raw API exposed may be nice as well), In this PR we introduce a very light wrapper around the raw API, for a more pleasant user experience. The wrapper implements functions that are specific to the wrapper type (for Array this would be methods like pop, push, etc) as well as implementing Deref<Target = JsObject> so we can call JsObject functions without converting to JsObject and Into<JsValue> for easy to JsValue conversions.

Please check jsarray.rs in the examples

@HalidOdat HalidOdat added enhancement New feature or request builtins PRs and Issues related to builtins/intrinsics API labels Dec 15, 2021
@HalidOdat HalidOdat added this to the v0.14.0 milestone Dec 15, 2021
@codecov
Copy link

codecov bot commented Dec 15, 2021

Codecov Report

Merging #1746 (e1c4fec) into main (46f96d4) will decrease coverage by 0.27%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1746      +/-   ##
==========================================
- Coverage   55.57%   55.30%   -0.28%     
==========================================
  Files         199      200       +1     
  Lines       17760    17848      +88     
==========================================
  Hits         9871     9871              
- Misses       7889     7977      +88     
Impacted Files Coverage Δ
boa/src/object/jsarray.rs 0.00% <0.00%> (ø)
boa/src/object/mod.rs 29.09% <ø> (ø)
boa/src/value/conversions.rs 71.73% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 46f96d4...e1c4fec. Read the comment docs.

@github-actions
Copy link

github-actions bot commented Dec 15, 2021

Test262 conformance changes

VM implementation

Test result main count PR count difference
Total 87,912 87,912 0
Passed 41,366 41,366 0
Ignored 21,153 21,153 0
Failed 25,393 25,393 0
Panics 0 0 0
Conformance 47.05% 47.05% 0.00%

jasonwilliams
jasonwilliams approved these changes Dec 15, 2021
boa/examples/jsarray.rs Outdated Show resolved Hide resolved
boa/src/object/jsarray.rs Outdated Show resolved Hide resolved
@jasonwilliams
Copy link
Member

Sounds good to me, the exposed API could work quite well. I'm assuming src/object will eventually have all the APIs we plan to expose?

@HalidOdat HalidOdat changed the title Feature JsArrayObject Feature JsArray Dec 16, 2021
@HalidOdat
Copy link
Member Author

Sounds good to me, the exposed API could work quite well. I'm assuming src/object will eventually have all the APIs we plan to expose?

Yeah, plan to add others like JsMap, JsSet, etc

Copy link
Member

@Razican Razican left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this :) It just needs a re-base, and maybe fixing that TODO, but all in all, I like this approach to improve the API, it should be much easier to use from Rust.

Copy link
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just some API suggestions that I would like to see implemented :)

boa/src/object/jsarray.rs Outdated Show resolved Hide resolved
@HalidOdat HalidOdat force-pushed the feature/jsarrayobject branch 2 times, most recently from af59c00 to 8a7670e Compare February 16, 2022 10:36
@github-actions
Copy link

Benchmark for 7676a2b

Click to view benchmark
Test Base PR %
Arithmetic operations (Compiler) 387.9±1.82ns 394.6±0.64ns +1.73%
Arithmetic operations (Execution) 1967.9±5.56ns 1972.6±16.70ns +0.24%
Arithmetic operations (Parser) 5.4±0.00µs 5.6±0.02µs +3.70%
Array access (Compiler) 822.5±1.79ns 820.1±1.69ns -0.29%
Array access (Execution) 10.5±0.07µs 10.4±0.04µs -0.95%
Array access (Parser) 11.8±0.03µs 11.9±0.02µs +0.85%
Array creation (Compiler) 1171.0±5.37ns 1187.5±3.42ns +1.41%
Array creation (Execution) 3.1±0.00ms 3.1±0.00ms 0.00%
Array creation (Parser) 13.2±0.03µs 13.3±0.02µs +0.76%
Array pop (Compiler) 2.8±0.01µs 2.8±0.01µs 0.00%
Array pop (Execution) 1348.7±4.73µs 1347.5±4.99µs -0.09%
Array pop (Parser) 135.4±0.07µs 138.4±0.13µs +2.22%
Boolean Object Access (Compiler) 686.6±1.17ns 684.2±1.18ns -0.35%
Boolean Object Access (Execution) 7.0±0.03µs 6.9±0.01µs -1.43%
Boolean Object Access (Parser) 14.0±0.01µs 14.3±0.01µs +2.14%
Clean js (Compiler) 2.2±0.01µs 2.2±0.00µs 0.00%
Clean js (Execution) 1490.6±10.99µs 1476.6±11.78µs -0.94%
Clean js (Parser) 28.6±0.05µs 29.0±0.03µs +1.40%
Create Realm 335.0±0.45ns 336.4±4.11ns +0.42%
Dynamic Object Property Access (Compiler) 1144.4±1.99ns 1159.4±3.65ns +1.31%
Dynamic Object Property Access (Execution) 6.9±0.04µs 6.8±0.04µs -1.45%
Dynamic Object Property Access (Parser) 10.6±0.02µs 10.7±0.02µs +0.94%
Fibonacci (Compiler) 1470.8±4.09ns 1447.2±3.07ns -1.60%
Fibonacci (Execution) 2.8±0.00ms 2.7±0.00ms -3.57%
Fibonacci (Parser) 16.0±0.02µs 16.2±0.05µs +1.25%
For loop (Compiler) 1272.5±5.27ns 1286.3±3.06ns +1.08%
For loop (Execution) 43.7±0.17µs 43.6±0.17µs -0.23%
For loop (Parser) 13.7±0.12µs 13.9±0.04µs +1.46%
Mini js (Compiler) 2.1±0.00µs 2.1±0.00µs 0.00%
Mini js (Execution) 1373.5±8.23µs 1361.9±7.61µs -0.84%
Mini js (Parser) 24.9±0.02µs 25.3±0.03µs +1.61%
Number Object Access (Compiler) 642.6±1.11ns 640.9±1.50ns -0.26%
Number Object Access (Execution) 5.4±0.01µs 5.4±0.01µs 0.00%
Number Object Access (Parser) 10.9±0.01µs 11.2±0.01µs +2.75%
Object Creation (Compiler) 953.6±2.12ns 951.5±7.66ns -0.22%
Object Creation (Execution) 6.2±0.02µs 6.2±0.03µs 0.00%
Object Creation (Parser) 9.1±0.05µs 9.3±0.02µs +2.20%
RegExp (Compiler) 1152.7±2.57ns 1133.6±2.74ns -1.66%
RegExp (Execution) 13.0±0.04µs 12.9±0.03µs -0.77%
RegExp (Parser) 10.0±0.02µs 10.1±0.02µs +1.00%
RegExp Creation (Compiler) 1052.8±2.59ns 1037.9±3.26ns -1.42%
RegExp Creation (Execution) 9.9±0.06µs 9.9±0.06µs 0.00%
RegExp Creation (Parser) 8.3±0.01µs 8.5±0.01µs +2.41%
RegExp Literal (Compiler) 1132.0±6.86ns 1133.0±2.58ns +0.09%
RegExp Literal (Execution) 12.9±0.04µs 12.8±0.03µs -0.78%
RegExp Literal (Parser) 8.0±0.02µs 8.1±0.02µs +1.25%
RegExp Literal Creation (Compiler) 1031.0±3.14ns 1038.3±2.67ns +0.71%
RegExp Literal Creation (Execution) 10.0±0.06µs 9.8±0.06µs -2.00%
RegExp Literal Creation (Parser) 6.3±0.02µs 6.4±0.01µs +1.59%
Static Object Property Access (Compiler) 966.2±2.97ns 974.7±3.05ns +0.88%
Static Object Property Access (Execution) 6.4±0.03µs 6.4±0.03µs 0.00%
Static Object Property Access (Parser) 9.8±0.01µs 10.0±0.02µs +2.04%
String Object Access (Compiler) 1028.7±6.55ns 1029.5±26.38ns +0.08%
String Object Access (Execution) 8.7±0.06µs 8.8±0.02µs +1.15%
String Object Access (Parser) 13.9±0.04µs 14.1±0.05µs +1.44%
String comparison (Compiler) 1290.3±2.58ns 1282.1±4.27ns -0.64%
String comparison (Execution) 7.2±0.03µs 7.2±0.02µs 0.00%
String comparison (Parser) 10.8±0.06µs 11.0±0.06µs +1.85%
String concatenation (Compiler) 1047.4±3.09ns 1059.0±4.85ns +1.11%
String concatenation (Execution) 6.2±0.02µs 6.1±0.01µs -1.61%
String concatenation (Parser) 7.4±0.02µs 7.6±0.04µs +2.70%
String copy (Compiler) 876.2±2.59ns 894.1±2.05ns +2.04%
String copy (Execution) 5.3±0.02µs 5.3±0.02µs 0.00%
String copy (Parser) 5.5±0.01µs 5.7±0.04µs +3.64%
Symbols (Compiler) 638.2±2.97ns 632.4±0.71ns -0.91%
Symbols (Execution) 5.1±0.01µs 4.9±0.02µs -3.92%
Symbols (Parser) 4.3±0.01µs 4.3±0.02µs 0.00%

@github-actions
Copy link

Benchmark for 3b831dd

Click to view benchmark
Test Base PR %
Arithmetic operations (Compiler) 395.3±0.58ns 392.6±0.72ns -0.68%
Arithmetic operations (Execution) 1978.5±2.54ns 1985.1±4.36ns +0.33%
Arithmetic operations (Parser) 5.6±0.01µs 5.5±0.01µs -1.79%
Array access (Compiler) 809.6±1.41ns 804.1±2.19ns -0.68%
Array access (Execution) 10.4±0.03µs 10.5±0.04µs +0.96%
Array access (Parser) 12.1±0.02µs 12.0±0.03µs -0.83%
Array creation (Compiler) 1171.8±3.86ns 1178.6±3.96ns +0.58%
Array creation (Execution) 3.1±0.00ms 3.1±0.00ms 0.00%
Array creation (Parser) 13.6±0.04µs 13.5±0.03µs -0.74%
Array pop (Compiler) 2.8±0.01µs 2.7±0.01µs -3.57%
Array pop (Execution) 1343.0±4.32µs 1342.0±4.65µs -0.07%
Array pop (Parser) 138.8±0.27µs 139.0±0.07µs +0.14%
Boolean Object Access (Compiler) 687.9±1.18ns 684.6±1.36ns -0.48%
Boolean Object Access (Execution) 6.7±0.01µs 6.8±0.01µs +1.49%
Boolean Object Access (Parser) 14.5±0.01µs 14.3±0.02µs -1.38%
Clean js (Compiler) 2.2±0.00µs 2.2±0.00µs 0.00%
Clean js (Execution) 1475.0±15.11µs 1471.6±10.31µs -0.23%
Clean js (Parser) 29.2±0.06µs 29.2±0.03µs 0.00%
Create Realm 337.7±0.37ns 334.7±3.57ns -0.89%
Dynamic Object Property Access (Compiler) 1148.9±2.65ns 1167.1±3.68ns +1.58%
Dynamic Object Property Access (Execution) 6.8±0.04µs 6.8±0.04µs 0.00%
Dynamic Object Property Access (Parser) 10.9±0.02µs 10.7±0.02µs -1.83%
Fibonacci (Compiler) 1444.8±2.69ns 1423.2±2.30ns -1.50%
Fibonacci (Execution) 2.7±0.00ms 2.7±0.00ms 0.00%
Fibonacci (Parser) 16.3±0.02µs 16.3±0.02µs 0.00%
For loop (Compiler) 1279.7±3.51ns 1271.1±5.13ns -0.67%
For loop (Execution) 43.6±0.14µs 43.8±0.15µs +0.46%
For loop (Parser) 14.1±0.09µs 13.9±0.03µs -1.42%
Mini js (Compiler) 2.2±0.01µs 2.1±0.00µs -4.55%
Mini js (Execution) 1368.3±29.76µs 1356.9±10.70µs -0.83%
Mini js (Parser) 25.5±0.03µs 25.5±0.09µs 0.00%
Number Object Access (Compiler) 640.1±1.34ns 637.4±1.54ns -0.42%
Number Object Access (Execution) 5.3±0.01µs 5.3±0.02µs 0.00%
Number Object Access (Parser) 11.4±0.03µs 11.2±0.05µs -1.75%
Object Creation (Compiler) 950.0±2.04ns 956.0±2.79ns +0.63%
Object Creation (Execution) 6.2±0.02µs 6.1±0.02µs -1.61%
Object Creation (Parser) 9.4±0.02µs 9.4±0.02µs 0.00%
RegExp (Compiler) 1150.4±3.87ns 1213.4±12.03ns +5.48%
RegExp (Execution) 12.9±0.02µs 12.9±0.04µs 0.00%
RegExp (Parser) 10.2±0.02µs 10.2±0.02µs 0.00%
RegExp Creation (Compiler) 1029.4±3.33ns 1028.0±3.98ns -0.14%
RegExp Creation (Execution) 10.0±0.07µs 9.9±0.05µs -1.00%
RegExp Creation (Parser) 8.6±0.02µs 8.5±0.09µs -1.16%
RegExp Literal (Compiler) 1144.9±5.41ns 1186.6±8.61ns +3.64%
RegExp Literal (Execution) 12.9±0.03µs 12.8±0.04µs -0.78%
RegExp Literal (Parser) 8.3±0.03µs 8.2±0.02µs -1.20%
RegExp Literal Creation (Compiler) 1028.7±2.45ns 1027.6±4.69ns -0.11%
RegExp Literal Creation (Execution) 9.9±0.05µs 9.8±0.05µs -1.01%
RegExp Literal Creation (Parser) 6.5±0.02µs 6.4±0.01µs -1.54%
Static Object Property Access (Compiler) 964.7±2.66ns 966.7±2.76ns +0.21%
Static Object Property Access (Execution) 6.4±0.04µs 6.4±0.03µs 0.00%
Static Object Property Access (Parser) 10.1±0.02µs 10.0±0.02µs -0.99%
String Object Access (Compiler) 1028.8±7.61ns 1028.7±6.05ns -0.01%
String Object Access (Execution) 8.7±0.05µs 8.7±0.03µs 0.00%
String Object Access (Parser) 14.2±0.01µs 14.0±0.02µs -1.41%
String comparison (Compiler) 1292.8±7.49ns 1303.3±4.11ns +0.81%
String comparison (Execution) 7.2±0.03µs 7.3±0.03µs +1.39%
String comparison (Parser) 11.1±0.11µs 11.0±0.06µs -0.90%
String concatenation (Compiler) 1043.6±2.60ns 1066.8±3.44ns +2.22%
String concatenation (Execution) 6.1±0.02µs 6.2±0.02µs +1.64%
String concatenation (Parser) 7.6±0.04µs 7.6±0.03µs 0.00%
String copy (Compiler) 871.6±2.06ns 866.3±1.64ns -0.61%
String copy (Execution) 5.3±0.02µs 5.3±0.02µs 0.00%
String copy (Parser) 5.7±0.03µs 5.7±0.02µs 0.00%
Symbols (Compiler) 631.3±0.75ns 645.1±1.57ns +2.19%
Symbols (Execution) 4.9±0.01µs 4.9±0.02µs 0.00%
Symbols (Parser) 4.4±0.01µs 4.4±0.02µs 0.00%

@github-actions
Copy link

Benchmark for 07e4868

Click to view benchmark
Test Base PR %
Arithmetic operations (Compiler) 459.1±0.77ns 459.6±0.83ns +0.11%
Arithmetic operations (Execution) 2.4±0.00µs 2.4±0.00µs 0.00%
Arithmetic operations (Parser) 6.2±0.00µs 6.2±0.01µs 0.00%
Array access (Compiler) 948.1±0.60ns 963.8±3.19ns +1.66%
Array access (Execution) 12.3±0.05µs 12.4±0.06µs +0.81%
Array access (Parser) 13.8±0.03µs 13.1±0.03µs -5.07%
Array creation (Compiler) 1358.2±2.84ns 1388.0±6.25ns +2.19%
Array creation (Execution) 3.8±0.01ms 3.8±0.01ms 0.00%
Array creation (Parser) 15.7±0.03µs 14.7±0.03µs -6.37%
Array pop (Compiler) 3.3±0.01µs 3.3±0.01µs 0.00%
Array pop (Execution) 1639.1±6.04µs 1641.5±5.91µs +0.15%
Array pop (Parser) 164.6±0.14µs 158.7±0.17µs -3.58%
Boolean Object Access (Compiler) 797.0±2.79ns 810.4±2.54ns +1.68%
Boolean Object Access (Execution) 8.2±0.04µs 8.3±0.04µs +1.22%
Boolean Object Access (Parser) 16.5±0.04µs 15.8±0.03µs -4.24%
Clean js (Compiler) 2.6±0.01µs 2.6±0.01µs 0.00%
Clean js (Execution) 1742.6±9.63µs 1741.5±8.77µs -0.06%
Clean js (Parser) 33.5±0.05µs 31.8±0.07µs -5.07%
Create Realm 392.8±0.52ns 393.7±1.02ns +0.23%
Dynamic Object Property Access (Compiler) 1355.3±4.78ns 1411.2±12.18ns +4.12%
Dynamic Object Property Access (Execution) 8.2±0.04µs 8.2±0.03µs 0.00%
Dynamic Object Property Access (Parser) 12.5±0.03µs 11.8±0.02µs -5.60%
Fibonacci (Compiler) 1709.2±3.26ns 1732.5±3.00ns +1.36%
Fibonacci (Execution) 3.3±0.01ms 3.2±0.01ms -3.03%
Fibonacci (Parser) 19.1±0.03µs 18.0±0.02µs -5.76%
For loop (Compiler) 1516.7±4.55ns 1523.2±6.28ns +0.43%
For loop (Execution) 52.9±0.18µs 53.0±0.16µs +0.19%
For loop (Parser) 16.5±0.04µs 15.6±0.04µs -5.45%
Mini js (Compiler) 2.5±0.01µs 2.6±0.01µs +4.00%
Mini js (Execution) 1605.9±9.08µs 1615.1±9.03µs +0.57%
Mini js (Parser) 29.1±0.04µs 27.7±0.04µs -4.81%
Number Object Access (Compiler) 739.2±3.63ns 755.0±5.76ns +2.14%
Number Object Access (Execution) 6.6±0.02µs 6.5±0.02µs -1.52%
Number Object Access (Parser) 12.6±0.02µs 12.2±0.04µs -3.17%
Object Creation (Compiler) 1130.6±3.35ns 1160.1±4.07ns +2.61%
Object Creation (Execution) 7.4±0.02µs 7.4±0.02µs 0.00%
Object Creation (Parser) 11.0±0.03µs 10.3±0.04µs -6.36%
RegExp (Compiler) 1378.6±3.59ns 1381.4±3.40ns +0.20%
RegExp (Execution) 15.4±0.05µs 15.5±0.06µs +0.65%
RegExp (Parser) 11.8±0.02µs 11.1±0.02µs -5.93%
RegExp Creation (Compiler) 1233.5±7.37ns 1230.9±6.27ns -0.21%
RegExp Creation (Execution) 11.8±0.03µs 11.7±0.03µs -0.85%
RegExp Creation (Parser) 9.9±0.02µs 9.3±0.01µs -6.06%
RegExp Literal (Compiler) 1383.5±5.10ns 1377.5±3.73ns -0.43%
RegExp Literal (Execution) 15.6±0.09µs 15.5±0.06µs -0.64%
RegExp Literal (Parser) 9.4±0.02µs 8.8±0.02µs -6.38%
RegExp Literal Creation (Compiler) 1205.7±5.55ns 1220.8±6.07ns +1.25%
RegExp Literal Creation (Execution) 11.9±0.04µs 11.8±0.04µs -0.84%
RegExp Literal Creation (Parser) 7.5±0.02µs 7.0±0.01µs -6.67%
Static Object Property Access (Compiler) 1156.8±3.59ns 1179.3±3.73ns +1.95%
Static Object Property Access (Execution) 7.8±0.02µs 7.7±0.02µs -1.28%
Static Object Property Access (Parser) 11.7±0.04µs 11.0±0.02µs -5.98%
String Object Access (Compiler) 1208.6±4.91ns 1211.3±4.66ns +0.22%
String Object Access (Execution) 10.3±0.04µs 10.4±0.04µs +0.97%
String Object Access (Parser) 16.2±0.04µs 15.5±0.02µs -4.32%
String comparison (Compiler) 1517.7±7.75ns 1564.6±5.69ns +3.09%
String comparison (Execution) 8.6±0.02µs 8.6±0.06µs 0.00%
String comparison (Parser) 13.3±0.03µs 12.4±0.02µs -6.77%
String concatenation (Compiler) 1270.8±4.33ns 1259.6±4.57ns -0.88%
String concatenation (Execution) 7.3±0.02µs 7.4±0.02µs +1.37%
String concatenation (Parser) 9.1±0.03µs 8.5±0.02µs -6.59%
String copy (Compiler) 1061.7±2.48ns 1053.2±3.46ns -0.80%
String copy (Execution) 6.2±0.04µs 6.3±0.04µs +1.61%
String copy (Parser) 6.7±0.02µs 6.2±0.04µs -7.46%
Symbols (Compiler) 768.4±1.84ns 782.2±1.75ns +1.80%
Symbols (Execution) 6.0±0.02µs 6.0±0.02µs 0.00%
Symbols (Parser) 4.9±0.02µs 4.7±0.02µs -4.08%

boa/src/object/mod.rs Outdated Show resolved Hide resolved
@github-actions
Copy link

Benchmark for ff3f778

Click to view benchmark
Test Base PR %
Arithmetic operations (Compiler) 479.9±1.91ns 481.1±0.92ns +0.25%
Arithmetic operations (Execution) 1942.9±2.17ns 1962.7±2.03ns +1.02%
Arithmetic operations (Parser) 5.5±0.01µs 5.6±0.00µs +1.82%
Array access (Compiler) 1194.3±2.44ns 1041.6±6.42ns -12.79%
Array access (Execution) 10.4±0.03µs 10.4±0.05µs 0.00%
Array access (Parser) 11.9±0.02µs 11.9±0.02µs 0.00%
Array creation (Compiler) 1713.5±4.84ns 1546.6±4.50ns -9.74%
Array creation (Execution) 3.2±0.00ms 3.1±0.00ms -3.13%
Array creation (Parser) 13.3±0.03µs 13.5±0.12µs +1.50%
Array pop (Compiler) 3.3±0.02µs 2.9±0.02µs -12.12%
Array pop (Execution) 1350.7±2.57µs 1350.1±2.76µs -0.04%
Array pop (Parser) 136.7±0.72µs 136.8±0.08µs +0.07%
Boolean Object Access (Compiler) 1046.5±2.78ns 1049.9±2.09ns +0.32%
Boolean Object Access (Execution) 5.5±0.02µs 5.5±0.02µs 0.00%
Boolean Object Access (Parser) 14.0±0.02µs 14.1±0.02µs +0.71%
Clean js (Compiler) 3.2±0.01µs 3.2±0.01µs 0.00%
Clean js (Execution) 1070.5±13.84µs 1069.9±6.96µs -0.06%
Clean js (Parser) 28.7±0.04µs 28.8±0.18µs +0.35%
Create Realm 269.2±0.40ns 306.9±0.43ns +14.00%
Dynamic Object Property Access (Compiler) 1524.0±8.41ns 1351.5±5.69ns -11.32%
Dynamic Object Property Access (Execution) 6.9±0.04µs 6.9±0.04µs 0.00%
Dynamic Object Property Access (Parser) 10.5±0.02µs 10.7±0.02µs +1.90%
Fibonacci (Compiler) 2.2±0.01µs 1954.5±7.31ns -11.16%
Fibonacci (Execution) 2.7±0.00ms 2.7±0.00ms 0.00%
Fibonacci (Parser) 15.9±0.03µs 15.9±0.04µs 0.00%
For loop (Compiler) 1806.8±4.45ns 1652.1±9.76ns -8.56%
For loop (Execution) 41.2±0.12µs 41.0±0.15µs -0.49%
For loop (Parser) 13.8±0.02µs 13.9±0.02µs +0.72%
Mini js (Compiler) 3.1±0.01µs 3.1±0.01µs 0.00%
Mini js (Execution) 986.2±6.15µs 988.7±4.33µs +0.25%
Mini js (Parser) 25.0±0.02µs 25.2±0.03µs +0.80%
Number Object Access (Compiler) 976.8±1.22ns 973.8±1.92ns -0.31%
Number Object Access (Execution) 4.3±0.01µs 4.3±0.01µs 0.00%
Number Object Access (Parser) 11.0±0.02µs 11.1±0.01µs +0.91%
Object Creation (Compiler) 1261.3±5.51ns 1178.7±11.01ns -6.55%
Object Creation (Execution) 6.3±0.03µs 6.2±0.04µs -1.59%
Object Creation (Parser) 9.1±0.02µs 9.2±0.02µs +1.10%
RegExp (Compiler) 1536.3±4.85ns 1400.3±13.75ns -8.85%
RegExp (Execution) 12.8±0.02µs 12.6±0.03µs -1.56%
RegExp (Parser) 9.9±0.02µs 10.1±0.01µs +2.02%
RegExp Creation (Compiler) 1309.8±4.75ns 1186.3±6.36ns -9.43%
RegExp Creation (Execution) 9.8±0.05µs 9.6±0.06µs -2.04%
RegExp Creation (Parser) 8.3±0.02µs 8.4±0.01µs +1.20%
RegExp Literal (Compiler) 1542.4±4.87ns 1385.4±9.90ns -10.18%
RegExp Literal (Execution) 12.8±0.02µs 12.7±0.04µs -0.78%
RegExp Literal (Parser) 8.0±0.02µs 8.1±0.01µs +1.25%
RegExp Literal Creation (Compiler) 1321.7±13.17ns 1182.7±7.49ns -10.52%
RegExp Literal Creation (Execution) 9.8±0.05µs 9.7±0.05µs -1.02%
RegExp Literal Creation (Parser) 6.3±0.01µs 6.4±0.01µs +1.59%
Static Object Property Access (Compiler) 1312.6±2.24ns 1351.9±90.20ns +2.99%
Static Object Property Access (Execution) 6.5±0.03µs 6.4±0.03µs -1.54%
Static Object Property Access (Parser) 9.8±0.02µs 9.9±0.01µs +1.02%
String Object Access (Compiler) 1363.1±3.30ns 1360.0±3.54ns -0.23%
String Object Access (Execution) 7.2±0.03µs 7.3±0.04µs +1.39%
String Object Access (Parser) 13.7±0.02µs 13.9±0.04µs +1.46%
String comparison (Compiler) 2.0±0.00µs 2.1±0.01µs +5.00%
String comparison (Execution) 6.0±0.01µs 6.0±0.01µs 0.00%
String comparison (Parser) 10.8±0.02µs 10.9±0.01µs +0.93%
String concatenation (Compiler) 1574.5±11.90ns 1564.7±11.59ns -0.62%
String concatenation (Execution) 5.5±0.02µs 5.4±0.02µs -1.82%
String concatenation (Parser) 7.4±0.01µs 7.5±0.04µs +1.35%
String copy (Compiler) 1201.8±2.91ns 1234.0±10.35ns +2.68%
String copy (Execution) 5.0±0.03µs 4.9±0.02µs -2.00%
String copy (Parser) 5.5±0.02µs 5.6±0.02µs +1.82%
Symbols (Compiler) 812.5±1.37ns 753.4±1.80ns -7.27%
Symbols (Execution) 4.7±0.01µs 4.7±0.01µs 0.00%
Symbols (Parser) 4.3±0.01µs 4.3±0.01µs 0.00%

@github-actions
Copy link

Benchmark for bd05fd5

Click to view benchmark
Test Base PR %
Arithmetic operations (Compiler) 640.5±34.33ns 638.6±34.99ns -0.30%
Arithmetic operations (Execution) 2.3±0.12µs 2.2±0.18µs -4.35%
Arithmetic operations (Parser) 6.1±0.46µs 6.3±0.46µs +3.28%
Array access (Compiler) 1447.1±86.29ns 1453.3±109.86ns +0.43%
Array access (Execution) 12.4±0.67µs 12.7±0.80µs +2.42%
Array access (Parser) 13.1±0.93µs 13.2±0.88µs +0.76%
Array creation (Compiler) 2.1±0.15µs 2.1±0.14µs 0.00%
Array creation (Execution) 3.8±0.18ms 3.8±0.21ms 0.00%
Array creation (Parser) 14.0±0.89µs 14.7±1.16µs +5.00%
Array pop (Compiler) 3.9±0.26µs 3.9±0.33µs 0.00%
Array pop (Execution) 1571.5±95.33µs 1543.2±96.13µs -1.80%
Array pop (Parser) 162.1±14.14µs 163.9±10.55µs +1.11%
Boolean Object Access (Compiler) 1296.5±67.09ns 1325.9±81.58ns +2.27%
Boolean Object Access (Execution) 6.9±0.29µs 6.4±0.44µs -7.25%
Boolean Object Access (Parser) 15.2±1.09µs 14.9±0.98µs -1.97%
Clean js (Compiler) 4.0±0.20µs 4.0±0.17µs 0.00%
Clean js (Execution) 1321.9±66.71µs 1267.1±82.93µs -4.15%
Clean js (Parser) 30.9±2.47µs 31.5±1.79µs +1.94%
Create Realm 308.1±24.50ns 328.8±32.68ns +6.72%
Dynamic Object Property Access (Compiler) 1820.9±130.88ns 1821.5±142.95ns +0.03%
Dynamic Object Property Access (Execution) 8.3±0.59µs 8.6±0.47µs +3.61%
Dynamic Object Property Access (Parser) 11.8±0.81µs 11.6±0.90µs -1.69%
Fibonacci (Compiler) 2.7±0.21µs 2.6±0.18µs -3.70%
Fibonacci (Execution) 3.6±0.18ms 3.5±0.15ms -2.78%
Fibonacci (Parser) 17.5±1.06µs 17.6±1.19µs +0.57%
For loop (Compiler) 2.2±0.13µs 2.2±0.17µs 0.00%
For loop (Execution) 51.0±3.50µs 51.1±3.03µs +0.20%
For loop (Parser) 15.2±1.06µs 14.9±1.08µs -1.97%
Mini js (Compiler) 4.0±0.28µs 3.9±0.24µs -2.50%
Mini js (Execution) 1165.8±68.62µs 1095.8±69.34µs -6.00%
Mini js (Parser) 27.1±1.97µs 27.8±1.73µs +2.58%
Number Object Access (Compiler) 1229.4±91.70ns 1229.9±77.10ns +0.04%
Number Object Access (Execution) 5.0±0.35µs 4.9±0.31µs -2.00%
Number Object Access (Parser) 11.6±0.81µs 12.4±0.97µs +6.90%
Object Creation (Compiler) 1601.4±94.45ns 1642.1±78.72ns +2.54%
Object Creation (Execution) 7.6±0.48µs 7.9±0.41µs +3.95%
Object Creation (Parser) 9.9±0.63µs 9.8±0.76µs -1.01%
RegExp (Compiler) 1926.7±104.74ns 1928.3±139.42ns +0.08%
RegExp (Execution) 15.0±0.81µs 16.1±1.12µs +7.33%
RegExp (Parser) 11.0±0.92µs 10.5±0.76µs -4.55%
RegExp Creation (Compiler) 1698.1±107.50ns 1629.2±107.30ns -4.06%
RegExp Creation (Execution) 11.1±0.71µs 11.3±0.63µs +1.80%
RegExp Creation (Parser) 9.0±0.90µs 9.8±0.55µs +8.89%
RegExp Literal (Compiler) 1952.2±118.49ns 1891.6±137.63ns -3.10%
RegExp Literal (Execution) 15.7±0.88µs 16.4±0.96µs +4.46%
RegExp Literal (Parser) 8.8±0.65µs 8.4±0.69µs -4.55%
RegExp Literal Creation (Compiler) 1648.5±100.72ns 1602.5±100.02ns -2.79%
RegExp Literal Creation (Execution) 10.8±0.68µs 11.4±0.71µs +5.56%
RegExp Literal Creation (Parser) 6.9±0.49µs 7.1±0.49µs +2.90%
Static Object Property Access (Compiler) 1634.3±107.46ns 1657.1±96.73ns +1.40%
Static Object Property Access (Execution) 7.8±0.61µs 7.7±0.49µs -1.28%
Static Object Property Access (Parser) 10.7±0.82µs 10.8±0.70µs +0.93%
String Object Access (Compiler) 1660.1±116.26ns 1745.5±123.27ns +5.14%
String Object Access (Execution) 9.1±0.54µs 8.5±0.57µs -6.59%
String Object Access (Parser) 15.1±0.95µs 14.8±0.95µs -1.99%
String comparison (Compiler) 2.4±0.22µs 2.4±0.14µs 0.00%
String comparison (Execution) 7.2±0.40µs 7.3±0.46µs +1.39%
String comparison (Parser) 13.3±1.66µs 12.4±0.83µs -6.77%
String concatenation (Compiler) 1852.0±120.39ns 1852.3±112.41ns +0.02%
String concatenation (Execution) 6.8±0.71µs 6.5±0.46µs -4.41%
String concatenation (Parser) 8.5±0.54µs 8.5±0.44µs 0.00%
String copy (Compiler) 1498.1±96.30ns 1652.5±73.17ns +10.31%
String copy (Execution) 6.4±0.24µs 6.1±0.40µs -4.69%
String copy (Parser) 6.1±0.48µs 5.7±0.38µs -6.56%
Symbols (Compiler) 1053.8±69.80ns 1155.7±58.30ns +9.67%
Symbols (Execution) 6.3±0.24µs 6.0±0.35µs -4.76%
Symbols (Parser) 4.8±0.29µs 4.5±0.30µs -6.25%

Copy link
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@Razican
Copy link
Member

Razican commented Feb 21, 2022

LGTM!

bors r+

bors bot pushed a commit that referenced this pull request Feb 21, 2022
This PR introduces a new API for JavaScript builtin objects in Rust (such as `Array`, `Map`, `Proxy`, etc). Rather than just expose the raw builtin functions as discussed here #1692 (though having raw API exposed may be nice as well), In this PR we introduce a very light wrapper around the raw API, for a more pleasant user experience. The wrapper implements functions that are specific to the wrapper type (for `Array` this would be methods like `pop`, `push`, etc) as well as implementing `Deref<Target = JsObject>` so we can call `JsObject` functions without converting to `JsObject` and `Into<JsValue>` for easy to `JsValue` conversions.

Please check `jsarray.rs` in the `examples`
@bors
Copy link

bors bot commented Feb 21, 2022

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title Feature JsArray [Merged by Bors] - Feature JsArray Feb 21, 2022
@bors bors bot closed this Feb 21, 2022
@bors bors bot deleted the feature/jsarrayobject branch February 21, 2022 12:15
Razican pushed a commit that referenced this pull request Feb 21, 2022
This PR introduces a new API for JavaScript builtin objects in Rust (such as `Array`, `Map`, `Proxy`, etc). Rather than just expose the raw builtin functions as discussed here #1692 (though having raw API exposed may be nice as well), In this PR we introduce a very light wrapper around the raw API, for a more pleasant user experience. The wrapper implements functions that are specific to the wrapper type (for `Array` this would be methods like `pop`, `push`, etc) as well as implementing `Deref<Target = JsObject>` so we can call `JsObject` functions without converting to `JsObject` and `Into<JsValue>` for easy to `JsValue` conversions.

Please check `jsarray.rs` in the `examples`
bors bot pushed a commit that referenced this pull request Apr 14, 2022
This PR adds a wrapper around the raw builtins for JavaScript typed arrays, like #1746
bors bot pushed a commit that referenced this pull request May 1, 2022
This PR adds `JsFunction` wrapper around JavaScript `Function` object, like #1746 
With this PR we can distinguish between regular object and function object when we need, such as accessors (because they always need to be functions), predicates in `JsArray` methods like `map`, `find`, etc. With this abstraction we leverage the type system of rust which cleans the API making intentions clear.

It changes the following:
- Make methods that take predicate/callback function take `JsFunction`s
- Make `.accessor()` and `.static_accessor()` take `Option<JsFunction>`
- Make `FunctionBuilder` return `JsFunction`
- Make `ConstructorBuilder` return `JsFunction`
- Make `ClassBuilder` return `JsFunction`
Razican pushed a commit that referenced this pull request Jun 8, 2022
This PR adds a wrapper around the raw builtins for JavaScript typed arrays, like #1746
Razican pushed a commit that referenced this pull request Jun 8, 2022
This PR adds `JsFunction` wrapper around JavaScript `Function` object, like #1746 
With this PR we can distinguish between regular object and function object when we need, such as accessors (because they always need to be functions), predicates in `JsArray` methods like `map`, `find`, etc. With this abstraction we leverage the type system of rust which cleans the API making intentions clear.

It changes the following:
- Make methods that take predicate/callback function take `JsFunction`s
- Make `.accessor()` and `.static_accessor()` take `Option<JsFunction>`
- Make `FunctionBuilder` return `JsFunction`
- Make `ConstructorBuilder` return `JsFunction`
- Make `ClassBuilder` return `JsFunction`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API builtins PRs and Issues related to builtins/intrinsics enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants