harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r649545 - in /harmony/enhanced/drlvm/trunk/vm: jitrino/src/jet/ vmcore/src/init/ vmcore/src/jit/ vmcore/src/jni/
Date Fri, 18 Apr 2008 14:09:38 GMT
Author: gshimansky
Date: Fri Apr 18 07:09:35 2008
New Revision: 649545

URL: http://svn.apache.org/viewvc?rev=649545&view=rev
Log:
Applied patch from HARMONY-5322
[drlvm] Lazy resolution in JET needs to be implemented on x86_64


Modified:
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_fld_arr.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_meth.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_obj.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/compiler.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/enc.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_fld_arr.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_fld_arr.cpp?rev=649545&r1=649544&r2=649545&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_fld_arr.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_fld_arr.cpp Fri Apr 18 07:09:35 2008
@@ -244,7 +244,6 @@
         }  else { //field is not resolved -> generate code to request offset
             SYNC_FIRST(static const CallSig cs_get_offset(CCONV_HELPERS, iplatf, iplatf,
i32, i32));
             gen_call_vm(cs_get_offset, rt_helper_field_get_offset_withresolve, 0, fieldOp.enclClass,
fieldOp.cpIndex, fieldOp.isPut());
-            runlock(cs_get_offset);
             AR gr_ret = cs_get_offset.ret_reg(0);
             rlock(gr_ret);
             Val& ref = vstack(ref_depth, true);
@@ -259,7 +258,6 @@
         }  else { //field is not resolved -> generate code to request address
             SYNC_FIRST(static const CallSig cs_get_addr(CCONV_HELPERS, iplatf, iplatf, i32,
i32));
             gen_call_vm(cs_get_addr, rt_helper_field_get_address_withresolve, 0, fieldOp.enclClass,
fieldOp.cpIndex, fieldOp.isPut());
-            runlock(cs_get_addr);
             AR gr_ret = cs_get_addr.ret_reg(0);
             where = Opnd(jt, gr_ret, 0);
         }

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_meth.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_meth.cpp?rev=649545&r1=649544&r2=649545&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_meth.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_meth.cpp Fri Apr 18 07:09:35 2008
@@ -754,7 +754,6 @@
     rlock(cs);
     
     const bool is_static = opcod == OPCODE_INVOKESTATIC;
