move ResourceTracker from heap to vm - #591
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
Codecov Results 📊✅ Patch coverage is 100.00%. Project has 8954 uncovered lines. Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 82.34% 82.34% —%
==========================================
Files 218 218 —
Lines 50709 50709 —
Branches 107202 107202 —
==========================================
+ Hits 41755 41755 —
- Misses 8954 8954 —
- Partials 3254 3254 —Generated by Codecov Action |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
1 issue found across 55 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="crates/monty/src/types/tuple.rs">
<violation number="1" location="crates/monty/src/types/tuple.rs:35">
P3: Rustdoc now has an unresolved `Heap::check_time` link in this module, so documentation builds can emit a warning or fail under `-D warnings`. Updating that link to `HeapReader::check_time` keeps the API documentation valid after this import change.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| exception_private::{ExcType, RunResult}, | ||
| hash::HashValue, | ||
| heap::{DropWithContext, Heap, HeapData, HeapId, HeapItem, HeapRead, HeapReadOutput}, | ||
| heap::{DropWithContext, HeapData, HeapId, HeapItem, HeapRead, HeapReadOutput, HeapReader}, |
There was a problem hiding this comment.
P3: Rustdoc now has an unresolved Heap::check_time link in this module, so documentation builds can emit a warning or fail under -D warnings. Updating that link to HeapReader::check_time keeps the API documentation valid after this import change.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At crates/monty/src/types/tuple.rs, line 35:
<comment>Rustdoc now has an unresolved `Heap::check_time` link in this module, so documentation builds can emit a warning or fail under `-D warnings`. Updating that link to `HeapReader::check_time` keeps the API documentation valid after this import change.</comment>
<file context>
@@ -32,7 +32,7 @@ use crate::{
exception_private::{ExcType, RunResult},
hash::HashValue,
- heap::{DropWithContext, Heap, HeapData, HeapId, HeapItem, HeapRead, HeapReadOutput},
+ heap::{DropWithContext, HeapData, HeapId, HeapItem, HeapRead, HeapReadOutput, HeapReader},
intern::StaticStrings,
resource::{ResourceError, ResourceTracker},
</file context>
ApprovabilityVerdict: Needs human review Unable to check for correctness in faddf6c. This PR introduces significant runtime behavior changes beyond the title's scope: new comprehension closure capture semantics with a new opcode ( You can customize Macroscope's approvability policy. Learn more. |
f7f9d9b to
faddf6c
Compare
|
Macroscope skipped reviewing this pull request. Per-review cost limit exceeded (workspace setting). This review would cost an estimated $9.97, which exceeds your per-review limit of $5.00. The top 3 files driving up this estimate:
Tip To get this pull request reviewed, you can:
|
This PR moves the resource tracker from the
Heapto theHeapReader, and makes it&shared. This should be a step towards enablingStringBuilderto access the tracker insidepy_repr_fmt(which needs the vm).Summary by cubic
Moved
ResourceTrackerfromHeaptoVMand threaded a shared tracker throughHeapReader. This reduces borrow conflicts, enablesStringBuilderinpy_repr_fmt, and clarifies when resource-sensitive operations are allowed. Also reworked external function identity and added captured comprehension support.Refactors
Heapis no longer generic;HeapReader<'h>carries the branded heap + shared tracker.ContainsHeapnow providesheap()anddec_ref(..)(removedheap_mut()); drop sites usedec_ref.&HeapReader(e.g.,allocate_string,allocate_tuple); read-only paths use&Heap.ExtFunctionvalues cached by name;Value::ExtFunction(StringId)removed.LoadGlobalCallNamenow pushes an external function for undefined names.Opcode::BuildCell; parser/compiler track captured comprehension slots and VM allocates undefined cells for inlined comprehensions so closures capture targets correctly. Serialization preserves captured cells.heapandResourceTrackerseparately; snapshots exposesnapshot.tracker; VM usesheap.tracker()/tracker_mut()where needed.indexmapfor deterministic capture/name handling; compiler/prepare updated.Migration
ContainsHeapwithfn heap(&self) -> &Heapandfn dec_ref(&mut self, HeapId).&Heap/&mut Heapto&HeapReader<'_>where allocating, refcounting, or tracking resources.ExtFunction(Value::ReftoHeapData::ExtFunction).Heap::new(0)and pass a tracker from theVM; update REPL/executor/snapshot code to accesstrackerdirectly.Written for commit faddf6c. Summary will update on new commits.