Use absolute stack offset when exiting from a native call
This commit is contained in:
parent
2000161d34
commit
ed9b522697
3
src/vm.c
3
src/vm.c
@ -833,9 +833,10 @@ static inline int _callNative(KrkNative* callee, int argCount, int returnDepth)
|
||||
krk_pop();
|
||||
krk_push(result);
|
||||
} else {
|
||||
size_t stackOffsetAfterCall = (krk_currentThread.stackTop - krk_currentThread.stack) - argCount - returnDepth;
|
||||
KrkValue result = krk_callNativeOnStack(argCount, krk_currentThread.stackTop - argCount, 0, native);
|
||||
if (unlikely(krk_currentThread.stackTop == krk_currentThread.stack)) return 0;
|
||||
krk_currentThread.stackTop -= argCount + returnDepth;
|
||||
krk_currentThread.stackTop = krk_currentThread.stack + stackOffsetAfterCall;
|
||||
krk_push(result);
|
||||
}
|
||||
return 2;
|
||||
|
Loading…
Reference in New Issue
Block a user