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

Fully implement EmptyStatement #1151

Merged
merged 6 commits into from
Mar 12, 2021
Merged

Conversation

SamuelQZQ
Copy link
Contributor

This Pull Request fixes/closes #892.

It changes the following:

  • Add a new Node type: Empty.
  • Parse the Empty

Why didn't I remove this line

If we remove this line, var a; will be two statements, a VariableStatement and an EmptyStatement. That's not what we want.

Why we must add this Empty Node?

Otherwise, if(foo()) ; won't work. We must do the same as statement section in ecma262 spec.

@SamuelQZQ
Copy link
Contributor Author

@Razican Can you help me review the pull request?

@Razican Razican added enhancement New feature or request parser Issues surrounding the parser labels Mar 8, 2021
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.

The implementation looks perfect to me. Could we additionally add some tests like the ones in #892 to make sure we correctly execute those? And can we add some parsing tests where we see that multiple ; characters are parsed as empty statements?

boa/src/syntax/ast/node/mod.rs Outdated Show resolved Hide resolved
@Razican
Copy link
Member

Razican commented Mar 8, 2021

Test262 conformance changes:

Test result master count PR count difference
Total 78,497 78,497 0
Passed 24,986 25,037 +51
Ignored 15,587 15,587 0
Failed 37,924 37,873 -51
Panics 16 16 0
Conformance 31.83 31.90 +0.06%

@Razican Razican added bug Something isn't working and removed enhancement New feature or request labels Mar 8, 2021
@Razican Razican added this to the v0.12.0 milestone Mar 8, 2021
@Razican
Copy link
Member

Razican commented Mar 8, 2021

Benchmarks

