Skip to content

Feature/allocate strings on heap#33

Merged
Mauw94 merged 9 commits into
masterfrom
feature/allocate-strings-on-heap
May 27, 2026
Merged

Feature/allocate strings on heap#33
Mauw94 merged 9 commits into
masterfrom
feature/allocate-strings-on-heap

Conversation

@Mauw94
Copy link
Copy Markdown
Owner

@Mauw94 Mauw94 commented May 25, 2026

No description provided.

Mauw94 added 2 commits May 25, 2026 19:10
Refactored `NativeMemberDispatcher` and `VirtualMachine` to use
`HeapManager` for heap-allocated strings and objects. Deprecated
direct string handling in `Value.cs` and transitioned to heap-based
methods. Added helper methods for heap management and string
concatenation. Enabled parallel test execution in `MSTestSettings.cs`.
Updated `Lumi.slnx` to adjust build configuration for tests. Added
a TODO in `ConstantPool.cs` for dead constant removal.
Removed the `String` property and related methods from the `Value` struct to transition to heap-allocated strings. Updated `NativeMemberDispatcher` to handle this change and throw appropriate errors for mismatched value kinds. Adjusted `ConstantToValue` to reflect the removal of direct string handling.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR moves runtime string values to heap-allocated HeapStringObject handles (via interning), and updates VM execution and stdlib native dispatch to work with heap-backed strings.

Changes:

  • VM: push string constants as heap strings; build concatenation results as heap strings.
  • VM: refactor heap allocations behind a helper (AllocateHeapObject).
  • Stdlib native dispatcher: return/read/accept heap-allocated strings for File prelude APIs; enable parallel test execution for StdLib tests.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
Lumi.VM/VirtualMachine.cs Push constants/concats as heap strings; refactor heap allocations; adds string helpers.
Lumi.VM/Value.cs Removes inline string payload from Value and updates constant/value printing logic.
Lumi.VM/NativeMemberDispatcher.cs Updates File prelude methods to consume/produce heap strings and adjusts argument extraction.
Lumi.StdLib.Tests/MSTestSettings.cs Enables method-level MSTest parallelization for StdLib tests.
Lumi.slnx Changes solution build behavior for Lumi.VM.Heap.Tests in Debug configuration.
Lumi.Bytecode/Constants/ConstantPool.cs Adds a TODO note about dead-constant cleanup after optimizations.
Comments suppressed due to low confidence (1)

Lumi.VM/Value.cs:65

  • Value.PrintValue() no longer handles heap-allocated string values (they are now ValueKind.HeapObject). This means composite heap objects that print nested Values via Value.PrintValue() (e.g., HeapArrayObject.PrintValue() / HeapStructObject.PrintValue()) will now throw UnkownValueKind(HeapObject) when they contain strings (or any other heap values).
        ValueKind.Boolean => Bool.ToString(),
        ValueKind.Null => "null",
        ValueKind.Undefined => "undefined",
        _ => throw VirtualMachineError.UnkownValueKind(Kind),
    };

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Lumi.VM/VirtualMachine.cs Outdated
Comment thread Lumi.VM/VirtualMachine.cs Outdated
Comment thread Lumi.VM/VirtualMachine.cs Outdated
Comment thread Lumi.VM/VirtualMachine.cs Outdated
Comment thread Lumi.VM/VirtualMachine.cs
Comment thread Lumi.VM/VirtualMachine.cs Outdated
Comment thread Lumi.VM/NativeMemberDispatcher.cs
Comment thread Lumi.VM/NativeMemberDispatcher.cs
Comment thread Lumi.slnx
Mauw94 and others added 6 commits May 25, 2026 19:37
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Extracted root enumeration to a Roots method for reuse. Updated string concatenation and heap allocation to use precise roots during garbage collection, improving clarity and maintainability.
@Mauw94 Mauw94 merged commit 95ff157 into master May 27, 2026
1 check passed
@Mauw94 Mauw94 deleted the feature/allocate-strings-on-heap branch May 27, 2026 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants