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

Refactor Property Descriptor flags #553

Merged
merged 3 commits into from
Jul 21, 2020
Merged

Refactor Property Descriptor flags #553

merged 3 commits into from
Jul 21, 2020

Conversation

HalidOdat
Copy link
Member

@HalidOdat HalidOdat commented Jul 8, 2020

This Pull Request fixes/closes #497 .

This PR changes:

  • Added Attribute bitflags for defineing when the property is WRITABLE, CONFIGURABLE or ENUMBERABLE
  • changed Option<bool> for writable, enumerable and configurable flags to take one byte.
  • Added data_descriptor constructor for Property.
  • Added has_*, set_* and *_or methods for property
  • Made flag selection more ergonomic for example:
some_function(Attribute::READONLY | Attribute::ENUMBERABLE | Attribute::CONFIGURABLE);

over

some_function(Some(false), Some(true), Some(true));

@HalidOdat HalidOdat added performance Performance related changes and issues technical debt builtins PRs and Issues related to builtins/intrinsics execution Issues or PRs related to code execution labels Jul 8, 2020
@HalidOdat HalidOdat added this to the v0.10.0 milestone Jul 8, 2020
@codecov
Copy link

codecov bot commented Jul 8, 2020

Codecov Report

Merging #553 into master will increase coverage by 0.34%.
The diff coverage is 76.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #553      +/-   ##
==========================================
+ Coverage   70.37%   70.71%   +0.34%     
==========================================
  Files         175      177       +2     
  Lines       11145    11275     +130     
==========================================
+ Hits         7843     7973     +130     
  Misses       3302     3302              
Impacted Files Coverage Δ
boa/src/environment/global_environment_record.rs 27.95% <0.00%> (+1.15%) ⬆️
boa/src/builtins/property/mod.rs 44.30% <44.00%> (-11.70%) ⬇️
boa/src/builtins/object/internal_methods.rs 31.60% <50.00%> (+1.76%) ⬆️
boa/src/environment/object_environment_record.rs 21.56% <50.00%> (+3.56%) ⬆️
boa/src/builtins/function/mod.rs 71.00% <87.50%> (-0.76%) ⬇️
boa/src/builtins/property/attribute/mod.rs 90.62% <90.62%> (ø)
boa/src/builtins/array/mod.rs 80.97% <100.00%> (ø)
boa/src/builtins/map/mod.rs 81.96% <100.00%> (ø)
boa/src/builtins/object/mod.rs 40.66% <100.00%> (ø)
boa/src/builtins/property/attribute/tests.rs 100.00% <100.00%> (ø)
... and 3 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 1c1132d...f6409f0. Read the comment docs.

@HalidOdat HalidOdat marked this pull request as draft July 8, 2020 10:41
@github-actions
Copy link

github-actions bot commented Jul 8, 2020

Benchmark for ffdf4de

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 417.1±40.19ns 437.0±22.54ns -4.55%
Array access (Execution) 14.0±1.29µs 13.5±0.59µs +3.70%
Array creation (Execution) 3.8±0.15ms 3.8±0.27ms 0.00%
Array pop (Execution) 1399.4±96.46µs 1396.0±43.54µs +0.24%
Boolean Object Access (Execution) 4.9±0.30µs 5.4±0.17µs -9.26%
Create Realm 149.3±10.12µs 146.9±7.67µs +1.63%
Dynamic Object Property Access (Execution) 6.8±0.64µs 7.7±0.93µs -11.69%
Expression (Lexer) 2.0±0.14µs 2.1±0.06µs -4.76%
Expression (Parser) 4.7±0.28µs 5.1±0.14µs -7.84%
Fibonacci (Execution) 964.5±59.89µs 976.4±55.61µs -1.22%
For loop (Execution) 22.6±1.64µs 22.6±2.16µs 0.00%
For loop (Lexer) 5.0±0.34µs 5.3±0.17µs -5.66%
For loop (Parser) 12.9±0.88µs 13.8±0.36µs -6.52%
Hello World (Lexer) 872.1±58.83ns 922.1±28.19ns -5.42%
Hello World (Parser) 2.2±0.12µs 2.3±0.03µs -4.35%
Long file (Parser) 5.8±0.21ms 6.3±0.17ms -7.94%
Number Object Access (Execution) 3.9±0.24µs 4.4±0.29µs -11.36%
Object Creation (Execution) 6.1±0.55µs 6.2±0.28µs -1.61%
RegExp (Execution) 72.7±8.08µs 75.0±4.45µs -3.07%
RegExp Literal (Execution) 74.6±4.89µs 78.5±3.84µs -4.97%
RegExp Literal Creation (Execution) 71.3±3.74µs 81.8±22.65µs -12.84%
Static Object Property Access (Execution) 6.3±0.45µs 6.6±0.24µs -4.55%
String Object Access (Execution) 8.3±0.81µs 9.0±0.35µs -7.78%
String comparison (Execution) 6.5±0.39µs 6.7±0.55µs -2.99%
String concatenation (Execution) 5.5±0.32µs 5.8±1.47µs -5.17%
String copy (Execution) 4.3±0.50µs 4.8±0.20µs -10.42%
Symbols (Execution) 4.1±0.23µs 4.0±0.21µs +2.50%

