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

Feature Context::register_global_property() #912

Merged
merged 1 commit into from Oct 24, 2020

Conversation

HalidOdat
Copy link
Member

This Pull Request fixes/closes #891.

It changes the following:

  • Add Context::register_global_property

This allows us to register any global property (primitive value, object, constructor, etc) with a property key (symbol, string, number) and the attributes that the property will be bound to the global object. (see register_global_property doc test/example)

@HalidOdat HalidOdat added enhancement New feature or request API labels Oct 23, 2020
@HalidOdat HalidOdat added this to the v0.11.0 milestone Oct 23, 2020
@HalidOdat HalidOdat force-pushed the feature/register-global-property branch from 27f2cf4 to b06cfeb Compare October 23, 2020 15:24
@github-actions
Copy link

github-actions bot commented Oct 23, 2020

Test262 conformance changes:

Test result master count PR count difference
Total 78,415 78,415 0
Passed 18,461 18,460 -1
Ignored 15,547 15,547 0
Failed 44,407 44,408 +1
Panics 1,129 1,130 +1
Conformance 23.54 23.54 -0.00%

@codecov
Copy link

codecov bot commented Oct 23, 2020

Codecov Report

Merging #912 into master will decrease coverage by 0.01%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #912      +/-   ##
==========================================
- Coverage   59.19%   59.18%   -0.02%     
==========================================
  Files         166      166              
  Lines       10512    10515       +3     
==========================================
  Hits         6223     6223              
- Misses       4289     4292       +3     
Impacted Files Coverage Δ
boa/src/context.rs 60.81% <0.00%> (-0.84%) ⬇️

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 863a4cf...b06cfeb. Read the comment docs.

@github-actions
Copy link

Benchmark for 4b19102

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 359.1±7.29ns 357.1±3.78ns +0.56%
Arithmetic operations (Full) 239.3±2.18µs 240.5±3.15µs -0.50%
Array access (Execution) 7.9±0.22µs 7.9±0.13µs 0.00%
Array access (Full) 256.5±3.86µs 263.5±0.48µs -2.66%
Array creation (Execution) 2.7±0.10ms 2.9±0.03ms -6.90%
Array creation (Full) 3.1±0.04ms 3.1±0.02ms 0.00%
Array pop (Execution) 989.2±36.77µs 1044.4±18.96µs -5.29%
Array pop (Full) 1518.7±32.41µs 1510.2±17.29µs +0.56%
Boolean Object Access (Execution) 4.6±0.10µs 4.7±0.04µs -2.13%
Boolean Object Access (Full) 255.7±0.60µs 254.8±0.51µs +0.35%
Clean js (Execution) 704.8±10.12µs 708.4±8.84µs -0.51%
Clean js (Full) 1015.1±8.72µs 1016.1±6.33µs -0.10%
Clean js (Parser) 37.3±0.13µs 37.1±0.07µs +0.54%
Create Realm 461.6±3.09ns 462.4±6.93ns -0.17%
Dynamic Object Property Access (Execution) 5.6±0.13µs 5.5±0.11µs +1.82%
Dynamic Object Property Access (Full) 257.6±1.07µs 258.4±0.75µs -0.31%
Expression (Parser) 7.0±0.01µs 6.9±0.04µs +1.45%
Fibonacci (Execution) 839.4±7.73µs 832.4±8.19µs +0.84%
Fibonacci (Full) 1096.3±20.01µs 1104.6±11.91µs -0.75%
For loop (Execution) 22.6±0.09µs 22.5±0.24µs +0.44%
For loop (Full) 278.5±2.99µs 283.5±2.39µs -1.76%
For loop (Parser) 18.5±0.04µs 18.2±0.25µs +1.65%
Goal Symbols (Parser) 12.6±0.03µs 12.5±0.20µs +0.80%
Hello World (Parser) 3.4±0.00µs 3.3±0.05µs +3.03%
Long file (Parser) 758.8±0.71ns 760.6±4.87ns -0.24%
Mini js (Execution) 625.1±14.30µs 634.0±11.29µs -1.40%
Mini js (Full) 918.3±5.11µs 918.1±10.12µs +0.02%
Mini js (Parser) 32.5±0.17µs 32.1±0.66µs +1.25%
Number Object Access (Execution) 3.6±0.06µs 3.7±0.02µs -2.70%
Number Object Access (Full) 250.1±1.90µs 251.5±2.91µs -0.56%
Object Creation (Execution) 4.6±0.16µs 4.7±0.07µs -2.13%
Object Creation (Full) 253.8±0.78µs 253.7±1.51µs +0.04%
RegExp (Execution) 10.6±0.11µs 10.7±0.10µs -0.93%
RegExp (Full) 263.6±2.78µs 264.5±1.58µs -0.34%
RegExp Literal (Execution) 10.6±0.17µs 10.6±0.18µs 0.00%
RegExp Literal (Full) 262.1±6.87µs 264.6±0.51µs -0.94%
RegExp Literal Creation (Execution) 9.3±0.21µs 9.4±0.14µs -1.06%
RegExp Literal Creation (Full) 257.5±0.57µs 258.4±0.93µs -0.35%
Static Object Property Access (Execution) 5.0±0.12µs 5.0±0.06µs 0.00%
Static Object Property Access (Full) 251.8±1.34µs 253.2±2.18µs -0.55%
String Object Access (Execution) 7.0±0.16µs 7.2±0.07µs -2.78%
String Object Access (Full) 256.3±2.58µs 258.5±2.44µs -0.85%
String comparison (Execution) 6.4±0.06µs 6.4±0.04µs 0.00%
String comparison (Full) 258.5±1.43µs 259.9±2.11µs -0.54%
String concatenation (Execution) 5.2±0.05µs 5.3±0.04µs -1.89%
String concatenation (Full) 249.9±2.52µs 253.0±1.00µs -1.23%
String copy (Execution) 4.0±0.05µs 4.0±0.03µs 0.00%
String copy (Full) 246.6±1.64µs 245.8±2.85µs +0.33%
Symbols (Execution) 3.4±0.02µs 3.4±0.04µs 0.00%
Symbols (Full) 235.0±6.63µs 243.1±1.38µs -3.33%

