Skip to content

Releases: V4-project/V4-engine

v0.15.0 - Word Shadowing Implementation

Choose a tag to compare

@kirisaki kirisaki released this 06 Nov 11:51

What's New

  • Word Shadowing: Implement backward search for Forth word definitions
    • vm_find_word() searches from newest to oldest definitions
    • Newer definitions shadow older ones with the same name
    • Fundamental Forth feature for interactive development
  • Comprehensive Tests: Added 12 unit tests for word shadowing semantics
  • RAII Test Fixture: Prevent memory leaks in tests with automatic cleanup

Bug Fixes

  • Fix AddressSanitizer memory leak in test_word_shadowing with VmFixture

Testing

  • All 12 tests passing (100%)
  • No memory leaks detected with AddressSanitizer
  • Hardware integration tests on ESP32-C6

🤖 Generated with Claude Code

v0.14.0 - Forth-style SYS instruction

Choose a tag to compare

@kirisaki kirisaki released this 05 Nov 15:20

🚨 Breaking Changes

SYS instruction changed from IMM16 to NoImm opcode:

  • Old format: SYS opcode (0x60) + 2-byte immediate operand = 3 bytes total
  • New format: SYS opcode (0x60) only = 1 byte total
  • SYS ID is now popped from the data stack instead of being encoded as an immediate

This enables dynamic SYS calls where the SYS ID can be computed at runtime.

Bytecode Example

Old bytecode: 60 01 00        (SYS with IMM16 = 0x0001)
New bytecode: 00 01 00 00 00 60  (LIT 1, SYS)

✨ Features

  • Stack-based SYS: SYS ID is popped from the data stack
  • Dynamic syscalls: Enable computed SYS IDs at runtime
  • Smaller opcode: SYS opcode reduced from 3 bytes to 1 byte (immediates handled separately)

🔧 Changes

Core Changes

  • opcodes.def: Changed SYS from IMM16 to NO_IMM
  • opcodes.hpp: Updated comment to reflect SYS as NoImm
  • core.cpp: Modified SYS handler to pop 16-bit ID from stack with validation (0-65535)

Test Updates

  • Updated all 19 SYS test cases in test_sys.cpp
  • Added emit16() helper function for test bytecode generation
  • Changed test bytecode from IMM16 pattern to LIT+SYS pattern

✅ Testing

  • All 11 V4-engine tests passing
  • Tested with address sanitizer
  • Tested with undefined behavior sanitizer
  • GPIO, UART, Timer, System SYS calls verified

📦 Compatibility

  • Requires V4-front v0.7.0 or later for correct Forth-style syntax
  • Breaking change: Old bytecode with IMM16 SYS will not work
  • Applications must be recompiled with new V4-front

Full Changelog: v0.13.0...v0.14.0

V4-engine v0.13.0

Choose a tag to compare

@kirisaki kirisaki released this 05 Nov 14:38

Major Changes

SYS Instruction Upgraded to IMM16

  • Support for 65536 system calls (previously 256)
  • SYSX opcode removed - no longer needed with 16-bit operands
  • All tests updated for new format

V4-std Integration

  • Dynamic SYS handler system for platform-specific syscall routing
  • Runtime registration of SYS handlers
  • See V4-std for implementation

Enhanced Debugging Support

  • Custom panic handler API with vm_set_panic_handler()
  • Comprehensive panic documentation in README
  • Platform-specific error handling support

New APIs

  • Word accessor functions for safe Word structure access
    • vm_word_get_name(), vm_word_get_code(), vm_word_get_code_len()
  • C++ v4::Word wrapper class
  • New type definitions: v4_u16, V4_OK

What's Changed

  • feat(opcodes): Update SYS to IMM16 and remove SYSX opcode by @kirisaki
  • feat(core): Add V4-std integration with dynamic SYS handler system by @kirisaki
  • docs: Add panic handler documentation to README by @kirisaki
  • feat: Add Word accessor APIs and custom panic handler support by @kirisaki
  • fix(tests): Update test_sys.cpp for SYS IMM16 format by @kirisaki

Full Changelog: https://github.com/V4-project/V4-engine/blob/v0.13.0/CHANGELOG.md

v0.12.0 - VM Panic Handler

Choose a tag to compare

@kirisaki kirisaki released this 04 Nov 18:46

🚨 VM Panic Handler System

This release adds a comprehensive panic handler system for debugging and diagnostics.

✨ New Features

  • vm_panic() API: Automatic error diagnostics with stack trace
  • Panic Information Structures: (C) and (C++)
  • Comprehensive Diagnostic Output:
    • Error code with human-readable message
    • Program Counter (PC) value
    • Data Stack depth and top 2 elements (TOS, NOS)
    • Return Stack depth with call trace (up to 16 entries)

🔧 Implementation Details

  • All error paths in VM core integrated with panic handler
  • Stack operations (push/pop) automatically log on overflow/underflow
  • Opcode errors (div-by-zero, invalid jumps, etc.) logged automatically
  • 5 comprehensive test cases covering all panic scenarios

📊 Size Impact

  • Library size increase: ~2KB (182KB stripped with LTO)
  • Minimal impact in final applications due to LTO optimization
  • Unused panic code eliminated at link time

🧪 Testing

All 11 tests passing, including 5 new panic handler tests.


Full Changelog: v0.11.1...v0.12.0

v0.11.2 - Error Code Refactoring