┌─────────┬──────────────────────────────────────────────┬─────────────────────┬──────────────────────┬────────────┐
│ (index) │                     name                     │   changesDuration   │    masterDuration    │ difference │
├─────────┼──────────────────────────────────────────────┼─────────────────────┼──────────────────────┼────────────┤
│    0    │     'Arithmetic operations (Execution)'      │   '321.9±21.88ns'   │ '**313.1±11.18ns**'  │   '+3.0'   │
│    1    │        'Arithmetic operations (Full)'        │   '220.9±11.16µs'   │  '**206.4±9.95µs**'  │   '+7.0'   │
│    2    │          'Array access (Execution)'          │  '**5.5±0.20µs**'   │     '5.5±0.24µs'     │  '-0.99'   │
│    3    │            'Array access (Full)'             │   '229.8±12.17µs'   │ '**221.3±10.33µs**'  │   '+4.0'   │
│    4    │         'Array creation (Execution)'         │  '**2.6±0.10ms**'   │     '2.7±0.09ms'     │   '-2.9'   │
│    5    │           'Array creation (Full)'            │  '**2.8±0.15ms**'   │     '3.0±0.16ms'     │   '-6.5'   │
│    6    │           'Array pop (Execution)'            │ '**867.3±40.52µs**' │   '894.8±52.26µs'    │   '-2.9'   │
│    7    │              'Array pop (Full)'              │  '1270.1±94.40µs'   │ '**1243.4±58.28µs**' │   '+2.0'   │
│    8    │     'Boolean Object Access (Execution)'      │    '4.7±0.24µs'     │   '**4.6±0.20µs**'   │   '+2.0'   │
│    9    │        'Boolean Object Access (Full)'        │   '219.8±8.90µs'    │    '219.6±9.99µs'    │   '0.0'    │
│   10    │            'Clean js (Execution)'            │   '648.5±34.31µs'   │ '**598.7±26.13µs**'  │   '+8.0'   │
│   11    │              'Clean js (Full)'               │ '**904.5±41.54µs**' │   '936.9±35.42µs'    │   '-3.8'   │
│   12    │             'Clean js (Parser)'              │  '**38.2±1.57µs**'  │    '39.3±1.96µs'     │   '-2.9'   │
│   13    │                'Create Realm'                │   '438.7±11.37ns'   │ '**413.2±19.53ns**'  │   '+6.0'   │
│   14    │ 'Dynamic Object Property Access (Execution)' │  '**4.6±0.22µs**'   │     '4.7±0.27µs'     │  '-0.99'   │
│   15    │   'Dynamic Object Property Access (Full)'    │   '218.5±5.34µs'    │  '**216.2±7.43µs**'  │   '+1.0'   │
│   16    │            'Expression (Parser)'             │  '**6.3±0.25µs**'   │     '6.5±0.29µs'     │   '-3.8'   │
│   17    │           'Fibonacci (Execution)'            │ '**769.3±40.84µs**' │   '790.5±54.66µs'    │   '-2.9'   │
│   18    │              'Fibonacci (Full)'              │  '1026.5±85.84µs'   │ '**986.7±46.37µs**'  │   '+4.0'   │
│   19    │            'For loop (Execution)'            │  '**20.1±0.65µs**'  │    '20.7±1.36µs'     │   '-2.9'   │
│   20    │              'For loop (Full)'               │   '256.6±13.54µs'   │ '**244.2±13.56µs**'  │   '+5.0'   │
│   21    │             'For loop (Parser)'              │  '**18.0±0.73µs**'  │    '18.9±1.48µs'     │   '-4.8'   │
│   22    │           'Goal Symbols (Parser)'            │  '**13.0±0.70µs**'  │    '13.1±0.78µs'     │  '-0.99'   │
│   23    │            'Hello World (Parser)'            │  '**3.4±0.13µs**'   │     '3.5±0.14µs'     │   '-2.0'   │
│   24    │             'Long file (Parser)'             │   '733.3±32.95ns'   │ '**708.7±30.69ns**'  │   '+3.0'   │
│   25    │            'Mini js (Execution)'             │   '559.0±33.98µs'   │ '**538.7±30.71µs**'  │   '+4.0'   │
│   26    │               'Mini js (Full)'               │ '**781.5±35.35µs**' │   '821.9±37.70µs'    │   '-4.8'   │
│   27    │              'Mini js (Parser)'              │  '**34.8±1.91µs**'  │    '35.1±2.00µs'     │  '-0.99'   │
│   28    │      'Number Object Access (Execution)'      │    '3.5±0.16µs'     │     '3.5±0.18µs'     │   '0.0'    │
│   29    │        'Number Object Access (Full)'         │   '213.1±8.08µs'    │  '**212.0±7.28µs**'  │   '+1.0'   │
│   30    │        'Object Creation (Execution)'         │    '4.0±0.34µs'     │   '**3.8±0.19µs**'   │   '+3.0'   │
│   31    │           'Object Creation (Full)'           │   '218.8±19.69µs'   │    '219.6±9.05µs'    │   '0.0'    │
│   32    │             'RegExp (Execution)'             │    '9.9±0.45µs'     │   '**9.5±0.46µs**'   │   '+4.0'   │
│   33    │               'RegExp (Full)'                │   '231.8±14.31µs'   │ '**222.8±10.94µs**'  │   '+4.0'   │
│   34    │         'RegExp Literal (Execution)'         │    '10.5±0.41µs'    │   '**9.6±0.44µs**'   │   '+9.0'   │
│   35    │           'RegExp Literal (Full)'            │   '230.8±11.72µs'   │ '**227.7±10.40µs**'  │   '+1.0'   │
│   36    │    'RegExp Literal Creation (Execution)'     │    '9.3±0.35µs'     │   '**8.5±0.47µs**'   │   '+9.0'   │
│   37    │       'RegExp Literal Creation (Full)'       │   '230.9±14.32µs'   │  '**214.1±4.64µs**'  │   '+8.0'   │
│   38    │ 'Static Object Property Access (Execution)'  │  '**4.0±0.13µs**'   │     '4.2±0.27µs'     │   '-2.9'   │
│   39    │    'Static Object Property Access (Full)'    │   '213.9±6.01µs'    │    '214.9±9.72µs'    │   '0.0'    │
│   40    │      'String Object Access (Execution)'      │    '6.1±0.15µs'     │   '**6.1±0.17µs**'   │   '+1.0'   │
│   41    │        'String Object Access (Full)'         │   '223.4±10.17µs'   │  '**220.3±5.34µs**'  │   '+1.0'   │
│   42    │       'String comparison (Execution)'        │    '5.7±0.25µs'     │     '5.7±0.19µs'     │   '0.0'    │
│   43    │          'String comparison (Full)'          │   '222.7±9.63µs'    │   '222.0±12.57µs'    │   '0.0'    │
│   44    │      'String concatenation (Execution)'      │    '4.9±0.21µs'     │   '**4.7±0.20µs**'   │   '+3.0'   │
│   45    │        'String concatenation (Full)'         │ '**220.0±9.98µs**'  │   '224.7±13.14µs'    │   '-2.0'   │
│   46    │          'String copy (Execution)'           │  '**3.5±0.19µs**'   │     '3.6±0.24µs'     │   '-2.9'   │
│   47    │             'String copy (Full)'             │ '**208.0±6.71µs**'  │   '212.4±11.97µs'    │   '-2.0'   │
│   48    │            'Symbols (Execution)'             │    '3.2±0.04µs'     │   '**3.0±0.28µs**'   │   '+7.0'   │
│   49    │               'Symbols (Full)'               │   '226.4±12.09µs'   │ '**214.9±14.95µs**'  │   '+5.0'   │
│   50    │                      ''                      │      undefined      │      undefined       │   '+NaN'   │
└─────────┴──────────────────────────────────────────────┴─────────────────────┴──────────────────────┴────────────┘

@SamuelQZQ
Copy link
Contributor Author

The implementation looks perfect to me. Could we additionally add some tests like the ones in #892 to make sure we correctly execute those? And can we add some parsing tests where we see that multiple ; characters are parsed as empty statements?

@Razican Added.

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.

Thanks! It looks very good now :)

@Razican Razican merged commit 7262882 into boa-dev:master Mar 12, 2021
@SamuelQZQ SamuelQZQ deleted the empty-statement branch April 26, 2021 14:31
Razican pushed a commit that referenced this pull request May 22, 2021
* add EmptyStatement

* add comments

* format code

* add test

* add test

* fmt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parser Issues surrounding the parser
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Empty statements not fully implemented
3 participants