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

Cross realm symbols #1243

Merged
merged 4 commits into from
May 11, 2021
Merged

Cross realm symbols #1243

merged 4 commits into from
May 11, 2021

Conversation

HalidOdat
Copy link
Member

Well known Symbols are able to be used between contexts (in the same thread) interchangeably, as described in the spec ("Unless otherwise specified, well-known symbols values are shared by all realms"). The spec only says this about well known symbols, but it's better to have all symbols be interchangeable rather than a few, since we will run into some hash collisions for later created symbols.

It changes the following:

  • Make symbols be cross realm movable.
  • Remove redundant _symbol suffix for well known symbol getters.
  • Fix PartialEq for Symbol so it only checks equality for hashes (which are unique).
  • Fix Hash for Symbol so it only hashes the Symbol's hash.

The two fixes (PartialEq and Hash) might gives us a performance boots since we don't need to compare and hash the symbol description. (now we only compare and hash a u64, instead of the string description too).

@HalidOdat HalidOdat added enhancement New feature or request builtins PRs and Issues related to builtins/intrinsics execution Issues or PRs related to code execution labels May 10, 2021
@HalidOdat HalidOdat added this to the v0.12.0 milestone May 10, 2021
@github-actions
Copy link

github-actions bot commented May 10, 2021

Test262 conformance changes:

Test result master count PR count difference
Total 78,701 78,701 0
Passed 25,730 25,730 0
Ignored 15,519 15,519 0
Failed 37,452 37,452 0
Panics 12 13 +1
Conformance 32.69% 32.69% 0.00%

@github-actions
Copy link

Benchmark for e4b198b

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 376.0±20.37ns 375.9±12.07ns +0.03%
Arithmetic operations (Full) 283.6±14.37µs 278.0±7.97µs +2.01%
Array access (Execution) 6.8±0.42µs 6.9±0.27µs -1.45%
Array access (Full) 317.2±11.54µs 306.9±15.48µs +3.36%
Array creation (Execution) 2.8±0.15ms 2.9±0.08ms -3.45%
Array creation (Full) 3.3±0.13ms 3.3±0.14ms 0.00%
Array pop (Execution) 972.8±57.61µs 945.4±29.19µs +2.90%
Array pop (Full) 1444.6±57.10µs 1467.6±46.68µs -1.57%
Boolean Object Access (Execution) 5.5±0.26µs 5.9±0.23µs -6.78%
Boolean Object Access (Full) 297.1±12.86µs 302.0±10.58µs -1.62%
Clean js (Execution) 715.2±41.27µs 715.2±25.56µs 0.00%
Clean js (Full) 1026.1±67.03µs 1034.0±39.66µs -0.76%
Clean js (Parser) 40.9±1.68µs 44.7±2.39µs -8.50%
Create Realm 472.5±32.89ns 460.3±16.90ns +2.65%
Dynamic Object Property Access (Execution) 5.6±0.27µs 5.8±0.18µs -3.45%
Dynamic Object Property Access (Full) 322.5±29.35µs 312.4±14.00µs +3.23%
Expression (Parser) 6.6±0.28µs 7.0±0.32µs -5.71%
Fibonacci (Execution) 961.5±53.01µs 929.0±26.54µs +3.50%
Fibonacci (Full) 1258.9±163.74µs 1195.7±25.67µs +5.29%
For loop (Execution) 24.4±1.34µs 24.1±0.87µs +1.24%
For loop (Full) 344.8±15.40µs 331.2±13.53µs +4.11%
For loop (Parser) 21.7±0.92µs 21.3±1.06µs +1.88%
Goal Symbols (Parser) 14.4±0.82µs 14.7±0.58µs -2.04%
Hello World (Parser) 3.8±0.20µs 3.9±0.17µs -2.56%
Long file (Parser) 820.1±53.38ns 827.5±29.16ns -0.89%
Mini js (Execution) 620.0±23.36µs 638.6±19.91µs -2.91%
Mini js (Full) 904.6±48.27µs 968.6±36.43µs -6.61%
Mini js (Parser) 38.8±1.64µs 39.5±1.95µs -1.77%
Number Object Access (Execution) 4.5±0.25µs 4.5±0.17µs 0.00%
Number Object Access (Full) 313.9±9.69µs 304.3±18.36µs +3.15%
Object Creation (Execution) 5.3±0.90µs 5.0±0.23µs +6.00%
Object Creation (Full) 295.9±11.09µs 300.5±14.44µs -1.53%
RegExp (Execution) 12.0±0.62µs 12.0±0.40µs 0.00%
RegExp (Full) 317.6±21.02µs 313.4±13.35µs +1.34%
RegExp Literal (Execution) 11.9±0.53µs 12.1±0.54µs -1.65%
RegExp Literal (Full) 318.0±14.22µs 316.8±12.52µs +0.38%
RegExp Literal Creation (Execution) 11.0±0.68µs 10.5±0.34µs +4.76%
RegExp Literal Creation (Full) 314.6±17.45µs 314.8±15.02µs -0.06%
Static Object Property Access (Execution) 5.3±0.22µs 5.3±0.19µs 0.00%
Static Object Property Access (Full) 298.5±12.36µs 303.5±13.24µs -1.65%
String Object Access (Execution) 8.1±0.29µs 8.0±0.28µs +1.25%
String Object Access (Full) 305.2±12.55µs 305.1±16.15µs +0.03%
String comparison (Execution) 7.6±0.45µs 7.2±0.22µs +5.56%
String comparison (Full) 291.8±12.11µs 309.5±15.28µs -5.72%
String concatenation (Execution) 5.9±0.29µs 5.8±0.20µs +1.72%
String concatenation (Full) 289.0±11.35µs 298.3±9.64µs -3.12%
String copy (Execution) 4.6±0.30µs 4.4±0.22µs +4.55%
String copy (Full) 295.2±9.39µs 290.3±8.27µs +1.69%
Symbols (Execution) 3.7±0.14µs 3.8±0.10µs -2.63%
Symbols (Full) 289.7±18.73µs 285.0±13.26µs +1.65%

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.

