⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 icode.c

📁 linux下建立JAVA虚拟机的源码KAFFE
💻 C
📖 第 1 页 / 共 5 页
字号:
}#endif#if defined(HAVE_returnarg_float)voidreturnarg_float(SlotInfo* src){	slot_slot_slot(NULL, NULL, src, HAVE_returnarg_float, Tcopy);}#endif#if defined(HAVE_returnarg_double)voidreturnarg_double(SlotInfo* src){	lslot_lslot_lslot(NULL, NULL, src, HAVE_returnarg_double, Tcopy);}#endif/* ----------------------------------------------------------------------- *//* Labels.								   *//*									   */label*reference_label(int32 i UNUSED, int32 n){	label* l;	assert(n < MAXLABTAB);	if (labtab[n] == 0) {		l = KaffeJIT_newLabel();		labtab[n] = l;		l->type = Lnull;		l->at = 0;		l->from = 0;		l->to = 0;	}	else {		l = labtab[n];		labtab[n] = NULL;	}	return (l);}label*reference_code_label(uintp offset){	label* l = KaffeJIT_newLabel();	l->at = 0;		/* Where is the jump */	l->to = offset;		/* What place does it goto */	l->from = 0;	l->type = Lcode;	return (l);}label*reference_table_label(int32 n){	label* l;	assert(n < MAXLABTAB);	if (labtab[n] == 0) {		l = KaffeJIT_newLabel();		labtab[n] = l;		l->type = Lnull;		l->at = 0;		l->from = 0;		l->to = 0;	}	else {		l = labtab[n];		labtab[n] = NULL;	}	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 UNUSED, int n){	assert(n < MAXLABTAB);	if (labtab[n] == 0) {		labtab[n] = KaffeJIT_newLabel();		labtab[n]->type = Linternal;		labtab[n]->at = 0;		labtab[n]->from = 0;		labtab[n]->to = 0;		slot_slot_const(NULL, NULL, (jword)labtab[n], HAVE_set_label, Tnull);	}	else {		assert(labtab[n]->type == Lnull);		labtab[n]->type = Linternal;		slot_slot_const(NULL, NULL, (jword)labtab[n], HAVE_set_label, Tnull);		labtab[n] = NULL;	}}#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(NULL, NULL, (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(NULL, NULL, 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, NULL, 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, NULL, 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, NULL, 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, NULL, 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);#elif defined(HAVE_cvt_float_int_ieee)	{	  SlotInfo *tmp;	  	  slot_alloctmp(tmp);	  end_sub_block();	  and_int_const(tmp, src, FEXPMASK);	  cbranch_int_const_ne(tmp, FEXPMASK, reference_label(1, 1));	  	  and_int_const(tmp, src, FMANMASK);	  cbranch_int_const_eq(tmp, 0, reference_label(1, 2));          start_sub_block();	  move_int_const(dst, 0);	  end_sub_block();	  branch_a(reference_label(1, 3));	  set_label(1, 1);	  set_label(1, 2);	  start_sub_block();	  slot_slot_lslot(dst, 0, src, HAVE_cvt_float_int_ieee, Tcomplex);	  end_sub_block();	  set_label(1, 3);	  start_sub_block();	  slot_freetmp(tmp);	}#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, NULL, 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, NULL, src, HAVE_cvt_double_int, Tcomplex);#elif defined(HAVE_cvt_double_int_ieee)	{	  SlotInfo *tmp;	  	  end_sub_block();	  slot_alloc2tmp(tmp);	  and_long_const(tmp, src, DEXPMASK);	  cbranch_int_const_ne(LSLOT(tmp), (jint)(DEXPMASK & 0xffffffff), reference_label(1, 1));	  cbranch_int_const_ne(HSLOT(tmp), (jint)((DEXPMASK >> 32) & 0xffffffff), reference_label(1, 2));	  	  and_long_const(tmp, src, DMANMASK);	  cbranch_int_const_ne(LSLOT(tmp), 0, reference_label(1, 3));	  cbranch_int_const_eq(HSLOT(tmp), 0, reference_label(1, 4));	  set_label(1, 3);	  start_sub_block();	  move_int_const(dst, 0);	  end_sub_block();	  branch_a(reference_label(1, 5));	  set_label(1, 4);	  set_label(1, 1);	  set_label(1, 2);	  start_sub_block();	  slot_slot_lslot(dst, 0, src, HAVE_cvt_double_int_ieee, Tcomplex);	  end_sub_block();	  set_label(1, 5);	  slot_free2tmp(tmp);	  start_sub_block();	}#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, NULL, 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(){	KAFFEVM_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:			KAFFEVM_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.								   *//*									   */voi

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -