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

📄 soft.c

📁 kaffe Java 解释器语言,源码,Java的子集系统,开放源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
}/* * soft_initialise_class. */voidsoft_initialise_class(Hjava_lang_Class* c){	/* We check this outside the processClass to save a subroutine call */	if (c->state != CSTATE_COMPLETE) {		errorInfo info;		if (processClass(c, CSTATE_COMPLETE, &info) == false) {			throwError(&info);		}	}}#if defined(TRANSLATOR)/* * Trampolines come in here - do the translation and replace the trampoline. */nativecode*soft_fixup_trampoline(FIXUP_TRAMPOLINE_DECL){	Method* meth;	void **where;	void *tramp;	errorInfo info;	/* FIXUP_TRAMPOLINE_INIT sets tramp and where */	FIXUP_TRAMPOLINE_INIT;	tramp = *where;DBG(MOREJIT,	dprintf("soft_fixup_trampoline(): meth %p, where %p\n",		meth, where);    );	/* If this class needs initializing, do it now.  */	if (meth->class->state < CSTATE_USABLE &&		processClass(meth->class, CSTATE_COMPLETE, &info) == false) {		throwError(&info);	}	/* Generate code on demand.  */	if (!METHOD_TRANSLATED(meth)) {		if (translate(meth, &info) == false) {			throwError(&info);		}	}	/*	 * Update the origin of the trampoline and free it if necessary. 	 * Another thread might have jumped through the same trampoline	 * while we were translating the method, so we have to make this	 * atomic.	 */#if defined(COMPARE_AND_EXCHANGE)	if (COMPARE_AND_EXCHANGE(where, tramp, METHOD_NATIVECODE(meth))) {		gc_free(tramp);	}#elif defined(ATOMIC_EXCHANGE)	{		void *tmp = METHOD_NATIVECODE(meth); 		ATOMIC_EXCHANGE(where, tmp);		if (tmp == tramp) {			gc_free(tramp);		}	}#else#error "You have to define either COMPARE_AND_EXCHANGE or ATOMIC_EXCHANGE"#endif#if 0	if (METHOD_PRE_COMPILED(meth)) {		nativecode* ncode = METHOD_TRUE_NCODE(meth);		nativecode* ocode = METHOD_NATIVECODE(meth);		METHOD_NATIVECODE(meth) = ncode;		/* Update the dtable entries for all classes if this isn't a	   	   static method.  */		if (meth->idx >= 0 && ocode != ncode) {			meth->class->dtable->method[meth->idx] = ncode;		}		SET_METHOD_PRE_COMPILED(meth, 0);	}#endifTDBG(	dprintf("Calling %s:%s%s @ %p\n", meth->class->name->data, meth->name->data, METHOD_SIGD(meth), METHOD_NATIVECODE(meth));	)DBG(MOREJIT,	dprintf("soft_fixup_trampoline(): return %p\n",		METHOD_NATIVECODE(meth));    );	return (METHOD_NATIVECODE(meth));}#endif/* * Check we can store 'obj' into the 'array'. */voidsoft_checkarraystore(Hjava_lang_Object* array, Hjava_lang_Object* obj){	if (obj != 0 && soft_instanceof(CLASS_ELEMENT_TYPE(OBJECT_CLASS(array)), obj) == 0) {		throwException(ArrayStoreException);	}}/* * soft_dcmpg */jintsoft_dcmpg(jdouble v1, jdouble v2){	jint ret;	if ((!isinf(v1) && isnan(v1)) || (!isinf(v2) && isnan(v2))) {		ret = 1;	}	else if (v1 > v2) {		ret = 1;	}	else if (v1 == v2) {		ret = 0;	}	else {		ret = -1;	}	return (ret);}/* * soft_dcmpl */jintsoft_dcmpl(jdouble v1, jdouble v2){        jint ret;	if ((!isinf(v1) && isnan(v1)) || (!isinf(v2) && isnan(v2))) {		ret = -1;	}        else if (v1 > v2) {                ret = 1;        }        else if (v1 == v2) {                ret = 0;        }        else {                ret = -1;        }	return (ret);}/* * soft_fcmpg */jintsoft_fcmpg(jfloat v1, jfloat v2){        jint ret;	jint v1bits;	jint v2bits;	v1bits = floatToInt(v1);	v2bits = floatToInt(v2);        if (FISNAN(v1bits) || FISNAN(v2bits)) {		ret = 1;	}        else if (v1 > v2) {                ret = 1;        }        else if (v1 == v2) {                ret = 0;        }        else {                ret = -1;        }	return (ret);}/* * soft_fcmpg */jintsoft_fcmpl(jfloat v1, jfloat v2){        jint ret;	jint v1bits;	jint v2bits;	v1bits = floatToInt(v1);	v2bits = floatToInt(v2);        if (FISNAN(v1bits) || FISNAN(v2bits)) {		ret = -1;	}        else if (v1 > v2) {                ret = 1;        }        else if (v1 == v2) {                ret = 0;        }        else {                ret = -1;        }	return (ret);}jlongsoft_lmul(jlong v1, jlong v2){	return (v1 * v2);}jlongsoft_ldiv(jlong v1, jlong v2){	return (v1 / v2);}jlongsoft_lrem(jlong v1, jlong v2){	return (v1 % v2);}jfloatsoft_fadd(jfloat v1, jfloat v2){	return floatAdd(v1, v2);}jdoublesoft_faddl(jdouble v1, jdouble v2){	return doubleAdd(v1, v2);}jfloatsoft_fsub(jfloat v1, jfloat v2){	return floatSubtract(v1, v2);}jdoublesoft_fsubl(jdouble v1, jdouble v2){	return doubleSubtract(v1, v2);}jfloatsoft_fmul(jfloat v1, jfloat v2){	return floatMultiply(v1, v2);}jdoublesoft_fmull(jdouble v1, jdouble v2){	return doubleMultiply(v1, v2);}jfloatsoft_fdiv(jfloat v1, jfloat v2){	return floatDivide(v1, v2);}jdoublesoft_fdivl(jdouble v1, jdouble v2){	return doubleDivide(v1, v2);}jfloatsoft_frem(jfloat v1, jfloat v2){	return (javaRemainderf(v1, v2));}jdoublesoft_freml(jdouble v1, jdouble v2){	return (javaRemainder(v1, v2));}jlongsoft_lshll(jlong v1, jint v2){	return (v1 << (v2 & 63));}jlongsoft_ashrl(jlong v1, jint v2){	return (v1 >> (v2 & 63));}jlongsoft_lshrl(jlong v1, jint v2){	return (((uint64)v1) >> (v2 & 63));}jintsoft_lcmp(jlong v1, jlong v2){#if 0	jlong lcc = v2 - v1;	if (lcc < 0) {		return (-1);	}	else if (lcc > 0) {		return (1);	}	else {		return (0);	}#endif	if (v2 < v1) {		return (-1);	}	else if (v2 > v1) {		return (1);	}	else {		return (0);	}}jintsoft_mul(jint v1, jint v2){	return (v1*v2);}jintsoft_div(jint v1, jint v2){	return (v1/v2);}jintsoft_rem(jint v1, jint v2){	return (v1%v2);}jfloatsoft_cvtlf(jlong v){	return ((jfloat)v);}jfloatsoft_cvtif(jint v){	return ((jfloat)v);}jdoublesoft_cvtid(jint v){	return ((jdouble)v);}jdoublesoft_cvtld(jlong v){	return ((jdouble)v);}jdoublesoft_cvtfd(jfloat v){	jint vbits;	vbits = floatToInt(v);        if (FISNAN(vbits)) {		return (longToDouble(DNANBITS));	}	else {		return ((jdouble)v);	}}jfloatsoft_cvtdf(jdouble v){	jlong vbits;	vbits = doubleToLong(v);        if (DISNAN(vbits)) {		return (intToFloat(FNANBITS));	}	else {		return ((jfloat)v);	}}/* * The following functions round the float/double to an int/long. * They round the value toward zero. */jlongsoft_cvtfl(jfloat v){	jint vbits;	vbits = floatToInt(v);        if (FISNAN(vbits)) {		return ((jlong)0);	}	if (v < 0.0) {		v = ceil(v);	}	else {		v = floor(v);	}	/* If too small return smallest long */	if (v <= -9223372036854775808.0) {	    return ((jlong)1) << 63;	}	/* If too big return biggest long */	else if (v >= 9223372036854775807.0) {	    return ~(((jlong)1) << 63);	}	else {	    return ((jlong)v);	}}jlongsoft_cvtdl(jdouble v){	jlong vbits;	vbits = doubleToLong(v);        if (DISNAN(vbits)) {		return ((jlong)0);	}	if (v < 0.0) {		v = ceil(v);	}	else {		v = floor(v);	}	/* If too small return smallest long */	if (v <= -9223372036854775808.0) {	    return ((jlong)1) << 63;	}	/* If too big return biggest long */	else if (v >= 9223372036854775807.0) {	    return ~(((jlong)1) << 63);	}	else {	    return ((jlong)v);	}}jintsoft_cvtfi(jfloat v){        jint vbits;	vbits = floatToInt(v);        if (FISNAN(vbits)) {		return (0);	}	if (v < 0.0) {		v = ceil(v);	}	else {		v = floor(v);	}	/* If too small return smallest int */	if (v <= -2147483648.0) {		return (-2147483647-1);	}	/* If too big return biggest int */	else if (v >= 2147483647.0) {		return (2147483647);	}	else {		return ((jint)v);	}}jintsoft_cvtdi(jdouble v){        jlong vbits;	vbits = doubleToLong(v);        if (DISNAN(vbits)) {		return (0);	}	if (v < 0.0) {		v = ceil(v);	}	else {		v = floor(v);	}	/* If too small return smallest int */	if (v <= -2147483648.0) {		return (-2147483647-1);	}	/* If too big return biggest int */	else if (v >= 2147483647.0) {		return (2147483647);	}	else {		return ((jint)v);	}}voidsoft_debug1(void* a0, void* a1, void* a2){}voidsoft_debug2(void* a0, void* a1, void* a2){}voidsoft_trace(Method* meth, void* args){    dprintf("soft_trace: %s.%s%s\n", CLASS_CNAME(meth->class), meth->name->data, METHOD_SIGD(meth));}voidsoft_enter_method(Hjava_lang_Object *obj, Method *meth){#if defined(ENABLE_JVMPI)	if( JVMPI_EVENT_ISENABLED(JVMPI_EVENT_METHOD_ENTRY) )	{		JVMPI_Event ev;		ev.event_type = JVMPI_EVENT_METHOD_ENTRY;		ev.u.method.method_id = meth;		jvmpiPostEvent(&ev);	}	if( JVMPI_EVENT_ISENABLED(JVMPI_EVENT_METHOD_ENTRY2) )	{		JVMPI_Event ev;		ev.event_type = JVMPI_EVENT_METHOD_ENTRY2;		ev.u.method_entry2.method_id = meth;		ev.u.method_entry2.obj_id = obj;		jvmpiPostEvent(&ev);	}#endif}voidsoft_exit_method(Method *meth){#if defined(ENABLE_JVMPI)	if( JVMPI_EVENT_ISENABLED(JVMPI_EVENT_METHOD_EXIT) )	{		JVMPI_Event ev;		ev.event_type = JVMPI_EVENT_METHOD_EXIT;		ev.u.method.method_id = meth;		jvmpiPostEvent(&ev);	}#endif}

⌨️ 快捷键说明

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