@@ -381,9 +381,7 @@ __NEXT_STEP:;
DISPATCH();
TARGET(RETURN_VALUE)
_0 = POPX();
- // cleanup the stack on return
- callstack.pop();
- s_data.reset(frame->_sp_base);
+ _pop_frame();
if(frame.index == base_id){ // [ frameBase<- ]
return _0;
}else{
@@ -570,7 +568,7 @@ __NEXT_STEP:;
PyObject* obj = POPX();
Exception& _e = CAST(Exception&, obj);
_e.st_push(frame->snapshot());
if(callstack.empty()){
#if DEBUG_FULL_EXCEPTION
std::cerr << _e.summary() << std::endl;
@@ -37,7 +37,7 @@
#define DEBUG_DIS_EXEC 1
#define DEBUG_CEVAL_STEP 0
#define DEBUG_CEVAL_STEP_MIN 0
-#define DEBUG_FULL_EXCEPTION 0
+#define DEBUG_FULL_EXCEPTION 1
#define DEBUG_MEMORY_POOL 0
#define DEBUG_NO_MEMORY_POOL 0
#define DEBUG_NO_AUTO_GC 0
@@ -72,7 +72,7 @@ inline PyObject* Generator::next(){
// backup the context
frame = std::move(vm->callstack.top());
for(PyObject* obj: frame.stack_view()) s_data.push_back(obj);
- vm->callstack.pop();
+ vm->_pop_frame();
state = 1;
return frame._s->popx();
@@ -769,11 +769,11 @@ inline void VM::post_init(){
add_module_math(this);
add_module_re(this);
add_module_dis(this);
- add_module_random(this);
add_module_io(this);
add_module_os(this);
add_module_c(this);
add_module_gc(this);
+ add_module_random(this);
for(const char* name: {"this", "functools", "collections", "heapq", "bisect"}){
_lazy_modules[name] = kPythonLibs[name];
@@ -195,6 +195,12 @@ public:
return _run_top_frame();
}
+ void _pop_frame(){
+ Frame* frame = &callstack.top();
+ s_data.reset(frame->_sp_base);
+ callstack.pop();
+ }
+
void _push_varargs(int n, ...){
va_list args;
va_start(args, n);