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

Merge Const/Let/Var DeclList into DeclarationList #1181

Merged
merged 2 commits into from
Apr 13, 2021

Conversation

0x7D2B
Copy link
Contributor

@0x7D2B 0x7D2B commented Mar 18, 2021

Currently Boa implements declaration lists as three separate structs (LetDeclList, ConstDeclList, VarDeclList) containing three separate structs for individual declarations (LetDecl, ConstDecl, VarDecl).

With a lot of code code duplication between the three declaration list implementations and borderline identical interfaces provided, it seems like a good idea to combine them.

For reference, the original spec treats Const and Let as a single type of declaration: https://tc39.es/ecma262/#sec-declarations-and-the-variable-statement - this commit goes one step further and also combines them with Var.

The new declaration is implemented as an enum with Const, Let, and Var as its variants. Each of these variants wraps a Box<[Declaration]>, similar to how the original separate structs worked. I opted to go for this implementation in anticipation of enum variant types.

Merging these structs will also simplify iteration over declaration lists, since they all now use the same objects. This will be useful for implementing features such as #1175 which make use of bound name lists.

@0x7D2B
Copy link
Contributor Author

0x7D2B commented Mar 18, 2021

no test regressions:

Test262 conformance changes:

Test result master count PR count difference
Total 78,497 78,497 0
Passed 25,344 25,344 0
Ignored 15,587 15,587 0
Failed 37,566 37,566 0
Panics 16 16 0
Conformance 32.29 32.29 0.00%

@RageKnify RageKnify added the parser Issues surrounding the parser label Mar 29, 2021
@RageKnify RageKnify added this to the v0.12.0 milestone Mar 29, 2021
@jasonwilliams
Copy link
Member

This looks good to me I have no issues, thanks for working on this @0x7D2B

@jasonwilliams
Copy link
Member

┌─────────┬──────────────────────────────────────────────┬──────────────────────┬─────────────────────┬────────────┐
│ (index) │                     name                     │   changesDuration    │   masterDuration    │ difference │
├─────────┼──────────────────────────────────────────────┼──────────────────────┼─────────────────────┼────────────┤
│    0    │     'Arithmetic operations (Execution)'      │   '370.6±28.00ns'    │ '**323.1±35.23ns**' │   '+15'    │
│    1    │        'Arithmetic operations (Full)'        │   '278.9±22.75µs'    │ '**264.1±32.91µs**' │   '+6.0'   │
│    2    │          'Array access (Execution)'          │   '**5.9±0.42µs**'   │    '6.3±0.68µs'     │   '-6.5'   │
│    3    │            'Array access (Full)'             │   '301.0±47.62µs'    │ '**262.0±19.41µs**' │   '+15'    │
│    4    │         'Array creation (Execution)'         │     '2.4±0.14ms'     │  '**2.4±0.15ms**'   │   '+1.0'   │
│    5    │           'Array creation (Full)'            │     '2.8±0.20ms'     │  '**2.7±0.17ms**'   │   '+2.0'   │
│    6    │           'Array pop (Execution)'            │   '924.6±92.35µs'    │ '**776.3±51.67µs**' │   '+19'    │
│    7    │              'Array pop (Full)'              │ '**1183.1±73.54µs**' │  '1237.7±93.11µs'   │   '-4.8'   │
│    8    │     'Boolean Object Access (Execution)'      │     '4.9±0.30µs'     │  '**4.8±0.33µs**'   │   '+1.0'   │
│    9    │        'Boolean Object Access (Full)'        │ '**249.1±16.81µs**'  │   '255.2±16.89µs'   │   '-2.0'   │
│   10    │            'Clean js (Execution)'            │   '729.7±28.17µs'    │ '**625.2±56.10µs**' │   '+17'    │
│   11    │              'Clean js (Full)'               │   '1035.3±53.93µs'   │ '**918.7±72.50µs**' │   '+13'    │
│   12    │             'Clean js (Parser)'              │    '43.5±4.52µs'     │  '**38.5±2.95µs**'  │   '+13'    │
│   13    │                'Create Realm'                │   '416.0±27.46ns'    │ '**410.9±38.77ns**' │   '+1.0'   │
│   14    │ 'Dynamic Object Property Access (Execution)' │     '5.5±0.50µs'     │  '**4.9±0.33µs**'   │   '+11'    │
│   15    │   'Dynamic Object Property Access (Full)'    │ '**246.4±13.98µs**'  │   '261.1±22.95µs'   │   '-5.7'   │
│   16    │            'Expression (Parser)'             │   '**6.2±0.40µs**'   │    '7.0±0.42µs'     │   '-12'    │
│   17    │           'Fibonacci (Execution)'            │   '869.4±46.44µs'    │   '870.0±73.76µs'   │   '0.0'    │
│   18    │              'Fibonacci (Full)'              │ '**1104.0±71.28µs**' │  '1151.5±89.51µs'   │   '-3.8'   │
│   19    │            'For loop (Execution)'            │    '23.4±2.29µs'     │  '**22.5±2.50µs**'  │   '+4.0'   │
│   20    │              'For loop (Full)'               │ '**287.3±21.17µs**'  │   '324.4±29.10µs'   │   '-12'    │
│   21    │             'For loop (Parser)'              │  '**19.0±2.05µs**'   │    '19.6±2.08µs'    │   '-2.9'   │
│   22    │           'Goal Symbols (Parser)'            │    '13.4±0.97µs'     │  '**13.1±0.93µs**'  │   '+2.0'   │
│   23    │            'Hello World (Parser)'            │     '3.9±0.44µs'     │    '3.9±0.20µs'     │   '0.0'    │
│   24    │             'Long file (Parser)'             │   '681.5±48.15ns'    │ '**676.2±44.27ns**' │   '+1.0'   │
│   25    │            'Mini js (Execution)'             │ '**556.8±40.04µs**'  │   '619.9±43.42µs'   │   '-9.9'   │
│   26    │               'Mini js (Full)'               │   '995.3±57.85µs'    │ '**812.9±52.37µs**' │   '+22'    │
│   27    │              'Mini js (Parser)'              │    '39.7±5.63µs'     │  '**33.3±2.02µs**'  │   '+19'    │
│   28    │      'Number Object Access (Execution)'      │     '3.9±0.25µs'     │  '**3.8±0.26µs**'   │   '+1.0'   │
│   29    │        'Number Object Access (Full)'         │   '252.7±22.89µs'    │ '**251.4±17.89µs**' │   '+1.0'   │
│   30    │        'Object Creation (Execution)'         │     '4.3±0.37µs'     │  '**4.1±0.24µs**'   │   '+4.0'   │
│   31    │           'Object Creation (Full)'           │   '265.3±53.31µs'    │ '**255.0±16.65µs**' │   '+4.0'   │
│   32    │             'RegExp (Execution)'             │  '**10.3±0.84µs**'   │    '10.7±1.42µs'    │   '-3.8'   │
│   33    │               'RegExp (Full)'                │ '**265.9±19.41µs**'  │   '282.2±25.27µs'   │   '-5.7'   │
│   34    │         'RegExp Literal (Execution)'         │  '**10.2±0.79µs**'   │    '10.3±0.73µs'    │  '-0.99'   │
│   35    │           'RegExp Literal (Full)'            │ '**260.0±16.74µs**'  │   '267.4±21.68µs'   │   '-2.9'   │
│   36    │    'RegExp Literal Creation (Execution)'     │     '9.0±0.77µs'     │    '9.0±0.70µs'     │   '0.0'    │
│   37    │       'RegExp Literal Creation (Full)'       │   '263.0±19.68µs'    │ '**254.1±18.15µs**' │   '+3.0'   │
│   38    │ 'Static Object Property Access (Execution)'  │   '**4.5±0.36µs**'   │    '4.5±0.30µs'     │  '-0.99'   │
│   39    │    'Static Object Property Access (Full)'    │ '**250.2±17.69µs**'  │   '252.4±16.29µs'   │  '-0.99'   │
│   40    │      'String Object Access (Execution)'      │     '7.0±0.41µs'     │  '**6.7±0.43µs**'   │   '+4.0'   │
│   41    │        'String Object Access (Full)'         │ '**257.9±17.19µs**'  │   '266.2±24.17µs'   │   '-2.9'   │
│   42    │       'String comparison (Execution)'        │     '6.7±0.49µs'     │  '**6.4±0.54µs**'   │   '+5.0'   │
│   43    │          'String comparison (Full)'          │   '264.6±21.58µs'    │ '**261.6±32.69µs**' │   '+1.0'   │
│   44    │      'String concatenation (Execution)'      │     '5.1±0.47µs'     │  '**4.9±0.40µs**'   │   '+4.0'   │
│   45    │        'String concatenation (Full)'         │   '262.2±17.94µs'    │ '**254.4±21.96µs**' │   '+3.0'   │
│   46    │          'String copy (Execution)'           │     '4.2±0.45µs'     │  '**3.8±0.29µs**'   │   '+11'    │
│   47    │             'String copy (Full)'             │ '**252.9±25.57µs**'  │   '257.7±24.94µs'   │   '-2.0'   │
│   48    │            'Symbols (Execution)'             │     '3.5±0.35µs'     │  '**3.4±0.27µs**'   │   '+4.0'   │
│   49    │               'Symbols (Full)'               │ '**262.3±22.01µs**'  │   '274.9±12.67µs'   │   '-4.8'   │
│   50    │                      ''                      │      undefined       │      undefined      │   '+NaN'   │
└─────────┴──────────────────────────────────────────────┴──────────────────────┴─────────────────────┴────────────┘

@jasonwilliams jasonwilliams merged commit ea8d9a2 into boa-dev:master Apr 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser Issues surrounding the parser technical debt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants