Skip to content

Commit

Permalink
try inlines
Browse files Browse the repository at this point in the history
  • Loading branch information
lacraig2 committed Jul 12, 2023
1 parent 737dcef commit 35339e8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
4 changes: 1 addition & 3 deletions panda/include/panda/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,9 @@ extern char *panda_os_variant; // parsed os variant
extern uint32_t panda_os_bits; // parsed os bits
extern PandaOsFamily panda_os_familyno; // numeric identifier for family

/* Internal callback functions that plugins shouldn't use. These unset the flag when called so must be handled */


/* Internal callback functions that plugins shouldn't use. These unset the flag when called so must be handled */
bool panda_break_exec(void);
bool panda_flush_tb(void);

/* Regular functions plugins should use */

Expand Down
24 changes: 3 additions & 21 deletions panda/src/callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ void panda_disable_plugin(void *plugin)
* @brief Allows to navigate the callback linked list skipping disabled
* callbacks.
*/
panda_cb_list *panda_cb_list_next(panda_cb_list *plist)
inline panda_cb_list *panda_cb_list_next(panda_cb_list *plist)
{
for (panda_cb_list *node = plist->next; node != NULL;
node = node->next) {
Expand All @@ -797,27 +797,9 @@ panda_cb_list *panda_cb_list_next(panda_cb_list *plist)
return NULL;
}

void panda_do_break_exec(void) {
panda_please_break_exec = true;
}

bool panda_break_exec(void) {
if (panda_please_break_exec) {
panda_please_break_exec = false;
return true;
} else {
return false;
}

}

bool panda_flush_tb(void)
void panda_do_break_exec(void)
{
if (panda_please_flush_tb) {
panda_please_flush_tb = false;
return true;
} else
return false;
panda_please_break_exec = true;
}

void panda_do_flush_tb(void)
Expand Down
25 changes: 23 additions & 2 deletions panda/src/cb-support.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,27 @@

#define PCB(name) panda_callbacks_ ## name

extern bool panda_please_flush_tb;
extern bool panda_please_break_exec;

inline bool panda_break_exec(void) {
if (panda_please_break_exec) {
panda_please_break_exec = false;
return true;
} else {
return false;
}
}

inline bool panda_flush_tb(void) {
if (panda_please_flush_tb) {
panda_please_flush_tb = false;
return true;
} else {
return false;
}
}

// TODO: macro names should be include return type - bools |= all cb fns, voids don't

MAKE_REPLAY_ONLY_CALLBACK(REPLAY_HD_TRANSFER, replay_hd_transfer,
Expand Down Expand Up @@ -89,7 +110,7 @@ void PCB(start_block_exec)(CPUState *cpu, TranslationBlock *tb) {
plist->entry.start_block_exec(plist->context, cpu, tb);
}

if (panda_break_exec()) {
if (unlikely(panda_break_exec())) {
cpu_loop_exit_noexc(cpu); // noreturn - lonjmps back to translation logic. Allows you to change pc in an SBE and go
// there immediately. It's like before_block_exec_invalidate_opt, but fast
}
Expand Down Expand Up @@ -206,7 +227,7 @@ void PCB(before_find_fast)(void) {
}
}
}
if (panda_flush_tb()) {
if (unlikely(panda_flush_tb())) {
tb_flush(first_cpu);
}
}
Expand Down

0 comments on commit 35339e8

Please sign in to comment.