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

Return optional value in to_json functions (fixes #1064) #1201

Merged
merged 3 commits into from
May 3, 2021

Conversation

fermian
Copy link
Contributor

@fermian fermian commented Apr 10, 2021

This Pull Request fixes/closes #1064.

It changes the following:

  • Makes Value::to_json, GcObject::to_json return an optional JSONValue. If the value cannot be converted into a JSON value, the functions return None.

@Razican
Copy link
Member

Razican commented Apr 19, 2021

Test262 conformance changes:

Test result master count PR count difference
Total 78,497 78,497 0
Passed 25,499 25,501 +2
Ignored 15,587 15,587 0
Failed 37,411 37,409 -2
Panics 18 14 -4
Conformance 32.48 32.49 +0.00%

Benchmarks

┌─────────┬──────────────────────────────────────────────┬─────────────────────┬──────────────────────┬────────────┐
│ (index) │                     name                     │   changesDuration   │    masterDuration    │ difference │
├─────────┼──────────────────────────────────────────────┼─────────────────────┼──────────────────────┼────────────┤
│    0    │     'Arithmetic operations (Execution)'      │ '**312.1±5.97ns**'  │    '314.7±5.83ns'    │  '-0.99'   │
│    1    │        'Arithmetic operations (Full)'        │   '244.1±5.81µs'    │  '**241.7±3.30µs**'  │   '+1.0'   │
│    2    │          'Array access (Execution)'          │  '**5.9±0.30µs**'   │     '5.9±0.19µs'     │  '-0.99'   │
│    3    │            'Array access (Full)'             │   '263.1±9.89µs'    │  '**257.5±5.38µs**'  │   '+2.0'   │
│    4    │         'Array creation (Execution)'         │    '2.6±0.10ms'     │     '2.6±0.09ms'     │   '0.0'    │
│    5    │           'Array creation (Full)'            │    '2.6±0.07ms'     │     '2.6±0.04ms'     │   '0.0'    │
│    6    │           'Array pop (Execution)'            │ '**823.3±13.16µs**' │   '842.9±45.96µs'    │   '-2.0'   │
│    7    │              'Array pop (Full)'              │  '1220.5±43.30µs'   │ '**1207.2±32.38µs**' │   '+1.0'   │
│    8    │     'Boolean Object Access (Execution)'      │    '5.2±0.43µs'     │   '**5.0±0.15µs**'   │   '+5.0'   │
│    9    │        'Boolean Object Access (Full)'        │   '256.2±8.04µs'    │    '256.0±4.92µs'    │   '0.0'    │
│   10    │            'Clean js (Execution)'            │ '**607.4±19.37µs**' │   '618.1±15.52µs'    │   '-2.0'   │
│   11    │              'Clean js (Full)'               │   '886.9±30.40µs'   │ '**870.3±15.63µs**'  │   '+2.0'   │
│   12    │             'Clean js (Parser)'              │    '40.6±1.06µs'    │  '**40.1±0.70µs**'   │   '+1.0'   │
│   13    │                'Create Realm'                │ '**404.6±15.41ns**' │    '419.7±8.71ns'    │   '-3.8'   │
│   14    │ 'Dynamic Object Property Access (Execution)' │    '4.8±0.13µs'     │     '4.8±0.14µs'     │   '0.0'    │
│   15    │   'Dynamic Object Property Access (Full)'    │   '263.0±31.09µs'   │  '**256.7±4.81µs**'  │   '+2.0'   │
│   16    │            'Expression (Parser)'             │  '**6.1±0.09µs**'   │     '6.5±0.18µs'     │   '-4.8'   │
│   17    │           'Fibonacci (Execution)'            │ '**774.4±14.13µs**' │   '780.7±16.34µs'    │  '-0.99'   │
│   18    │              'Fibonacci (Full)'              │  '1008.5±34.38µs'   │   '1012.3±43.14µs'   │   '0.0'    │
│   19    │            'For loop (Execution)'            │    '20.3±0.68µs'    │    '20.2±0.38µs'     │   '0.0'    │
│   20    │              'For loop (Full)'               │   '275.8±14.36µs'   │  '**270.0±9.04µs**'  │   '+2.0'   │
│   21    │             'For loop (Parser)'              │    '19.0±0.62µs'    │    '18.9±0.51µs'     │   '0.0'    │
│   22    │           'Goal Symbols (Parser)'            │    '13.2±0.28µs'    │    '13.2±0.40µs'     │   '0.0'    │
│   23    │            'Hello World (Parser)'            │    '3.5±0.13µs'     │     '3.6±0.06µs'     │   '0.0'    │
│   24    │             'Long file (Parser)'             │ '**692.0±22.38ns**' │   '699.3±16.00ns'    │  '-0.99'   │
│   25    │            'Mini js (Execution)'             │   '553.5±33.67µs'   │ '**548.4±12.50µs**'  │   '+1.0'   │
│   26    │               'Mini js (Full)'               │   '807.0±18.57µs'   │   '803.8±15.03µs'    │   '0.0'    │
│   27    │              'Mini js (Parser)'              │    '35.4±0.93µs'    │  '**35.2±0.70µs**'   │   '+1.0'   │
│   28    │      'Number Object Access (Execution)'      │    '4.0±0.12µs'     │   '**3.8±0.12µs**'   │   '+6.0'   │
│   29    │        'Number Object Access (Full)'         │   '257.2±9.82µs'    │ '**253.7±13.61µs**'  │   '+1.0'   │
│   30    │        'Object Creation (Execution)'         │  '**4.1±0.15µs**'   │     '4.1±0.17µs'     │  '-0.99'   │
│   31    │           'Object Creation (Full)'           │   '255.4±10.68µs'   │    '255.2±8.40µs'    │   '0.0'    │
│   32    │             'RegExp (Execution)'             │  '**9.1±0.51µs**'   │     '9.3±0.33µs'     │   '-2.9'   │
│   33    │               'RegExp (Full)'                │   '262.1±5.45µs'    │  '**258.6±7.71µs**'  │   '+1.0'   │
│   34    │         'RegExp Literal (Execution)'         │  '**10.2±0.18µs**'  │    '10.5±0.33µs'     │   '-2.9'   │
│   35    │           'RegExp Literal (Full)'            │   '267.2±15.32µs'   │    '266.4±7.80µs'    │   '0.0'    │
│   36    │    'RegExp Literal Creation (Execution)'     │    '8.9±0.32µs'     │     '9.0±0.18µs'     │   '0.0'    │
│   37    │       'RegExp Literal Creation (Full)'       │   '263.2±14.31µs'   │  '**259.3±7.92µs**'  │   '+2.0'   │
│   38    │ 'Static Object Property Access (Execution)'  │    '4.3±0.13µs'     │     '4.3±0.12µs'     │   '0.0'    │
│   39    │    'Static Object Property Access (Full)'    │   '260.6±8.57µs'    │  '**253.3±5.20µs**'  │   '+3.0'   │
│   40    │      'String Object Access (Execution)'      │    '7.0±0.18µs'     │   '**6.8±0.18µs**'   │   '+3.0'   │
│   41    │        'String Object Access (Full)'         │   '261.1±10.29µs'   │  '**259.3±7.44µs**'  │   '+1.0'   │
│   42    │       'String comparison (Execution)'        │  '**6.0±0.16µs**'   │     '6.1±0.15µs'     │   '-2.0'   │
│   43    │          'String comparison (Full)'          │ '**259.1±6.43µs**'  │   '260.6±11.41µs'    │  '-0.99'   │
│   44    │      'String concatenation (Execution)'      │  '**4.9±0.19µs**'   │     '5.0±0.25µs'     │  '-0.99'   │
│   45    │        'String concatenation (Full)'         │   '253.5±9.56µs'    │  '**250.5±8.28µs**'  │   '+1.0'   │
│   46    │          'String copy (Execution)'           │  '**3.7±0.13µs**'   │     '3.7±0.09µs'     │  '-0.99'   │
│   47    │             'String copy (Full)'             │   '245.3±5.94µs'    │    '245.3±5.54µs'    │   '0.0'    │
│   48    │            'Symbols (Execution)'             │    '3.3±0.16µs'     │   '**3.2±0.10µs**'   │   '+2.0'   │
│   49    │               'Symbols (Full)'               │   '235.9±7.46µs'    │  '**232.2±5.05µs**'  │   '+2.0'   │
│   50    │                      ''                      │      undefined      │      undefined       │   '+NaN'   │
└─────────┴──────────────────────────────────────────────┴─────────────────────┴──────────────────────┴────────────┘

Benchmarks and test results look good.

@Razican Razican added this to the v0.12.0 milestone Apr 19, 2021
@RageKnify RageKnify added the execution Issues or PRs related to code execution label Apr 19, 2021
@HalidOdat HalidOdat merged commit c843afd into boa-dev:master May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
execution Issues or PRs related to code execution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic on unreachable code when converting object to JSON
4 participants