Index: vm/include/open/rt_helpers.h =================================================================== --- vm/include/open/rt_helpers.h (revision 636754) +++ vm/include/open/rt_helpers.h (working copy) @@ -601,9 +601,6 @@ // Conversions - VM_RT_LSHL=910, - VM_RT_LSHR=911, - VM_RT_LUSHR=912, /** * @param The parameters are the following: * (new version) @@ -616,26 +613,9 @@ */ - VM_RT_LMUL=920, -#ifdef VM_LONG_OPT - VM_RT_LMUL_CONST_MULTIPLIER=921, -#endif - VM_RT_LREM=922, - VM_RT_LDIV=923, - VM_RT_ULDIV=924, - VM_RT_CONST_LDIV=925, - VM_RT_CONST_LREM=926, - // Long arithmetic - VM_RT_IMUL=930, - VM_RT_IREM=931, - VM_RT_IDIV=932, - // Int arithmetic - VM_RT_FREM=940, - VM_RT_FDIV=941, VM_RT_DREM=942, - VM_RT_DDIV=943, // Float/double arithmetic VM_RT_CHAR_ARRAYCOPY_NO_EXC=950, @@ -677,17 +657,6 @@ VM_RT_NEW_VECTOR=1001, /** * @param The parameters are the following: - * arg\ Vector length - * arg\ Class handle of the vector class - * - * @return Reference to the new object - * - * Create a vector (zero-based, one dimensional array) - * of the given type. See also VM_RT_NEW_VECTOR_USING_VTABLE. - */ - VM_RT_WRITE_BARRIER_FASTCALL=1002 -/** - * @param The parameters are the following: * arg\ Address of a memory location being written to * arg\ Object reference being written. * Index: vm/vmcore/src/jit/rt_helper_info.cpp =================================================================== --- vm/vmcore/src/jit/rt_helper_info.cpp (revision 636754) +++ vm/vmcore/src/jit/rt_helper_info.cpp (working copy) @@ -208,67 +208,16 @@ {VM_RT_D2L, "VM_RT_D2L", INTERRUPTIBLE_NEVER, CALLING_CONVENTION_STDCALL, 1, NULL, NULL, NULL, NULL}, - {VM_RT_LSHL, "VM_RT_LSHL", - INTERRUPTIBLE_NEVER, CALLING_CONVENTION_STDCALL, 2, - NULL, NULL, NULL, NULL}, - {VM_RT_LSHR, "VM_RT_LSHR", - INTERRUPTIBLE_NEVER, CALLING_CONVENTION_STDCALL, 2, - NULL, NULL, NULL, NULL}, - {VM_RT_LUSHR, "VM_RT_LUSHR", - INTERRUPTIBLE_NEVER, CALLING_CONVENTION_STDCALL, 2, - NULL, NULL, NULL, NULL}, - {VM_RT_LMUL, "VM_RT_LMUL", - INTERRUPTIBLE_NEVER, CALLING_CONVENTION_STDCALL, 2, - NULL, NULL, NULL, NULL}, -#ifdef VM_LONG_OPT - {VM_RT_LMUL_CONST_MULTIPLIER, "VM_RT_LMUL_CONST_MULTIPLIER", - INTERRUPTIBLE_NEVER, CALLING_CONVENTION_STDCALL, 2, - NULL, NULL, NULL, NULL}, -#endif // VM_LONG_OPT - {VM_RT_LREM, "VM_RT_LREM", - INTERRUPTIBLE_NEVER, CALLING_CONVENTION_STDCALL, 2, - NULL, NULL, NULL, NULL}, - {VM_RT_LDIV, "VM_RT_LDIV", - INTERRUPTIBLE_NEVER, CALLING_CONVENTION_STDCALL, 2, - NULL, NULL, NULL, NULL}, - {VM_RT_ULDIV, "VM_RT_ULDIV", - INTERRUPTIBLE_NEVER, CALLING_CONVENTION_STDCALL, 2, - NULL, NULL, NULL, NULL}, - {VM_RT_CONST_LDIV, "VM_RT_CONST_LDIV", - INTERRUPTIBLE_NEVER, CALLING_CONVENTION_STDCALL, 2, - NULL, NULL, NULL, NULL}, - {VM_RT_CONST_LREM, "VM_RT_CONST_LREM", - INTERRUPTIBLE_NEVER, CALLING_CONVENTION_STDCALL, 2, - NULL, NULL, NULL, NULL}, - {VM_RT_IMUL, "VM_RT_IMUL", - INTERRUPTIBLE_NEVER, CALLING_CONVENTION_STDCALL, 2, - NULL, NULL, NULL, NULL}, - {VM_RT_IREM, "VM_RT_IREM", - INTERRUPTIBLE_NEVER, CALLING_CONVENTION_STDCALL, 2, - NULL, NULL, NULL, NULL}, - {VM_RT_IDIV, "VM_RT_IDIV", - INTERRUPTIBLE_NEVER, CALLING_CONVENTION_STDCALL, 2, - NULL, NULL, NULL, NULL}, {VM_RT_FREM, "VM_RT_FREM", INTERRUPTIBLE_NEVER, CALLING_CONVENTION_STDCALL, 2, NULL, NULL, NULL, NULL}, - {VM_RT_FDIV, "VM_RT_FDIV", - INTERRUPTIBLE_NEVER, CALLING_CONVENTION_STDCALL, 2, - NULL, NULL, NULL, NULL}, {VM_RT_DREM, "VM_RT_DREM", INTERRUPTIBLE_NEVER, CALLING_CONVENTION_STDCALL, 2, NULL, NULL, NULL, NULL}, - {VM_RT_DDIV, "VM_RT_DDIV", - INTERRUPTIBLE_NEVER, CALLING_CONVENTION_STDCALL, 2, - NULL, NULL, NULL, NULL}, {VM_RT_CHAR_ARRAYCOPY_NO_EXC, "VM_RT_CHAR_ARRAYCOPY_NO_EXC", INTERRUPTIBLE_ALWAYS, CALLING_CONVENTION_STDCALL, 5, NULL, NULL, NULL, NULL}, - - {VM_RT_WRITE_BARRIER_FASTCALL, "VM_RT_WRITE_BARRIER_FASTCALL", - INTERRUPTIBLE_ALWAYS, CALLING_CONVENTION_STDCALL, 2, - NULL, NULL, NULL, NULL} }; static JIT_RT_Function_Entry *jit_rt_function_entries = &(_jit_rt_function_entries_base[0]); Index: vm/vmcore/src/jit/jit_runtime_support.cpp =================================================================== --- vm/vmcore/src/jit/jit_runtime_support.cpp (revision 636754) +++ vm/vmcore/src/jit/jit_runtime_support.cpp (working copy) @@ -992,421 +992,6 @@ return addr; } -static int64 lshl(int64 v, int32 c) -{ - return v<<(c&0x3f); -} - -static NativeCodePtr rth_get_lil_lshl(int* dyn_count) -{ - static NativeCodePtr addr = NULL; - - if (!addr) { - int64 (*p_lshl)(int64, int32) = lshl; - LilCodeStub* cs = lil_parse_code_stub("entry 0:stdcall:g8,g4:g8;"); - assert(cs); - if (dyn_count) { - cs = lil_parse_onto_end(cs, "inc [%0i:pint];", dyn_count); - assert(cs); - } - cs = lil_parse_onto_end(cs, - "in2out platform:g8;" - "call %0i;" - "ret;", - p_lshl); - assert(cs && lil_is_valid(cs)); - addr = LilCodeGenerator::get_platform()->compile(cs); - - DUMP_STUB(addr, "rth_lshl", lil_cs_get_code_size(cs)); - - lil_free_code_stub(cs); - } - - return addr; -} - -static int64 lshr(int64 v, int32 c) -{ - return v>>(c&0x3f); -} - -static NativeCodePtr rth_get_lil_lshr(int* dyn_count) -{ - static NativeCodePtr addr = NULL; - - if (!addr) { - int64 (*p_lshr)(int64, int32) = lshr; - LilCodeStub* cs = lil_parse_code_stub("entry 0:stdcall:g8,g4:g8;"); - assert(cs); - if (dyn_count) { - cs = lil_parse_onto_end(cs, "inc [%0i:pint];", dyn_count); - assert(cs); - } - cs = lil_parse_onto_end(cs, - "in2out platform:g8;" - "call %0i;" - "ret;", - p_lshr); - assert(cs && lil_is_valid(cs)); - addr = LilCodeGenerator::get_platform()->compile(cs); - - DUMP_STUB(addr, "rth_lshr", lil_cs_get_code_size(cs)); - - lil_free_code_stub(cs); - } - - return addr; -} - -static uint64 lushr(uint64 v, uint32 c) -{ - return v>>(c&0x3f); -} - -static NativeCodePtr rth_get_lil_lushr(int* dyn_count) -{ - static NativeCodePtr addr = NULL; - - if (!addr) { - uint64 (*p_lushr)(uint64, uint32) = lushr; - LilCodeStub* cs = lil_parse_code_stub("entry 0:stdcall:g8,g4:g8;"); - assert(cs); - if (dyn_count) { - cs = lil_parse_onto_end(cs, "inc [%0i:pint];", dyn_count); - assert(cs); - } - cs = lil_parse_onto_end(cs, - "in2out platform:g8;" - "call %0i;" - "ret;", - p_lushr); - assert(cs && lil_is_valid(cs)); - addr = LilCodeGenerator::get_platform()->compile(cs); - - DUMP_STUB(addr, "rth_lushr", lil_cs_get_code_size(cs)); - - lil_free_code_stub(cs); - } - - return addr; -} - -static int64 lmul(int64 m, int64 n) -{ - return m*n; -} - -static NativeCodePtr rth_get_lil_lmul(int* dyn_count) -{ - static NativeCodePtr addr = NULL; - - if (!addr) { - int64 (*p_lmul)(int64, int64) = lmul; - LilCodeStub* cs = lil_parse_code_stub("entry 0:stdcall:g8,g8:g8;"); - assert(cs); - if (dyn_count) { - cs = lil_parse_onto_end(cs, "inc [%0i:pint];", dyn_count); - assert(cs); - } - cs = lil_parse_onto_end(cs, - "in2out platform:g8;" - "call %0i;" - "ret;", - p_lmul); - assert(cs && lil_is_valid(cs)); - addr = LilCodeGenerator::get_platform()->compile(cs); - - DUMP_STUB(addr, "rth_lmul", lil_cs_get_code_size(cs)); - - lil_free_code_stub(cs); - } - - return addr; -} - -static int64 lrem(int64 m, int64 n) -{ - assert(n); - return m%n; -} - -static NativeCodePtr rth_get_lil_lrem(int* dyn_count) -{ - static NativeCodePtr addr = NULL; - - if (!addr) { - int64 (*p_lrem)(int64, int64) = lrem; - LilCodeStub* cs = lil_parse_code_stub("entry 0:stdcall:g8,g8:g8;"); - assert(cs); - if (dyn_count) { - cs = lil_parse_onto_end(cs, "inc [%0i:pint];", dyn_count); - assert(cs); - } - cs = lil_parse_onto_end(cs, - "jc i1=0,remzero;" - "in2out platform:g8;" - "call %0i;" - "ret;" - ":remzero;" - "tailcall %1i;", - p_lrem, lil_npc_to_fp(exn_get_rth_throw_arithmetic())); - assert(cs && lil_is_valid(cs)); - addr = LilCodeGenerator::get_platform()->compile(cs); - - DUMP_STUB(addr, "rth_lrem", lil_cs_get_code_size(cs)); - - lil_free_code_stub(cs); - } - - return addr; -} - -static int64 ldiv(int64 m, int64 n) -{ - assert(n); - return m/n; -} - -static NativeCodePtr rth_get_lil_ldiv(int* dyn_count) -{ - static NativeCodePtr addr = NULL; - - if (!addr) { - int64 (*p_ldiv)(int64, int64) = ldiv; - LilCodeStub* cs = lil_parse_code_stub("entry 0:stdcall:g8,g8:g8;"); - assert(cs); - if (dyn_count) { - cs = lil_parse_onto_end(cs, "inc [%0i:pint];", dyn_count); - assert(cs); - } - cs = lil_parse_onto_end(cs, - "jc i1=0,divzero;" - "in2out platform:g8;" - "call %0i;" - "ret;" - ":divzero;" - "tailcall %1i;", - p_ldiv, lil_npc_to_fp(exn_get_rth_throw_arithmetic())); - assert(cs && lil_is_valid(cs)); - addr = LilCodeGenerator::get_platform()->compile(cs); - - DUMP_STUB(addr, "rth_ldiv", lil_cs_get_code_size(cs)); - - lil_free_code_stub(cs); - } - - return addr; -} - -static uint64 ludiv(uint64 m, uint64 n) -{ - assert(n); - return m/n; -} - -static NativeCodePtr rth_get_lil_ludiv(int* dyn_count) -{ - static NativeCodePtr addr = NULL; - - if (!addr) { - uint64 (*p_ludiv)(uint64, uint64) = ludiv; - LilCodeStub* cs = lil_parse_code_stub("entry 0:stdcall:g8,g8:g8;"); - assert(cs); - if (dyn_count) { - cs = lil_parse_onto_end(cs, "inc [%0i:pint];", dyn_count); - assert(cs); - } - cs = lil_parse_onto_end(cs, - "jc i1=0,divzero;" - "in2out platform:g8;" - "call %0i;" - "ret;" - ":divzero;" - "tailcall %1i;", - p_ludiv, lil_npc_to_fp(exn_get_rth_throw_arithmetic())); - assert(cs && lil_is_valid(cs)); - addr = LilCodeGenerator::get_platform()->compile(cs); - - DUMP_STUB(addr, "rth_ludiv", lil_cs_get_code_size(cs)); - - lil_free_code_stub(cs); - } - - return addr; -} - -static NativeCodePtr rth_get_lil_ldiv_const(int* dyn_count) -{ - static NativeCodePtr addr = NULL; - - if (!addr) { - // This constant must be kept in sync with MAGIC in ir.cpp - POINTER_SIZE_INT divisor_offset = 40; - int64 (*p_ldiv)(int64, int64) = ldiv; - LilCodeStub* cs = lil_parse_code_stub("entry 0:stdcall:g8,pint:g8;"); - assert(cs); - if (dyn_count) { - cs = lil_parse_onto_end(cs, "inc [%0i:pint];", dyn_count); - assert(cs); - } - cs = lil_parse_onto_end(cs, - "out platform:g8,g8:g8;" - "o0=i0;" - "ld o1,[i1+%0i:g8];" - "call %1i;" - "ret;", - divisor_offset, p_ldiv); - assert(cs && lil_is_valid(cs)); - addr = LilCodeGenerator::get_platform()->compile(cs); - - DUMP_STUB(addr, "rth_ldiv_const", lil_cs_get_code_size(cs)); - - lil_free_code_stub(cs); - } - - return addr; -} - -static NativeCodePtr rth_get_lil_lrem_const(int* dyn_count) -{ - static NativeCodePtr addr = NULL; - - if (!addr) { - // This constant must be kept in sync with MAGIC in ir.cpp - POINTER_SIZE_INT divisor_offset = 40; - int64 (*p_lrem)(int64, int64) = lrem; - LilCodeStub* cs = lil_parse_code_stub("entry 0:stdcall:g8,pint:g8;"); - assert(cs); - if (dyn_count) { - cs = lil_parse_onto_end(cs, "inc [%0i:pint];", dyn_count); - assert(cs); - } - cs = lil_parse_onto_end(cs, - "out platform:g8,g8:g8;" - "o0=i0;" - "ld o1,[i1+%0i:g8];" - "call %1i;" - "ret;", - divisor_offset, p_lrem); - assert(cs && lil_is_valid(cs)); - addr = LilCodeGenerator::get_platform()->compile(cs); - - DUMP_STUB(addr, "rth_lrem_const", lil_cs_get_code_size(cs)); - - lil_free_code_stub(cs); - } - - return addr; -} - -static int32 imul(int32 m, int32 n) -{ - return m*n; -} - -static NativeCodePtr rth_get_lil_imul(int* dyn_count) -{ - static NativeCodePtr addr = NULL; - - if (!addr) { - int32 (*p_imul)(int32, int32) = imul; - LilCodeStub* cs = lil_parse_code_stub("entry 0:stdcall:g4,g4:g4;"); - assert(cs); - if (dyn_count) { - cs = lil_parse_onto_end(cs, "inc [%0i:pint];", dyn_count); - assert(cs); - } - cs = lil_parse_onto_end(cs, - "in2out platform:g4;" - "call %0i;" - "ret;", - p_imul); - assert(cs && lil_is_valid(cs)); - addr = LilCodeGenerator::get_platform()->compile(cs); - - DUMP_STUB(addr, "rth_imul", lil_cs_get_code_size(cs)); - - lil_free_code_stub(cs); - } - - return addr; -} - -static int32 irem(int32 m, int32 n) -{ - assert(n); - return m%n; -} - -static NativeCodePtr rth_get_lil_irem(int* dyn_count) -{ - static NativeCodePtr addr = NULL; - - if (!addr) { - int32 (*p_irem)(int32, int32) = irem; - LilCodeStub* cs = lil_parse_code_stub("entry 0:stdcall:g4,g4:g4;"); - assert(cs); - if (dyn_count) { - cs = lil_parse_onto_end(cs, "inc [%0i:pint];", dyn_count); - assert(cs); - } - cs = lil_parse_onto_end(cs, - "jc i1=0,remzero;" - "in2out platform:g4;" - "call %0i;" - "ret;" - ":remzero;" - "tailcall %1i;", - p_irem, lil_npc_to_fp(exn_get_rth_throw_arithmetic())); - assert(cs && lil_is_valid(cs)); - addr = LilCodeGenerator::get_platform()->compile(cs); - - DUMP_STUB(addr, "rth_irem", lil_cs_get_code_size(cs)); - - lil_free_code_stub(cs); - } - - return addr; -} - -static int32 idiv(int32 m, int32 n) -{ - assert(n); - return m/n; -} - -static NativeCodePtr rth_get_lil_idiv(int* dyn_count) -{ - static NativeCodePtr addr = NULL; - - if (!addr) { - int32 (*p_idiv)(int32, int32) = idiv; - LilCodeStub* cs = lil_parse_code_stub("entry 0:stdcall:g4,g4:g4;"); - assert(cs); - if (dyn_count) { - cs = lil_parse_onto_end(cs, "inc [%0i:pint];", dyn_count); - assert(cs); - } - cs = lil_parse_onto_end(cs, - "jc i1=0,remzero;" - "in2out platform:g4;" - "call %0i;" - "ret;" - ":remzero;" - "tailcall %1i;", - p_idiv, lil_npc_to_fp(exn_get_rth_throw_arithmetic())); - assert(cs && lil_is_valid(cs)); - addr = LilCodeGenerator::get_platform()->compile(cs); - - DUMP_STUB(addr, "rth_idiv", lil_cs_get_code_size(cs)); - - lil_free_code_stub(cs); - } - - return addr; -} - - const int nan_data = 0xffc00000; #define NANF (*(float*)&nan_data) @@ -1470,39 +1055,6 @@ return addr; } -static float fdiv(float m, float n) -{ - return m/n; -} - -static NativeCodePtr rth_get_lil_fdiv(int* dyn_count) -{ - static NativeCodePtr addr = NULL; - - if (!addr) { - float (*p_fdiv)(float, float) = fdiv; - LilCodeStub* cs = lil_parse_code_stub("entry 0:stdcall:f4,f4:f4;"); - assert(cs); - if (dyn_count) { - cs = lil_parse_onto_end(cs, "inc [%0i:pint];", dyn_count); - assert(cs); - } - cs = lil_parse_onto_end(cs, - "in2out platform:f4;" - "call %0i;" - "ret;", - p_fdiv); - assert(cs && lil_is_valid(cs)); - addr = LilCodeGenerator::get_platform()->compile(cs); - - DUMP_STUB(addr, "rth_fdiv", lil_cs_get_code_size(cs)); - - lil_free_code_stub(cs); - } - - return addr; -} - static double my_drem(double m, double n) { return fmod(m, n); @@ -1536,40 +1088,7 @@ return addr; } -static double ddiv(double m, double n) -{ - return m/n; -} -static NativeCodePtr rth_get_lil_ddiv(int* dyn_count) -{ - static NativeCodePtr addr = NULL; - - if (!addr) { - double (*p_ddiv)(double, double) = ddiv; - LilCodeStub* cs = lil_parse_code_stub("entry 0:stdcall:f8,f8:f8;"); - assert(cs); - if (dyn_count) { - cs = lil_parse_onto_end(cs, "inc [%0i:pint];", dyn_count); - assert(cs); - } - cs = lil_parse_onto_end(cs, - "in2out platform:f8;" - "call %0i;" - "ret;", - p_ddiv); - assert(cs && lil_is_valid(cs)); - addr = LilCodeGenerator::get_platform()->compile(cs); - - DUMP_STUB(addr, "rth_ddiv", lil_cs_get_code_size(cs)); - - lil_free_code_stub(cs); - } - - return addr; -} - - ////////////////////////////////////////////////////////////////////////// // Get LIL version of Runtime Helper @@ -2495,41 +2014,10 @@ return rth_get_lil_d2i(dyn_count); case VM_RT_D2L: return rth_get_lil_d2l(dyn_count); - case VM_RT_LSHL: - return rth_get_lil_lshl(dyn_count); - case VM_RT_LSHR: - return rth_get_lil_lshr(dyn_count); - case VM_RT_LUSHR: - return rth_get_lil_lushr(dyn_count); - case VM_RT_LMUL: -#ifdef VM_LONG_OPT - case VM_RT_LMUL_CONST_MULTIPLIER: // Not optimized, but functional -#endif - return rth_get_lil_lmul(dyn_count); - case VM_RT_LREM: - return rth_get_lil_lrem(dyn_count); - case VM_RT_LDIV: - return rth_get_lil_ldiv(dyn_count); - case VM_RT_ULDIV: - return rth_get_lil_ludiv(dyn_count); - case VM_RT_CONST_LDIV: // Not optimized, but functional - return rth_get_lil_ldiv_const(dyn_count); - case VM_RT_CONST_LREM: // Not optimized, but functional - return rth_get_lil_lrem_const(dyn_count); - case VM_RT_IMUL: - return rth_get_lil_imul(dyn_count); - case VM_RT_IREM: - return rth_get_lil_irem(dyn_count); - case VM_RT_IDIV: - return rth_get_lil_idiv(dyn_count); case VM_RT_FREM: return rth_get_lil_frem(dyn_count); - case VM_RT_FDIV: - return rth_get_lil_fdiv(dyn_count); case VM_RT_DREM: return rth_get_lil_drem(dyn_count); - case VM_RT_DDIV: - return rth_get_lil_ddiv(dyn_count); case VM_RT_NEWOBJ_WITHRESOLVE: return rth_get_lil_newobj_withresolve(dyn_count); case VM_RT_NEWARRAY_WITHRESOLVE: Index: vm/vmcore/src/util/ia32/base/jit_generic_rt_support_ia32.cpp =================================================================== --- vm/vmcore/src/util/ia32/base/jit_generic_rt_support_ia32.cpp (revision 636754) +++ vm/vmcore/src/util/ia32/base/jit_generic_rt_support_ia32.cpp (working copy) @@ -49,509 +49,7 @@ #include "dump.h" #include "vm_stats.h" -static uint64 vm_lshl(unsigned count, uint64 n) -{ - assert(!hythread_is_suspend_enabled()); - return n << (count & 0x3f); -} //vm_lshl - -// The arguments are: -// edx:eax - the value to be shifted -// ecx - how many bits to shift by -// The result is returned in edx:eax. - - -void * getaddress__vm_lshl_naked() -{ - static void *addr = 0; - if (addr) { - return addr; - } - - const int stub_size = 12+12; - char *stub = (char *)malloc_fixed_code_for_jit(stub_size, DEFAULT_CODE_ALIGNMENT, CODE_BLOCK_HEAT_DEFAULT, CAA_Allocate); -#ifdef _DEBUG - memset(stub, 0xcc /*int 3*/, stub_size); -#endif - char *ss = stub; - - unsigned n=12; - M_Base_Opnd mem(esp_reg, 12); - ss = push(ss, mem); - ss = push(ss, mem); - ss = push(ss, mem); - ss = call(ss, (char *)vm_lshl); - ss = alu(ss, add_opc, esp_opnd, Imm_Opnd(12)); - Imm_Opnd imm(n); - ss = ret(ss, imm); - - addr = stub; - assert((ss - stub) <= stub_size); - - compile_add_dynamic_generated_code_chunk("vm_lshl_naked", false, stub, stub_size); - - if (jvmti_should_report_event(JVMTI_EVENT_DYNAMIC_CODE_GENERATED)) { - jvmti_send_dynamic_code_generated_event("vm_lshl_naked", stub, stub_size); - } - - DUMP_STUB(stub, "getaddress__vm_lshl_naked", ss - stub); - - return addr; -} //getaddress__vm_lshl_naked - - -static int64 vm_lshr(unsigned count, int64 n) -{ - assert(!hythread_is_suspend_enabled()); - return n >> (count & 0x3f); -} //vm_lshr - - -// The arguments are: -// edx:eax - the value to be shifted -// ecx - how many bits to shift by -// The result is returned in edx:eax. - - -void * getaddress__vm_lshr_naked() -{ - static void *addr = 0; - if (addr) { - return addr; - } - - const int stub_size = 13+12; - char *stub = (char *)malloc_fixed_code_for_jit(stub_size, DEFAULT_CODE_ALIGNMENT, CODE_BLOCK_HEAT_DEFAULT, CAA_Allocate); -#ifdef _DEBUG - memset(stub, 0xcc /*int 3*/, stub_size); -#endif - char *ss = stub; - - unsigned n=12; - M_Base_Opnd mem(esp_reg, 12); - ss = push(ss, mem); - ss = push(ss, mem); - ss = push(ss, mem); - ss = call(ss, (char *)vm_lshr); - ss = alu(ss, add_opc, esp_opnd, Imm_Opnd(12)); - Imm_Opnd imm(n); - ss = ret(ss, imm); - - addr = stub; - assert((ss - stub) < stub_size); - - compile_add_dynamic_generated_code_chunk("vm_lshr_naked", false, stub, stub_size); - - if (jvmti_should_report_event(JVMTI_EVENT_DYNAMIC_CODE_GENERATED)) { - jvmti_send_dynamic_code_generated_event("vm_lshr_naked", stub, stub_size); - } - - DUMP_STUB(stub, "getaddress__vm_lshr_naked", ss - stub); - - return addr; -} //getaddress__vm_lshr_naked - - -static uint64 vm_lushr(unsigned count, uint64 n) -{ - assert(!hythread_is_suspend_enabled()); - return n >> (count & 0x3f); -} //vm_lushr - - -// The arguments are: -// edx:eax - the value to be shifted -// ecx - how many bits to shift by -// The result is returned in edx:eax. - - -void * getaddress__vm_lushr_naked() -{ - static void *addr = 0; - if (addr) { - return addr; - } - - const int stub_size = 12+12; - char *stub = (char *)malloc_fixed_code_for_jit(stub_size, DEFAULT_CODE_ALIGNMENT, CODE_BLOCK_HEAT_DEFAULT, CAA_Allocate); -#ifdef _DEBUG - memset(stub, 0xcc /*int 3*/, stub_size); -#endif - char *ss = stub; - - unsigned n=12; - M_Base_Opnd mem(esp_reg, 12); - ss = push(ss, mem); - ss = push(ss, mem); - ss = push(ss, mem); - ss = call(ss, (char *)vm_lushr); - ss = alu(ss, add_opc, esp_opnd, Imm_Opnd(12)); - Imm_Opnd imm(n); - ss = ret(ss, imm); - - addr = stub; - assert((ss - stub) <= stub_size); - - compile_add_dynamic_generated_code_chunk("vm_lushr_naked", false, stub, stub_size); - - if (jvmti_should_report_event(JVMTI_EVENT_DYNAMIC_CODE_GENERATED)) { - jvmti_send_dynamic_code_generated_event("vm_lushr_naked", stub, stub_size); - } - - DUMP_STUB(stub, "getaddress__vm_lushr_naked", ss - stub); - - return addr; -} //getaddress__vm_lushr_naked - - -static int64 __stdcall vm_lmul(int64 m, int64 n); - -static int64 __stdcall vm_lmul(int64 m, int64 n) -{ - assert(!hythread_is_suspend_enabled()); - - return m * n; -} //vm_lmul - -#ifdef VM_LONG_OPT -static int64 __stdcall vm_lmul_const_multiplier(int64 m, int64 n); - -static int64 __stdcall vm_lmul_const_multiplier(int64 m, int64 n) -{ - assert(!hythread_is_suspend_enabled()); - __asm{ - mov eax,dword ptr [ebp+0ch] - mov ecx,dword ptr [ebp+10h] - mul ecx - mov ebx,eax - mov eax,dword ptr [ebp+08h] - mul ecx - add edx,ebx - } -} //vm_lmul_const_multiplier -#endif - - -static int64 __stdcall do_lrem(int64 m, int64 n); - -static int64 __stdcall do_lrem(int64 m, int64 n) -{ - assert(!hythread_is_suspend_enabled()); - - return m % n; -} //do_lrem - - -void * getaddress__vm_const_lrem_naked() -{ - static void *addr = 0; - if (addr) { - return addr; - } - - const int stub_size = 200 ; - char *stub = (char *)malloc_fixed_code_for_jit(stub_size, DEFAULT_CODE_ALIGNMENT, CODE_BLOCK_HEAT_DEFAULT, CAA_Allocate); - char* ss = stub ; - - ss = push(ss, ebp_opnd); - ss = mov(ss, ebp_opnd, esp_opnd); - ss = push(ss, ebx_opnd); - ss = push(ss, esi_opnd); - ss = push(ss, edi_opnd); - - ss = mov(ss, esi_opnd, M_Base_Opnd(ebp_reg, +0x0c) ); - ss = mov(ss, edi_opnd, M_Base_Opnd(ebp_reg, +0x10) ); - ss = mov(ss, eax_opnd, M_Base_Opnd(edi_reg, +0x28) ); - ss = alu(ss, cmp_opc, esi_opnd, eax_opnd); - ss = branch8(ss, Condition_AE, Imm_Opnd(size_8, 0x60)); // jae slower - ss = mov(ss, ebx_opnd, M_Base_Opnd(edi_reg, +0x30) ); - ss = mov(ss, eax_opnd, M_Base_Opnd(ebp_reg, +0x0c) ); - ss = mov(ss, edx_opnd, M_Base_Opnd(ebp_reg, +0x8) ); - ss = mov(ss, ecx_opnd, Imm_Opnd(0x20) ); - ss = alu(ss, sub_opc, ecx_opnd, ebx_opnd); - ss = branch8(ss, Condition_Z, Imm_Opnd(size_8, 0x5)); // je l_is_32 - ss = shift(ss, shld_opc, eax_opnd, edx_opnd); //shld eax,edx,cl - ss = shift(ss, shl_opc, edx_opnd); //shld eax,edx,cl -//l_is_32: - ss = mov(ss, ebx_opnd, edx_opnd); - ss = shift(ss, sar_opc, ebx_opnd, Imm_Opnd(0x1f)); //shld eax,edx,cl - ss = mov(ss, esi_opnd, M_Base_Opnd(edi_reg, +0x38) ); - ss = alu(ss, and_opc, esi_opnd, ebx_opnd); - ss = alu(ss, add_opc, esi_opnd, edx_opnd); - ss = mov(ss, ecx_opnd, eax_opnd); - ss = alu(ss, cmp_opc, eax_opnd, ebx_opnd); - ss = branch8(ss, Condition_Z, Imm_Opnd(size_8, 0x0b)); // je mul_zero - ss = alu(ss, sub_opc, eax_opnd, ebx_opnd); - ss = mov(ss, ebx_opnd, eax_opnd); - ss = mov(ss, edx_opnd, M_Base_Opnd(edi_reg, +0x34) ); - ss = mul(ss, edx_opnd); - ss = jump8(ss, Imm_Opnd(size_8, 0x4)); // jmp next1 -//mul_zero: - ss = alu(ss, xor_opc, edx_opnd, edx_opnd); - ss = alu(ss, xor_opc, eax_opnd, eax_opnd); - ss = alu(ss, add_opc, eax_opnd, esi_opnd); - ss = alu(ss, adc_opc, edx_opnd, Imm_Opnd(0)); - ss = alu(ss, add_opc, ecx_opnd, edx_opnd); - ss = mov(ss, esi_opnd, ecx_opnd); - ss = mov(ss, eax_opnd, esi_opnd); - ss = _not(ss, eax_opnd); - ss = mov(ss, ebx_opnd, M_Base_Opnd(edi_reg, +0x28) ); - ss = mul(ss, ebx_opnd); - ss = mov(ss, ecx_opnd, M_Base_Opnd(ebp_reg, +0x0c) ); - ss = mov(ss, edi_opnd, M_Base_Opnd(ebp_reg, +0x8) ); - ss = alu(ss, sub_opc, ecx_opnd, ebx_opnd); - ss = alu(ss, add_opc, eax_opnd, edi_opnd); - ss = alu(ss, adc_opc, edx_opnd, ecx_opnd); - ss = mov(ss, edi_opnd, edx_opnd); - ss = alu(ss, and_opc, edi_opnd, ebx_opnd); - ss = alu(ss, add_opc, eax_opnd, edi_opnd); - ss = alu(ss, xor_opc, edx_opnd, edx_opnd); - ss = jump8(ss, Imm_Opnd(size_8, 0x11)); // jmp end -//slower: - ss = push(ss, M_Base_Opnd(edi_reg, +0x2c) ); - ss = push(ss, M_Base_Opnd(edi_reg, +0x28) ); - ss = push(ss, M_Base_Opnd(ebp_reg, +0x0c) ); - ss = push(ss, M_Base_Opnd(ebp_reg, +0x8) ); - ss = call(ss, (char *)do_lrem); -//end: - - ss = pop(ss, edi_opnd); - ss = pop(ss, esi_opnd); - ss = pop(ss, ebx_opnd); - ss = mov(ss, esp_opnd, ebp_opnd); - ss = pop(ss, ebp_opnd); - - ss = ret(ss, Imm_Opnd(0x0c)); - - assert((ss - stub) <= stub_size); - addr = stub; - - compile_add_dynamic_generated_code_chunk("vm_const_lrem_naked", false, stub, stub_size); - - if (jvmti_should_report_event(JVMTI_EVENT_DYNAMIC_CODE_GENERATED)) { - jvmti_send_dynamic_code_generated_event("vm_const_lrem_naked", stub, stub_size); - } - - DUMP_STUB(stub, "getaddress__vm_const_lrem_naked", ss - stub); - - return addr; -} //getaddress__vm_const_lrem_naked - -static void *getaddress__vm_const_ldiv_naked() -{ - static void *addr = 0; - if(addr) { - return addr; - } - -/****************************************************************************** - * fast long division in this function - ******************************************************************************/ - const int stub_size = 420; - char *stub = (char *)malloc_fixed_code_for_jit(stub_size, DEFAULT_CODE_ALIGNMENT, CODE_BLOCK_HEAT_DEFAULT, CAA_Allocate); - char* ss = stub ; - - ss = push(ss, ebp_opnd); - ss = mov(ss, ebp_opnd, esp_opnd); - ss = alu(ss, sub_opc, esp_opnd, Imm_Opnd(0x4c)) ; - ss = push(ss, ebx_opnd); - ss = push(ss, esi_opnd); - ss = push(ss, edi_opnd); - - ss = mov(ss, esi_opnd, M_Base_Opnd(ebp_reg, +0x0c) ); - ss = alu(ss, or_opc, esi_opnd, esi_opnd) ; - ss = branch8(ss, Condition_NZ, Imm_Opnd(size_8, 0x28)); // jne fast_64 - ss = mov(ss, edi_opnd, M_Base_Opnd(ebp_reg, +0x10) ); - ss = mov(ss, ecx_opnd, M_Base_Opnd(edi_reg, +0x1c) ); - ss = alu(ss, or_opc, ecx_opnd, ecx_opnd) ; - ss = branch8(ss, Condition_Z, Imm_Opnd(size_8, 0x21)); // jne fast_64_2 - /******************************************************************************* - * Fast 32/32 - *******************************************************************************/ - ss = mov(ss, eax_opnd, M_Base_Opnd(ebp_reg, +0x08) ); - ss = mov(ss, esi_opnd, eax_opnd ); - ss = mul(ss, ecx_opnd) ; - ss = alu(ss, sub_opc, esi_opnd, edx_opnd) ; - ss = mov(ss, ecx_opnd, M_Base_Opnd(edi_reg, +0x0c) ); - ss = shift(ss, shr_opc, esi_opnd) ; - ss = alu(ss, add_opc, edx_opnd, esi_opnd) ; - ss = mov(ss, ecx_opnd, M_Base_Opnd(edi_reg, +0x20) ); - ss = shift(ss, shr_opc, edx_opnd) ; - ss = mov(ss, eax_opnd, edx_opnd ); - ss = alu(ss, xor_opc, edx_opnd, edx_opnd) ; - ss = jump32(ss, Imm_Opnd(0x130)); // jmp end -//fast_64: - ss = mov(ss, edi_opnd, M_Base_Opnd(ebp_reg, +0x10) ); -//fast_64_2: - ss = mov(ss, eax_opnd, M_Base_Opnd(edi_reg, +0x28) ); - ss = alu(ss, or_opc, esi_opnd, esi_opnd) ; - ss = branch8(ss, Condition_L, Imm_Opnd(size_8, 0x68)); // js fast_64_64 - ss = alu(ss, cmp_opc, esi_opnd, eax_opnd) ; - ss = branch8(ss, Condition_AE, Imm_Opnd(size_8, 0x64)); // jae fast_64_64 - /******************************************************************************* - * Fast 64/32 - *******************************************************************************/ - ss = mov(ss, ebx_opnd, M_Base_Opnd(edi_reg, +0x30) ); - ss = mov(ss, eax_opnd, esi_opnd ); - ss = mov(ss, edx_opnd, M_Base_Opnd(ebp_reg, +0x8) ); - ss = mov(ss, ecx_opnd, Imm_Opnd(0x20) ); - ss = alu(ss, sub_opc, ecx_opnd, ebx_opnd) ; - ss = branch8(ss, Condition_Z, Imm_Opnd(size_8, 0x5)); // je l_is_32 - ss = shift(ss, shld_opc, eax_opnd, edx_opnd) ; - ss = shift(ss, shl_opc, edx_opnd) ; -//l_is_32: - ss = mov(ss, ebx_opnd, edx_opnd ); - ss = shift(ss, sar_opc, ebx_opnd, Imm_Opnd(0x1f)) ; - ss = mov(ss, esi_opnd, M_Base_Opnd(edi_reg, +0x38) ); - ss = alu(ss, and_opc, esi_opnd, ebx_opnd) ; - ss = alu(ss, add_opc, esi_opnd, edx_opnd) ; - ss = mov(ss, ecx_opnd, eax_opnd ); - ss = alu(ss, cmp_opc, eax_opnd, ebx_opnd) ; - ss = branch8(ss, Condition_Z, Imm_Opnd(size_8, 0xb)); // je mul_zero - ss = alu(ss, sub_opc, eax_opnd, ebx_opnd) ; - ss = mov(ss, ebx_opnd, eax_opnd ); - ss = mov(ss, edx_opnd, M_Base_Opnd(edi_reg, +0x34) ); - ss = mul(ss, edx_opnd) ; - ss = jump8(ss, Imm_Opnd(size_8, 0x4)); // jmp next1 -//mul_zero: - ss = alu(ss, xor_opc, edx_opnd, edx_opnd) ; - ss = alu(ss, xor_opc, eax_opnd, eax_opnd) ; -//next1: - ss = alu(ss, add_opc, eax_opnd, esi_opnd) ; - ss = alu(ss, adc_opc, edx_opnd, Imm_Opnd(0)) ; - ss = alu(ss, add_opc, ecx_opnd, edx_opnd) ; - ss = mov(ss, esi_opnd, ecx_opnd ); - ss = mov(ss, eax_opnd, esi_opnd ); - ss = _not(ss, eax_opnd) ; - ss = mov(ss, ebx_opnd, M_Base_Opnd(edi_reg, +0x28) ); - ss = mul(ss, ebx_opnd) ; - ss = mov(ss, ecx_opnd, M_Base_Opnd(ebp_reg, +0x0c) ); - ss = mov(ss, edi_opnd, M_Base_Opnd(ebp_reg, +0x8) ); - ss = alu(ss, sub_opc, ecx_opnd, ebx_opnd) ; - ss = alu(ss, add_opc, eax_opnd, edi_opnd) ; - ss = alu(ss, adc_opc, edx_opnd, ecx_opnd) ; - ss = mov(ss, ecx_opnd, esi_opnd ); - ss = _not(ss, ecx_opnd) ; - ss = mov(ss, eax_opnd, edx_opnd ); - ss = alu(ss, sub_opc, eax_opnd, ecx_opnd) ; - ss = alu(ss, xor_opc, edx_opnd, edx_opnd) ; - ss = jump32(ss, Imm_Opnd(0xbe)); // jmp end - /******************************************************************************* - * Fast 64/64 - *******************************************************************************/ -//fast_64_64 - ss = alu(ss, or_opc, esi_opnd, esi_opnd) ; - ss = branch8(ss, Condition_GE, Imm_Opnd(size_8, 0x21)); // jge positive - ss = mov(ss, edx_opnd, esi_opnd ); - ss = mov(ss, ecx_opnd, esi_opnd ); - ss = shift(ss, sar_opc, ecx_opnd, Imm_Opnd(0x1f)) ; - ss = shift(ss, shr_opc, esi_opnd, Imm_Opnd(0x1f)) ; - ss = mov(ss, M_Base_Opnd(ebp_reg, -0x0c), ecx_opnd ); - ss = mov(ss, eax_opnd, M_Base_Opnd(ebp_reg, +0x8) ); - ss = alu(ss, xor_opc, eax_opnd, ecx_opnd) ; - ss = alu(ss, xor_opc, edx_opnd, ecx_opnd) ; - ss = alu(ss, add_opc, eax_opnd, esi_opnd) ; - ss = alu(ss, adc_opc, edx_opnd, Imm_Opnd(0) ) ; - ss = mov(ss, M_Base_Opnd(ebp_reg, -0x04), edx_opnd ); - ss = mov(ss, M_Base_Opnd(ebp_reg, -0x08), eax_opnd ); - ss = jump8(ss,Imm_Opnd(size_8, 0x0e)); // jmp Cal_t1 -//positive: - ss = mov(ss, M_Base_Opnd(ebp_reg, -0x04), esi_opnd ); - ss = mov(ss, eax_opnd, M_Base_Opnd(ebp_reg, +0x8) ); - ss = mov(ss, M_Base_Opnd(ebp_reg, -0x08), eax_opnd ); - ss = alu(ss, xor_opc, esi_opnd, esi_opnd) ; - ss = mov(ss, M_Base_Opnd(ebp_reg, -0x0c), esi_opnd ); -//Cal_t1: - ss = mov(ss, ecx_opnd, eax_opnd ); - ss = mov(ss, ebx_opnd, M_Base_Opnd(edi_reg, +0x0) ); - ss = mul(ss, ebx_opnd) ; - ss = alu(ss, sub_opc, eax_opnd, Imm_Opnd(0x1) ) ; - ss = alu(ss, sbb_opc, edx_opnd, Imm_Opnd(0x1) ) ; - ss = alu(ss, add_opc, eax_opnd, esi_opnd ) ; - ss = alu(ss, adc_opc, edx_opnd, Imm_Opnd(0) ) ; - ss = mov(ss, edi_opnd, edx_opnd ); - ss = mov(ss, eax_opnd, M_Base_Opnd(ebp_reg, -0x4) ); - ss = mul(ss, ebx_opnd) ; - ss = alu(ss, add_opc, eax_opnd, edi_opnd ) ; - ss = alu(ss, adc_opc, edx_opnd, Imm_Opnd(0) ) ; - ss = mov(ss, edi_opnd, edx_opnd ); - ss = mov(ss, esi_opnd, eax_opnd ); - ss = mov(ss, eax_opnd, ecx_opnd ); - ss = mov(ss, ebx_opnd, M_Base_Opnd(ebp_reg, +0x10) ); - ss = mov(ss, ebx_opnd, M_Base_Opnd(ebx_reg, +0x04) ); - ss = mul(ss, ebx_opnd) ; - ss = alu(ss, add_opc, eax_opnd, esi_opnd ) ; - ss = alu(ss, adc_opc, edx_opnd, edi_opnd ) ; - ss = mov(ss, edi_opnd, Imm_Opnd(0) ); - ss = alu(ss, adc_opc, edi_opnd, Imm_Opnd(0) ) ; - ss = mov(ss, esi_opnd, edx_opnd ); - ss = mov(ss, eax_opnd, M_Base_Opnd(ebp_reg, -0x4) ); - ss = mul(ss, ebx_opnd) ; - ss = alu(ss, add_opc, eax_opnd, esi_opnd ) ; - ss = alu(ss, adc_opc, edx_opnd, edi_opnd ) ; - ss = mov(ss, edi_opnd, M_Base_Opnd(ebp_reg, -0x0c) ); - ss = mov(ss, ebx_opnd, edi_opnd ); - ss = _not(ss, edi_opnd) ; - ss = alu(ss, xor_opc, eax_opnd, edi_opnd) ; - ss = alu(ss, xor_opc, edx_opnd, edi_opnd) ; - ss = mov(ss, edi_opnd, M_Base_Opnd(ebp_reg, +0x08) ); - ss = mov(ss, esi_opnd, M_Base_Opnd(ebp_reg, +0x0c) ); - ss = alu(ss, add_opc, eax_opnd, edi_opnd ) ; - ss = alu(ss, adc_opc, edx_opnd, esi_opnd ) ; - ss = mov(ss, ecx_opnd, M_Base_Opnd(ebp_reg, +0x10) ); - ss = mov(ss, ecx_opnd, M_Base_Opnd(ecx_reg, +0x10) ); - ss = alu(ss, cmp_opc, ecx_opnd, Imm_Opnd(0x20) ) ; - ss = branch8(ss, Condition_GE, Imm_Opnd(size_8, 0x07)); // jge biger_than_32 - ss = shift(ss, shrd_opc, eax_opnd, edx_opnd ) ; - ss = shift(ss, sar_opc, edx_opnd ) ; - ss = jump8(ss,Imm_Opnd(size_8, 0x0a)); // jmp next -//biger_than_32: - ss = alu(ss, sub_opc, ecx_opnd, Imm_Opnd(0x20) ) ; - ss = mov(ss, eax_opnd, edx_opnd ); - ss = shift(ss, sar_opc, edx_opnd, Imm_Opnd(0x1f) ) ; - ss = shift(ss, sar_opc, eax_opnd ) ; -//next: - ss = alu(ss, sub_opc, eax_opnd, ebx_opnd ) ; - ss = alu(ss, sbb_opc, edx_opnd, ebx_opnd ) ; - ss = mov(ss, ecx_opnd, M_Base_Opnd(ebp_reg, +0x10) ); - ss = mov(ss, ecx_opnd, M_Base_Opnd(ecx_reg, +0x14) ); - ss = test(ss, ecx_opnd, ecx_opnd) ; - ss = branch8(ss, Condition_Z, Imm_Opnd(size_8, 0x08)); // je end - ss = alu(ss, xor_opc, eax_opnd, ecx_opnd) ; - ss = alu(ss, xor_opc, edx_opnd, ecx_opnd) ; - ss = alu(ss, sub_opc, eax_opnd, ecx_opnd) ; - ss = alu(ss, sbb_opc, edx_opnd, ecx_opnd) ; - -//end: - ss = pop(ss, edi_opnd); - ss = pop(ss, esi_opnd); - ss = pop(ss, ebx_opnd); - ss = mov(ss, esp_opnd, ebp_opnd); - ss = pop(ss, ebp_opnd); - ss = ret(ss, Imm_Opnd(0x0c)); - - assert((ss - stub) <= stub_size); - addr = stub; - - compile_add_dynamic_generated_code_chunk("vm_const_ldiv_naked", false, stub, stub_size); - - if (jvmti_should_report_event(JVMTI_EVENT_DYNAMIC_CODE_GENERATED)) { - jvmti_send_dynamic_code_generated_event("vm_const_ldiv_naked", stub, stub_size); - } - - DUMP_STUB(stub, "getaddress__vm_const_ldiv_naked", ss - stub); - - return addr; -} //getaddress__vm_ldiv_naked - - -static double vm_rt_ddiv(double a, double b) -{ - double result = a / b; - return result; -} //vm_rt_ddiv - static int32 d2i_infinite(double d) { #ifdef __INTEL_COMPILER @@ -1091,28 +589,6 @@ } //vm_rt_char_arraycopy_no_exc -static int32 vm_rt_imul_common(int32 v1, int32 v2) -{ - return v1 * v2; -} //vm_rt_imul_common - - - -static int32 vm_rt_idiv_common(int32 v1, int32 v2) -{ - assert(v2); - return v1 / v2; -} //vm_rt_idiv_common - - - -static int32 vm_rt_irem_common(int32 v1, int32 v2) -{ - assert(v2); - return v1 % v2; -} //vm_rt_irem_common - - void *get_generic_rt_support_addr_ia32(VM_RT_SUPPORT f) { switch(f) { @@ -1124,35 +600,11 @@ return getaddress__vm_d2i(); case VM_RT_D2L: return (void *)vm_d2l; - case VM_RT_LSHL: - return getaddress__vm_lshl_naked(); - case VM_RT_LSHR: - return getaddress__vm_lshr_naked(); - case VM_RT_LUSHR: - return getaddress__vm_lushr_naked(); case VM_RT_FREM: return getaddress__vm_frem(); case VM_RT_DREM: return getaddress__vm_drem(); - case VM_RT_LMUL: - return (void *)vm_lmul; -#ifdef VM_LONG_OPT - case VM_RT_LMUL_CONST_MULTIPLIER: - return (void *)vm_lmul_const_multiplier; -#endif - case VM_RT_CONST_LDIV: - return getaddress__vm_const_ldiv_naked() ; - case VM_RT_CONST_LREM: - return getaddress__vm_const_lrem_naked() ; - case VM_RT_DDIV: - return (void *)vm_rt_ddiv; - case VM_RT_IMUL: - return (void *)vm_rt_imul_common; - case VM_RT_IDIV: - return (void *)vm_rt_idiv_common; - case VM_RT_IREM: - return (void *)vm_rt_irem_common; case VM_RT_CHAR_ARRAYCOPY_NO_EXC: return (void *)vm_rt_char_arraycopy_no_exc; Index: vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp =================================================================== --- vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp (revision 636754) +++ vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp (working copy) @@ -999,157 +999,6 @@ } //getaddress__vm_throw_linking_exception_naked - -// 20030321 This JIT support routine expects to be called directly from managed code. -void * getaddress__gc_write_barrier_fastcall() -{ - static void *addr = 0; - if (addr) { - return addr; - } - - const int stub_size = 11; - char *stub = (char *)malloc_fixed_code_for_jit(stub_size, DEFAULT_CODE_ALIGNMENT, CODE_BLOCK_HEAT_MAX/2, CAA_Allocate); -#ifdef _DEBUG - memset(stub, 0xcc /*int 3*/, stub_size); -#endif - char *ss = stub; - - ss = push(ss, ecx_opnd); - -#ifdef REFS_RUNTIME_OR_COMPRESSED - REFS_RUNTIME_SWITCH_IF - // 20030321 Convert a null reference in %ecx from a managed (heap_base) to an unmanaged null (0/NULL). - ss = test(ss, ecx_opnd, Imm_Opnd((unsigned)VM_Global_State::loader_env->managed_null)); - ss = branch8(ss, Condition_NE, Imm_Opnd(size_8, 0)); // branch around mov 0 - char *backpatch_address__not_managed_null = ((char *)ss) - 1; - ss = mov(ss, ecx_opnd, Imm_Opnd(0)); - signed offset = (signed)ss - (signed)backpatch_address__not_managed_null - 1; - *backpatch_address__not_managed_null = (char)offset; - REFS_RUNTIME_SWITCH_ENDIF -#endif // REFS_RUNTIME_OR_UNCOMPRESSED - - ss = call(ss, (char *)gc_write_barrier); - ss = alu(ss, add_opc, esp_opnd, Imm_Opnd(4)); - - ss = ret(ss); - - addr = stub; - assert((ss - stub) < stub_size); - - compile_add_dynamic_generated_code_chunk("gc_write_barrier_fastcall", false, stub, stub_size); - - if (jvmti_should_report_event(JVMTI_EVENT_DYNAMIC_CODE_GENERATED)) { - jvmti_send_dynamic_code_generated_event("gc_write_barrier_fastcall", stub, stub_size); - } - - DUMP_STUB(stub, "getaddress__gc_write_barrier_fastcall", ss - stub); - - return addr; -} //getaddress__gc_write_barrier_fastcall - - -static int64 __stdcall vm_lrem(int64 m, int64 n); - -static int64 __stdcall vm_lrem(int64 m, int64 n) -{ - assert(!hythread_is_suspend_enabled()); - return m % n; -} //vm_lrem - - -void * getaddress__vm_lrem_naked() -{ - static void *addr = 0; - if (addr) { - return addr; - } - - const int stub_size = 25; - char *stub = (char *)malloc_fixed_code_for_jit(stub_size, DEFAULT_CODE_ALIGNMENT, CODE_BLOCK_HEAT_DEFAULT, CAA_Allocate); -#ifdef _DEBUG - memset(stub, 0xcc /*int 3*/, stub_size); -#endif - char *ss = stub; - ss = mov(ss, eax_opnd, M_Base_Opnd(esp_reg, +12) ); - ss = alu(ss, or_opc, eax_opnd, M_Base_Opnd(esp_reg, +16)); - ss = branch8(ss, Condition_Z, Imm_Opnd(size_8, 0)); - char *backpatch_address__divide_by_zero = ((char *)ss) - 1; - - ss = jump(ss, (char *)vm_lrem); - - signed offset = (signed)ss - (signed)backpatch_address__divide_by_zero - 1; - *backpatch_address__divide_by_zero = (char)offset; - - ss = gen_setup_j2n_frame(ss); - ss = call(ss, (char *)vm_throw_java_lang_ArithmeticException); - assert((ss - stub) <= stub_size); - addr = stub; - - compile_add_dynamic_generated_code_chunk("vm_lrem_naked", false, stub, stub_size); - - if (jvmti_should_report_event(JVMTI_EVENT_DYNAMIC_CODE_GENERATED)) { - jvmti_send_dynamic_code_generated_event("vm_lrem_naked", stub, stub_size); - } - - DUMP_STUB(stub, "getaddress__vm_lrem_naked", ss - stub); - - return addr; -} //getaddress__vm_lrem_naked - - -static int64 __stdcall vm_ldiv(int64 m, int64 n); - -static int64 __stdcall vm_ldiv(int64 m, int64 n) -{ - assert(!hythread_is_suspend_enabled()); - assert(n); - return m / n; -} //vm_ldiv - - -static void *getaddress__vm_ldiv_naked() -{ - static void *addr = 0; - if(addr) { - return addr; - } - - const int stub_size = 25; - char *stub = (char *)malloc_fixed_code_for_jit(stub_size, DEFAULT_CODE_ALIGNMENT, CODE_BLOCK_HEAT_DEFAULT, CAA_Allocate); -#ifdef _DEBUG - memset(stub, 0x90, stub_size); // nop -#endif - char *s = stub; - s = mov(s, eax_opnd, M_Base_Opnd(esp_reg, 12)); - s = alu(s, or_opc, eax_opnd, M_Base_Opnd(esp_reg, 16)); - s = branch8(s, Condition_E, Imm_Opnd(size_8, 5)); // skip 5 bytes over the next instruction - s = jump32(s, Imm_Opnd((((uint32)vm_ldiv) - ((uint32)s)) - 5)); - - s = gen_setup_j2n_frame(s); - - s = call(s, (char *)vm_throw_java_lang_ArithmeticException); - - - assert((s - stub) <= stub_size); - addr = stub; - - compile_add_dynamic_generated_code_chunk("vm_ldiv_naked", false, stub, stub_size); - - if (jvmti_should_report_event(JVMTI_EVENT_DYNAMIC_CODE_GENERATED)) { - jvmti_send_dynamic_code_generated_event("vm_ldiv_naked", stub, stub_size); - } - - DUMP_STUB(stub, "getaddress__vm_ldiv_naked", s - stub); - - return addr; -} //getaddress__vm_ldiv_naked - - - - - - #ifdef VM_STATS static void register_request_for_rt_function(VM_RT_SUPPORT f) { @@ -1207,9 +1056,6 @@ } case VM_RT_AASTORE_TEST: return (void *)vm_aastore_test; - case VM_RT_WRITE_BARRIER_FASTCALL: - return getaddress__gc_write_barrier_fastcall(); - case VM_RT_CHECKCAST: return getaddress__vm_checkcast_naked(); @@ -1237,30 +1083,12 @@ case VM_RT_THROW_LINKING_EXCEPTION: return getaddress__vm_throw_linking_exception_naked(); - case VM_RT_LREM: - return getaddress__vm_lrem_naked(); - case VM_RT_LDIV: - return getaddress__vm_ldiv_naked(); - case VM_RT_F2I: case VM_RT_F2L: case VM_RT_D2I: case VM_RT_D2L: - case VM_RT_LSHL: - case VM_RT_LSHR: - case VM_RT_LUSHR: case VM_RT_FREM: case VM_RT_DREM: - case VM_RT_LMUL: -#ifdef VM_LONG_OPT - case VM_RT_LMUL_CONST_MULTIPLIER: -#endif - case VM_RT_CONST_LDIV: - case VM_RT_CONST_LREM: - case VM_RT_DDIV: - case VM_RT_IMUL: - case VM_RT_IDIV: - case VM_RT_IREM: case VM_RT_CHAR_ARRAYCOPY_NO_EXC: return get_generic_rt_support_addr_ia32(f); case VM_RT_GC_HEAP_WRITE_REF: Index: vm/vmcore/src/util/ipf/base/jit_runtime_support_ipf.cpp =================================================================== --- vm/vmcore/src/util/ipf/base/jit_runtime_support_ipf.cpp (revision 636754) +++ vm/vmcore/src/util/ipf/base/jit_runtime_support_ipf.cpp (working copy) @@ -81,23 +81,11 @@ ///////// begin arithmetic helpers -int32 vm_rt_imul(int32 a, int32 b); -int64 vm_rt_lmul(int64 a, int64 b); -int32 vm_rt_irem(int32 a, int32 b); -int64 vm_rt_lrem(int64 a, int64 b); -int32 vm_rt_idiv(int32 a, int32 b); -int64 vm_rt_ldiv(int64 a, int64 b); float vm_rt_frem(float a, float b); -float vm_rt_fdiv(float a, float b); double vm_rt_drem(double a, double b); -double vm_rt_ddiv(double a, double b); int32 vm_rt_f2i(float f); int64 vm_rt_f2l(float f); void *get_vm_rt_int_div_address_compactor(void *func, char *stub_name); -void *get_vm_rt_lrem_address(); -void *get_vm_rt_ldiv_address(); -void *get_vm_rt_irem_address(); -void *get_vm_rt_idiv_address(); ///////// end arithmetic helpers @@ -2395,16 +2383,6 @@ } -static void *get_fdiv_compactor() -{ - static void *addr = NULL; - if (addr == NULL) - addr = create_direct_helper_call_wrapper((void **)vm_rt_fdiv, 2, "fdiv_wrapper_compactor"); - // maybe it should take 0 arguments since both are floating point - return addr; -} - - static void *get_frem_compactor() { static void *addr = NULL; @@ -2445,25 +2423,6 @@ } -static void *get_lmul_compactor() -{ - static void *addr = NULL; - if (addr == NULL) - addr = create_direct_helper_call_wrapper((void **)vm_rt_lmul, 2, "lmul_wrapper_compactor"); - return addr; -} - - -static void *get_imul_compactor() -{ - static void *addr = NULL; - if (addr == NULL) - addr = create_direct_helper_call_wrapper((void **)vm_rt_imul, 2, "imul_wrapper_compactor"); - return addr; -} - - - #ifdef VM_STATS static void increment_helper_count(VM_RT_SUPPORT f) { @@ -2637,46 +2596,14 @@ fptr = get_f2l_compactor(); dereference_fptr = false; break; - case VM_RT_LMUL: - fptr = get_lmul_compactor(); - dereference_fptr = false; - break; - case VM_RT_LREM: - fptr = get_vm_rt_lrem_address(); - dereference_fptr = false; - break; - case VM_RT_LDIV: - fptr = get_vm_rt_ldiv_address(); - dereference_fptr = false; - break; - case VM_RT_IMUL: - fptr = get_imul_compactor(); - dereference_fptr = false; - break; - case VM_RT_IREM: - fptr = get_vm_rt_irem_address(); - dereference_fptr = false; - break; - case VM_RT_IDIV: - fptr = get_vm_rt_idiv_address(); - dereference_fptr = false; - break; case VM_RT_FREM: fptr = get_frem_compactor(); dereference_fptr = false; break; - case VM_RT_FDIV: - fptr = get_fdiv_compactor(); - dereference_fptr = false; - break; case VM_RT_DREM: fptr = get_drem_compactor(); dereference_fptr = false; break; - case VM_RT_DDIV: - fptr = get_fdiv_compactor(); - dereference_fptr = false; - break; case VM_RT_CHECKCAST: fptr = get_vm_rt_checkcast_address_compactor(); dereference_fptr = false; Index: vm/vmcore/src/util/ipf/base/arithmetic_helpers_ipf.cpp =================================================================== --- vm/vmcore/src/util/ipf/base/arithmetic_helpers_ipf.cpp (revision 636754) +++ vm/vmcore/src/util/ipf/base/arithmetic_helpers_ipf.cpp (working copy) @@ -77,59 +77,6 @@ } //get_vm_rt_athrow_naked_div_compactor - -int32 vm_rt_imul(int32 a, int32 b) -{ - int result = a * b; - return result; -} //vm_rt_imul - - - -int64 vm_rt_lmul(int64 a, int64 b) -{ - int64 result = a * b; - return result; -} //vm_rt_lmul - - - -int32 vm_rt_irem(int32 a, int32 b) -{ - assert(b); - int32 result = a % b; - return result; -} //vm_rt_irem - - - -int64 vm_rt_lrem(int64 a, int64 b) -{ - assert(b); - int64 result = a % b; - return result; -} //vm_rt_lrem - - - -int32 vm_rt_idiv(int32 a, int32 b) -{ - assert(b); - int32 result = a / b; - return result; -} //vm_rt_idiv - - - -int64 vm_rt_ldiv(int64 a, int64 b) -{ - assert(b); - int64 result = a / b; - return result; -} //vm_rt_ldiv - - - float vm_rt_frem(float a, float b) { float result = (float) fmod(a, b); @@ -138,14 +85,6 @@ -float vm_rt_fdiv(float a, float b) -{ - float result = a / b; - return result; -} //vm_rt_fdiv - - - double vm_rt_drem(double a, double b) { double result = fmod(a, b); @@ -154,12 +93,6 @@ -double vm_rt_ddiv(double a, double b) -{ - double result = a / b; - return result; -} //vm_rt_ddiv - // gashiman - fix _isnan on linux #ifdef PLATFORM_POSIX #define _isnan isnan @@ -201,97 +134,3 @@ } //vm_rt_f2l - -void *get_vm_rt_int_div_address_compactor(void *func, char *stub_name) -{ - void *addr = 0; - tl::MemoryPool mem_pool; - Merced_Code_Emitter emitter(mem_pool, 2, 0); - emitter.disallow_instruction_exchange(); - emitter.memory_type_is_unknown(); - - emitter.ipf_cmp(icmp_eq, cmp_none, SCRATCH_PRED_REG2, SCRATCH_PRED_REG, 33, 0, false); - - uint64 func_addr = (uint64)*(void **)func; - emit_movl_compactor(emitter, SCRATCH_GENERAL_REG, func_addr); - emitter.ipf_mtbr(SCRATCH_BRANCH_REG, SCRATCH_GENERAL_REG); - emitter.ipf_bri(br_cond, br_many, br_sptk, br_none, SCRATCH_BRANCH_REG, SCRATCH_PRED_REG); - - //The following may be broken... - uint64 vm_rt_athrow_naked_div_addr = (uint64)get_vm_rt_athrow_naked_div_compactor(); - - emit_movl_compactor(emitter, SCRATCH_GENERAL_REG, vm_rt_athrow_naked_div_addr); - - emit_movl_compactor(emitter, 33, (uint64)VM_Global_State::loader_env->java_lang_ArithmeticException_Class); - - emitter.ipf_add(32, 0, 0); - - emitter.ipf_mtbr(SCRATCH_BRANCH_REG, SCRATCH_GENERAL_REG); - emitter.ipf_bri(br_cond, br_many, br_sptk, br_none, SCRATCH_BRANCH_REG); - - addr = finalize_stub(emitter, stub_name); - return addr; -} //get_vm_rt_int_div_address_compactor - - - -void *get_vm_rt_lrem_address() -{ - static void *addr = 0; - if(addr) { - return addr; - } - - // gashiman - added (void*) to make it compile on gcc - addr = get_vm_rt_int_div_address_compactor((void*)vm_rt_lrem, "rt_lrem"); - - return addr; -} //get_vm_rt_lrem_address - - - -void *get_vm_rt_ldiv_address() -{ - static void *addr = 0; - if(addr) { - return addr; - } - - // gashiman - added (void*) to make it compile on gcc - addr = get_vm_rt_int_div_address_compactor((void*)vm_rt_ldiv, "rt_ldiv"); - - return addr; -} //get_vm_rt_ldiv_address - - - -void *get_vm_rt_irem_address() -{ - static void *addr = 0; - if(addr) { - return addr; - } - - // gashiman - added (void*) to make it compile on gcc - addr = get_vm_rt_int_div_address_compactor((void*)vm_rt_irem, "rt_irem"); - - return addr; -} //get_vm_rt_irem_address - - - -void *get_vm_rt_idiv_address() -{ - static void *addr = 0; - if(addr) { - return addr; - } - - // gashiman - added (void*) to make it compile on gcc - addr = get_vm_rt_int_div_address_compactor((void*)vm_rt_idiv, "rt_idiv"); - - return addr; -} //get_vm_rt_idiv_address - - -