[runtime] Refactor a little bit to avoid code duplication. (#5924)
This commit is contained in:
Родитель
adb57537b5
Коммит
464882d14a
|
@ -14,6 +14,9 @@ struct CallState {
|
|||
double double_ret;
|
||||
float float_ret;
|
||||
};
|
||||
bool is_stret () { return (type & Tramp_Stret) == Tramp_Stret; }
|
||||
id self () { return ((id *) esp) [(is_stret () ? 2 : 1)]; }
|
||||
SEL sel () { return ((SEL *) esp) [(is_stret () ? 3 : 2)]; }
|
||||
};
|
||||
|
||||
struct ParamIterator {
|
||||
|
|
|
@ -32,10 +32,10 @@ create_mt_exception (char *msg)
|
|||
|
||||
#ifdef TRACE
|
||||
static void
|
||||
dump_state (struct CallState *state, id self, SEL sel)
|
||||
dump_state (struct CallState *state)
|
||||
{
|
||||
fprintf (stderr, "type: %u is_stret: %i self: %p SEL: %s eax: 0x%x edx: 0x%x esp: 0x%x -- double_ret: %f float_ret: %f\n",
|
||||
state->type, (state->type & Tramp_Stret) == Tramp_Stret, self, sel_getName (sel), state->eax, state->edx, state->esp,
|
||||
state->type, state->is_stret (), state->self (), sel_getName (state->sel ()), state->eax, state->edx, state->esp,
|
||||
state->double_ret, state->float_ret);
|
||||
}
|
||||
#else
|
||||
|
@ -183,16 +183,11 @@ marshal_return_value (void *context, const char *type, size_t size, void *vvalue
|
|||
void
|
||||
xamarin_arch_trampoline (struct CallState *state)
|
||||
{
|
||||
enum TrampolineType type = (enum TrampolineType) state->type;
|
||||
bool is_stret = (type & Tramp_Stret) == Tramp_Stret;
|
||||
int offset = is_stret ? 1 : 0;
|
||||
id self = ((id *) state->esp) [offset + 1];
|
||||
SEL sel = ((SEL *) state->esp) [offset + 2];
|
||||
dump_state (state, self, sel);
|
||||
dump_state (state);
|
||||
struct ParamIterator iter;
|
||||
iter.state = state;
|
||||
xamarin_invoke_trampoline (type, self, sel, param_iter_next, marshal_return_value, &iter);
|
||||
dump_state (state, self, sel);
|
||||
xamarin_invoke_trampoline ((enum TrampolineType) state->type, state->self (), state->sel (), param_iter_next, marshal_return_value, &iter);
|
||||
dump_state (state);
|
||||
}
|
||||
|
||||
#endif /* __i386__ */
|
|
@ -25,6 +25,10 @@ struct CallState {
|
|||
long double xmm5;
|
||||
long double xmm6;
|
||||
long double xmm7;
|
||||
|
||||
bool is_stret () { return (type & Tramp_Stret) == Tramp_Stret; }
|
||||
id self () { return is_stret () ? (id) rsi : (id) rdi; }
|
||||
SEL sel () { return is_stret () ? (SEL) rdx : (SEL) rsi; }
|
||||
};
|
||||
|
||||
struct ParamIterator {
|
||||
|
|
|
@ -77,10 +77,10 @@ get_primitive_size (char type)
|
|||
|
||||
#ifdef TRACE
|
||||
static void
|
||||
dump_state (struct CallState *state, id self, SEL sel)
|
||||
dump_state (struct CallState *state)
|
||||
{
|
||||
fprintf (stderr, "type: %llu is_stret: %i self: %p SEL: %s rdi: 0x%llx rsi: 0x%llx rdx: 0x%llx rcx: 0x%llx r8: 0x%llx r9: 0x%llx rbp: 0x%llx -- xmm0: %Lf xmm1: %Lf xmm2: %Lf xmm3: %Lf xmm4: %Lf xmm5: %Lf xmm6: %Lf xmm7: %Lf\n",
|
||||
state->type, (state->type & Tramp_Stret) == Tramp_Stret, self, sel_getName (sel), state->rdi, state->rsi, state->rdx, state->rcx, state->r8, state->r9, state->rbp,
|
||||
state->type, state->is_stret (), state->self (), sel_getName (state->sel ()), state->rdi, state->rsi, state->rdx, state->rcx, state->r8, state->r9, state->rbp,
|
||||
state->xmm0, state->xmm1, state->xmm2, state->xmm3, state->xmm4, state->xmm5, state->xmm6, state->xmm7);
|
||||
}
|
||||
#else
|
||||
|
@ -538,14 +538,11 @@ xamarin_arch_trampoline (struct CallState *state)
|
|||
MONO_ASSERT_GC_SAFE;
|
||||
|
||||
enum TrampolineType type = (enum TrampolineType) state->type;
|
||||
bool is_stret = (type & Tramp_Stret) == Tramp_Stret;
|
||||
id self = is_stret ? (id) state->rsi : (id) state->rdi;
|
||||
SEL sel = is_stret ? (SEL) state->rdx : (SEL) state->rsi;
|
||||
dump_state (state, self, sel);
|
||||
dump_state (state);
|
||||
struct ParamIterator iter;
|
||||
iter.state = state;
|
||||
xamarin_invoke_trampoline (type, self, sel, param_iter_next, marshal_return_value, &iter);
|
||||
dump_state (state, self, sel);
|
||||
xamarin_invoke_trampoline (type, state->self (), state->sel (), param_iter_next, marshal_return_value, &iter);
|
||||
dump_state (state);
|
||||
}
|
||||
|
||||
#endif /* __x86_64__ */
|
Загрузка…
Ссылка в новой задаче