@github-actions
Copy link

github-actions bot commented Jul 8, 2020

Benchmark for 0078c4c

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 423.8±18.62ns 412.4±21.84ns +2.76%
Array access (Execution) 12.8±0.81µs 14.8±0.90µs -13.51%
Array creation (Execution) 3.6±0.20ms 4.0±0.26ms -10.00%
Array pop (Execution) 1455.1±86.22µs 1352.2±63.28µs +7.61%
Boolean Object Access (Execution) 4.9±0.32µs 5.1±0.34µs -3.92%
Create Realm 145.1±10.27µs 166.0±19.89µs -12.59%
Dynamic Object Property Access (Execution) 6.7±0.39µs 7.0±0.36µs -4.29%
Expression (Lexer) 2.0±0.18µs 2.0±0.09µs 0.00%
Expression (Parser) 4.9±0.18µs 4.8±0.39µs +2.08%
Fibonacci (Execution) 965.6±58.88µs 1095.2±109.60µs -11.83%
For loop (Execution) 21.8±1.02µs 23.3±1.14µs -6.44%
For loop (Lexer) 5.4±0.34µs 5.2±0.25µs +3.85%
For loop (Parser) 13.5±0.66µs 13.8±0.83µs -2.17%
Goal Symbols (Parser) 8.5±0.32µs 8.4±0.61µs +1.19%
Hello World (Lexer) 891.9±57.14ns 896.4±69.48ns -0.50%
Hello World (Parser) 2.2±0.11µs 2.2±0.12µs 0.00%
Long file (Parser) 5.7±0.24ms 6.0±0.24ms -5.00%
Number Object Access (Execution) 3.9±0.27µs 3.8±0.25µs +2.63%
Object Creation (Execution) 5.8±0.46µs 6.1±0.32µs -4.92%
RegExp (Execution) 75.3±5.28µs 72.3±4.29µs +4.15%
RegExp Literal (Execution) 76.5±3.84µs 75.4±3.22µs +1.46%
RegExp Literal Creation (Execution) 73.7±3.75µs 72.3±2.87µs +1.94%
Static Object Property Access (Execution) 6.2±0.38µs 6.2±0.35µs 0.00%
String Object Access (Execution) 8.2±0.40µs 8.3±0.43µs -1.20%
String comparison (Execution) 7.0±0.35µs 7.0±0.62µs 0.00%
String concatenation (Execution) 5.5±0.32µs 5.6±0.22µs -1.79%
String copy (Execution) 4.5±0.26µs 4.4±0.36µs +2.27%
Symbols (Execution) 4.0±0.20µs 4.4±0.35µs -9.09%

@github-actions
Copy link

