Captain Bob: "give frames IDs and call by ID" -- frames stack per VM, each
with an ID. New vm_frame.h/.c: VMFrameEntry { VMFrameID id; VMUuid vm_id;
kind (INTERPRET/DRAIN/IDLE) }, a growable VMFrameStack embedded as VM.frames
(reserved at birth, freed in vm_cleanup, grown by allocate-copy-free).
vm_interpret() -> vm_interpret_kind() pushes a frame onto the running stack's
owner, holds only its ID, fails closed if it cannot grow, and pops by ID
(mismatch reported as VM FRAME CORRUPTION).
The Stage A/B loose fields are gone and everything is derived from the stack:
- ownership gate: one frame, and it is vm's own
- drain guard: a DRAIN frame for vm already on the running stack
- parked-idle: an IDLE frame the trampoline pushes around its yield
- log attribution: the top frame's vm_id, resolved by ID through the registry
The single saved-and-restored attribution global is removed.
Evidence: the probe baseline on the pre-frame code read HSSAS (the global
named Hestia while Hera resumed). With frames it reads HSHAS on all three
ISAs, with Hestia's top frame IDLE and Hera's frames back to 0; the probe is
reverted. Formal acceptance on all three ISAs: dict_hash identical and
unchanged, zero UNKNOWN WORD, faults, frame corruption or refused interprets,
and the WIREBIND relay 1 2 + . -> 3 works.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
70 lines
2.7 KiB
C
70 lines
2.7 KiB
C
/*
|
||
StarForth — Steady-State Virtual Machine Runtime
|
||
|
||
Copyright (c) 2023–2025 Robert A. James
|
||
All rights reserved.
|
||
|
||
This file is part of the StarForth project.
|
||
|
||
Licensed under the StarForth License, Version 1.0 (the "License");
|
||
you may not use this file except in compliance with the License.
|
||
|
||
You may obtain a copy of the License at:
|
||
https://github.com/star.4th@proton.me/StarForth/LICENSE.txt
|
||
|
||
This software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||
express or implied, including but not limited to the warranties of
|
||
merchantability, fitness for a particular purpose, and noninfringement.
|
||
|
||
See the License for the specific language governing permissions and
|
||
limitations under the License.
|
||
*/
|
||
|
||
/**
|
||
* log_attrib.h - "Which VM is currently executing" for log persistence
|
||
* attribution (FABRIC-3.md §XXVI follow-on, Step 4, 2026-09-13)
|
||
*
|
||
* log_message() (shim.c) is a global function called from hundreds of
|
||
* existing sites -- most with no VM in scope at all (boot, PCI, xHCI,
|
||
* driver code). Rather than thread a VM parameter through every one of
|
||
* those call sites (a large, invasive change for no benefit to the ones
|
||
* that genuinely have no VM), vm_interpret() (vm_core.c, the single
|
||
* dispatch entry point for ALL FORTH execution -- interactive lines,
|
||
* LOAD'd block content, and every VM-EXEC/MSG-DELIVER dispatch into a
|
||
* target VM) sets this at entry and restores the previous value at exit,
|
||
* save/restore style so nested vm_interpret() calls (VM-EXEC dispatching
|
||
* into a different VM's own dictionary, mid-interpret) attribute
|
||
* correctly to whichever VM is actually running at the moment
|
||
* log_message() fires -- not the outermost caller.
|
||
*
|
||
* NULL means "no VM is currently interpreting" -- boot sequence, PCI/
|
||
* xHCI/driver code, anything running outside a vm_interpret() call frame.
|
||
* log_message()'s own persistence hook (shim.c) treats NULL as the fixed
|
||
* "HADES" pseudo-source, matching the console's own existing
|
||
* "[HADES][LEVEL]" prefix convention for exactly this class of message.
|
||
*/
|
||
|
||
#ifndef STARKERNEL_LOG_ATTRIB_H
|
||
#define STARKERNEL_LOG_ATTRIB_H
|
||
|
||
#ifdef __cplusplus
|
||
extern "C" {
|
||
#endif
|
||
|
||
struct VM;
|
||
|
||
/* vm_log_attributed_vm - The VM whose dictionary context is currently
|
||
* executing, or NULL if none (see this header's own doc comment).
|
||
* FABRIC-3.8.md §3.12 (Stage FR, 2026-09-23): stack-scoped -- the innermost
|
||
* VM interpreting on the stack owned by sk_vm_switch_current_vm(), kept in
|
||
* that owner's VMFrame, so it stays correct across context switches. NULL
|
||
* means nothing is interpreting on the current stack; callers map that to
|
||
* the unattributed "HADES" source, never to the current VM itself. */
|
||
struct VM *vm_log_attributed_vm(void);
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|
||
|
||
#endif /* STARKERNEL_LOG_ATTRIB_H */
|