mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
support hook_instruct
This commit is contained in:
parent
874f3ff7ed
commit
1d97f4b34e
@ -191,3 +191,7 @@ PIKA_WEAK long __platform_ftell(FILE* stream) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PIKA_WEAK void __pks_hook_instruct(void) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
@ -158,4 +158,6 @@ long __platform_ftell(FILE* stream);
|
|||||||
/* error */
|
/* error */
|
||||||
void __platform_error_handle(void);
|
void __platform_error_handle(void);
|
||||||
|
|
||||||
|
void __pks_hook_instruct(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -2203,6 +2203,7 @@ static VMParameters* __pikaVM_runByteCodeFrameWithState(
|
|||||||
.line_error_code = PIKA_RES_OK,
|
.line_error_code = PIKA_RES_OK,
|
||||||
.try_error_code = PIKA_RES_OK,
|
.try_error_code = PIKA_RES_OK,
|
||||||
.try_info = try_info,
|
.try_info = try_info,
|
||||||
|
.ins_cnt = 0,
|
||||||
};
|
};
|
||||||
stack_init(&(vs.stack));
|
stack_init(&(vs.stack));
|
||||||
VMState_initReg(&vs);
|
VMState_initReg(&vs);
|
||||||
@ -2218,6 +2219,12 @@ static VMParameters* __pikaVM_runByteCodeFrameWithState(
|
|||||||
vs.line_error_code = 0;
|
vs.line_error_code = 0;
|
||||||
}
|
}
|
||||||
vs.pc = pikaVM_runInstructUnit(self, &vs, this_ins_unit);
|
vs.pc = pikaVM_runInstructUnit(self, &vs, this_ins_unit);
|
||||||
|
vs.ins_cnt++;
|
||||||
|
#if PIKA_INSTRUCT_HOOK_ENABLE
|
||||||
|
if (vs.ins_cnt % PIKA_INSTRUCT_HOOK_PERIOD == 0) {
|
||||||
|
__pks_hook_instruct();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (0 != vs.error_code) {
|
if (0 != vs.error_code) {
|
||||||
vs.line_error_code = vs.error_code;
|
vs.line_error_code = vs.error_code;
|
||||||
InstructUnit* head_ins_unit = this_ins_unit;
|
InstructUnit* head_ins_unit = this_ins_unit;
|
||||||
|
@ -76,6 +76,7 @@ struct VMState {
|
|||||||
uint8_t error_code;
|
uint8_t error_code;
|
||||||
uint8_t line_error_code;
|
uint8_t line_error_code;
|
||||||
uint8_t try_error_code;
|
uint8_t try_error_code;
|
||||||
|
uint32_t ins_cnt;
|
||||||
PikaObj* lreg[PIKA_REGIST_SIZE];
|
PikaObj* lreg[PIKA_REGIST_SIZE];
|
||||||
PIKA_BOOL ireg[PIKA_REGIST_SIZE];
|
PIKA_BOOL ireg[PIKA_REGIST_SIZE];
|
||||||
TryInfo* try_info;
|
TryInfo* try_info;
|
||||||
|
@ -2,4 +2,4 @@
|
|||||||
#define PIKA_VERSION_MINOR 10
|
#define PIKA_VERSION_MINOR 10
|
||||||
#define PIKA_VERSION_MICRO 0
|
#define PIKA_VERSION_MICRO 0
|
||||||
|
|
||||||
#define PIKA_EDIT_TIME "2022/08/05 22:39:41"
|
#define PIKA_EDIT_TIME "2022/08/06 15:56:22"
|
||||||
|
@ -254,6 +254,14 @@
|
|||||||
#define PIKA_ARG_BUFF_SIZE 8
|
#define PIKA_ARG_BUFF_SIZE 8
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef PIKA_INSTRUCT_HOOK_ENABLE
|
||||||
|
#define PIKA_INSTRUCT_HOOK_ENABLE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PIKA_INSTRUCT_HOOK_PERIOD
|
||||||
|
#define PIKA_INSTRUCT_HOOK_PERIOD 50
|
||||||
|
#endif
|
||||||
|
|
||||||
/* configuration validation */
|
/* configuration validation */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user