cleanup(chansvm): typed buffers and names #1376

Merged
coah80 merged 1 commits from agent/w0929/clean3-c1-land into main 2026-10-09 19:54:26 +00:00
3 changed files with 258 additions and 134 deletions

View File

@@ -19,7 +19,7 @@ extern "C" {
#define CHANS_VM_CLASS_NAME_LEN 32
CHANSVmErr CHANSVmInit(CHANSVm* vm, vmPtr work, vmU32 size);
CHANSVmErr CHANSVmLinkModules(CHANSVm* vm, vmS32 unk0);
CHANSVmErr CHANSVmLinkModules(CHANSVm* vm, vmS32 reserved);
void CHANSVmSetSignal(CHANSVm* vm, vmBool* signal);
@@ -30,7 +30,7 @@ void CHANSVmSetSignal(CHANSVm* vm, vmBool* signal);
vmU32 CHANSVmGetFreeExeSize(CHANSVm* vm);
vmPtr CHANSVmGetFreeExeBufp(CHANSVm* vm);
CHANSVmErr CHANSVmAddExe(CHANSVm* vm, vmS32 unk0, CHANSVm* execCtx);
CHANSVmErr CHANSVmAddExe(CHANSVm* vm, vmS32 reserved, CHANSVm* execCtx);
CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount);

View File

