📄 icode.c
字号:
l->type = Lcode; return (l);}label*reference_table_label(int32 n){ label* l; assert(n < MAXLABTAB); if (labtab[n] == 0) { l = newLabel(); labtab[n] = l; l->type = Lnull; l->at = 0; l->from = 0; l->to = 0; } else { l = labtab[n]; labtab[n] = 0; } return (l);}SlotInfo*stored_code_label(SlotInfo* dst){ return (dst);}SlotInfo*table_code_label(SlotInfo* dst){ return (dst);}#if defined(HAVE_set_label)voidset_label(int i, int n){ assert(n < MAXLABTAB); if (labtab[n] == 0) { labtab[n] = newLabel(); labtab[n]->type = Linternal; labtab[n]->at = 0; labtab[n]->from = 0; labtab[n]->to = 0; slot_slot_const(0, 0, (jword)labtab[n], HAVE_set_label, Tnull); } else { assert(labtab[n]->type == Lnull); labtab[n]->type = Linternal; slot_slot_const(0, 0, (jword)labtab[n], HAVE_set_label, Tnull); labtab[n] = 0; }}#endif#if defined(HAVE_build_code_ref)label*build_code_ref(uint8* pos, uintp pc){ label* l; jint offset; offset = (pos[0] * 0x01000000 + pos[1] * 0x00010000 + pos[2] * 0x00000100 + pos[3] * 0x00000001); l = reference_code_label(pc+offset); slot_slot_const(0, 0, (jword)l, HAVE_build_code_ref, Tnull); return (l);}#endif#if defined(HAVE_build_key)voidbuild_key(uint8* pos){ jint val = (pos[0] * 0x01000000 + pos[1] * 0x00010000 + pos[2] * 0x00000100 + pos[3] * 0x00000001); slot_slot_const(0, 0, val, HAVE_build_key, Tnull);}#endif/* ----------------------------------------------------------------------- *//* Comparisons. *//* */#if defined(HAVE_cmp_int)voidcmp_int_const(SlotInfo* dst, SlotInfo* src, jint val){#if defined(HAVE_cmp_int_const) if (HAVE_cmp_int_const_rangecheck(val)) { slot_slot_const(dst, src, val, HAVE_cmp_int_const, Tcomplex); } else#endif { SlotInfo* tmp; slot_alloctmp(tmp); move_int_const(tmp, val); cmp_int(dst, src, tmp); slot_freetmp(tmp); }}voidcmp_int(SlotInfo* dst, SlotInfo* src, SlotInfo* src2){ slot_slot_slot(dst, src, src2, HAVE_cmp_int, Tcomplex);}#endif#if defined(HAVE_cmp_ref)voidcmp_ref_const(SlotInfo* dst, SlotInfo* src, void* val){#if defined(HAVE_cmp_ref_const) if (HAVE_cmp_ref_const_rangecheck((jword)val)) { slot_slot_const(dst, src, (jword)val, HAVE_cmp_ref_const, Tcomplex); } else#endif { SlotInfo* tmp; slot_alloctmp(tmp); move_ref_const(tmp, val); cmp_ref(dst, src, tmp); slot_freetmp(tmp); }}voidcmp_ref(SlotInfo* dst, SlotInfo* src, SlotInfo* src2){ slot_slot_slot(dst, src, src2, HAVE_cmp_ref, Tcomplex);}#endifvoidlcmp(SlotInfo* dst, SlotInfo* src, SlotInfo* src2){#if defined(HAVE_lcmp) slot_lslot_lslot(dst, src, src2, HAVE_lcmp, Tcomplex);#else end_sub_block(); pusharg_long(src2, pusharg_long_idx_inc); pusharg_long(src, 0); call_soft(soft_lcmp); popargs(); start_sub_block(); return_int(dst);#endif}voidcmpl_float(SlotInfo* dst, SlotInfo* src, SlotInfo* src2){#if defined(HAVE_cmpl_float) slot_slot_slot(dst, src, src2, HAVE_cmpl_float, Tcomplex);#else end_sub_block(); pusharg_float(src2, 1); pusharg_float(src, 0); call_soft(soft_fcmpl); popargs(); start_sub_block(); return_int(dst);#endif}voidcmpl_double(SlotInfo* dst, SlotInfo* src, SlotInfo* src2){#if defined(HAVE_cmpl_double) slot_lslot_lslot(dst, src, src2, HAVE_cmpl_double, Tcomplex);#else end_sub_block(); pusharg_double(src2, pusharg_long_idx_inc); pusharg_double(src, 0); call_soft(soft_dcmpl); popargs(); start_sub_block(); return_int(dst);#endif}voidcmpg_float(SlotInfo* dst, SlotInfo* src, SlotInfo* src2){#if defined(HAVE_cmpg_float) slot_slot_slot(dst, src, src2, HAVE_cmpg_float, Tcomplex);#else end_sub_block(); pusharg_float(src2, 1); pusharg_float(src, 0); call_soft(soft_fcmpg); popargs(); start_sub_block(); return_int(dst);#endif}voidcmpg_double(SlotInfo* dst, SlotInfo* src, SlotInfo* src2){#if defined(HAVE_cmpg_double) slot_lslot_lslot(dst, src, src2, HAVE_cmpg_double, Tcomplex);#else end_sub_block(); pusharg_double(src2, pusharg_long_idx_inc); pusharg_double(src, 0); call_soft(soft_dcmpg); popargs(); start_sub_block(); return_int(dst);#endif}/* ----------------------------------------------------------------------- *//* Conversions. *//* */voidcvt_int_long(SlotInfo* dst, SlotInfo* src){#if defined(HAVE_cvt_int_long) lslot_lslot_slot(dst, 0, src, HAVE_cvt_int_long, Tcomplex);#else move_int(LSLOT(dst), src); ashr_int_const(HSLOT(dst), src, (8 * sizeof(jint)) - 1);#endif}voidcvt_int_float(SlotInfo* dst, SlotInfo* src){#if defined(HAVE_cvt_int_float) slot_slot_slot(dst, 0, src, HAVE_cvt_int_float, Tcomplex);#else end_sub_block(); pusharg_int(src, 0); call_soft(soft_cvtif); popargs(); start_sub_block(); return_float(dst);#endif}voidcvt_int_double(SlotInfo* dst, SlotInfo* src){#if defined(HAVE_cvt_int_double) lslot_lslot_slot(dst, 0, src, HAVE_cvt_int_double, Tcomplex);#else end_sub_block(); pusharg_int(src, 0); call_soft(soft_cvtid); popargs(); start_sub_block(); return_double(dst);#endif}voidcvt_long_int(SlotInfo* dst, SlotInfo* src){ move_int(dst, LSLOT(src));}voidcvt_long_float(SlotInfo* dst, SlotInfo* src){#if defined(HAVE_cvt_long_float) slot_slot_lslot(dst, 0, src, HAVE_cvt_long_float, Tcomplex);#else end_sub_block(); pusharg_long(src, 0); call_soft(soft_cvtlf); popargs(); start_sub_block(); return_float(dst);#endif}voidcvt_long_double(SlotInfo* dst, SlotInfo* src){#if defined(HAVE_cvt_long_double) lslot_lslot_lslot(dst, 0, src, HAVE_cvt_long_double, Tcomplex);#else end_sub_block(); pusharg_long(src, 0); call_soft(soft_cvtld); popargs(); start_sub_block(); return_double(dst);#endif}voidcvt_float_int(SlotInfo* dst, SlotInfo* src){ used_ieee_rounding = true;#if defined(HAVE_cvt_float_int) slot_slot_slot(dst, 0, src, HAVE_cvt_float_int, Tcomplex);#else end_sub_block(); pusharg_float(src, 0); call_soft(soft_cvtfi); popargs(); start_sub_block(); return_int(dst);#endif}voidcvt_float_long(SlotInfo* dst, SlotInfo* src){ used_ieee_rounding = true;#if defined(HAVE_cvt_float_long) lslot_lslot_slot(dst, 0, src, HAVE_cvt_float_long, Tcomplex);#else end_sub_block(); pusharg_float(src, 0); call_soft(soft_cvtfl); popargs(); start_sub_block(); return_long(dst);#endif}voidcvt_float_double(SlotInfo* dst, SlotInfo* src){#if defined(HAVE_cvt_float_double) lslot_lslot_slot(dst, 0, src, HAVE_cvt_float_double, Tcomplex);#else end_sub_block(); pusharg_float(src, 0); call_soft(soft_cvtfd); popargs(); start_sub_block(); return_double(dst);#endif}voidcvt_double_int(SlotInfo* dst, SlotInfo* src){ used_ieee_rounding = true;#if defined(HAVE_cvt_double_int) slot_slot_lslot(dst, 0, src, HAVE_cvt_double_int, Tcomplex);#else end_sub_block(); pusharg_double(src, 0); call_soft(soft_cvtdi); popargs(); start_sub_block(); return_int(dst);#endif}voidcvt_double_long(SlotInfo* dst, SlotInfo* src){ used_ieee_rounding = true;#if defined(HAVE_cvt_double_long) lslot_lslot_lslot(dst, 0, src, HAVE_cvt_double_long, Tcomplex);#else end_sub_block(); pusharg_double(src, 0); call_soft(soft_cvtdl); popargs(); start_sub_block(); return_long(dst);#endif}voidcvt_double_float(SlotInfo* dst, SlotInfo* src){#if defined(HAVE_cvt_double_float) slot_slot_lslot(dst, 0, src, HAVE_cvt_double_float, Tcomplex);#else end_sub_block(); pusharg_double(src, 0); call_soft(soft_cvtdf); popargs(); start_sub_block(); return_float(dst);#endif}voidcvt_int_byte(SlotInfo* dst, SlotInfo* src){#if defined(HAVE_cvt_int_byte) slot_slot_slot(dst, 0, src, HAVE_cvt_int_byte, Tcomplex);#else lshl_int_const(dst, src, 8 * (sizeof(jint) - sizeof(jbyte))); ashr_int_const(dst, dst, 8 * (sizeof(jint) - sizeof(jbyte)));#endif}voidcvt_int_char(SlotInfo* dst, SlotInfo* src){ and_int_const(dst, src, (1 << (8 * sizeof(jchar))) - 1);}voidcvt_int_short(SlotInfo* dst, SlotInfo* src){#if defined(HAVE_cvt_int_short) slot_slot_slot(dst, 0, src, HAVE_cvt_int_short, Tcomplex);#else lshl_int_const(dst, src, 8 * (sizeof(jint) - sizeof(jshort))); ashr_int_const(dst, dst, 8 * (sizeof(jint) - sizeof(jshort)));#endif}/* ----------------------------------------------------------------------- *//* Breakpoints. *//* */voidsoftcall_breakpoint(){ ABORT();}/* ----------------------------------------------------------------------- *//* Build call frame. *//* */voidbuild_call_frame(Utf8Const* sig, SlotInfo* obj, int sp_idx){ struct pusharg_info { char type; uint16 arg_idx; uint16 sp_idx; }; static struct pusharg_info* args; static int sz_args = 0; int arg_idx; int idx; const char* sigptr; /* Make sure we have enough argument space */ if (sp_idx + 1 > sz_args) { /* add differential */ addToCounter(&jitmem, "jitmem-temp", 1, (sp_idx + 1 - sz_args) * sizeof(struct pusharg_info)); sz_args = sp_idx + 1; args = KREALLOC(args, sizeof(struct pusharg_info) * sz_args); } /* If we've got an object ... */ idx = 0; if (obj != 0) { args[idx].type = 'O'; args[idx].arg_idx = idx; args[idx].sp_idx = sp_idx; idx++; } sp_idx--; arg_idx = idx; sigptr = sig->data; assert(sigptr[0] == '('); for (sigptr++; *sigptr != ')'; sigptr++) { args[idx].arg_idx = arg_idx; args[idx].sp_idx = sp_idx; args[idx].type = *sigptr; switch (*sigptr) { case '[': while (*++sigptr == '[') ; if (*sigptr == 'L') { sigptr = strchr(sigptr, ';'); } break; case 'L': sigptr = strchr(sigptr, ';'); break; case 'I': case 'Z': case 'S': case 'B': case 'C': case 'F': break; case 'J': case 'D': sp_idx--; args[idx].sp_idx = sp_idx; arg_idx += pusharg_long_idx_inc - 1; break; case 'V': default: ABORT(); } sp_idx--; arg_idx++; idx++; } for (idx--; idx >= 0; idx--) { sp_idx = args[idx].sp_idx; arg_idx = args[idx].arg_idx; switch (args[idx].type) { case 'L': case '[': pusharg_ref(stack(sp_idx), arg_idx); break; case 'O': /* Special: object we've invoking on */ pusharg_ref(obj, arg_idx); break; case 'I': case 'Z': case 'S': case 'B': case 'C': { pusharg_int(stack(sp_idx), arg_idx); } break; case 'J': pusharg_long(stack_long(sp_idx), arg_idx); break; case 'F': pusharg_float(stack_float(sp_idx), arg_idx); break; case 'D': pusharg_double(stack_double(sp_idx), arg_idx); break; } }}/* ----------------------------------------------------------------------- *//* Soft calls. *//* */voidsoftcall_lookupinterfacemethod(SlotInfo* dst, Method* meth, SlotInfo* obj){ /* 'obj' must be written back since it will be reused */ prepare_function_call(); /* FIXME: should there be a pusharg_int_const? */ pusharg_ref_const((void*)(int)meth->idx, 2); pusharg_class_const(meth->class, 1); pusharg_ref(obj, 0); call_soft(soft_lookupinterfacemethod); popargs(); fixup_function_call(); return_ref(dst);}voidcheck_array_index(SlotInfo* obj, SlotInfo* idx){ SlotInfo* tmp; slot_alloctmp(tmp); load_offset_int(tmp, obj, object_array_length);#if defined(HAVE_ccall_ugt) ccall_int_ugt(tmp, idx, soft_badarrayindex);#else end_sub_block(); cbranch_int_ult(idx, tmp, reference_label(1, 1)); call_soft(soft_badarrayindex); start_sub_block(); set_label(1, 1);#endif slot_freetmp(tmp);}voidcheck_array_constindex(SlotInfo* obj, jint idx){ SlotInfo* tmp; slot_alloctmp(tmp); load_offset_int(tmp, obj, object_array_length);#if defined(HAVE_ccall_ugt) ccall_int_const_ugt(tmp, idx, soft_badarrayindex);#else end_sub_block(); cbranch_int_const_ugt(tmp, idx, reference_label(1, 1)); call_soft(soft_badarrayindex); start_sub_block(); set_label(1, 1);#endif slot_freetmp(tmp);}#if defined(HAVE_ccall_ugt)voidccall_ugt(void* func){ slot_const_const(0, 0, (jword)func, HAVE_ccall_ugt, Tnull);}voidccall_int_ugt(SlotInfo* s1, SlotInfo* s2, void* func){ cmp_int(0, s1, s2); ccall_ugt(func);}voidccall_int_const_ugt(SlotInfo* s1, jint s2, void* func){ cmp_int_const(0, s1, s2); ccall_ugt(func);}#endifvoidsoftcall_nullpointer(void){ sync_registers(); call_soft(soft_nullpointer);}voidsoftcall_nosuchclass(Utf8Const* name){ sync_registers(); prepare_function_call(); pusharg_utf8_const(name, 0); call_soft(soft_nosuchclass); popargs(); fixup_function_call();}voidsoftcall_nosuchmethod(Hjava_lang_Class* cls, Utf8Const* name, Utf8Const* sig){ sync_registers(); prepare_function_call(); pusharg_utf8_const(sig, 0); pusharg_utf8_const(name, 0); pusharg_class_const(cls, 0); call_soft(soft_nosuchmethod); popargs(); fixup_function_call();}voidsoftcall_nosuchfield(Utf8Const* cls, Utf8Const* name){ sync_registers(); prepare_function_call(); pusharg_utf8_const(name, 1); pusharg_utf8_const(cls, 0); call_soft(soft_nosuchfield); popargs(); fixup_function_call();}voidsoftcall_new(SlotInfo* dst, Hjava_lang_Class* classobj){ prepare_function_call();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -