stage0 重构vm使其依赖自己的地址空间不再共用宿主机 修改vm的ABI 修正相关nob构建问题

This commit is contained in:
zzy committed 2026-09-22 23:12:15 +08:00
1 parent fae017b52d
commit c0a86ea552
14 files changed
+2149 -1572

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
#ifndef __SPL_ASP_H__
#define __SPL_ASP_H__
/* spl_asp.h - 地址空间抽象(Address SPace)
*
* SPL 侧指针语义由 spl_asp_t 统一描述:
* - native(编译器自身):identity,指针就是宿主地址。
* - VM:句柄/偏移,offset = (handle<<32) | 区内字节偏移,0 为 null。
*
* runtime(spl_rt_core.h)的解引用/分配一律经此接口,从而同一份 SPL
* 源的 Vec/Map/mem 在两种后端下都自洽。
*/
#include <stdint.h>
#include <stddef.h>
#ifndef SPL_USIZE_TYPEDEF
#define SPL_USIZE_TYPEDEF
typedef uintptr_t usize;
#endif
typedef struct spl_asp spl_asp_t;
struct spl_asp {
void *ctx;
/* offset -> 宿主地址;size>0 时做边界检查;失败返回 NULL。 */
unsigned char *(*xlate)(void *ctx, uintptr_t off, uintptr_t size);
/* 分配 size 字节,返回 offset(0=失败)。 */
uintptr_t (*alloc)(void *ctx, uintptr_t size);
/* 重新分配 offset@old,返回新 offset(0=失败)。 */
uintptr_t (*realloc)(void *ctx, uintptr_t off, uintptr_t size);
/* 释放 offset。 */
void (*free)(void *ctx, uintptr_t off);
/* 宿主地址 -> offset;size>0 时校验范围。不属于该空间返回 0。 */
uintptr_t (*to_off)(void *ctx, const void *host, uintptr_t size);
};
#endif /* __SPL_ASP_H__ */