Benchmark for aa28fa1

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 357.3±0.22ns 356.8±0.28ns +0.14%
Arithmetic operations (Full) 144.5±0.18µs 146.8±0.23µs -1.57%
Array access (Execution) 11.7±0.05µs 11.9±0.03µs -1.68%
Array access (Full) 163.6±2.15µs 166.5±0.36µs -1.74%
Array creation (Execution) 3.3±0.00ms 3.3±0.00ms 0.00%
Array creation (Full) 3.6±0.01ms 3.6±0.00ms 0.00%
Array pop (Execution) 1224.4±3.45µs 1238.4±3.03µs -1.13%
Array pop (Full) 1504.2±5.35µs 1521.2±1.86µs -1.12%
Boolean Object Access (Execution) 4.3±0.01µs 4.5±0.01µs -4.44%
Boolean Object Access (Full) 152.9±0.17µs 153.9±0.25µs -0.65%
Create Realm 133.5±0.42µs 132.7±0.14µs +0.60%
Dynamic Object Property Access (Execution) 6.0±0.08µs 6.2±0.02µs -3.23%
Dynamic Object Property Access (Full) 154.5±0.27µs 156.3±0.42µs -1.15%
Expression (Lexer) 1796.7±1.83ns 1776.4±9.24ns +1.14%
Expression (Parser) 4.4±0.00µs 4.5±0.00µs -2.22%
Fibonacci (Execution) 846.7±1.27µs 859.0±1.58µs -1.43%
Fibonacci (Full) 1016.7±1.52µs 1041.1±1.46µs -2.34%
For loop (Execution) 19.4±0.14µs 19.4±0.04µs 0.00%
For loop (Full) 167.6±0.25µs 169.0±0.28µs -0.83%
For loop (Lexer) 4.6±0.01µs 4.6±0.00µs 0.00%
For loop (Parser) 12.4±0.05µs 12.4±0.07µs 0.00%
Goal Symbols (Parser) 7.7±0.02µs 7.7±0.01µs 0.00%
Hello World (Lexer) 806.0±4.49ns 806.7±0.63ns -0.09%
Hello World (Parser) 1950.8±3.00ns 1958.9±3.64ns -0.41%
Long file (Parser) 5.5±0.02ms 5.5±0.03ms 0.00%
Number Object Access (Execution) 3.3±0.00µs 3.5±0.02µs -5.71%
Number Object Access (Full) 191.1±0.91µs 192.1±0.29µs -0.52%
Object Creation (Execution) 5.3±0.01µs 5.4±0.01µs -1.85%
Object Creation (Full) 170.6±0.21µs 171.6±0.85µs -0.58%
RegExp (Execution) 62.9±0.48µs 62.8±0.52µs +0.16%
RegExp (Full) 262.2±0.49µs 263.3±0.39µs -0.42%
RegExp Literal (Execution) 65.9±0.51µs 65.9±0.55µs 0.00%
RegExp Literal (Full) 225.3±0.83µs 226.2±2.16µs -0.40%
RegExp Literal Creation (Execution) 62.9±0.46µs 62.8±0.41µs +0.16%
RegExp Literal Creation (Full) 259.9±0.46µs 261.3±0.57µs -0.54%
Static Object Property Access (Execution) 5.4±0.01µs 5.6±0.02µs -3.57%
Static Object Property Access (Full) 153.5±1.33µs 153.5±0.20µs 0.00%
String Object Access (Execution) 7.2±0.02µs 7.5±0.01µs -4.00%
String Object Access (Full) 155.9±0.25µs 159.7±0.62µs -2.38%
String comparison (Execution) 5.9±0.02µs 5.9±0.03µs 0.00%
String comparison (Full) 157.5±0.22µs 155.4±0.55µs +1.35%
String concatenation (Execution) 4.9±0.02µs 5.0±0.02µs -2.00%
String concatenation (Full) 151.9±0.22µs 151.6±0.24µs +0.20%
String copy (Execution) 3.9±0.04µs 4.1±0.02µs -4.88%
String copy (Full) 150.0±0.18µs 148.0±0.37µs +1.35%
Symbols (Execution) 3.4±0.01µs 3.5±0.00µs -2.86%
Symbols (Full) 141.1±2.31µs 141.6±0.20µs -0.35%

@HalidOdat HalidOdat marked this pull request as ready for review July 19, 2020 17:08
@HalidOdat HalidOdat changed the title Refactor Property Descriptor Refactor Property Descriptor flags Jul 19, 2020
@github-actions
Copy link