@@ -748,15 +748,14 @@ static inline s32 CHANSVmParseFloat(const CHANSVmObjHdr* obj, f64* out) {
u64 val = strtoull(buf, &endPtr, 0);
if (endPtr == bufEnd) {
number = VmIntToFloat(val);
goto store;
} else {
number = strtod(buf, &endPtr);
if (endPtr == buf) {
number = VM_NAN;
}
}
}
number = strtod(buf, &endPtr);
if (endPtr == buf) {
number = VM_NAN;
}
store:
if (out != vmNull) {
*out = number;
@@ -1570,7 +1569,7 @@ CHANSVmNativeClass* CHANSVmAddNativeClass2(CHANSVm* vm, const char* clsName, CHA
if (CHANSVmFindNativeClass(vm, clsName) == vmNull) {
clsNameLen = strlen(clsName);
if (clsNameLen != 0) {
cls = CHANSVmAlloc(vm, VM_ALIGN(clsNameLen + sizeof(CHANSVmNativeClass) - 0x20));
cls = CHANSVmAlloc(vm, VM_ALIGN(clsNameLen + sizeof(CHANSVmNativeClass) - CHANS_VM_CLASS_NAME_LEN));
if (cls != vmNull) {
if (pVm->pNativeClasses == vmNull) {
pVm->pNativeClasses = cls;
@@ -2467,87 +2466,84 @@ vmBoolInt VmDateCommon(CHANSVm* vm, OSCalendarTime* out) {
if (out != vmNull) {
argc = ((CHANSVmPrivate*)vm)->pActiveCtx->argc;
if (argc == 0) {
goto osgettime;
}
if (argc == 1) {
CHANSVmObjHdr* arg = CHANSVmGetArg(vm, 0);
if (argc != 0) {
if (argc == 1) {
CHANSVmObjHdr* arg = CHANSVmGetArg(vm, 0);
if (arg && arg->type == CHANS_VM_OBJ_TYPE_STRING) {
if (arg->value.wstring_v->len == 6 && memcmp(arg->value.wstring_v->spData, VmDateConstantTbl[0].spName, 6) == 0) {
NETGetUniversalCalendar(&nettime);
time = OSCalendarTimeToTicks(&nettime);
time = (u64)((s64)time / (__OSBusClock / 4 / 1000));
if (arg && arg->type == CHANS_VM_OBJ_TYPE_STRING) {
if (arg->value.wstring_v->len == 6 && memcmp(arg->value.wstring_v->spData, VmDateConstantTbl[0].spName, 6) == 0) {
NETGetUniversalCalendar(&nettime);
time = OSCalendarTimeToTicks(&nettime);
time = (u64)((s64)time / (__OSBusClock / 4 / 1000));
goto finalize;
}
}
arg = CHANSVmGetArg(vm, 0);
arg = CHANSVmConvertObjectType(vm, CHANS_VM_OBJ_TYPE_INTEGER, arg);
if (arg) {
time = arg->value.int_v;
goto finalize;
}
}
arg = CHANSVmGetArg(vm, 0);
arg = CHANSVmConvertObjectType(vm, CHANS_VM_OBJ_TYPE_INTEGER, arg);
if (arg) {
time = arg->value.int_v;
goto finalize;
}
}
memset(&nettime, 0, sizeof(nettime));
memset(&nettime, 0, sizeof(nettime));
if (argc > 7) {
argc = 7;
}
for (i = 0; i < argc; i++) {
int* dst;
CHANSVmObjHdr* arg = CHANSVmGetArg(vm, i);
arg = CHANSVmConvertObjectType(vm, CHANS_VM_OBJ_TYPE_INTEGER, arg);
if (arg == vmNull) {
break;
if (argc > 7) {
argc = 7;
}
switch (i) {
case 0:
dst = &nettime.year;
for (i = 0; i < argc; i++) {
int* dst;
CHANSVmObjHdr* arg = CHANSVmGetArg(vm, i);
arg = CHANSVmConvertObjectType(vm, CHANS_VM_OBJ_TYPE_INTEGER, arg);
if (arg == vmNull) {
break;
case 1:
dst = &nettime.mon;
break;
case 2:
dst = &nettime.mday;
break;
case 3:
dst = &nettime.hour;
break;
case 4:
dst = &nettime.min;
break;
case 5:
dst = &nettime.sec;
break;
case 6:
dst = &nettime.msec;
break;
default:
CHANS_VM_PRINTF_CUSTOM("internal error in %s line %d\n", __FUNCTION__, 211);
return vmFalse;
}
switch (i) {
case 0:
dst = &nettime.year;
break;
case 1:
dst = &nettime.mon;
break;
case 2:
dst = &nettime.mday;
break;
case 3:
dst = &nettime.hour;
break;
case 4:
dst = &nettime.min;
break;
case 5:
dst = &nettime.sec;
break;
case 6:
dst = &nettime.msec;
break;
default:
CHANS_VM_PRINTF_CUSTOM("internal error in %s line %d\n", __FUNCTION__, 211);
return vmFalse;
}
*dst = (s32)arg->value.int_v;
}
*dst = (s32)arg->value.int_v;
}
if (nettime.year < 2000) {
nettime.year = 2000;
}
if (nettime.mday < 1) {
nettime.mday = 1;
}
if (nettime.year < 2000) {
nettime.year = 2000;
time = OSCalendarTimeToTicks(&nettime);
time = (u64)((s64)time / (__OSBusClock / 4 / 1000));
} else {
time = OSGetTime();
time = (u64)((s64)time / (__OSBusClock / 4 / 1000));
}
if (nettime.mday < 1) {
nettime.mday = 1;
}
time = OSCalendarTimeToTicks(&nettime);
time = (u64)((s64)time / (__OSBusClock / 4 / 1000));
goto finalize;
osgettime:
time = OSGetTime();
time = (u64)((s64)time / (__OSBusClock / 4 / 1000));
finalize:
time = time * (__OSBusClock / 4 / 1000);
@@ -3386,17 +3382,17 @@ VmMethodDefine(String, ToUpperCase) {
return vmFalse;
}
CHANSVmObjHdr* CHANSVmFormatString(CHANSVm* vm, CHANSVmObjHdr* obj, u32 arg) {
u8 charBuffer[8];
CHANSVmObjHdr* CHANSVmFormatString(CHANSVm* vm, CHANSVmObjHdr* obj, u32 formatArgIndex) {
vmWChar charBuffer[4];
CHANSVmObjHdr* formattedObj;
u8 stringHeaderBuffer[16];
CHANSVmObjHdr stringHeader;
u8 fmtBufData[32];
u8* fmtBuf;
wchar_t wideFmt[32];
u32 halfMaxSize;
BOOL alternateForm;
CHANSVmObjHdr* stringArg;
u32 argIdxCounter;
u32 argumentOffset;
u32 totalLen;
u8* str;
u32 strLen;
@@ -3407,6 +3403,7 @@ CHANSVmObjHdr* CHANSVmFormatString(CHANSVm* vm, CHANSVmObjHdr* obj, u32 arg) {
u32 maxSize;
u8* outputBuf;
u32 outputPos;
// MWCC needs the maximum-length comparisons even though the result is unused.
u32 maxLitLen;
u32 litLen;
u32 isEscaped;
@@ -3415,13 +3412,13 @@ CHANSVmObjHdr* CHANSVmFormatString(CHANSVm* vm, CHANSVmObjHdr* obj, u32 arg) {
CHANSVmObjHdr* argObj;
pVm = (CHANSVmPrivate*)vm;
memset(stringHeaderBuffer, 0, sizeof(stringHeaderBuffer));
memset(&stringHeader, 0, sizeof(stringHeader));
if (pVm->pActiveCtx->argc == 0) {
goto empty_create;
}
argObj = CHANSVmGetArg(vm, arg);
argObj = CHANSVmGetArg(vm, formatArgIndex);
if (argObj == vmNull || argObj->type != CHANS_VM_OBJ_TYPE_STRING) {
goto null_return;
}
@@ -3440,7 +3437,7 @@ CHANSVmObjHdr* CHANSVmFormatString(CHANSVm* vm, CHANSVmObjHdr* obj, u32 arg) {
while (vmTrue) {
strPos = 0;
segStart = 0;
argIdxCounter = 1;
argumentOffset = 1;
while (strPos < strLen) {
// Label allows to continue without checking the condition
@@ -3589,11 +3586,11 @@ CHANSVmObjHdr* CHANSVmFormatString(CHANSVm* vm, CHANSVmObjHdr* obj, u32 arg) {
fmtBuf[fmtBufPos++] = 'l';
fmtBuf[fmtBufPos++] = conversionChar;
fmtBuf[fmtBufPos] = 0;
valueObj = CHANSVmConvertObjectType(vm, CHANS_VM_OBJ_TYPE_INTEGER, CHANSVmGetArg(vm, arg + argIdxCounter));
valueObj = CHANSVmConvertObjectType(vm, CHANS_VM_OBJ_TYPE_INTEGER, CHANSVmGetArg(vm, formatArgIndex + argumentOffset));
}
common_number_format: {
argIdxCounter++;
argumentOffset++;
if (valueObj == vmNull) {
goto loop_hint;
}
@@ -3627,35 +3624,35 @@ CHANSVmObjHdr* CHANSVmFormatString(CHANSVm* vm, CHANSVmObjHdr* obj, u32 arg) {
fmtBuf[fmtBufPos++] = 'l';
fmtBuf[fmtBufPos++] = conversionChar;
fmtBuf[fmtBufPos] = 0;
valueObj = CHANSVmConvertObjectType(vm, CHANS_VM_OBJ_TYPE_FLOAT, CHANSVmGetArg(vm, arg + argIdxCounter));
valueObj = CHANSVmConvertObjectType(vm, CHANS_VM_OBJ_TYPE_FLOAT, CHANSVmGetArg(vm, formatArgIndex + argumentOffset));
litLen = 1;
goto common_number_format;
}
char_body: {
valueObj = CHANSVmConvertObjectType(vm, CHANS_VM_OBJ_TYPE_INTEGER, CHANSVmGetArg(vm, arg + argIdxCounter));
argIdxCounter++;
valueObj = CHANSVmConvertObjectType(vm, CHANS_VM_OBJ_TYPE_INTEGER, CHANSVmGetArg(vm, formatArgIndex + argumentOffset));
argumentOffset++;
if (valueObj == vmNull) {
goto loop_hint;
}
stringData = charBuffer;
*(u16*)charBuffer = valueObj->value.int_v;
*(u16*)(charBuffer + 2) = 0;
charBuffer[0] = valueObj->value.int_v;
charBuffer[1] = 0;
formattedObj = vmNull;
goto common_string_format;
}
string_body: {
u32 objLen;
stringArg = CHANSVmConvertObjectType(vm, CHANS_VM_OBJ_TYPE_STRING, CHANSVmGetArg(vm, arg + argIdxCounter));
argIdxCounter++;
stringArg = CHANSVmConvertObjectType(vm, CHANS_VM_OBJ_TYPE_STRING, CHANSVmGetArg(vm, formatArgIndex + argumentOffset));
argumentOffset++;
if (stringArg == vmNull) {
goto loop_hint;
}
objLen = stringArg->value.string_v->len & ~1U;
{
formattedObj = CHANSVmNewObject(vm, vmFalse, (CHANSVmObjHdr*)stringHeaderBuffer, CHANS_VM_OBJ_TYPE_STRING, objLen + 2);
formattedObj = CHANSVmNewObject(vm, vmFalse, &stringHeader, CHANS_VM_OBJ_TYPE_STRING, objLen + 2);
if (formattedObj == vmNull) {
goto null_return;
}
@@ -4839,35 +4836,35 @@ static CHANSVmBlobPackFormatList vmBlobPackFormatList[25] = {
{0x0A, 1, 2, 0}, // '\n'
};
static u32 vmBlobParsePackFormatString(u32* out_nextPos, u32* out_elemType, u32* out_elemSize, u32* out_paramValue, const wchar_t* fmtStr, u32 fmtLen,
static u32 vmBlobParsePackFormatString(u32* out_formatChar, u32* out_elemType, u32* out_elemSize, u32* out_paramValue, const wchar_t* fmtStr, u32 fmtLen,
u32 curPos) {
wchar_t curChar;
u32 elemType;
u32 elemSize;
u32 hasStar;
u32 supportsStar;
s32 paramValue;
u32 hasParam;
u32 i;
const CHANSVmBlobPackFormatList* p;
elemSize = 1;
hasStar = 0;
supportsStar = 0;
paramValue = 0;
while (curPos < fmtLen) {
curChar = fmtStr[curPos];
p = vmBlobPackFormatList;
for (i = 0; i < 25; i++, p++) {
for (i = 0; i < sizeof(vmBlobPackFormatList) / sizeof(vmBlobPackFormatList[0]); i++, p++) {
if (curChar == p->charCode) {
elemType = p->type;
elemSize = p->size;
hasStar = p->flags;
supportsStar = p->flags;
break;
}
}
if (i >= 25) {
if (i >= sizeof(vmBlobPackFormatList) / sizeof(vmBlobPackFormatList[0])) {
elemSize = 1;
elemType = 0;
goto exit;
@@ -4899,7 +4896,7 @@ param_processing:
if (!hasParam) {
if (digit == '*') {
if (hasStar & 1) {
if (supportsStar & 1) {
paramValue = -1;
curPos++;
goto exit;
@@ -4932,8 +4929,8 @@ param_processing:
}
exit:
if (out_nextPos != vmNull) {
*out_nextPos = curChar;
if (out_formatChar != vmNull) {
*out_formatChar = curChar;
}
if (out_elemType != vmNull) {
*out_elemType = elemType;
@@ -6562,30 +6559,27 @@ static CHANSVmErr VmPushFuncReturnInfo(CHANSVm* vm, u32 argCount, u32 totalSlots
}
}
if (block == vmNull) {
goto return_result;
if (block != vmNull) {
if (pVm->pActiveCtx != vmNull) {
block->pDbg = pVm->pActiveCtx->pDbg;
block->pc = pVm->pActiveCtx->pc;
block->pNext = pVm->pActiveCtx;
}
pVm->pActiveCtx = block;
block->pArgv = (vmWString*)objStackTopBuf;
block->argc = argCount;
block->totalSlots = totalSlots;
block->headerCount = headerCount;
block->frameBase = (vmU16)(VM_FRAME_ARENA_SIZE - (headerCount + totalSlots));
for (i = 0; i < headerCount; i++) {
memset(&block->headers[i], 0, sizeof(CHANSVmObjHdr));
}
result = CHANS_VM_OK;
}
if (pVm->pActiveCtx != vmNull) {
block->pDbg = pVm->pActiveCtx->pDbg;
block->pc = pVm->pActiveCtx->pc;
block->pNext = pVm->pActiveCtx;
}
pVm->pActiveCtx = block;
block->pArgv = (vmWString*)objStackTopBuf;
block->argc = argCount;
block->totalSlots = totalSlots;
block->headerCount = headerCount;
block->frameBase = (vmU16)(VM_FRAME_ARENA_SIZE - (headerCount + totalSlots));
for (i = 0; i < headerCount; i++) {
memset(&block->headers[i], 0, sizeof(CHANSVmObjHdr));
}
result = 0;
}
return_result:
return result;
}
@@ -6758,7 +6752,9 @@ CHANSVmErr CHANSVmLinkModules(CHANSVm* vm, vmS32 reserved) {
CHANSVmObjHdr* obj;
if (idx >= module->moduleCount) {
goto pass3_idx_err;
} else if (obj = CHANSVmLookupScopedObject(vm, idx), obj == vmNull) {
}
obj = CHANSVmLookupScopedObject(vm, idx);
if (obj == vmNull) {
goto pass3_obj_err;
} else if (obj->type == CHANS_VM_OBJ_TYPE_BLANK) {
goto pass3_success;
@@ -6870,7 +6866,7 @@ static CHANSVmErr VmCallMethod(CHANSVm* vm, u32 instructionSize, u32 callType, u
CHANSVmFunction funcPtr;
CHANSVmNativeClass* target;
u32 pushEnd, headerCount;
CHANSVmObjHdr localBuf;
CHANSVmObjHdr nativeResult;
u32 pushDepth;
acc = &pVm->accumulator;
@@ -6940,7 +6936,7 @@ static CHANSVmErr VmCallMethod(CHANSVm* vm, u32 instructionSize, u32 callType, u
}
}
memset(&localBuf, 0, sizeof(CHANSVmObjHdr));
memset(&nativeResult, 0, sizeof(CHANSVmObjHdr));
if (callType == CHANS_VM_CALL_TYPE_FUNCTION) {
methodRef = 0;
@@ -7024,8 +7020,8 @@ static CHANSVmErr VmCallMethod(CHANSVm* vm, u32 instructionSize, u32 callType, u
return CHANS_VM_ERR_NO_SUCH_FUNCTION;
}
if (ctorFlag != vmFalse) {
localBuf.parentCls = target;
localBuf.type = CHANS_VM_TYPE_OBJECT;
nativeResult.parentCls = target;
nativeResult.type = CHANS_VM_TYPE_OBJECT;
funcPtr = target->ctor;
if (funcPtr == vmNull) {
return CHANS_VM_ERR_NOT_CONSTRUCTOR;
@@ -7042,7 +7038,7 @@ static CHANSVmErr VmCallMethod(CHANSVm* vm, u32 instructionSize, u32 callType, u
retVal = VmPushFuncReturnInfo(vm, pushDepth, target != vmNull ? pushDepth : pushEnd, headerCount);
if (retVal == CHANS_VM_OK) {
if (target != vmNull) {
if (funcPtr != vmNull && funcPtr(vm, acc, &localBuf) == CHANS_VM_OK) {
if (funcPtr != vmNull && funcPtr(vm, acc, &nativeResult) == CHANS_VM_OK) {
retVal = CHANS_VM_ERR_IN_METHOD_OR_PROPERTY;
if (ctorFlag != vmFalse) {
retVal = CHANS_VM_ERR_NEW;
@@ -7052,9 +7048,9 @@ static CHANSVmErr VmCallMethod(CHANSVm* vm, u32 instructionSize, u32 callType, u
if (retVal == CHANS_VM_OK && callType != CHANS_VM_CALL_TYPE_PROP_SET) {
retVal = CHANSVmDeleteObject(vm, acc);
if (retVal == CHANS_VM_OK) {
memcpy(acc, &localBuf, sizeof(CHANSVmObjHdr));
memcpy(acc, &nativeResult, sizeof(CHANSVmObjHdr));
acc->flags.raw &= ~CHANSVM_OBJ_FLAG_READONLY;
memset(&localBuf, 0, sizeof(CHANSVmObjHdr));
memset(&nativeResult, 0, sizeof(CHANSVmObjHdr));
}
}
}
@@ -7074,7 +7070,6 @@ static CHANSVmErr VmCallMethod(CHANSVm* vm, u32 instructionSize, u32 callType, u
}
}
return_label:
return retVal;
}

View File

@@ -0,0 +1,129 @@
# clean3-c1 cleanup attempts
Worktree: /mnt/drive2/projects/wii-ipl-workers/clean3-c1.
Branch: agent/w1009/clean3-c1. Baseline: 8a67b68cf.
Assigned module: channelScript. Every touched unit must remain exact and linked.
Read clean3-head.md and cleanup-common.md fully, AGENTS.md, unslop,
writing-for-agents, and graphify. Inspected cleanup-c1, cleanup2-x8, and
cleanup2-x11 attempts before editing. Memory only identified earlier CHANSVm
work; current source and object measurements determine acceptance.
Prior failed families excluded: plain lifetime-pragma removal, accumulator
pointer sharing, broad declaration permutations, and string conversion early
returns. The pragma preserves interpreter register allocation. Try a distinct
scope or control-flow hypothesis before revisiting it.
Private header fields already have meaningful names. Unused padding has no
established role and retains its layout names. Public unk0 parameters correspond
to the reserved parameters in the definitions.
Initial DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d.
Initial CHANSVm source object saved under /tmp/clean3-c1-baseline.o.
Each trial builds the object and compares every allocated section, layout,
resolved relocation, and exported symbol with this baseline. Restore any
trial that changes this signature. No other worktree is modified.
## Trials
- RESTORE: CHANSVmLookupScopedObject: return directly for a missing argument. .text 36 differing bytes
- KEEP: VmPushFuncReturnInfo: guard frame initialization with the allocated block. Allocated bytes, layout, relocations, and exports identical.
- RESTORE: CHANSVmParseFloat: structured constant search and numeric conversion. .text layout 53564 -> 53588 bytes; .rela.data resolved relocations changed; .rela.rodata resolved relocations changed; .rela.sdata2 resolved relocations changed; .rela.text resolved relocations changed; exported symbols changed
- RESTORE: VmCmpEq: normal object-equality branch instead of jumping into another case. .text layout 53564 -> 53632 bytes; .rela.data resolved relocations changed; .rela.rodata resolved relocations changed; .rela.sdata2 resolved relocations changed; .rela.text resolved relocations changed; exported symbols changed
- KEEP: VmDateCommon: structured current-time branch instead of osgettime jump. Allocated bytes, layout, relocations, and exports identical.
- RESTORE: CHANSVmLinkModules: break from failed module-name resolution. .text layout 53564 -> 53580 bytes; .rela.data resolved relocations changed; .rela.text resolved relocations changed; exported symbols changed
- KEEP: CHANSVm.h: name the two reserved parameters consistently with their definitions. Allocated bytes, layout, relocations, and exports identical.
- KEEP: VmCallMethod: name the native return object and remove an unused return label. Allocated bytes, layout, relocations, and exports identical.
- RESTORE: CHANSVmLookupScopedObject: guard access with a valid argument index. .text layout 53564 -> 53556 bytes; .rela.data resolved relocations changed; .rela.text resolved relocations changed; exported symbols changed
- RESTORE: CHANSVmLinkModules: return a local-function error directly from the resolution loop. .text layout 53564 -> 53544 bytes; .rela.data resolved relocations changed; .rela.text resolved relocations changed; exported symbols changed
- RESTORE: CHANSVmStep: group construction and function-call cases with a constructor flag. .text layout 53564 -> 53572 bytes; .rela.data resolved relocations changed; .rela.text resolved relocations changed; exported symbols changed
- RESTORE: CHANSVmStep: select the immediate width inside grouped load cases. .text layout 53564 -> 53604 bytes; .rela.data resolved relocations changed; .rela.text resolved relocations changed; exported symbols changed
- KEEP: CHANSVmFormatString: use a typed temporary string header. Allocated bytes, layout, relocations, and exports identical.
- KEEP: CHANSVmFormatString: index a wide-character buffer directly. Allocated bytes, layout, relocations, and exports identical.
- RESTORE: CHANSVmParseFloat: use an exhausted-search bound before parsing numbers. .text layout 53564 -> 53588 bytes; .rela.data resolved relocations changed; .rela.rodata resolved relocations changed; .rela.sdata2 resolved relocations changed; .rela.text resolved relocations changed; exported symbols changed
- RESTORE: CHANSVmStep: remove the lifetime pragma with property-result and accumulator scoped to their opcode. .text 183 differing bytes
- RESTORE: CHANSVmAddExe: break on an invalid string-table entry. .text layout 53564 -> 53548 bytes; .rela.data resolved relocations changed; .rela.text resolved relocations changed; exported symbols changed
- RESTORE: CHANSVmLinkModules: structured success with one common error exit. .text layout 53564 -> 53560 bytes; .rela.data resolved relocations changed; .rela.text resolved relocations changed; exported symbols changed
- KEEP: CHANSVmLinkModules: separate scoped-object lookup from its condition. Allocated bytes, layout, relocations, and exports identical.
- RESTORE: CHANSVmStep: break from the strict-equality switch and keep its status. .text layout 53564 -> 53560 bytes; .rela.data resolved relocations changed; .rela.text resolved relocations changed; exported symbols changed
- KEEP: CHANSVmFormatString: name the format argument index and value-argument offset. Allocated bytes, layout, relocations, and exports identical.
- RESTORE: CHANSVmStep: guard index conversion and select success with structured cases. .text layout 53564 -> 53596 bytes; .rela.data resolved relocations changed; .rela.text resolved relocations changed; exported symbols changed
- RESTORE: vmBlobParsePackFormatString: break after finding a token and parse it in a guarded block. .text layout 53564 -> 53572 bytes; .rela.data resolved relocations changed; .rela.rodata resolved relocations changed; .rela.sdata2 resolved relocations changed; .rela.text resolved relocations changed; exported symbols changed
- RESTORE: VmReserveChunkEntry: search free entries with loop bounds and breaks. .text layout 53564 -> 53588 bytes; .rela.data resolved relocations changed; .rela.rodata resolved relocations changed; .rela.sdata2 resolved relocations changed; .rela.text resolved relocations changed; exported symbols changed
- RESTORE: CHANSVmAddExe: preserve string-validation status while replacing the jump with break. .text layout 53564 -> 53572 bytes; .rela.data resolved relocations changed; .rela.text resolved relocations changed; exported symbols changed
- RESTORE: VmDateCommon: finish a universal-time argument without the shared-tail jump. .text layout 53564 -> 53592 bytes; .rela.data resolved relocations changed; .rela.rodata resolved relocations changed; .rela.sdata2 resolved relocations changed; .rela.text resolved relocations changed; exported symbols changed
- KEEP: vmBlobParsePackFormatString: name the returned format character and star support flag. Allocated bytes, layout, relocations, and exports identical.
- RESTORE: VmBlobCreateDirect: return after failed allocation before looking up the class. .text layout 53564 -> 53572 bytes; .rela.data resolved relocations changed; .rela.rodata resolved relocations changed; .rela.sdata2 resolved relocations changed; .rela.text resolved relocations changed; exported symbols changed
- RESTORE: CHANSVmInit: guard String-class lookup with successful built-in registration. .text layout 53564 -> 53572 bytes; .rela.data resolved relocations changed; .rela.text resolved relocations changed; exported symbols changed
- RESTORE: CHANSVmInit: separate the guarded Array-class lookup from its condition. .text layout 53564 -> 53576 bytes; .rela.data resolved relocations changed; .rela.text resolved relocations changed; exported symbols changed
- RESTORE: CHANSVmAddExe: jump straight to the existing error exit for an invalid string. .text layout 53564 -> 53540 bytes; .rela.data resolved relocations changed; .rela.text resolved relocations changed; exported symbols changed
- RESTORE: CHANSVmLinkModules: keep successful initialization inside its validity branch. .text 20 differing bytes
- RESTORE: CHANSVmParseFloat: break from constant lookup while keeping the numeric store exit. .text layout 53564 -> 53588 bytes; .rela.data resolved relocations changed; .rela.rodata resolved relocations changed; .rela.sdata2 resolved relocations changed; .rela.text resolved relocations changed; exported symbols changed
- KEEP: CHANSVmParseFloat: choose integer or floating conversion in a normal if/else. Allocated bytes, layout, relocations, and exports identical.
- KEEP: VmDateCommon: indent the current-time branch to match its scope. Allocated bytes, layout, relocations, and exports identical.
- RESTORE: CHANSVmFormatString: remove the unused maximum-literal-length accumulator. .text layout 53564 -> 53520 bytes; .rela.data resolved relocations changed; .rela.rodata resolved relocations changed; .rela.sdata2 resolved relocations changed; .rela.text resolved relocations changed; exported symbols changed
- RESTORE: CHANSVmAddNativeClass2: size the trailing class name from its declared field. .text 1 differing bytes
- RESTORE: CHANSVmLookupScopedObject: explicitly choose null or the indexed argument. .text 36 differing bytes
- RESTORE: CHANSVmStep: assign the next program counter after validating the active context. .text layout 53564 -> 53572 bytes; .rela.text resolved relocations changed; exported symbols changed
- KEEP: vmBlobParsePackFormatString: derive the format-table count from the array. Allocated bytes, layout, relocations, and exports identical.
- KEEP: VmPushFuncReturnInfo: use the named success constant for frame allocation. Allocated bytes, layout, relocations, and exports identical.
- KEEP: CHANSVmAddNativeClass2: use the existing class-name length constant in allocation. Allocated bytes, layout, relocations, and exports identical.
- RESTORE: VmCallMethod: use a shared error exit outside the object-type switch. .text 760 differing bytes; .rela.text resolved relocations changed
- KEEP: CHANSVmFormatString: explain the retained unused maximum-length comparisons. Allocated bytes, layout, relocations, and exports identical.
## Retained source
CHANSVm.c: gotos 246 -> 242. Replaced the integer-versus-float parse jump
with if/else, the current-time jump with a calendar-argument branch, and the
frame-allocation jump with a guarded initialization block. Removed the unused
native-call return label. Extracted module lookup from the comma condition.
Formatting uses a real CHANSVmObjHdr and vmWChar buffer instead of byte overlays;
named the format argument index, argument offset, and native return object.
The blob parser names its character output correctly and derives its table
count from the array. Allocation uses the existing class-name length constant;
frame allocation uses CHANS_VM_OK.
CHANSVm.h: both unk0 parameters are reserved, matching the definitions.
Private module headers already have descriptive fields. Padding has no named
uses establishing a role, so it stays unchanged. No other channelScript unit
was modified.
Keep the lifetime pragma and its existing one-line compiler explanation.
The new property-scoped alternative changed 183 .text bytes. Earlier cleanup
already rejected plain removal and pointer-sharing alternatives. Keep formatter
maximum-length tracking: removing it deletes 44 .text bytes. Added its one-line
compiler explanation. Existing shared failure exits and parser/interpreter
state-machine labels stay; tested structured alternatives changed target bytes.
44 built trials: 15 retained, 29 restored. The full allocated-object signature
is identical to the initial snapshot, including every resolved relocation and
exported symbol. Pool check: 125/125 identical. The early sizeof(sName) allocation
trial was not equivalent: sName holds four bytes and classNameStorage holds the
remaining 28. It was restored; the retained form uses CHANS_VM_CLASS_NAME_LEN.
Utility corrections selected a multiline function signature, a NO_INLINE
suffix, and unique transformation spans. These failed assertions happened
before source writes. The first pool command passed a unit instead of object
paths; the corrected two-object command passed. No failed trial remains.
## Final validation
Ran the final gate once for src/channelScript/CHANSVm with --quick.
Full 43U build passed. Pool IDENTICAL; objdiff code 53564/53564, data
6904/6904, functions 233/233, all fully linked. Instruction-exact 233/233.
Every owned section is 100%: .text, .data, .rodata, .sbss, .sdata, .sdata2.
GATE PASS: 0 regressions, 0 forbidden additions, 0 readability warnings.
Transcript: /tmp/clean3-c1-gate.log.
Fresh focused ctxdiff: CHANSVmStep 1253/1253 instructions, diffs 0;
CHANSVmFormatString 431/431 instructions, diffs 0. The complete allocated
source-object signature remains identical after the full build.
Requested report.json and build/43U/ok targets are current. Completion check:
DECOMPLETE_OK. All 1028 unit measures equal the initial complete report;
12563/12563 functions remain exact. Assembly inventory: 162 ORIGINAL,
0 PLACEHOLDER, ASM INVENTORY PASS. git diff --check passed.
DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d.
Source files committed separately: 1aab434ba CHANSVm.c; 0fa082e3d CHANSVm.h.
No configure changes, other-unit edits, push, PR, merge, rebase, subagent,
or other-worktree edits. Ready for independent parent verification.