This commit is contained in:
blueloveTH 2023-04-17 18:08:37 +08:00
parent b637190ae7
commit b8a54d0d43
5 changed files with 11 additions and 7 deletions

View File

@ -381,9 +381,7 @@ __NEXT_STEP:;
DISPATCH(); DISPATCH();
TARGET(RETURN_VALUE) TARGET(RETURN_VALUE)
_0 = POPX(); _0 = POPX();
// cleanup the stack on return _pop_frame();
callstack.pop();
s_data.reset(frame->_sp_base);
if(frame.index == base_id){ // [ frameBase<- ] if(frame.index == base_id){ // [ frameBase<- ]
return _0; return _0;
}else{ }else{
@ -570,7 +568,7 @@ __NEXT_STEP:;
PyObject* obj = POPX(); PyObject* obj = POPX();
Exception& _e = CAST(Exception&, obj); Exception& _e = CAST(Exception&, obj);
_e.st_push(frame->snapshot()); _e.st_push(frame->snapshot());
callstack.pop(); _pop_frame();
if(callstack.empty()){ if(callstack.empty()){
#if DEBUG_FULL_EXCEPTION #if DEBUG_FULL_EXCEPTION
std::cerr << _e.summary() << std::endl; std::cerr << _e.summary() << std::endl;

View File

@ -37,7 +37,7 @@
#define DEBUG_DIS_EXEC 1 #define DEBUG_DIS_EXEC 1
#define DEBUG_CEVAL_STEP 0 #define DEBUG_CEVAL_STEP 0
#define DEBUG_CEVAL_STEP_MIN 0 #define DEBUG_CEVAL_STEP_MIN 0
#define DEBUG_FULL_EXCEPTION 0 #define DEBUG_FULL_EXCEPTION 1
#define DEBUG_MEMORY_POOL 0 #define DEBUG_MEMORY_POOL 0
#define DEBUG_NO_MEMORY_POOL 0 #define DEBUG_NO_MEMORY_POOL 0
#define DEBUG_NO_AUTO_GC 0 #define DEBUG_NO_AUTO_GC 0

View File

@ -72,7 +72,7 @@ inline PyObject* Generator::next(){
// backup the context // backup the context
frame = std::move(vm->callstack.top()); frame = std::move(vm->callstack.top());
for(PyObject* obj: frame.stack_view()) s_data.push_back(obj); for(PyObject* obj: frame.stack_view()) s_data.push_back(obj);
vm->callstack.pop(); vm->_pop_frame();
state = 1; state = 1;
return frame._s->popx(); return frame._s->popx();
}else{ }else{

View File

@ -769,11 +769,11 @@ inline void VM::post_init(){
add_module_math(this); add_module_math(this);
add_module_re(this); add_module_re(this);
add_module_dis(this); add_module_dis(this);
add_module_random(this);
add_module_io(this); add_module_io(this);
add_module_os(this); add_module_os(this);
add_module_c(this); add_module_c(this);
add_module_gc(this); add_module_gc(this);
add_module_random(this);
for(const char* name: {"this", "functools", "collections", "heapq", "bisect"}){ for(const char* name: {"this", "functools", "collections", "heapq", "bisect"}){
_lazy_modules[name] = kPythonLibs[name]; _lazy_modules[name] = kPythonLibs[name];

View File

@ -195,6 +195,12 @@ public:
return _run_top_frame(); return _run_top_frame();
} }
void _pop_frame(){
Frame* frame = &callstack.top();
s_data.reset(frame->_sp_base);
callstack.pop();
}
void _push_varargs(int n, ...){ void _push_varargs(int n, ...){
va_list args; va_list args;
va_start(args, n); va_start(args, n);