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] - Removed reference counted pointers from JsValue variants #1866

Closed
wants to merge 1 commit into from

Conversation

Razican
Copy link
Member

@Razican Razican commented Feb 23, 2022

This Pull Request fixes/closes #1864.

It changes the following:

  • Removed JsBigInt from Const nodes, using a boxed BigInt instead.
  • Modifies the JsObject variant so that it has a similar structure to other variants, where the internal structure is private.

The size of JsValue stays in 2 64-bit words (in a 64-bit system at least), and the size of Const also stays the same.

I have noticed that we clone tokens too much in the parser, so I was thinking that we should implement a by-value getter for kind(). Something like kind_unwrap().

@Razican Razican added enhancement New feature or request builtins PRs and Issues related to builtins/intrinsics API labels Feb 23, 2022
@Razican Razican added this to the v0.14.0 milestone Feb 23, 2022
@github-actions
Copy link

github-actions bot commented Feb 23, 2022

Test262 conformance changes

VM implementation

Test result main count PR count difference
Total 88,342 88,342 0
Passed 42,933 42,933 0
Ignored 21,413 21,413 0
Failed 23,996 23,996 0
Panics 12 12 0
Conformance 48.60% 48.60% 0.00%

@codecov
Copy link

codecov bot commented Feb 23, 2022

Codecov Report

Merging #1866 (8cec9c0) into main (ada4ca8) will increase coverage by 0.03%.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1866      +/-   ##
==========================================
+ Coverage   46.65%   46.69%   +0.03%     
==========================================
  Files         204      204              
  Lines       16706    16718      +12     
==========================================
+ Hits         7795     7806      +11     
- Misses       8911     8912       +1     
Impacted Files Coverage Δ
boa_engine/src/bigint.rs 36.09% <0.00%> (-0.56%) ⬇️
boa_engine/src/string.rs 58.39% <ø> (ø)
boa_engine/src/syntax/ast/constant.rs 42.85% <0.00%> (-7.15%) ⬇️
boa_engine/src/syntax/lexer/token.rs 20.00% <0.00%> (ø)
boa_engine/src/syntax/lexer/number.rs 50.00% <50.00%> (-0.60%) ⬇️
boa_engine/src/object/jsobject.rs 50.31% <60.00%> (+0.62%) ⬆️
boa_engine/src/bytecompiler.rs 38.73% <100.00%> (-0.08%) ⬇️
boa_engine/src/builtins/map/map_iterator.rs 91.17% <0.00%> (-2.95%) ⬇️
boa_engine/src/environments/compile.rs 39.82% <0.00%> (-2.66%) ⬇️
... and 11 more

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 ada4ca8...8cec9c0. Read the comment docs.

@Razican
Copy link
Member Author

Razican commented Feb 23, 2022

Actually, I think this will reduce the performance when doing clones of JsValue, I think I can get a better solution for StatementList.

@github-actions
Copy link

Benchmark for f2ee903

Click to view benchmark
Test Base PR %
Arithmetic operations (Compiler) 445.8±0.70ns 448.8±1.48ns +0.67%
Arithmetic operations (Execution) 2.0±0.00µs 2.0±0.00µs 0.00%
Arithmetic operations (Parser) 5.5±0.01µs 5.6±0.01µs +1.82%
Array access (Compiler) 1205.5±3.15ns 1230.5±5.50ns +2.07%
Array access (Execution) 10.5±0.03µs 10.3±0.05µs -1.90%
Array access (Parser) 11.8±0.02µs 12.0±0.04µs +1.69%
Array creation (Compiler) 1853.0±19.19ns 1758.3±26.57ns -5.11%
Array creation (Execution) 3.1±0.01ms 3.2±0.00ms +3.23%
Array creation (Parser) 13.0±0.02µs 13.4±0.02µs +3.08%
Array pop (Compiler) 3.3±0.02µs 3.3±0.01µs 0.00%
Array pop (Execution) 1368.7±8.67µs 1374.1±4.35µs +0.39%
Array pop (Parser) 135.7±0.14µs 137.1±0.09µs +1.03%
Boolean Object Access (Compiler) 1028.8±1.91ns 1032.1±24.73ns +0.32%
Boolean Object Access (Execution) 6.0±0.02µs 5.7±0.01µs -5.00%
Boolean Object Access (Parser) 13.9±0.04µs 14.2±0.01µs +2.16%
Clean js (Compiler) 3.2±0.02µs 3.3±0.01µs +3.12%
Clean js (Execution) 1117.3±5.59µs 1103.5±7.77µs -1.24%
Clean js (Parser) 28.1±0.03µs 28.8±0.02µs +2.49%
Create Realm 273.5±3.04ns 262.4±0.34ns -4.06%
Dynamic Object Property Access (Compiler) 1560.5±2.91ns 1517.2±14.94ns -2.77%
Dynamic Object Property Access (Execution) 6.8±0.04µs 6.9±0.03µs +1.47%
Dynamic Object Property Access (Parser) 10.5±0.01µs 10.6±0.01µs +0.95%
Fibonacci (Compiler) 2.3±0.02µs 2.2±0.01µs -4.35%
Fibonacci (Execution) 1773.7±2.59µs 1819.7±2.98µs +2.59%
Fibonacci (Parser) 15.8±0.02µs 16.1±0.03µs +1.90%
For loop (Compiler) 1866.6±4.10ns 1825.2±3.36ns -2.22%
For loop (Execution) 42.7±0.28µs 42.7±0.15µs 0.00%
For loop (Parser) 13.5±0.03µs 13.8±0.02µs +2.22%
Mini js (Compiler) 3.2±0.02µs 3.2±0.01µs 0.00%
Mini js (Execution) 1027.4±6.19µs 1018.8±6.38µs -0.84%
Mini js (Parser) 24.7±0.14µs 25.1±0.03µs +1.62%
Number Object Access (Compiler) 962.5±1.58ns 975.0±1.59ns +1.30%
Number Object Access (Execution) 4.7±0.01µs 4.5±0.05µs -4.26%
Number Object Access (Parser) 10.9±0.01µs 11.1±0.01µs +1.83%
Object Creation (Compiler) 1331.3±18.86ns 1369.7±2.88ns +2.88%
Object Creation (Execution) 6.1±0.02µs 6.2±0.01µs +1.64%
Object Creation (Parser) 9.1±0.02µs 9.3±0.01µs +2.20%
RegExp (Compiler) 1581.6±2.58ns 1559.1±11.39ns -1.42%
RegExp (Execution) 12.2±0.06µs 12.4±0.06µs +1.64%
RegExp (Parser) 9.9±0.02µs 10.2±0.01µs +3.03%
RegExp Creation (Compiler) 1329.7±2.80ns 1365.1±7.36ns +2.66%
RegExp Creation (Execution) 9.1±0.04µs 9.5±0.04µs +4.40%
RegExp Creation (Parser) 8.2±0.02µs 8.5±0.02µs +3.66%
RegExp Literal (Compiler) 1556.6±2.55ns 1558.6±4.43ns +0.13%
RegExp Literal (Execution) 12.1±0.05µs 12.5±0.06µs +3.31%
RegExp Literal (Parser) 8.0±0.02µs 8.2±0.01µs +2.50%
RegExp Literal Creation (Compiler) 1353.4±3.24ns 1372.0±4.22ns +1.37%
RegExp Literal Creation (Execution) 9.1±0.03µs 9.5±0.07µs +4.40%
RegExp Literal Creation (Parser) 6.3±0.02µs 6.5±0.01µs +3.17%
Static Object Property Access (Compiler) 1333.7±14.33ns 1372.2±12.70ns +2.89%
Static Object Property Access (Execution) 6.4±0.01µs 6.4±0.02µs 0.00%
Static Object Property Access (Parser) 9.7±0.01µs 9.9±0.01µs +2.06%
String Object Access (Compiler) 1379.3±4.04ns 1420.4±7.37ns +2.98%
String Object Access (Execution) 7.9±0.06µs 7.6±0.02µs -3.80%
String Object Access (Parser) 13.6±0.01µs 13.9±0.01µs +2.21%
String comparison (Compiler) 2.1±0.00µs 2.0±0.01µs -4.76%
String comparison (Execution) 5.9±0.02µs 6.0±0.03µs +1.69%
String comparison (Parser) 10.6±0.02µs 10.8±0.02µs +1.89%
String concatenation (Compiler) 1631.4±4.89ns 1530.0±4.70ns -6.22%
String concatenation (Execution) 5.3±0.03µs 5.4±0.01µs +1.89%
String concatenation (Parser) 7.3±0.02µs 7.5±0.01µs +2.74%
String copy (Compiler) 1301.5±2.62ns 1244.0±11.41ns -4.42%
String copy (Execution) 4.8±0.01µs 4.9±0.02µs +2.08%
String copy (Parser) 5.5±0.02µs 5.6±0.06µs +1.82%
Symbols (Compiler) 846.7±2.37ns 876.8±2.36ns +3.55%
Symbols (Execution) 4.5±0.01µs 4.5±0.01µs 0.00%
Symbols (Parser) 4.3±0.02µs 4.3±0.01µs 0.00%

@@ -554,7 +554,7 @@ impl<'b> ByteCompiler<'b> {
)),
Const::Int(v) => self.emit_push_integer(*v),
Const::Num(v) => self.emit_push_rational(*v),
Const::BigInt(v) => self.emit_push_literal(Literal::BigInt(v.clone())),
Const::BigInt(v) => self.emit_push_literal(Literal::BigInt(v.clone().into())),
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the only place where I see that it will actually be less performant.

@github-actions
Copy link

Benchmark for ea9fc25

Click to view benchmark
Test Base PR %
Arithmetic operations (Compiler) 385.4±1.37ns 447.9±0.69ns +16.22%
Arithmetic operations (Execution) 2.1±0.00µs 1853.2±2.10ns -11.75%
Arithmetic operations (Parser) 5.5±0.01µs 5.5±0.01µs 0.00%
Array access (Compiler) 1159.2±2.52ns 1066.3±11.85ns -8.01%
Array access (Execution) 8.9±0.04µs 9.0±0.03µs +1.12%
Array access (Parser) 10.3±0.02µs 10.6±0.02µs +2.91%
Array creation (Compiler) 1744.3±13.17ns 1566.6±5.91ns -10.19%
Array creation (Execution) 2.7±0.00ms 2.7±0.01ms 0.00%
Array creation (Parser) 11.5±0.02µs 13.4±0.02µs +16.52%
Array pop (Compiler) 3.3±0.02µs 2.9±0.01µs -12.12%
Array pop (Execution) 1180.0±4.47µs 1172.5±2.89µs -0.64%
Array pop (Parser) 135.5±0.17µs 122.5±0.11µs -9.59%
Boolean Object Access (Compiler) 919.4±2.11ns 1024.0±2.91ns +11.38%
Boolean Object Access (Execution) 5.1±0.02µs 5.0±0.03µs -1.96%
Boolean Object Access (Parser) 12.3±0.02µs 14.3±0.02µs +16.26%
Clean js (Compiler) 2.9±0.02µs 3.2±0.01µs +10.34%
Clean js (Execution) 961.9±2.97µs 953.8±4.35µs -0.84%
Clean js (Parser) 24.8±0.03µs 25.7±0.06µs +3.63%
Create Realm 230.4±0.44ns 267.2±0.31ns +15.97%
Dynamic Object Property Access (Compiler) 1324.7±2.69ns 1554.3±13.70ns +17.33%
Dynamic Object Property Access (Execution) 6.7±0.03µs 5.9±0.01µs -11.94%
Dynamic Object Property Access (Parser) 9.2±0.04µs 9.4±0.01µs +2.17%
Fibonacci (Compiler) 1954.8±7.93ns 1949.8±8.52ns -0.26%
Fibonacci (Execution) 1554.5±6.44µs 1567.7±10.42µs +0.85%
Fibonacci (Parser) 13.8±0.02µs 14.1±0.03µs +2.17%
For loop (Compiler) 1624.0±4.70ns 1656.3±8.77ns +1.99%
For loop (Execution) 37.7±0.08µs 43.1±0.14µs +14.32%
For loop (Parser) 12.0±0.03µs 14.0±0.03µs +16.67%
Mini js (Compiler) 3.1±0.03µs 2.8±0.01µs -9.68%
Mini js (Execution) 882.5±3.42µs 882.9±3.64µs +0.05%
Mini js (Parser) 21.8±0.03µs 22.4±0.03µs +2.75%
Number Object Access (Compiler) 855.5±2.10ns 861.1±2.19ns +0.65%
Number Object Access (Execution) 4.0±0.01µs 3.9±0.01µs -2.50%
Number Object Access (Parser) 9.6±0.02µs 11.2±0.02µs +16.67%
Object Creation (Compiler) 1136.9±4.55ns 1211.0±9.82ns +6.52%
Object Creation (Execution) 5.4±0.01µs 5.4±0.01µs 0.00%
Object Creation (Parser) 8.0±0.02µs 8.2±0.02µs +2.50%
RegExp (Compiler) 1342.6±4.00ns 1399.6±7.76ns +4.25%
RegExp (Execution) 10.7±0.03µs 11.0±0.04µs +2.80%
RegExp (Parser) 9.9±0.02µs 10.1±0.02µs +2.02%
RegExp Creation (Compiler) 1152.0±5.15ns 1188.7±6.44ns +3.19%
RegExp Creation (Execution) 8.0±0.02µs 9.5±0.04µs +18.75%
RegExp Creation (Parser) 7.3±0.01µs 7.5±0.02µs +2.74%
RegExp Literal (Compiler) 1326.5±2.29ns 1410.5±9.96ns +6.33%
RegExp Literal (Execution) 10.6±0.05µs 12.4±0.05µs +16.98%
RegExp Literal (Parser) 7.9±0.04µs 7.2±0.01µs -8.86%
RegExp Literal Creation (Compiler) 1292.4±2.52ns 1206.4±11.18ns -6.65%
RegExp Literal Creation (Execution) 7.9±0.02µs 9.5±0.04µs +20.25%
RegExp Literal Creation (Parser) 5.5±0.01µs 5.6±0.01µs +1.82%
Static Object Property Access (Compiler) 1164.8±10.66ns 1220.1±4.99ns +4.75%
Static Object Property Access (Execution) 5.6±0.01µs 6.3±0.03µs +12.50%
Static Object Property Access (Parser) 8.6±0.02µs 8.8±0.01µs +2.33%
String Object Access (Compiler) 1201.5±3.79ns 1363.9±3.84ns +13.52%
String Object Access (Execution) 7.5±0.03µs 6.6±0.01µs -12.00%
String Object Access (Parser) 12.0±0.02µs 12.4±0.01µs +3.33%
String comparison (Compiler) 1990.8±4.19ns 1787.6±6.18ns -10.21%
String comparison (Execution) 5.1±0.01µs 5.1±0.01µs 0.00%
String comparison (Parser) 9.4±0.02µs 9.6±0.02µs +2.13%
String concatenation (Compiler) 1364.4±2.82ns 1376.5±3.41ns +0.89%
String concatenation (Execution) 4.6±0.02µs 4.7±0.01µs +2.17%
String concatenation (Parser) 6.5±0.02µs 6.6±0.01µs +1.54%
String copy (Compiler) 1059.7±2.67ns 1096.5±4.09ns +3.47%
String copy (Execution) 4.1±0.01µs 4.7±0.02µs +14.63%
String copy (Parser) 4.8±0.02µs 5.0±0.01µs +4.17%
Symbols (Compiler) 822.2±1.41ns 791.4±1.96ns -3.75%
Symbols (Execution) 4.4±0.01µs 4.0±0.01µs -9.09%
Symbols (Parser) 3.7±0.02µs 4.3±0.01µs +16.22%

