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

Fix function object constructable/callable #409

Merged
merged 1 commit into from
May 26, 2020
Merged

Conversation

HalidOdat
Copy link
Member

@HalidOdat HalidOdat commented May 22, 2020

It changes the following:

  • Removed unnesecary FunctionKind and cleanup
  • Added name property to global objects. example: BigInt.name === "BigInt"
  • Added length property to global objects. example: Boolean.length === 1
  • Made arrow functions only callable.
  • Fixes function objects constructability and callability.

Not all function objects are constructable or callable for example:

Type constructable callable
Arrow Functions false true
Function Decl/Expr true true
Classes true false
Builtins false (unless explicit true) true

More informations see: https://stackoverflow.com/a/40922715

@github-actions
Copy link

Benchmark for a0da1a2

Click to view benchmark
Test PR Benchmark Master Benchmark %
Create Realm 394.5±6.14µs 396.5±11.51µs 100%
Expression (Lexer) 1957.1±32.12ns 1966.2±37.16ns 100%
Expression (Parser) 4.9±0.16µs 5.2±0.25µs 95%
Fibonacci (Execution) 2.6±0.03ms 2.6±0.07ms 100%
For loop (Execution) 420.9±6.72µs 413.5±6.22µs 102%
For loop (Lexer) 5.1±0.09µs 5.3±0.40µs 96%
For loop (Parser) 14.2±0.47µs 14.4±0.37µs 98%
Hello World (Lexer) 949.2±20.50ns 921.2±26.49ns 103%
Hello World (Parser) 2.4±0.09µs 2.4±0.08µs 98%
Symbols (Execution) 423.4±5.30µs 432.0±23.36µs 98%
undefined undefined 100%

@HalidOdat HalidOdat added the bug Something isn't working label May 23, 2020
@HalidOdat HalidOdat added this to the v0.9.0 milestone May 23, 2020
@github-actions
Copy link

Benchmark for 34a4151

Click to view benchmark
Test PR Benchmark Master Benchmark %
Create Realm 406.4±18.58µs 402.8±14.87µs 101%
Expression (Lexer) 1923.7±87.99ns 1993.8±103.14ns 96%
Expression (Parser) 5.1±0.18µs 5.2±0.28µs 98%
Fibonacci (Execution) 2.8±0.15ms 2.7±0.11ms 105%
For loop (Execution) 432.3±37.47µs 440.4±20.19µs 98%
For loop (Lexer) 5.2±0.22µs 5.1±0.13µs 101%
For loop (Parser) 15.0±0.84µs 14.5±0.68µs 103%
Hello World (Lexer) 973.4±49.54ns 965.9±57.57ns 101%
Hello World (Parser) 2.4±0.15µs 2.4±0.08µs 98%
Symbols (Execution) 433.1±19.05µs 421.5±20.40µs 103%
undefined undefined 100%

@github-actions
Copy link

Benchmark for 5c092ba

Click to view benchmark
Test PR Benchmark Master Benchmark %
Create Realm 368.3±17.55µs 340.3±26.17µs 108%
Expression (Lexer) 1675.2±78.08ns 1742.6±97.11ns 96%
Expression (Parser) 4.7±0.35µs 4.2±0.22µs 111.00000000000001%
Fibonacci (Execution) 2.3±0.10ms 2.4±0.13ms 98%
For loop (Execution) 377.8±23.02µs 408.0±22.87µs 92%
For loop (Lexer) 4.5±0.26µs 4.6±0.26µs 99%
For loop (Parser) 13.0±0.98µs 12.5±1.04µs 104%
Hello World (Lexer) 828.4±40.88ns 840.4±42.82ns 99%
Hello World (Parser) 2.2±0.18µs 2.1±0.15µs 103%
Symbols (Execution) 387.3±17.77µs 401.5±22.22µs 96%
undefined undefined 100%

@HalidOdat HalidOdat marked this pull request as ready for review May 23, 2020 13:55
 - Maded arrow functions non-constructable
 - Simplified Function object and removed FunctionKind
 - Rnamed create_ordinary -> ordinary, create_builtin -> builtin
 - Added name and length properties in global objects
@HalidOdat
Copy link
Member Author

If everything is good with this PR, could we merge it. It has some changes that would make it easier to implement #419 .

@HalidOdat HalidOdat added the builtins PRs and Issues related to builtins/intrinsics label May 26, 2020
@Razican Razican merged commit d42e413 into master May 26, 2020
@HalidOdat HalidOdat deleted the fix/construct-and-call branch May 31, 2020 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working builtins PRs and Issues related to builtins/intrinsics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants