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 Subclassed WeakReference
to be GCed
#3347
Fix Subclassed WeakReference
to be GCed
#3347
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took a look at the changes (mostly for learning purposes), and it looks good to me. I can indeed confirm that this change address the specific examples mentioned in the original issue. 🎉
However, since I'm not very familiar with this particular area, I would appreciate it if someone else could review it as well 😃
@@ -86,7 +87,8 @@ static inline size_t Object_Size(Object *object) { | |||
} | |||
|
|||
static inline bool Object_IsWeakReference(Object *object) { | |||
return object->rtti->rt.id == __weak_ref_id; | |||
int32_t id = object->rtti->rt.id; | |||
return __weak_ref_ids_min <= id && id <= __weak_ref_ids_max; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[note] range is closed set 👍
scala-native/tools/src/main/scala/scala/scalanative/codegen/Metadata.scala
Lines 53 to 62 in 6d20a92
def loop(node: Class): Unit = { | |
out += node | |
val start = id | |
id += 1 | |
val directSubclasses = | |
node.subclasses.filter(_.parent == Some(node)).toArray | |
directSubclasses.sortBy(_.name.show).foreach { subcls => loop(subcls) } | |
val end = id - 1 | |
ids(node) = start | |
ranges(node) = start to end |
Instead of using WeakReferenceId directly to determine WeakReference, we use the ranges of WeakReference to make the determination, as `Class.is` does. (cherry picked from commit 8c87a9a)
Instead of using WeakReferenceId directly to determine WeakReference, we use the ranges of WeakReference to make the determination, as `Class.is` does. (cherry picked from commit 8c87a9a)
Fix #3341
Instead of using
WeakReferenceId
directory to determine WeakReference, we use theranges
of WeakReference to make the determination, asClass.is
does.