@github-actions
Copy link

Benchmark for 845144e

Click to view benchmark
Test Base PR %
Arithmetic operations (Compiler) 437.7±0.96ns 432.5±0.83ns -1.19%
Arithmetic operations (Execution) 1803.2±1.81ns 1801.7±2.09ns -0.08%
Arithmetic operations (Parser) 4.8±0.01µs 5.6±0.00µs +16.67%
Array access (Compiler) 1199.1±2.66ns 1160.2±2.57ns -3.24%
Array access (Execution) 9.1±0.02µs 9.0±0.04µs -1.10%
Array access (Parser) 10.3±0.02µs 12.0±0.02µs +16.50%
Array creation (Compiler) 1562.6±9.26ns 1721.3±5.95ns +10.16%
Array creation (Execution) 2.7±0.00ms 2.7±0.01ms 0.00%
Array creation (Parser) 11.5±0.02µs 13.4±0.02µs +16.52%
Array pop (Compiler) 3.3±0.01µs 3.3±0.01µs 0.00%
Array pop (Execution) 1178.6±4.06µs 1172.7±4.69µs -0.50%
Array pop (Parser) 120.2±4.65µs 138.5±0.08µs +15.22%
Boolean Object Access (Compiler) 924.1±2.34ns 1021.3±2.08ns +10.52%
Boolean Object Access (Execution) 5.1±0.01µs 5.0±0.01µs -1.96%
Boolean Object Access (Parser) 12.3±0.01µs 14.2±0.02µs +15.45%
Clean js (Compiler) 3.3±0.01µs 3.2±0.01µs -3.03%
Clean js (Execution) 963.0±2.97µs 949.9±3.97µs -1.36%
Clean js (Parser) 24.9±0.03µs 28.8±0.04µs +15.66%
Create Realm 231.2±0.50ns 266.0±0.36ns +15.05%
Dynamic Object Property Access (Compiler) 1353.7±2.78ns 1528.6±3.52ns +12.92%
Dynamic Object Property Access (Execution) 6.0±0.02µs 6.7±0.04µs +11.67%
Dynamic Object Property Access (Parser) 10.4±0.01µs 10.7±0.01µs +2.88%
Fibonacci (Compiler) 2.0±0.00µs 2.2±0.02µs +10.00%
Fibonacci (Execution) 1771.0±6.50µs 1764.7±2.91µs -0.36%
Fibonacci (Parser) 15.8±0.02µs 16.2±0.20µs +2.53%
For loop (Compiler) 1882.5±5.50ns 1842.6±6.19ns -2.12%
For loop (Execution) 42.7±0.13µs 43.1±0.16µs +0.94%
For loop (Parser) 13.5±0.02µs 14.0±0.02µs +3.70%
Mini js (Compiler) 2.9±0.01µs 3.1±0.01µs +6.90%
Mini js (Execution) 887.0±7.60µs 876.8±3.68µs -1.15%
Mini js (Parser) 21.9±0.02µs 25.1±0.07µs +14.61%
Number Object Access (Compiler) 876.9±1.90ns 974.6±1.37ns +11.14%
Number Object Access (Execution) 4.0±0.01µs 4.4±0.02µs +10.00%
Number Object Access (Parser) 9.6±0.01µs 11.1±0.02µs +15.63%
Object Creation (Compiler) 1171.4±5.42ns 1274.6±2.48ns +8.81%
Object Creation (Execution) 6.1±0.01µs 6.0±0.01µs -1.64%
Object Creation (Parser) 8.0±0.02µs 9.3±0.03µs +16.25%
RegExp (Compiler) 1356.5±4.41ns 1524.6±3.14ns +12.39%
RegExp (Execution) 10.7±0.04µs 12.4±0.07µs +15.89%
RegExp (Parser) 8.7±0.01µs 10.2±0.02µs +17.24%
RegExp Creation (Compiler) 1318.5±2.61ns 1308.6±4.95ns -0.75%
RegExp Creation (Execution) 8.0±0.02µs 9.5±0.03µs +18.75%
RegExp Creation (Parser) 7.3±0.02µs 8.5±0.02µs +16.44%
RegExp Literal (Compiler) 1563.8±6.18ns 1530.3±3.33ns -2.14%
RegExp Literal (Execution) 12.0±0.06µs 11.0±0.05µs -8.33%
RegExp Literal (Parser) 7.0±0.02µs 8.1±0.02µs +15.71%
RegExp Literal Creation (Compiler) 1152.2±2.09ns 1301.8±2.07ns +12.98%
RegExp Literal Creation (Execution) 9.0±0.03µs 9.5±0.04µs +5.56%
RegExp Literal Creation (Parser) 6.2±0.02µs 6.4±0.03µs +3.23%
Static Object Property Access (Compiler) 1189.3±5.23ns 1325.6±1.92ns +11.46%
Static Object Property Access (Execution) 6.3±0.02µs 6.2±0.02µs -1.59%
Static Object Property Access (Parser) 8.6±0.02µs 9.9±0.02µs +15.12%
String Object Access (Compiler) 1379.5±4.04ns 1362.8±3.95ns -1.21%
String Object Access (Execution) 6.6±0.03µs 6.5±0.02µs -1.52%
String Object Access (Parser) 12.0±0.02µs 13.9±0.02µs +15.83%
String comparison (Compiler) 1778.4±9.16ns 1998.5±11.23ns +12.38%
String comparison (Execution) 5.9±0.01µs 5.8±0.01µs -1.69%
String comparison (Parser) 9.4±0.01µs 10.9±0.02µs +15.96%
String concatenation (Compiler) 1500.0±3.44ns 1512.3±3.09ns +0.82%
String concatenation (Execution) 4.7±0.01µs 4.6±0.01µs -2.13%
String concatenation (Parser) 6.5±0.01µs 7.5±0.01µs +15.38%
String copy (Compiler) 1066.4±2.21ns 1229.1±3.13ns +15.26%
String copy (Execution) 4.8±0.02µs 4.7±0.01µs -2.08%
String copy (Parser) 4.9±0.01µs 5.7±0.01µs +16.33%
Symbols (Compiler) 828.6±1.48ns 828.4±1.35ns -0.02%
Symbols (Execution) 3.9±0.01µs 4.5±0.01µs +15.38%
Symbols (Parser) 3.7±0.01µs 4.3±0.00µs +16.22%

