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

Migration from ESR 115 to 128 #85

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open

Migration from ESR 115 to 128 #85

wants to merge 1 commit into from

Conversation

ptomato
Copy link
Collaborator

@ptomato ptomato commented Jul 27, 2024

Includes updated build instructions and a migration guide. Only one of the examples needs to be updated, with the new column number API; everything else builds as is.

Comment on lines +93 to +128
Also, note that `JS::GCPolicy<JS::Heap<T>>` does not implement
`needsSweep()`.
If you were storing a `JS::Heap` inside `JS::WeakCache<T>`, you will
need to use a different data structure.
An easy drop-in replacement for `JS::Heap` suitable for this purpose
would be something like this:

```c++
template <typename T>
class WeakPtr : public JS::Heap<T> {
public:
using JS::Heap<T>::Heap;
using JS::Heap<T>::operator=;
};

namespace JS {

template <typename T>
struct GCPolicy<WeakPtr<T>> {
static void trace(JSTracer* trc, WeakPtr<T>* thingp, const char* name) {
return JS::TraceEdge(trc, thingp, name);
}

static bool traceWeak(JSTracer* trc, WeakPtr<T>* thingp) {
return js::gc::TraceWeakEdge(trc, thingp);
}

static bool needsSweep(JSTracer* trc, const WeakPtr<T>* thingp) {
WeakPtr<T> thing{*thingp};
return !js::gc::TraceWeakEdge(trc, &thing);
}
};

} // namespace JS
```
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also wondering if this omission was unintentional and we should have JS::Heap's GCPolicy be sweepable after all.

Copy link
Contributor

@arai-a arai-a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for covering the changes around column number and function name.

docs/Migration Guide.md Outdated Show resolved Hide resolved
docs/Migration Guide.md Outdated Show resolved Hide resolved
@ptomato
Copy link
Collaborator Author

ptomato commented Jul 28, 2024

@arai-a Thanks for the review. I've pushed another revision.

Any thoughts on whether we should add JS::GCPolicy<JS::Heap<T>>::needsSweep()?

Copy link
Contributor

@arai-a arai-a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for updating!
The parts other than JS::GCPolicy looks good.
Let's wait for GC devs for the JS::GCPolicy part.

Includes updated build instructions and a migration guide.
One of the examples needs to be updated, with the new column number API;
and the WeakRefs example needs its job queue and realm creation options
adjusted. Everything else builds as is.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants