harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r419557 - in /incubator/harmony/enhanced/drlvm/trunk/vm: interpreter/src/interpreter.cpp vmcore/src/init/vm.cpp vmcore/src/jit/jit_runtime_support.cpp vmcore/src/verifier/Verifier.cpp
Date Thu, 06 Jul 2006 14:02:51 GMT
Author: geirm
Date: Thu Jul  6 07:02:51 2006
New Revision: 419557

URL: http://svn.apache.org/viewvc?rev=419557&view=rev
Log:
HARMONY-677 

minimal 1.5 class support - DRLVM can handle v49 classfiles


Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/Verifier.cpp

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp?rev=419557&r1=419556&r2=419557&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp Thu Jul  6 07:02:51
2006
@@ -13,10 +13,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/** 
- * @author Ivan Volosyuk
- * @version $Revision: 1.61.4.15.4.4 $
- */  
 #include "interpreter.h"
 #include "interpreter_exports.h"
 #include "interpreter_imports.h"
@@ -955,18 +951,22 @@
 
 #ifndef NDEBUG
     switch(cp_tag(cp, index)) {
-        case 8:
+        case CONSTANT_String:
             DEBUG_BYTECODE("#" << dec << (int)index << " String: \"" <<
cp[index].CONSTANT_String.string->bytes << "\"");
             break;
-        case 3:
+        case CONSTANT_Integer:
             DEBUG_BYTECODE("#" << dec << (int)index << " Integer: " <<
(int)cp[index].int_value);
             break;
-        case 4:
+        case CONSTANT_Float:
             DEBUG_BYTECODE("#" << dec << (int)index << " Float: " <<
cp[index].float_value);
             break;
+        case CONSTANT_Class:
+            DEBUG_BYTECODE("#" << dec << (int)index << " Class: \"" <<
const_pool_get_class_name(clazz, index) << "\"");
+            break;
         default:
             DEBUG_BYTECODE("#" << dec << (int)index << " Unknown type =
" << cp_tag(cp, index));
-            ABORT("Unknown type");
+            DIE("ldc instruction: unexpected type (" << cp_tag(cp, index) 
+                << ") of constant pool entry [" << index << "]");
             break;
     }
 #endif
@@ -979,6 +979,19 @@
         // FIXME: only compressed references
         frame.stack.pick().cr = COMPRESS_REF(vm_instantiate_cp_string_resolved(str));
         frame.stack.ref() = FLAG_OBJECT;
+        return !exn_raised();
+    } 
+    else if (cp_is_class(cp, index)) 
+    {
+        Class *other_class = interp_resolve_class(clazz, index);
+        if (!other_class) {
+             return false;
+        }
+        assert(!tmn_is_suspend_enabled());
+        
+        frame.stack.pick().cr = COMPRESS_REF(*(other_class->class_handle));
+        frame.stack.ref() = FLAG_OBJECT;
+        
         return !exn_raised();
     }
     

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm.cpp?rev=419557&r1=419556&r2=419557&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm.cpp Thu Jul  6 07:02:51 2006
@@ -115,25 +115,25 @@
 
 
 // A run-time error occurs if called for an index which does not represent
-// a constant of type String, Integer, Float, Long or Double.
+// a constant of type Class, String, Integer, Float, Long or Double.
 Java_Type class_get_cp_const_type(Class *clss, unsigned cp_index)
 {
     Const_Pool *cp = clss->const_pool;
-    assert(cp_is_constant(cp, cp_index));
     switch(cp_tag(cp, cp_index)) {
     case CONSTANT_String:
         return JAVA_TYPE_STRING;
     case CONSTANT_Integer:
-            return JAVA_TYPE_INT;
+        return JAVA_TYPE_INT;
     case CONSTANT_Float:
-            return JAVA_TYPE_FLOAT;
+        return JAVA_TYPE_FLOAT;
     case CONSTANT_Long:
-            return JAVA_TYPE_LONG;
+        return JAVA_TYPE_LONG;
     case CONSTANT_Double:
-            return JAVA_TYPE_DOUBLE;
-    
+        return JAVA_TYPE_DOUBLE;
+    case CONSTANT_Class:
+        return JAVA_TYPE_CLASS;
     default:
-        DIE("unknown constant type in classfile");
+        DIE("non-constant type is requested from constant pool : " << cp_tag(cp, cp_index));
     }
     return JAVA_TYPE_INVALID;
 } //class_get_cp_const_type

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp?rev=419557&r1=419556&r2=419557&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp Thu Jul
 6 07:02:51 2006
@@ -154,14 +154,40 @@
 }
 
 ///////////////////////////////////////////////////////////
-// Load Constant String
+// Load Constant String or Class
 
-static NativeCodePtr rth_get_lil_ldc_string(int* dyn_count)
+static ManagedObject * rth_ldc_ref_helper(Class *c, unsigned cp_index) 
+    {
+    Const_Pool *cp = c->const_pool;
+    if (cp_is_string(cp, cp_index)) 
+    {
+        return vm_instantiate_cp_string_slow(c, cp_index);
+    } 
+    else if (cp_is_class(cp, cp_index)) 
+    {
+        assert(!tmn_is_suspend_enabled());
+        tmn_suspend_enable();
+        Class *objClass = class_resolve_class(c, cp_index); 
+        tmn_suspend_disable();
+        if (objClass) {
+            return struct_Class_to_java_lang_Class(objClass);
+        }
+        if (!exn_raised()) {
+            class_throw_linking_error(c, cp_index, 0);
+        } else {
+            exn_throw(exn_get());
+        }
+    }
+    exn_throw_by_name("java/lang/InternalError", "Unsupported ldc argument");
+    return NULL;
+}
+
+static NativeCodePtr rth_get_lil_ldc_ref(int* dyn_count)
 {
     static NativeCodePtr addr = NULL;
 
     if (!addr) {
-        ManagedObject* (*p_instantiate_string)(Class*,unsigned) = vm_instantiate_cp_string_slow;
+        ManagedObject* (*p_instantiate_ref)(Class*,unsigned) = rth_ldc_ref_helper;
         LilCodeStub* cs = lil_parse_code_stub("entry 0:managed:g4,pint:ref;");
         assert(cs);
         if (dyn_count) {
@@ -176,9 +202,9 @@
             "call %0i;"
             "pop_m2n;"
             "ret;",
-            p_instantiate_string);
+            p_instantiate_ref);
         assert(cs && lil_is_valid(cs));
-        addr = LilCodeGenerator::get_platform()->compile(cs, "rth_ldc_string", dump_stubs);
+        addr = LilCodeGenerator::get_platform()->compile(cs, "rth_ldc_ref", dump_stubs);
         lil_free_code_stub(cs);
     }
 
@@ -1665,7 +1691,7 @@
     case VM_RT_MULTIANEWARRAY_RESOLVED:
         return rth_get_lil_multianewarray(dyn_count);
     case VM_RT_LDC_STRING:
-        return rth_get_lil_ldc_string(dyn_count);
+        return rth_get_lil_ldc_ref(dyn_count);
         // Exceptions
     case VM_RT_THROW:
     case VM_RT_THROW_SET_STACK_TRACE:

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/Verifier.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/Verifier.cpp?rev=419557&r1=419556&r2=419557&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/Verifier.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/Verifier.cpp Thu Jul  6
07:02:51 2006
@@ -1747,12 +1747,16 @@
         type = ctex->m_type->NewType( "Ljava/lang/String", 17 );
         vf_set_vector_stack_entry_ref( cp_parse->field.f_vector, 0, type );
         break;
+	case _CONSTANT_Class:
+        type = ctex->m_type->NewType( "Ljava/lang/Class", 16 );
+        vf_set_vector_stack_entry_ref( cp_parse->field.f_vector, 0, type );
+		break;
     default:
         VERIFY_REPORT( ctex, "(class: " << class_get_name( ctex->m_class )
             << ", method: " << method_get_name( ctex->m_method )
             << method_get_descriptor( ctex->m_method )
             << ") Illegal type in constant pool,"
-            << index << ": CONSTANT_Integer, CONSTANT_Float or CONSTANT_String
are expected" );
+            << index << ": CONSTANT_Integer, CONSTANT_Float, CONSTANT_String
or CONSTANT_Class are expected" );
         return VER_ErrorConstantPool;
     }
     return VER_OK;



Mime
View raw message