@github-actions
Copy link

Benchmark for 61fc4cd

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 358.6±13.25ns 362.8±21.19ns -1.16%
Arithmetic operations (Full) 265.0±32.52µs 259.5±10.89µs +2.12%
Array access (Execution) 8.8±0.35µs 9.0±0.41µs -2.22%
Array access (Full) 273.8±14.26µs 300.2±15.36µs -8.79%
Array creation (Execution) 2.9±0.13ms 2.9±0.10ms 0.00%
Array creation (Full) 2.9±0.15ms 3.1±0.09ms -6.45%
Array pop (Execution) 1035.8±55.00µs 1066.0±46.79µs -2.83%
Array pop (Full) 1435.3±89.45µs 1547.3±64.88µs -7.24%
Boolean Object Access (Execution) 5.0±0.25µs 5.1±0.23µs -1.96%
Boolean Object Access (Full) 290.7±13.05µs 279.4±18.33µs +4.04%
Clean js (Execution) 734.7±30.69µs 725.7±30.52µs +1.24%
Clean js (Full) 1041.3±39.89µs 1046.8±64.75µs -0.53%
Clean js (Parser) 41.2±1.51µs 42.4±2.22µs -2.83%
Create Realm 478.2±21.85ns 508.9±31.64ns -6.03%
Dynamic Object Property Access (Execution) 6.2±0.58µs 6.3±0.27µs -1.59%
Dynamic Object Property Access (Full) 277.0±18.52µs 288.4±7.92µs -3.95%
Expression (Parser) 7.0±0.35µs 7.4±0.25µs -5.41%
Fibonacci (Execution) 972.0±34.09µs 916.8±43.30µs +6.02%
Fibonacci (Full) 1181.0±70.78µs 1307.2±36.47µs -9.65%
For loop (Execution) 24.6±1.06µs 23.8±1.47µs +3.36%
For loop (Full) 297.7±15.38µs 317.0±9.84µs -6.09%
For loop (Parser) 18.7±1.24µs 20.5±0.37µs -8.78%
Goal Symbols (Parser) 13.1±0.75µs 14.1±0.40µs -7.09%
Hello World (Parser) 3.4±0.20µs 3.8±0.12µs -10.53%
Long file (Parser) 803.0±54.43ns 863.3±43.06ns -6.98%
Mini js (Execution) 646.9±37.40µs 647.3±25.93µs -0.06%
Mini js (Full) 940.6±47.59µs 969.7±115.36µs -3.00%
Mini js (Parser) 36.3±1.42µs 36.6±1.32µs -0.82%
Number Object Access (Execution) 4.0±0.19µs 3.9±0.18µs +2.56%
Number Object Access (Full) 272.0±13.07µs 277.9±10.40µs -2.12%
Object Creation (Execution) 5.1±0.37µs 5.5±0.22µs -7.27%
Object Creation (Full) 275.7±14.14µs 264.7±14.13µs +4.16%
RegExp (Execution) 11.7±0.54µs 11.3±0.53µs +3.54%
RegExp (Full) 300.8±8.26µs 293.7±8.55µs +2.42%
RegExp Literal (Execution) 11.5±0.47µs 11.6±0.64µs -0.86%
RegExp Literal (Full) 294.0±13.49µs 290.2±8.17µs +1.31%
RegExp Literal Creation (Execution) 9.4±0.59µs 10.4±0.44µs -9.62%
RegExp Literal Creation (Full) 268.2±20.15µs 289.3±18.43µs -7.29%
Static Object Property Access (Execution) 5.4±0.31µs 5.8±0.26µs -6.90%
Static Object Property Access (Full) 282.7±19.49µs 287.6±8.31µs -1.70%
String Object Access (Execution) 7.8±1.54µs 7.6±0.53µs +2.63%
String Object Access (Full) 282.0±12.61µs 289.7±14.82µs -2.66%
String comparison (Execution) 7.2±0.17µs 6.8±0.42µs +5.88%
String comparison (Full) 290.4±15.29µs 284.8±11.88µs +1.97%
String concatenation (Execution) 5.8±0.28µs 5.6±0.30µs +3.57%
String concatenation (Full) 281.8±9.38µs 279.1±11.52µs +0.97%
String copy (Execution) 4.6±0.18µs 4.3±0.27µs +6.98%
String copy (Full) 275.6±12.46µs 275.1±26.96µs +0.18%
Symbols (Execution) 4.0±0.14µs 3.9±0.20µs +2.56%
Symbols (Full) 258.6±14.44µs 273.2±7.72µs -5.34%

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 very good! Just one question, could this be used to replace register_global_function()? Even then, I think it would make sense to have the helper, as it makes things much easier.

@HalidOdat
Copy link
Member Author

Looks very good! Just one question, could this be used to replace register_global_function()? Even then, I think it would make sense to have the helper, as it makes things much easier.

Yes. it can replace it, we can create a function object with FunctionBuilder and register the function object.
And I agree we should keep it as a helper function, since it's more simple to register a function with register_global_function

@HalidOdat HalidOdat merged commit 4eb2ed4 into master Oct 24, 2020
@HalidOdat HalidOdat deleted the feature/register-global-property branch October 24, 2020 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable creating a global Object
3 participants