Benchmark for 627558f

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 388.5±21.62ns 396.9±27.21ns -2.12%
Arithmetic operations (Full) 185.2±8.15µs 192.7±9.34µs -3.89%
Array access (Execution) 15.5±1.06µs 15.9±0.78µs -2.52%
Array access (Full) 228.5±13.42µs 225.9±20.12µs +1.15%
Array creation (Execution) 3.9±0.18ms 3.8±0.15ms +2.63%
Array creation (Full) 4.2±0.16ms 4.3±0.20ms -2.33%
Array pop (Execution) 1480.5±70.64µs 1483.9±69.62µs -0.23%
Array pop (Full) 1867.5±101.45µs 1835.7±74.98µs +1.73%
Boolean Object Access (Execution) 5.4±0.33µs 6.0±0.45µs -10.00%
Boolean Object Access (Full) 193.9±14.43µs 206.1±10.69µs -5.92%
Create Realm 167.9±9.41µs 177.9±15.81µs -5.62%
Dynamic Object Property Access (Execution) 7.6±0.45µs 8.0±0.39µs -5.00%
Dynamic Object Property Access (Full) 199.4±8.81µs 219.9±19.49µs -9.32%
Expression (Lexer) 2.5±0.11µs 2.6±0.16µs -3.85%
Expression (Parser) 5.3±0.28µs 5.4±0.40µs -1.85%
Fibonacci (Execution) 1126.6±62.86µs 1165.2±70.57µs -3.31%
Fibonacci (Full) 1346.6±75.58µs 1404.7±90.88µs -4.14%
For loop (Execution) 25.7±1.50µs 25.6±1.76µs +0.39%
For loop (Full) 211.3±10.05µs 225.5±10.57µs -6.30%
For loop (Lexer) 5.5±0.27µs 5.7±0.34µs -3.51%
For loop (Parser) 15.2±0.85µs 15.2±1.08µs 0.00%
Goal Symbols (Parser) 8.8±0.43µs 8.8±0.60µs 0.00%
Hello World (Lexer) 901.5±45.63ns 906.7±58.25ns -0.57%
Hello World (Parser) 2.3±0.11µs 2.3±0.18µs 0.00%
Long file (Parser) 6.9±0.25ms 6.9±0.24ms 0.00%
Number Object Access (Execution) 4.2±0.25µs 4.6±0.46µs -8.70%
Number Object Access (Full) 234.7±12.92µs 247.9±14.09µs -5.32%
Object Creation (Execution) 6.8±0.40µs 7.1±0.41µs -4.23%
Object Creation (Full) 216.7±10.44µs 233.4±15.11µs -7.16%
RegExp (Execution) 76.4±5.53µs 75.8±4.13µs +0.79%
RegExp (Full) 322.5±15.74µs 342.5±26.91µs -5.84%
RegExp Literal (Execution) 81.3±4.97µs 81.4±4.39µs -0.12%
RegExp Literal (Full) 279.5±8.70µs 302.4±15.43µs -7.57%
RegExp Literal Creation (Execution) 76.4±5.40µs 76.0±4.05µs +0.53%
RegExp Literal Creation (Full) 325.1±19.54µs 348.7±21.76µs -6.77%
Static Object Property Access (Execution) 7.2±0.47µs 7.2±0.36µs 0.00%
Static Object Property Access (Full) 199.7±10.76µs 212.3±14.57µs -5.93%
String Object Access (Execution) 9.3±0.42µs 10.4±1.28µs -10.58%
String Object Access (Full) 196.7±6.98µs 215.4±13.62µs -8.68%
String comparison (Execution) 7.5±0.39µs 7.7±0.41µs -2.60%
String comparison (Full) 197.2±8.87µs 211.4±11.14µs -6.72%
String concatenation (Execution) 6.6±0.37µs 6.7±0.49µs -1.49%
String concatenation (Full) 200.1±11.82µs 205.5±10.39µs -2.63%
String copy (Execution) 5.1±0.36µs 5.5±0.43µs -7.27%
String copy (Full) 189.6±9.47µs 198.9±11.37µs -4.68%
Symbols (Execution) 4.4±0.27µs 4.7±0.33µs -6.38%
Symbols (Full) 180.6±8.12µs 198.3±11.33µs -8.93%

Copy link
Member

@jasonwilliams jasonwilliams left a comment

Choose a reason for hiding this comment

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

Looks great!

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.

This looks very good :) check my comments in case they make sense, but this is ready to merge :)

boa/src/builtins/object/internal_methods.rs Outdated Show resolved Hide resolved
boa/src/builtins/property/mod.rs Show resolved Hide resolved
@HalidOdat HalidOdat merged commit 5d4d8fe into master Jul 21, 2020
@HalidOdat HalidOdat deleted the refactor/property branch July 21, 2020 00:26
@github-actions
Copy link