Choose a tag to compare

@kirisaki kirisaki released this 04 Nov 17:51

Improved

  • Replace error code integer literals with named constants
    • Changed hardcoded error values (-1, -2, -3, etc.) to proper error code constants throughout the codebase
    • Updated files:
      • src/task_backend_custom.cpp: Use V4_ERR() macros (InvalidArg, InvalidWordIdx, TaskLimit, NoMemory, MsgQueueFull)
      • src/task_backend_freertos.cpp: Use V4_ERR() macros for all error returns
      • src/hal_wrapper.cpp: Use HAL error constants (HAL_ERR_PARAM, HAL_ERR_IO, HAL_ERR_NODEV, HAL_OK)
      • src/memory.cpp: Use V4_ERR() macros for MMIO and validation errors
      • tests/test_task.cpp: Update test assertions to check against error constants

This refactoring improves code maintainability and readability by making error handling more explicit and type-safe.

Full Changelog: v0.11.1...v0.11.2

v0.11.1 - FreeRTOS Backend Error Code Fix

Choose a tag to compare

@kirisaki kirisaki released this 04 Nov 17:31

Fixed

  • Incorrect error code name in FreeRTOS backend
    • Changed V4_ERR(OutOfMemory) to V4_ERR(NoMemory) in task_backend_freertos.cpp
    • This error prevented compilation of the FreeRTOS backend in v0.11.0

This is a critical bug fix for anyone using the FreeRTOS backend introduced in v0.11.0.

Full Changelog: v0.11.0...v0.11.1

v0.11.0 - Task Backend Abstraction

Choose a tag to compare

@kirisaki kirisaki released this 04 Nov 17:13

What's New

Pluggable Task Backend System

V4-engine now supports pluggable task backends, enabling seamless integration with both bare-metal and RTOS platforms.

Two backends available:

  • Custom Backend (default): V4's own priority + round-robin scheduler
  • FreeRTOS Backend: Native FreeRTOS integration for ESP32 and other RTOS platforms

Key Features:

  • Compile-time backend selection via V4_TASK_BACKEND CMake option
  • ESP-IDF automatic FreeRTOS detection
  • Priority mapping between V4 (0-255) and FreeRTOS priorities
  • Unified API regardless of backend

Usage:

# Custom backend (default)
cmake -B build -DV4_TASK_BACKEND=CUSTOM

# FreeRTOS backend
cmake -B build -DV4_TASK_BACKEND=FREERTOS

For ESP-IDF projects, FreeRTOS is automatically detected and configured.

Changes

  • Task system refactored with backend abstraction layer
  • task.cpp and message.cpp now delegate to backend implementations
  • Original scheduler moved to task_backend_custom.cpp
  • New task_backend_freertos.cpp for FreeRTOS integration

Full Changelog: https://github.com/V4-project/V4-engine/blob/main/CHANGELOG.md#0110---2025-11-04

v0.10.1 - Repository Rename

Choose a tag to compare

@kirisaki kirisaki released this 04 Nov 16:14

Changes

Repository Rename

  • Repository renamed from V4 to V4-engine to better reflect its purpose as the core VM engine
  • Project name: V4VM → V4Engine
  • Library artifact: libv4vm.a → libv4engine.a
  • Updated all documentation and build files
  • Updated GitHub repository URLs

Testing

  • ✅ All 10 tests passing
  • ✅ Build configurations validated
  • ✅ Integration with V4-front and V4-repl confirmed

Migration Guide

For projects depending on this library:

CMake users:
```cmake

Update target name

target_link_libraries(your_target PRIVATE v4engine) # was: v4vm
```

Direct users:
```bash

Update library reference

-lv4engine # was: -lv4vm
```

Git submodule/dependency users:
Update repository URL from:

To:


🤖 Generated with Claude Code

v0.10.0

Choose a tag to compare

@kirisaki kirisaki released this 03 Nov 11:53

What's New

C Compatibility Enhancement

  • Added C-compatible error header: Introduced errors.h for C projects
    • Enables C code to use V4's error system without C++ dependencies
    • Generated from errors.def macro definitions
    • Exports V4_ERR_* constants compatible with both C and C++

RTOS Support

  • Added RTOS-specific error codes:
    • V4_ERR_TaskLimit (-20): Task limit reached
    • V4_ERR_MsgQueueFull (-21): Message queue full
    • V4_ERR_NoMessage (-22): No message available
    • V4_ERR_NoMemory (-23): Out of memory

Integration

This release enables the V4-rtos kernel to integrate V4 VM as a library dependency, eliminating code duplication while maintaining clean error handling across C and C++ boundaries.

Full Changelog

v0.9.1...v0.10.0

v0.9.1: Memory leak fix for task system

Choose a tag to compare

@kirisaki kirisaki released this 03 Nov 03:49

What's Changed

Added

  • vm_task_cleanup(): New API to cleanup task system and free allocated task stacks
    • Should be called before vm_destroy() to prevent memory leaks
    • Frees all task stacks (ds_base, rs_base) allocated by vm_task_spawn()
    • Resets scheduler and message queue state

Fixed

  • Memory leak in task system detected by AddressSanitizer
    • Task stacks allocated by vm_task_spawn() were not being freed
    • All test cases now properly call vm_task_cleanup() before vm_destroy()

Full Changelog: v0.9.0...v0.9.1


🤖 Generated with Claude Code