Skip to content

Commit b567123

Browse files
committed
rewrite some things
1 parent 6024ba0 commit b567123

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

blog/boa-release-21/index.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ in conformance will be minor or bound to the feature size going forward.
2626
You can check the full list of changes [here][changelog], and the full
2727
information on conformance [here][conformance].
2828

29+
[changelog]: https://github.com/boa-dev/boa/blob/v0.21/CHANGELOG.md
30+
[conformance]: https://boajs.dev/boa/test262/
31+
2932
<!--truncate-->
3033

3134
## Feature Highlights
@@ -113,14 +116,14 @@ very difficult for two reasons:
113116

114117
1. We needed to change all definitions to take `&RefCell<Context>` instead
115118
of `&mut Context`, which meant changing pretty much the whole codebase.
116-
2. Some of our VM code was reentrant, which meant calling `RefCell::borrow_mut`
117-
would cause panics in the reentrant parts of the code; we would need to
118-
redesign some parts of the engine to remove the reentrancy.
119+
2. Some of our VM code was reentrant, and that would cause panics in the reentrant
120+
parts of the code when calling `RefCell::borrow_mut`; we would need to patch up
121+
the engine to remove the reentrancy.
119122

120123
After putting a lot of thought on this, we came up with a really nice solution;
121124
instead of wrapping `Context` with `RefCell`, we would wrap `&mut Context` with
122125
`RefCell`, and only on the async-related APIs. This would allow not only capturing
123-
the context to `Future`-related functions, but also doing this without having to
126+
the context on `Future`-related functions, but also doing this without having to
124127
refactor big parts of the code. Thus, we ditched `FutureJob` and introduced a new
125128
type of job: `NativeAsyncJob`.
126129

@@ -283,13 +286,13 @@ finish_load: Box<dyn FnOnce(JsResult<Module>, &mut Context)>,
283286
...
284287
```
285288

286-
Unfortunately,
287-
this API has downsides: it is possible to forget to call `finish_load`,
288-
which is safer than a dangling `*const()` pointer, but still prone to bugs.
289-
It is also really painful to work with, because you cannot capture the `Context`
290-
to further process the module after loading it ... Sounds familiar?
291-
**[The async code snippet we showed before](#async-apis-enhancements) has this exact problem!**
292-
And that snippet is directly taken from [one of our `ModuleLoader` implementation examples][mod-loader].
289+
Unfortunately, this API has downsides:
290+
- It's possible to forget to call `finish_load`, which is safer than a dangling `*const()`
291+
pointer, but still prone to bugs.
292+
- It is also really painful to work with, because you cannot capture the `Context`
293+
to further process the module after loading it. ... Sounds familiar?
294+
**[The async code snippet we showed before](#async-apis-enhancements) has this exact problem!**
295+
And that snippet is directly taken from [one of our `ModuleLoader` implementation examples][mod-loader].
293296

294297
[mod-loader]: https://github.com/boa-dev/boa/blob/b345775138f56401bd627b1f36daadfc5bf75772/examples/src/bin/module_fetch.rs#L38
295298

@@ -619,8 +622,6 @@ Once again, big thanks to [all the contributors][contributors] of this
619622
release!!!
620623

621624
[contributors]: https://github.com/boa-dev/boa/graphs/contributors?from=2024-12-05&to=2025-08-30&type=c
622-
[changelog]: https://github.com/boa-dev/boa/blob/v0.21/CHANGELOG.md
623-
[conformance]: https://boajs.dev/boa/test262/
624625
[feed]: https://boajs.dev/blog/rss.xml
625626
[collective]: https://opencollective.com/boa
626627
[easy_issues]: https://github.com/boa-dev/boa/issues?q=is%3Aopen+is%3Aissue+label%3AE-Easy

0 commit comments

Comments
 (0)