@Razican
Copy link
Member Author

Razican commented Feb 23, 2022

Wow performance seems pretty bad

@jedel1043
Copy link
Member

Wow performance seems pretty bad

I'm curious if the cause was moving the internal Gc<GcCell<Object>> to inner.

@raskad
Copy link
Member

raskad commented Feb 26, 2022

I'm curious if the cause was moving the internal Gc<GcCell<Object>> to inner.

I don't see how this could have an impact. From the unsafe code guide:
In terms of their layout, tuple structs can be understood as equivalent to a named struct with fields named 0..n-1
https://rust-lang.github.io/unsafe-code-guidelines/layout/structs-and-tuples.html#struct-types

Other than the layout is there anything that could be affected by the struct definition?

@Razican
Copy link
Member Author

Razican commented Feb 26, 2022

I'm curious if the cause was moving the internal Gc<GcCell<Object>> to inner.

I don't see how this could have an impact. From the unsafe code guide: In terms of their layout, tuple structs can be understood as equivalent to a named struct with fields named 0..n-1 https://rust-lang.github.io/unsafe-code-guidelines/layout/structs-and-tuples.html#struct-types

Other than the layout is there anything that could be affected by the struct definition?

Nope, that structure should be exactly the same. But the issue is that calling clone() on a Box is much more expensive than calling it on Rc. So, we should find where we are using it. I will try to do that by removing the Clone derive temporarily to see what happens.

