Boa: Implement `async` / `await`

Created on 8 Oct 2020  路  6Comments  路  Source: boa-dev/boa

ECMASCript feature
We currently have no support for async / await in Boa. These two keywords are used to create "promises" that will be executed asynchronously, without blocking the execution of the code that follows.

There are two types of async constructs:

Implementing this has to be done in two phases. First we need to be able to parse these async constructs, and for that, we will need new AST nodes and new parsers, that will be called when finding the async keyword.

After the parsing is done, we need to implement the execution. This will be a bit tricky, since we currently just execute the nodes one by one. This means we need to follow the spec in the "Runtime Semantics" for these two constructs, and implement the needed methods.

This might require further talk in #367.

enhancement help wanted parser execution E-Hard

Most helpful comment

I'll have a go at this - honestly I've always been very curious as to how the more exotic async stuff is actually implemented so this should be interesting.

All 6 comments

I'll have a go at this - honestly I've always been very curious as to how the more exotic async stuff is actually implemented so this should be interesting.

Once this is implemented we will also need to setup benchmark(s) for async operations

I'll have a go at this - honestly I've always been very curious as to how the more exotic async stuff is actually implemented so this should be interesting.

Most of the asynchronous stuff happens at runtime level rather than engine level. V8 doesn鈥檛 handle the event loop, Node does. I think after parse we鈥檒l need to look at how it integrates in other engines. JS in its pure form doesn鈥檛 have anything that鈥檚 async, setTimeout is injected in for e.g

I'll have a go at this - honestly I've always been very curious as to how the more exotic async stuff is actually implemented so this should be interesting.

Most of the asynchronous stuff happens at runtime level rather than engine level. V8 doesn鈥檛 handle the event loop, Node does. I think after parse we鈥檒l need to look at how it integrates in other engines. JS in its pure form doesn鈥檛 have anything that鈥檚 async, setTimeout is injected in for e.g

Interesting - I will need to look into this - what is the scope of boa, are we going to implement an event-loop system?

I think we could provide a default and very limited boa_event_loop crate, just with the minimum to comply with the spec, and to be able to use it in tests. We would add a trait in the boa crate with the needed methods, and then rely on the implementers to comply with it.

BTW, any news with the parsing, @Lan2u?

I think we could provide a default and very limited boa_event_loop crate, just with the minimum to comply with the spec, and to be able to use it in tests. We would add a trait in the boa crate with the needed methods, and then rely on the implementers to comply with it.

BTW, any news with the parsing, @Lan2u?

Yeah, I think that's a good move so we can get stuff tested. Parsing wise I'll try and get the branch ready for review/merge by the end of the week so we can get started on an event_loop (which should be a separate issue I think)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

croraf picture croraf  路  5Comments

HalidOdat picture HalidOdat  路  3Comments

IovoslavIovchev picture IovoslavIovchev  路  4Comments

HalidOdat picture HalidOdat  路  5Comments

attliaLin picture attliaLin  路  3Comments