Berry add stack increase observability (#13482)

* Berry add stack increase observability

* Berry stack increase in bytes
This commit is contained in:
s-hadinger 2021-10-26 23:13:16 +02:00 committed by GitHub
parent f989063f29
commit 6158032723
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

View File

@ -390,6 +390,10 @@ void be_stack_expansion(bvm *vm, int n)
stack_resize(vm, size + 1);
be_raise(vm, "runtime_error", STACK_OVER_MSG(BE_STACK_TOTAL_MAX));
}
#if BE_USE_OBSERVABILITY_HOOK
if (vm->obshook != NULL)
(*vm->obshook)(vm, BE_OBS_STACK_RESIZE_START, size * sizeof(bvalue), (size + n) * sizeof(bvalue));
#endif
stack_resize(vm, size + n);
}

View File

@ -405,6 +405,7 @@ enum beobshookevents {
BE_OBS_GC_START, /* start of GC, arg = allocated size */
BE_OBS_GC_END, /* end of GC, arg = allocated size */
BE_OBS_VM_HEARTBEAT, /* VM heartbeat called every million instructions */
BE_OBS_STACK_RESIZE_START, /* Berry stack resized */
};
/* FFI functions */

View File

@ -268,6 +268,13 @@ void BerryObservability(bvm *vm, int event...) {
}
}
break;
case BE_OBS_STACK_RESIZE_START:
{
int32_t stack_before = va_arg(param, int32_t);
int32_t stack_after = va_arg(param, int32_t);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_BERRY "Stack resized from %i to %i bytes"), stack_before, stack_after);
}
break;
case BE_OBS_VM_HEARTBEAT:
{
// AddLog(LOG_LEVEL_INFO, ">>>: Heartbeat now=%i timeout=%i", millis(), berry.timeout);