mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 19:40:18 +00:00
up
This commit is contained in:
parent
e020997305
commit
2c145f7751
36
src/ceval.h
36
src/ceval.h
@ -10,7 +10,6 @@ inline PyObject* VM::_run_top_frame(){
|
|||||||
FrameId frame = top_frame();
|
FrameId frame = top_frame();
|
||||||
const int base_id = frame.index;
|
const int base_id = frame.index;
|
||||||
bool need_raise = false;
|
bool need_raise = false;
|
||||||
PyObject* __ret;
|
|
||||||
|
|
||||||
while(true){
|
while(true){
|
||||||
#if DEBUG_EXTRA_CHECK
|
#if DEBUG_EXTRA_CHECK
|
||||||
@ -26,6 +25,8 @@ inline PyObject* VM::_run_top_frame(){
|
|||||||
* `Args` containing strong references is safe if it is passed to `call` or `fast_call`
|
* `Args` containing strong references is safe if it is passed to `call` or `fast_call`
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
#define DISPATCH_OP_CALL() { frame = top_frame(); goto __NEXT_FRAME; }
|
||||||
|
__NEXT_FRAME:
|
||||||
Bytecode byte = frame->next_bytecode();
|
Bytecode byte = frame->next_bytecode();
|
||||||
// cache
|
// cache
|
||||||
const CodeObject* co = frame->co;
|
const CodeObject* co = frame->co;
|
||||||
@ -351,7 +352,7 @@ __NEXT_STEP:;
|
|||||||
ArgsView args = frame->top_n_view(ARGC + int(method_call));
|
ArgsView args = frame->top_n_view(ARGC + int(method_call));
|
||||||
PyObject* ret = _py_call(callable, args, {});
|
PyObject* ret = _py_call(callable, args, {});
|
||||||
frame->pop_n(ARGC + 2);
|
frame->pop_n(ARGC + 2);
|
||||||
if(ret == nullptr) goto __PY_OP_CALL;
|
if(ret == nullptr) { DISPATCH_OP_CALL(); }
|
||||||
else frame->push(ret); // a generator
|
else frame->push(ret); // a generator
|
||||||
DISPATCH();
|
DISPATCH();
|
||||||
}
|
}
|
||||||
@ -362,7 +363,7 @@ __NEXT_STEP:;
|
|||||||
if(byte.op == OP_CALL_UNPACK) unpack_args(args);
|
if(byte.op == OP_CALL_UNPACK) unpack_args(args);
|
||||||
frame->pop();
|
frame->pop();
|
||||||
PyObject* ret = call(callable, std::move(args), no_arg(), true);
|
PyObject* ret = call(callable, std::move(args), no_arg(), true);
|
||||||
if(ret == _py_op_call) { __ret=ret; goto __PY_OP_CALL; }
|
if(ret == _py_op_call) { DISPATCH_OP_CALL(); }
|
||||||
frame->push(ret);
|
frame->push(ret);
|
||||||
} DISPATCH();
|
} DISPATCH();
|
||||||
TARGET(CALL_KWARGS)
|
TARGET(CALL_KWARGS)
|
||||||
@ -379,10 +380,21 @@ __NEXT_STEP:;
|
|||||||
if(byte.op == OP_CALL_KWARGS_UNPACK) unpack_args(args);
|
if(byte.op == OP_CALL_KWARGS_UNPACK) unpack_args(args);
|
||||||
PyObject* callable = frame->popx();
|
PyObject* callable = frame->popx();
|
||||||
PyObject* ret = call(callable, std::move(args), kwargs, true);
|
PyObject* ret = call(callable, std::move(args), kwargs, true);
|
||||||
if(ret == _py_op_call) { __ret=ret; goto __PY_OP_CALL; }
|
if(ret == _py_op_call) { DISPATCH_OP_CALL(); }
|
||||||
frame->push(ret);
|
frame->push(ret);
|
||||||
} DISPATCH();
|
} DISPATCH();
|
||||||
TARGET(RETURN_VALUE) { __ret=frame->popx(); goto __PY_SIMPLE_RETURN; }
|
TARGET(RETURN_VALUE) {
|
||||||
|
PyObject* __ret = frame->popx();
|
||||||
|
if(frame.index == base_id){ // [ frameBase<- ]
|
||||||
|
callstack.pop();
|
||||||
|
return __ret;
|
||||||
|
}else{
|
||||||
|
callstack.pop();
|
||||||
|
frame = top_frame();
|
||||||
|
frame->push(__ret);
|
||||||
|
goto __NEXT_FRAME;
|
||||||
|
}
|
||||||
|
}
|
||||||
TARGET(YIELD_VALUE) return _py_op_yield;
|
TARGET(YIELD_VALUE) return _py_op_yield;
|
||||||
/*****************************************/
|
/*****************************************/
|
||||||
TARGET(LIST_APPEND) {
|
TARGET(LIST_APPEND) {
|
||||||
@ -543,19 +555,7 @@ __NEXT_STEP:;
|
|||||||
#undef DISPATCH
|
#undef DISPATCH
|
||||||
#undef TARGET
|
#undef TARGET
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
__PY_SIMPLE_RETURN:
|
UNREACHABLE();
|
||||||
if(frame.index == base_id){ // [ frameBase<- ]
|
|
||||||
callstack.pop();
|
|
||||||
return __ret;
|
|
||||||
}else{
|
|
||||||
callstack.pop();
|
|
||||||
frame = top_frame();
|
|
||||||
frame->push(__ret);
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
__PY_OP_CALL:
|
|
||||||
frame = top_frame(); // [ frameBase, newFrame<- ]
|
|
||||||
continue;
|
|
||||||
}catch(HandledException& e){
|
}catch(HandledException& e){
|
||||||
continue;
|
continue;
|
||||||
}catch(UnhandledException& e){
|
}catch(UnhandledException& e){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user