Something I also noticed is that we clone tokens too much. We should have a unwrap_kind() function to extract the kind by value instead of by reference, and get ownership of it. I will also add that.

@github-actions
Copy link

Benchmark for 16437d8

Click to view benchmark
Test Base PR %
Arithmetic operations (Compiler) 612.0±12.70ns 606.3±5.86ns -0.93%
Arithmetic operations (Execution) 2.3±0.02µs 2.4±0.02µs +4.35%
Arithmetic operations (Parser) 5.6±0.08µs 5.7±0.07µs +1.79%
Array access (Compiler) 1519.5±21.95ns 1492.5±13.45ns -1.78%
Array access (Execution) 11.6±0.16µs 11.5±0.08µs -0.86%
Array access (Parser) 12.4±0.17µs 12.6±0.18µs +1.61%
Array creation (Compiler) 2.1±0.03µs 2.1±0.03µs 0.00%
Array creation (Execution) 3.8±0.06ms 3.6±0.02ms -5.26%
Array creation (Parser) 14.1±0.15µs 14.1±0.20µs 0.00%
Array pop (Compiler) 4.3±0.06µs 4.4±0.07µs +2.33%
Array pop (Execution) 1635.7±20.95µs 1600.7±8.93µs -2.14%
Array pop (Parser) 146.0±2.81µs 148.5±1.43µs +1.71%
Boolean Object Access (Compiler) 1192.3±13.46ns 1151.4±14.79ns -3.43%
Boolean Object Access (Execution) 6.8±0.09µs 6.8±0.08µs 0.00%
Boolean Object Access (Parser) 15.4±0.21µs 15.7±0.23µs +1.95%
Clean js (Compiler) 3.9±0.06µs 3.9±0.05µs 0.00%
Clean js (Execution) 1291.8±18.15µs 1282.3±22.95µs -0.74%
Clean js (Parser) 30.5±0.42µs 31.0±0.33µs +1.64%
Create Realm 319.8±3.73ns 330.4±3.46ns +3.31%
Dynamic Object Property Access (Compiler) 1881.9±26.83ns 1877.4±20.70ns -0.24%
Dynamic Object Property Access (Execution) 7.9±0.09µs 7.9±0.07µs 0.00%
Dynamic Object Property Access (Parser) 11.0±0.16µs 11.0±0.18µs 0.00%
Fibonacci (Compiler) 2.6±0.03µs 2.6±0.03µs 0.00%
Fibonacci (Execution) 2.1±0.02ms 2.1±0.01ms 0.00%
Fibonacci (Parser) 17.2±0.17µs 17.4±0.22µs +1.16%
For loop (Compiler) 2.3±0.03µs 2.3±0.03µs 0.00%
For loop (Execution) 49.4±0.61µs 50.0±0.46µs +1.21%
For loop (Parser) 14.7±0.19µs 14.9±0.18µs +1.36%
Mini js (Compiler) 3.8±0.09µs 3.8±0.03µs 0.00%
Mini js (Execution) 1181.4±15.18µs 1171.9±15.92µs -0.80%
Mini js (Parser) 26.5±0.33µs 26.4±0.36µs -0.38%
Number Object Access (Compiler) 1089.5±14.19ns 1099.5±12.06ns +0.92%
Number Object Access (Execution) 5.3±0.05µs 5.4±0.04µs +1.89%
Number Object Access (Parser) 11.6±0.14µs 12.0±0.14µs +3.45%
Object Creation (Compiler) 1624.2±29.39ns 1643.7±25.42ns +1.20%
Object Creation (Execution) 7.1±0.13µs 7.0±0.09µs -1.41%
Object Creation (Parser) 9.6±0.18µs 9.8±0.15µs +2.08%
RegExp (Compiler) 1913.4±31.75ns 1934.6±25.72ns +1.11%
RegExp (Execution) 14.1±0.11µs 14.0±0.13µs -0.71%
RegExp (Parser) 10.4±0.18µs 10.8±0.20µs +3.85%
RegExp Creation (Compiler) 1644.4±21.28ns 1678.4±25.19ns +2.07%
RegExp Creation (Execution) 10.6±0.12µs 10.5±0.08µs -0.94%
RegExp Creation (Parser) 8.8±0.10µs 9.0±0.12µs +2.27%
RegExp Literal (Compiler) 1904.3±24.15ns 1883.7±35.15ns -1.08%
RegExp Literal (Execution) 14.1±0.15µs 14.0±0.11µs -0.71%
RegExp Literal (Parser) 8.6±0.11µs 8.6±0.08µs 0.00%
RegExp Literal Creation (Compiler) 1634.3±24.25ns 1664.4±18.50ns +1.84%
RegExp Literal Creation (Execution) 10.5±0.14µs 10.5±0.13µs 0.00%
RegExp Literal Creation (Parser) 6.7±0.11µs 6.7±0.10µs 0.00%
Static Object Property Access (Compiler) 1637.8±27.46ns 1688.8±23.39ns +3.11%
Static Object Property Access (Execution) 7.4±0.12µs 7.4±0.08µs 0.00%
Static Object Property Access (Parser) 10.2±0.19µs 10.6±0.17µs +3.92%
String Object Access (Compiler) 1603.1±21.86ns 1576.1±21.82ns -1.68%
String Object Access (Execution) 8.9±0.10µs 8.9±0.09µs 0.00%
String Object Access (Parser) 15.1±0.16µs 15.4±0.16µs +1.99%
String comparison (Compiler) 2.5±0.03µs 2.5±0.02µs 0.00%
String comparison (Execution) 6.8±0.10µs 6.8±0.06µs 0.00%
String comparison (Parser) 11.8±0.12µs 11.8±0.13µs 0.00%
String concatenation (Compiler) 1911.8±25.10ns 1935.1±26.76ns +1.22%
String concatenation (Execution) 6.1±0.10µs 6.2±0.07µs +1.64%
String concatenation (Parser) 8.0±0.08µs 7.9±0.08µs -1.25%
String copy (Compiler) 1559.4±22.29ns 1570.8±19.49ns +0.73%
String copy (Execution) 5.5±0.05µs 5.5±0.03µs 0.00%
String copy (Parser) 5.8±0.10µs 5.9±0.05µs +1.72%
Symbols (Compiler) 1065.4±13.78ns 1066.4±13.63ns +0.09%
Symbols (Execution) 5.3±0.06µs 5.2±0.05µs -1.89%
Symbols (Parser) 4.4±0.15µs 4.5±0.05µs +2.27%

It also modifies the `JsObject` variant so that it has a similar structure
to other variants, where the internal structure is private.
@github-actions
Copy link

Benchmark for e6ea8bd

Click to view benchmark
Test Base PR %
Arithmetic operations (Compiler) 509.1±1.60ns 509.9±1.93ns +0.16%
Arithmetic operations (Execution) 1971.2±2.01ns 1976.6±16.53ns +0.27%
Arithmetic operations (Parser) 5.2±0.01µs 5.2±0.01µs 0.00%
Array access (Compiler) 1258.6±2.80ns 1278.8±6.24ns +1.60%
Array access (Execution) 9.8±0.51µs 9.7±0.05µs -1.02%
Array access (Parser) 11.7±0.02µs 11.7±0.01µs 0.00%
Array creation (Compiler) 1840.8±10.24ns 1826.1±14.21ns -0.80%
Array creation (Execution) 3.2±0.00ms 3.0±0.01ms -6.25%
Array creation (Parser) 13.1±0.01µs 13.0±0.03µs -0.76%
Array pop (Compiler) 3.7±0.01µs 4.0±0.01µs +8.11%
Array pop (Execution) 1393.3±2.40µs 1318.5±10.66µs -5.37%
Array pop (Parser) 129.8±0.08µs 130.7±0.16µs +0.69%
Boolean Object Access (Compiler) 1093.7±4.14ns 1112.0±2.13ns +1.67%
Boolean Object Access (Execution) 5.9±0.03µs 5.7±0.01µs -3.39%
Boolean Object Access (Parser) 14.1±0.01µs 14.2±0.01µs +0.71%
Clean js (Compiler) 3.4±0.01µs 3.4±0.02µs 0.00%
Clean js (Execution) 1098.5±8.05µs 1076.6±5.77µs -1.99%
Clean js (Parser) 28.0±0.04µs 28.4±0.32µs +1.43%
Create Realm 262.9±0.40ns 273.8±4.05ns +4.15%
Dynamic Object Property Access (Compiler) 1565.8±3.16ns 1596.0±2.11ns +1.93%
Dynamic Object Property Access (Execution) 6.8±0.03µs 6.7±0.03µs -1.47%
Dynamic Object Property Access (Parser) 10.3±0.02µs 10.6±0.01µs +2.91%
Fibonacci (Compiler) 2.2±0.01µs 2.3±0.01µs +4.55%
Fibonacci (Execution) 1765.7±2.28µs 1775.3±13.02µs +0.54%
Fibonacci (Parser) 15.8±0.03µs 16.0±0.01µs +1.27%
For loop (Compiler) 1958.0±5.52ns 1944.9±4.85ns -0.67%
For loop (Execution) 42.5±0.12µs 42.7±0.11µs +0.47%
For loop (Parser) 13.5±0.02µs 13.6±0.04µs +0.74%
Mini js (Compiler) 3.2±0.01µs 3.3±0.01µs +3.12%
Mini js (Execution) 1007.1±5.58µs 988.2±4.26µs -1.88%
Mini js (Parser) 24.5±0.04µs 24.5±0.03µs 0.00%
Number Object Access (Compiler) 1032.1±5.06ns 1045.2±4.26ns +1.27%
Number Object Access (Execution) 4.7±0.04µs 4.4±0.01µs -6.38%
Number Object Access (Parser) 10.8±0.01µs 11.1±0.01µs +2.78%
Object Creation (Compiler) 1366.4±5.91ns 1383.9±5.90ns +1.28%
Object Creation (Execution) 6.1±0.02µs 6.0±0.02µs -1.64%
Object Creation (Parser) 9.0±0.01µs 9.3±0.03µs +3.33%
RegExp (Compiler) 1591.1±3.34ns 1625.8±5.36ns +2.18%
RegExp (Execution) 12.6±0.03µs 12.2±0.08µs -3.17%
RegExp (Parser) 9.9±0.02µs 10.0±0.02µs +1.01%
RegExp Creation (Compiler) 1399.6±5.27ns 1378.6±5.96ns -1.50%
RegExp Creation (Execution) 9.5±0.04µs 9.0±0.03µs -5.26%
RegExp Creation (Parser) 8.2±0.02µs 8.3±0.02µs +1.22%
RegExp Literal (Compiler) 1594.1±2.27ns 1616.0±3.14ns +1.37%
RegExp Literal (Execution) 12.6±0.03µs 12.1±0.07µs -3.97%
RegExp Literal (Parser) 8.0±0.02µs 8.1±0.01µs +1.25%
RegExp Literal Creation (Compiler) 1408.4±5.57ns 1415.1±5.71ns +0.48%
RegExp Literal Creation (Execution) 9.4±0.04µs 9.0±0.13µs -4.26%
RegExp Literal Creation (Parser) 6.3±0.02µs 6.4±0.02µs +1.59%
Static Object Property Access (Compiler) 1368.0±6.00ns 1409.2±4.72ns +3.01%
Static Object Property Access (Execution) 6.3±0.02µs 6.3±0.02µs 0.00%
Static Object Property Access (Parser) 9.7±0.01µs 10.0±0.02µs +3.09%
String Object Access (Compiler) 1456.1±8.70ns 1460.2±7.77ns +0.28%
String Object Access (Execution) 7.6±0.04µs 7.5±0.02µs -1.32%
String Object Access (Parser) 13.7±0.01µs 13.9±0.02µs +1.46%
String comparison (Compiler) 2.1±0.01µs 2.1±0.01µs 0.00%
String comparison (Execution) 5.8±0.02µs 5.8±0.01µs 0.00%
String comparison (Parser) 10.7±0.01µs 10.7±0.01µs 0.00%
String concatenation (Compiler) 1644.8±8.01ns 1607.0±5.56ns -2.30%
String concatenation (Execution) 5.3±0.01µs 5.3±0.01µs 0.00%
String concatenation (Parser) 7.3±0.02µs 7.4±0.01µs +1.37%
String copy (Compiler) 1287.2±2.83ns 1288.7±2.45ns +0.12%
String copy (Execution) 4.7±0.01µs 4.7±0.02µs 0.00%
String copy (Parser) 5.5±0.01µs 5.5±0.02µs 0.00%
Symbols (Compiler) 893.0±1.33ns 927.0±1.78ns +3.81%
Symbols (Execution) 4.5±0.01µs 4.4±0.01µs -2.22%
Symbols (Parser) 4.3±0.01µs 4.3±0.01µs 0.00%

Copy link
Member

@HalidOdat HalidOdat 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 from my side :)

@raskad
Copy link
Member

raskad commented Feb 27, 2022

bors r+

bors bot pushed a commit that referenced this pull request Feb 27, 2022
This Pull Request fixes/closes #1864.

It changes the following:

- Removed `JsBigInt` from `Const` nodes, using a boxed `BigInt` instead.
- Modifies the `JsObject` variant so that it has a similar structure to other variants, where the internal structure is private.

The size of `JsValue` stays in 2 64-bit words (in a 64-bit system at least), and the size of `Const` also stays the same.

I have noticed that we clone tokens too much in the parser, so I was thinking that we should implement a by-value getter for `kind()`. Something like `kind_unwrap()`.
@bors
Copy link

bors bot commented Feb 27, 2022

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title Removed reference counted pointers from JsValue variants [Merged by Bors] - Removed reference counted pointers from JsValue variants Feb 27, 2022
@bors bors bot closed this Feb 27, 2022
@bors bors bot deleted the rc_removal branch February 27, 2022 20:19
@RageKnify RageKnify added this to the v0.14.0 milestone Feb 27, 2022
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.

Enable a parsed StatementList to be passed across async/await boundaries
5 participants