Avoiding function lookup for compiled functions. Still need caching.

This commit is contained in:
Ben Vanik 2014-02-02 14:41:57 -08:00
parent ef5f59ed0b
commit 0d88e83daa
2 changed files with 11 additions and 5 deletions

View File

@ -576,8 +576,10 @@ int Translate_TRAP_TRUE(TranslationContext& ctx, Instr* i) {
uint32_t IntCode_CALL_XX(IntCodeState& ics, const IntCode* i, uint32_t reg) {
FunctionInfo* symbol_info = (FunctionInfo*)ics.rf[reg].u64;
Function* fn = NULL;
Function* fn = symbol_info->function();
if (!fn) {
ics.thread_state->runtime()->ResolveFunction(symbol_info->address(), &fn);
}
XEASSERTNOTNULL(fn);
// TODO(benvanik): proper tail call support, somehow.
uint64_t return_address =

View File

@ -233,11 +233,15 @@ void TransitionToHost(X64Emitter& e) {
e.call(e.rax);
}
void IssueCall(X64Emitter& e, FunctionInfo* symbol_info, uint32_t flags) {
auto fn = symbol_info->function();
auto fn = (X64Function*)symbol_info->function();
// Resolve address to the function to call and store in rax.
// TODO(benvanik): caching/etc. For now this makes debugging easier.
if (fn) {
e.mov(e.rax, (uint64_t)fn->machine_code());
} else {
e.mov(e.rdx, (uint64_t)symbol_info);
CallNative(e, ResolveFunctionSymbol);
}
// Actually jump/call to rax.
if (flags & CALL_TAIL) {