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

Create execution context and execution stack #186

Closed
jasonwilliams opened this issue Oct 23, 2019 · 4 comments
Closed

Create execution context and execution stack #186

jasonwilliams opened this issue Oct 23, 2019 · 4 comments
Labels
enhancement New feature or request Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com help wanted Extra attention is needed

Comments

@jasonwilliams
Copy link
Member

jasonwilliams commented Oct 23, 2019

This is a bit of a refactor.
https://tc39.es/ecma262/#sec-execution-contexts

First we need a context struct which holds information about the context.
fields would be https://tc39.es/ecma262/#table-22

Then we need to create a stack structure, this holds execution contexts in a FIFO order, and the top most one is the currently running context

This stack structure would also have methods on it:
8.3.1GetActiveScriptOrModule
8.3.2ResolveBinding
8.3.3GetThisEnvironment
8.3.4ResolveThisBinding
8.3.5GetNewTarget
8.3.6GetGlobalObject

Then the exec.rs would accept a new executionContext and run it
https://github.com/jasonwilliams/boa/blob/master/src/lib/exec.rs#L24-L29

Note
Multiple contexts can point to the same realm, so realm needs to be wrapped in a GC

@jasonwilliams jasonwilliams added help wanted Extra attention is needed Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com labels Oct 23, 2019
@KrisChambers
Copy link
Contributor

I will take a look at this.

@rumpl
Copy link
Contributor

rumpl commented Feb 15, 2022

👋 I would like to take a stab at this

bors bot pushed a commit that referenced this issue Mar 4, 2022
Building up to #186, this PR extracts an `Intrinsics` struct from `Context`, facilitating a lot the extraction of a `Realm` struct.
Also, it adapts the `BuiltIn` trait to be useful for builtins that don't expose a global property on initialization (`Generator`, `TypedArray`, etc.)

It changes the following:

- Creates an `Intrinsics` struct and refactors `Context` to transfer its intrinsic related fields to `Intrinsics`.
- Renames some methods and parameters to better describe their functionality.
- Makes `BuiltIn::init` return `Option<JsValue>` to skip global property initialization if the builtin initialization returns `None`
@Razican
Copy link
Member

Razican commented Mar 27, 2022

@rumpl did you have the chance to look into this?

@jedel1043
Copy link
Member

We decided that we don't need to follow the spec because our current implementation is more optimal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants