想请教下JamVM的JIT编译器部分,patchExternalJumps函数里面跳转到外部块的疑惑?
sundreams2009
2013-12-09
void patchExternalJumps(TestCodeBlock *test_block, CodeBlockHeader *new_block) { BasicBlock *patchers = test_block->patchers; char *test_addr = (char*)(test_block + 1); char *new_addr = (char*)(new_block + 1); for(; patchers; patchers = patchers->u.patch.next) { Instruction *target = patchers->start[patchers->length - 1].operand.pntr; char *handler = (char*)target->handler; if(handler < min_entry_point || handler > max_entry_point) { char *addr = patchers->u.patch.addr - test_addr + new_addr; if(GEN_REL_JMP(handler, addr, goto_len)) { TRACE("Patched branch to external block %p\n", handler); } } } } if(handler < min_entry_point || handler > max_entry_point)这句话不太理解,外部块可能会是什么地方?刚大概看了下这部分的代码,感觉handler就是取自handler表中的,这个判断条件应该肯定能满足的吧,我搜了下对operand.pntr赋值的地方,就是在prepare函数里面进行了赋值,其他地方看着不像,这里的外部块应该是其他的拼凑的代码块吧? |