Benchmark for a9a4b96

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 369.9±9.22ns 380.3±8.67ns -2.73%
Arithmetic operations (Full) 155.1±7.12µs 164.3±2.74µs -5.60%
Array access (Execution) 13.2±0.38µs 13.8±0.28µs -4.35%
Array access (Full) 182.8±11.16µs 184.6±3.77µs -0.98%
Array creation (Execution) 3.7±0.11ms 3.8±0.12ms -2.63%
Array creation (Full) 4.0±0.08ms 4.2±0.10ms -4.76%
Array pop (Execution) 1389.7±39.02µs 1462.8±77.89µs -5.00%
Array pop (Full) 1717.4±37.86µs 1820.3±39.43µs -5.65%
Boolean Object Access (Execution) 4.0±0.14µs 4.5±0.16µs -11.11%
Boolean Object Access (Full) 166.1±5.43µs 171.2±5.20µs -2.98%
Create Realm 149.7±6.75µs 156.0±4.28µs -4.04%
Dynamic Object Property Access (Execution) 6.4±0.37µs 6.3±0.17µs +1.59%
Dynamic Object Property Access (Full) 172.1±4.74µs 177.4±7.20µs -2.99%
Expression (Lexer) 2.3±0.06µs 2.4±0.09µs -4.17%
Expression (Parser) 5.3±0.16µs 5.3±0.15µs 0.00%
Fibonacci (Execution) 954.1±33.27µs 1002.0±44.09µs -4.78%
Fibonacci (Full) 1139.5±48.42µs 1188.7±57.34µs -4.14%
For loop (Execution) 22.1±0.55µs 22.3±0.38µs -0.90%
For loop (Full) 186.1±6.53µs 189.9±7.65µs -2.00%
For loop (Lexer) 5.2±0.31µs 5.2±0.11µs 0.00%
For loop (Parser) 14.0±0.70µs 13.8±0.25µs +1.45%
Goal Symbols (Parser) 8.2±0.29µs 8.4±0.27µs -2.38%
Hello World (Lexer) 769.4±30.31ns 807.5±23.48ns -4.72%
Hello World (Parser) 2.1±0.07µs 2.1±0.05µs 0.00%
Long file (Parser) 6.0±0.14ms 6.3±0.15ms -4.76%
Number Object Access (Execution) 3.2±0.08µs 3.5±0.07µs -8.57%
Number Object Access (Full) 164.6±3.83µs 168.0±2.85µs -2.02%
Object Creation (Execution) 5.5±0.23µs 5.6±0.18µs -1.79%
Object Creation (Full) 191.9±5.38µs 197.4±6.76µs -2.79%
RegExp (Execution) 65.6±2.36µs 66.0±2.53µs -0.61%
RegExp (Full) 245.1±7.61µs 249.9±5.48µs -1.92%
RegExp Literal (Execution) 69.3±3.53µs 69.3±2.72µs 0.00%
RegExp Literal (Full) 243.3±6.26µs 251.5±17.93µs -3.26%
RegExp Literal Creation (Execution) 66.3±3.05µs 64.3±2.27µs +3.11%
RegExp Literal Creation (Full) 289.4±10.11µs 288.0±7.33µs +0.49%
Static Object Property Access (Execution) 5.7±0.22µs 5.8±0.28µs -1.72%
Static Object Property Access (Full) 168.8±4.00µs 176.4±5.64µs -4.31%
String Object Access (Execution) 7.5±0.20µs 8.2±0.17µs -8.54%
String Object Access (Full) 168.6±6.19µs 178.4±7.30µs -5.49%
String comparison (Execution) 6.4±0.33µs 6.7±0.31µs -4.48%
String comparison (Full) 170.9±5.74µs 176.0±3.31µs -2.90%
String concatenation (Execution) 5.3±0.22µs 5.5±0.46µs -3.64%
String concatenation (Full) 168.2±5.08µs 171.8±3.78µs -2.10%
String copy (Execution) 4.1±0.44µs 4.3±0.09µs -4.65%
String copy (Full) 162.5±6.69µs 167.7±5.33µs -3.10%
Symbols (Execution) 3.6±0.06µs 3.7±0.07µs -2.70%
Symbols (Full) 155.6±6.77µs 162.3±5.32µs -4.13%

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 execution Issues or PRs related to code execution performance Performance related changes and issues technical debt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactoring Property flags
3 participants