-    Val thiz = is_static ? Val() : vstack(thiz_depth, true);
     if (meth == NULL && !m_lazy_resolution) {
         runlock(cs); // was just locked above - unlock
         gen_call_throw(ci_helper_linkerr, rt_helper_throw_linking_exc, 0,
@@ -771,35 +770,6 @@
         return;
     }
     
-    if (!is_static) {
-        rlock(thiz);
-    }
-    
-    // INVOKEINTERFACE and lazy resolution must have VM helper call first, so will place

-    // its args later, after the call, to avoid destruction of args 
-    // on registers.
-    if (opcod != OPCODE_INVOKEINTERFACE && meth != NULL) {
-        stackFix = gen_stack_to_args(true, cs, 0);
-        vpark();
-        gen_gc_stack(-1, true);
-    }
-    //
-    // Check for null here - we just spilled all the args and 
-    // parked all the registers, so we have a chance to use HW NPE 
-    // For INVOKEINTERFACE we did not spill args, but we'll call VM first,
-    // which is pretty expensive by itself, so the HW check does not give 
-    // much.
-    //
-    if (!is_static) {
-        // For invokeSPECIAL, we're using indirect address provided by 
-        // the VM. This means we do not read vtable, which means no 
-        // memory access, so we can't use HW checks - have to use 
-        // explicit one. Not a big loss, as the INVOKESPECIAL mostly
-        // comes right after NEW which guarantees non-null.
-        // in lazy resolution mode we must do manual check and provide helper with
-        // non-null results.
-        gen_check_null(thiz, opcod != OPCODE_INVOKESPECIAL && meth!=NULL);
-    }
     if (meth == NULL) {
         //lazy resolution mode: get method addr and call it.
         assert(m_lazy_resolution);
@@ -807,19 +777,41 @@
         //1. get method address
         if (opcod == OPCODE_INVOKESTATIC || opcod == OPCODE_INVOKESPECIAL) {
             SYNC_FIRST(static const CallSig cs_get_is_addr(CCONV_HELPERS, iplatf, iplatf,
i32));
+            rlock(cs_get_is_addr);
+
+            if (!is_static)
+            {
+                Val &thiz = vstack(thiz_depth, false);
+                // For invokeSPECIAL, we're using indirect address provided by 
+                // the VM. This means we do not read vtable, which means no 
+                // memory access, so we can't use HW checks - have to use 
+                // explicit one. Not a big loss, as the INVOKESPECIAL mostly
+                // comes right after NEW which guarantees non-null.
+                // in lazy resolution mode we must do manual check and provide helper with
+                // non-null results.
+                gen_check_null(thiz, false);
+            }
+
             char* helper = opcod == OPCODE_INVOKESTATIC ?  rt_helper_get_invokestatic_addr_withresolve
:
                                                            rt_helper_get_invokespecial_addr_withresolve;
+            vpark(); 
             gen_call_vm(cs_get_is_addr, helper, 0, m_klass, cpIndex);
             runlock(cs_get_is_addr);
             gr_ret = cs_get_is_addr.ret_reg(0);
         } else {
             assert(opcod == OPCODE_INVOKEVIRTUAL || opcod == OPCODE_INVOKEINTERFACE);
             SYNC_FIRST(static const CallSig cs_get_iv_addr(CCONV_HELPERS, iplatf, iplatf,
i32, jobj));
+            rlock(cs_get_iv_addr);
+
+            Val &thiz = vstack(thiz_depth, false);
+            gen_check_null(thiz, false);
+
             char * helper = opcod == OPCODE_INVOKEVIRTUAL ? rt_helper_get_invokevirtual_addr_withresolve
: 
                                                             rt_helper_get_invokeinterface_addr_withresolve;
             // setup constant parameters first,
             Val vclass(iplatf, m_klass);
             Val vcpIdx(cpIndex);
+            vpark();
             gen_args(cs_get_iv_addr, 0, &vclass, &vcpIdx, &thiz);
             gen_call_vm(cs_get_iv_addr, helper, 3);
             runlock(cs_get_iv_addr);
@@ -841,6 +833,12 @@
         // if it's INVOKEINTERFACE, then first resolve it
         Class_Handle klass = method_get_class(meth);
         const CallSig cs_vtbl(CCONV_HELPERS, iplatf, jobj, jobj);
+        rlock(cs_vtbl);
+
+        Val &thiz = vstack(thiz_depth, true);
+        rlock(thiz);
+        gen_check_null(thiz, true);
+
         // Prepare args for ldInterface helper
         if (cs_vtbl.reg(0) == gr_x) {
             assert(cs_vtbl.size() != 0);
@@ -854,8 +852,10 @@
             }
             mov(cs_vtbl.get(0), thiz.as_opnd());
         }
+        runlock(thiz);
         gen_call_vm(cs_vtbl, rt_helper_get_vtable, 1, klass);
         AR gr_ret = cs_vtbl.ret_reg(0);
+        runlock(cs_vtbl);
         //
         // Method's vtable is in gr_ret now, prepare stack
         //
@@ -871,9 +871,20 @@
         call(gr_ret, cs, is_set(DBG_CHECK_STACK));
     }
     else if (opcod == OPCODE_INVOKEVIRTUAL) {
+        Val &thiz = vstack(thiz_depth, true);
+        rlock(thiz);
+
+        stackFix = gen_stack_to_args(true, cs, 0);
+        vpark();
+        gen_gc_stack(-1, true);
+        // Check for null here - we just spilled all the args and 
+        // parked all the registers, so we have a chance to use HW NPE 
+        gen_check_null(thiz, true);
+
         AR gr = valloc(jobj);
         unsigned offset = method_get_vtable_offset(meth);
         Opnd ptr;
+
         if (g_vtbl_squeeze) {
             ld4(gr, thiz.reg(), rt_vtable_offset);
             AR gr_vtbase = valloc(jobj);
@@ -886,8 +897,30 @@
             ptr = Opnd(jobj, gr, offset);
         }
         call(ptr, cs, is_set(DBG_CHECK_STACK));
+        runlock(thiz);
     }
     else {
+        Val *thiz = NULL;
+
+        if (!is_static)
+            thiz = &vstack(thiz_depth, true);
+
+        stackFix = gen_stack_to_args(true, cs, 0);
+        vpark();
+        gen_gc_stack(-1, true);
+
+        if (!is_static)
+            // Check for null here - we just spilled all the args and 
+            // parked all the registers, so we have a chance to use HW NPE 
+            // For invokeSPECIAL, we're using indirect address provided by 
+            // the VM. This means we do not read vtable, which means no 
+            // memory access, so we can't use HW checks - have to use 
+            // explicit one. Not a big loss, as the INVOKESPECIAL mostly
+            // comes right after NEW which guarantees non-null.
+            // in lazy resolution mode we must do manual check and provide helper with
+            // non-null results.
+            gen_check_null(*thiz, false);
+
         void * paddr = method_get_indirect_address(meth);
 #ifdef _IA32_
         Opnd ptr(jobj, ar_x, paddr);
@@ -900,9 +933,6 @@
         call(ptr, cs, is_set(DBG_CHECK_STACK));
     }
     
-    if (!is_static) {
-        runlock(thiz);
-    }
     // to unlock after gen_stack_to_args()
     runlock(cs);
     // to unlock after explicit lock at the top of this method
@@ -931,7 +961,7 @@
         if (args[i] == 0) {
             break;
         }
-        rlock(*args[0]);
+        rlock(*args[i]);
     }
     // 2nd, generate moves
     for (unsigned i=0; i<steps; i++) {
@@ -942,7 +972,7 @@
         Opnd arg = cs.get(id);
         do_mov(arg, *args[i]);
         // 3d, unlock when not needed anymore
-        runlock(*args[0]);
+        runlock(*args[i]);
     }
 }
 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_obj.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_obj.cpp?rev=649545&r1=649544&r2=649545&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_obj.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_obj.cpp Fri Apr 18 07:09:35 2008
@@ -58,13 +58,16 @@
         return;
     } 
     assert(lazy);
+    vpark();
     SYNC_FIRST(static const CallSig cs_newarray_withresolve(CCONV_HELPERS, jobj, iplatf,
i32, i32));
+    rlock(cs_newarray_withresolve);
     Val sizeVal = vstack(0);
     // setup constant parameters first,
     Val vclass(iplatf, enclClass);
     Val vcpIdx((int)cpIndex);
     gen_args(cs_newarray_withresolve, 0, &vclass, &vcpIdx, &sizeVal);
     gen_call_vm(cs_newarray_withresolve, rt_helper_new_array_withresolve, 3);
+    runlock(cs_newarray_withresolve);
     vpop();// pop array size
     gen_save_ret(cs_newarray_withresolve);
 
@@ -123,7 +126,6 @@
         assert(lazy);
         SYNC_FIRST(static const CallSig ci_get_class_withresolve(CCONV_HELPERS, jobj, iplatf,
i32));
         gen_call_vm(ci_get_class_withresolve, rt_helper_get_class_withresolve, 0, enclClass,
cpIndex);
-        runlock(ci_get_class_withresolve);
         AR gr_ret = ci_get_class_withresolve.ret_reg(0);
         klassVal = Val(jobj, gr_ret);
     }  else {
@@ -214,9 +216,11 @@
         gen_save_ret(cs);
     } else {
         assert(lazy);
+        vpark();
         SYNC_FIRST(static const CallSig cs_checkcast_with_resolve(CCONV_HELPERS, jobj, iplatf,
i32, jobj));
         SYNC_FIRST(static const CallSig cs_instanceof_with_resolve(CCONV_HELPERS, i32, iplatf,
i32, jobj));
         const CallSig& cs_with_resolve = (opcode == OPCODE_CHECKCAST) ? cs_checkcast_with_resolve
: cs_instanceof_with_resolve;
+        rlock(cs_with_resolve);
         char * helper = (opcode == OPCODE_CHECKCAST) ? rt_helper_checkcast_withresolve :
rt_helper_instanceof_withresolve;
         Val tos = vstack(0);
         // setup constant parameters first,

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/compiler.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/compiler.cpp?rev=649545&r1=649544&r2=649545&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/compiler.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/compiler.cpp Fri Apr 18 07:09:35 2008
@@ -163,11 +163,8 @@
     if (!get_bool_arg("bbp", true)) {
         compile_flags &= ~JMF_BBPOLLING;
     }
-#ifndef _EM64T_    
+
     m_lazy_resolution  = get_bool_arg("lazyResolution", true);
-#else
-    m_lazy_resolution  = get_bool_arg("lazyResolution", false);
-#endif
 
 #ifdef _DEBUG
     bool assertOnRecursion = get_bool_arg("assertOnRecursion", false);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/enc.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/enc.cpp?rev=649545&r1=649544&r2=649545&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/enc.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/enc.cpp Fri Apr 18 07:09:35 2008
@@ -369,14 +369,24 @@
                 mov(Opnd(i32, sp, cs.off(i)), val);
             }
             else {
+#ifdef _EM64T_
+                long val = va_arg(valist, long);
+                mov(Opnd(i64, sp, cs.off(i)), val);
+#else
                 int val = lo32((jlong)(int_ptr)addr);
                 mov(Opnd(i32, sp, cs.off(i)), val);
                 val = hi32((jlong)(int_ptr)addr);
                 mov(Opnd(i32, sp, cs.off(i)+4), val);
+#endif
             }
         }
         else if (jt==i64) {
+#ifdef _EM64T_
+            long val = va_arg(valist, long);
+            mov(gr == gr_x ? Opnd(i64, sp, cs.off(i)) : Opnd(i64, gr), val);
+#else
             assert(false);
+#endif
         }
         else {
             int val = va_arg(valist, int);

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp?rev=649545&r1=649544&r2=649545&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp Fri Apr 18 07:09:35 2008
@@ -509,6 +509,15 @@
     vm_env->java_lang_ThreadDeath_Class = 
         preload_class(vm_env, "java/lang/ThreadDeath");
 
+    // String must be initialized before strings from intern pool are
+    // used. But for initializing l.j.String we need to have exception
+    // classes loaded, because the first call to compilations
+    // initializes all of the JIT helpers that hardcode class handles
+    // inside of the helpers.
+    hythread_suspend_disable();
+    class_initialize(vm_env->JavaLangString_Class);
+    hythread_suspend_enable();
+
     vm_env->java_lang_Cloneable_Class =
         preload_class(vm_env, vm_env->Clonable_String);
     vm_env->java_lang_Thread_Class =
@@ -899,10 +908,9 @@
     // Precompile InternalError.
     class_alloc_new_object_and_run_default_constructor(vm_env->java_lang_InternalError_Class);
 
-    //String must be initialized before strings from intern pool are used
-    class_initialize(vm_env->JavaLangString_Class);
-
-
+    // j.l.Class needs to be initialized for loading magics helper
+    // class
+    class_initialize(vm_env->JavaLangClass_Class);
     hythread_suspend_enable();
 
     Method * m;

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp?rev=649545&r1=649544&r2=649545&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp Fri Apr 18 07:09:35
2008
@@ -1382,9 +1382,9 @@
     ASSERT_THROW_AREA;
 
     Global_Env* env = VM_Global_State::loader_env;
-    if (obj == NULL) {
+    if (obj == (ManagedObject*)VM_Global_State::loader_env->managed_null) {
         exn_throw_by_class(env->java_lang_NullPointerException_Class);
-        return NULL;
+        return obj;
     }
 
     Method* m = NULL;
@@ -1434,17 +1434,17 @@
     ASSERT_THROW_AREA;
 
     Global_Env* env = VM_Global_State::loader_env;
-    if (obj == NULL) {
+    if (obj == (ManagedObject*)VM_Global_State::loader_env->managed_null) {
+
+        //Returning zero address and not generating NPE if the object is null 
+        //is safe in terms of preserving program semantics(the exception will be generated

+        //on the first method invocation) and
+        //allows profitable code transformations such as hoisting vm helper outside the loop
body 
+        //This is our current convention which touches all variants of this helper, 
+        //If it changes, all variants must be fixed. 
 
-    //Returning zero address and not generating NPE if the object is null 
-    //is safe in terms of preserving program semantics(the exception will be generated 
-    //on the first method invocation) and
-    //allows profitable code transformations such as hoisting vm helper outside the loop
body 
-    //This is our current convention which touches all variants of this helper, 
-    //If it changes, all variants must be fixed. 
-            
         //exn_throw_by_class(env->java_lang_NullPointerException_Class);
-        return NULL;
+        return obj;
     }
 
     Method* m = NULL;
@@ -1576,7 +1576,7 @@
 ///OPCODE_CHECKCAST
 
 static void *rth_checkcast_withresolve(Class_Handle klass, unsigned cp_idx, ManagedObject*
obj) {
-    if (obj==NULL) {
+    if (obj == (ManagedObject*)VM_Global_State::loader_env->managed_null) {
         return obj;
     }
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp?rev=649545&r1=649544&r2=649545&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp Fri Apr 18 07:09:35 2008
@@ -1032,6 +1032,9 @@
         ThrowNew_Quick(jni_env, "java/lang/InstantiationException", clss->get_name()->bytes);
         return NULL;
     }
+    if (!ensure_initialised(jni_env, clss)) {
+        return NULL;
+    }
 
     tmn_suspend_disable();      //---------------------------------v
     ManagedObject *new_obj = (ManagedObject *)class_alloc_new_object(clss);



Mime
View raw message