Looking very good @HalidOdat. This will be very helpful when implementing the rest of the test262 suite with the shared object that should be able to create new realms, for example.

I only added a couple of comments on documentation, and opened a question on whether we should be using the Default trait for an empty new() function, mostly related to this clippy lint.

boa/src/symbol/mod.rs Show resolved Hide resolved
boa/src/symbol/mod.rs Show resolved Hide resolved
@HalidOdat HalidOdat requested a review from Razican May 10, 2021 14:55
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.

Looks good to me!

@github-actions
Copy link

Benchmark for b9c478e

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 409.6±18.40ns 418.2±19.12ns -2.06%
Arithmetic operations (Full) 305.0±24.38µs 307.0±9.67µs -0.65%
Array access (Execution) 7.3±0.32µs 7.2±0.33µs +1.39%
Array access (Full) 332.2±12.23µs 338.7±17.89µs -1.92%
Array creation (Execution) 2.9±0.12ms 3.0±0.11ms -3.33%
Array creation (Full) 3.3±0.18ms 3.3±0.14ms 0.00%
Array pop (Execution) 943.7±28.98µs 974.9±30.29µs -3.20%
Array pop (Full) 1549.5±142.07µs 1542.8±63.06µs +0.43%
Boolean Object Access (Execution) 6.0±0.43µs 6.0±0.37µs 0.00%
Boolean Object Access (Full) 320.4±13.89µs 330.4±12.59µs -3.03%
Clean js (Execution) 749.3±35.48µs 747.6±36.74µs +0.23%
Clean js (Full) 1081.8±40.59µs 1075.6±44.55µs +0.58%
Clean js (Parser) 45.4±1.99µs 44.6±1.39µs +1.79%
Create Realm 466.5±25.03ns 473.6±33.45ns -1.50%
Dynamic Object Property Access (Execution) 6.1±0.36µs 6.1±0.27µs 0.00%
Dynamic Object Property Access (Full) 331.1±19.39µs 342.9±14.98µs -3.44%
Expression (Parser) 7.2±0.38µs 7.4±0.30µs -2.70%
Fibonacci (Execution) 938.7±34.25µs 954.6±31.09µs -1.67%
Fibonacci (Full) 1292.9±61.03µs 1278.4±54.42µs +1.13%
For loop (Execution) 24.4±1.36µs 25.7±1.38µs -5.06%
For loop (Full) 348.7±14.41µs 345.7±21.76µs +0.87%
For loop (Parser) 21.2±1.05µs 22.2±1.06µs -4.50%
Goal Symbols (Parser) 15.1±1.31µs 15.1±0.70µs 0.00%
Hello World (Parser) 4.0±0.20µs 4.1±0.15µs -2.44%
Long file (Parser) 914.6±57.89ns 859.4±35.94ns +6.42%
Mini js (Execution) 661.9±31.04µs 666.2±32.65µs -0.65%
Mini js (Full) 1016.0±75.29µs 998.0±47.12µs +1.80%
Mini js (Parser) 40.6±2.66µs 39.3±4.17µs +3.31%
Number Object Access (Execution) 4.7±0.17µs 4.7±0.21µs 0.00%
Number Object Access (Full) 314.1±11.02µs 325.6±14.05µs -3.53%
Object Creation (Execution) 5.2±0.60µs 5.3±0.47µs -1.89%
Object Creation (Full) 325.8±11.50µs 337.1±19.56µs -3.35%
RegExp (Execution) 12.3±0.64µs 12.5±0.95µs -1.60%
RegExp (Full) 328.9±15.71µs 336.1±22.64µs -2.14%
RegExp Literal (Execution) 12.5±0.51µs 12.2±0.55µs +2.46%
RegExp Literal (Full) 342.7±18.93µs 348.8±20.19µs -1.75%
RegExp Literal Creation (Execution) 11.1±0.86µs 11.1±0.32µs 0.00%
RegExp Literal Creation (Full) 344.6±36.99µs 344.7±19.66µs -0.03%
Static Object Property Access (Execution) 5.4±0.23µs 5.4±0.27µs 0.00%
Static Object Property Access (Full) 322.5±11.03µs 341.0±15.31µs -5.43%
String Object Access (Execution) 8.6±0.39µs 8.3±0.28µs +3.61%
String Object Access (Full) 329.4±10.51µs 330.0±27.18µs -0.18%
String comparison (Execution) 7.6±0.39µs 7.6±0.29µs 0.00%
String comparison (Full) 335.3±13.16µs 331.7±14.45µs +1.09%
String concatenation (Execution) 6.3±0.32µs 6.2±0.32µs +1.61%
String concatenation (Full) 331.0±18.68µs 322.0±15.85µs +2.80%
String copy (Execution) 4.7±0.21µs 4.6±0.18µs +2.17%
String copy (Full) 323.1±10.87µs 321.1±12.58µs +0.62%
Symbols (Execution) 3.9±0.18µs 3.9±0.26µs 0.00%
Symbols (Full) 301.8±14.59µs 300.7±10.95µs +0.37%

@HalidOdat HalidOdat requested a review from jasonwilliams May 11, 2021 14:40
@HalidOdat HalidOdat merged commit 087a857 into master May 11, 2021
@HalidOdat HalidOdat deleted the cross-realm-symbols branch May 11, 2021 23:56
Razican added a commit that referenced this pull request May 22, 2021
* Cross context symbols

* Remove redundant '_symbol' suffix for well known symbol getters

* Fix symbol equality and hashing

* Add documentation
Razican added a commit that referenced this pull request May 22, 2021
* Cross context symbols

* Remove redundant '_symbol' suffix for well known symbol getters

* Fix symbol equality and hashing

* Add documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builtins PRs and Issues related to builtins/intrinsics enhancement New feature or request execution Issues or PRs related to code execution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants