You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by wj...@apache.org on 2006/11/09 05:52:17 UTC
svn commit: r472771 [9/11] - in /incubator/harmony/enhanced/drlvm/trunk/vm:
gc_cc/src/ gcv4/src/ include/ include/open/ interpreter/src/
jitrino/src/jet/ jitrino/src/vm/drl/ port/src/lil/ia32/pim/
port/src/lil/pim/ vmcore/include/ vmcore/src/class_supp...
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/method_lookup.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/method_lookup.cpp?view=diff&rev=472771&r1=472770&r2=472771
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/method_lookup.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/method_lookup.cpp Wed Nov 8 20:52:12 2006
@@ -30,6 +30,8 @@
#include "lock_manager.h"
#include "nogc.h"
#include "vm_stats.h"
+#include "cci.h"
+#include "class_member.h"
#include "method_lookup.h"
@@ -268,7 +270,7 @@
num++;
printf("%8" FMT64 "u :::: %s.%s%s\n",
m->num_throws,
- m->get_method()->get_class()->name->bytes,
+ m->get_method()->get_class()->get_name()->bytes,
m->get_method()->get_name()->bytes,
m->get_method()->get_descriptor()->bytes);
}
@@ -285,7 +287,7 @@
num++;
printf("%8" FMT64 "u :::: %s.%s%s\n",
m->num_catches,
- m->get_method()->get_class()->name->bytes,
+ m->get_method()->get_class()->get_name()->bytes,
m->get_method()->get_name()->bytes,
m->get_method()->get_descriptor()->bytes);
}
@@ -302,7 +304,7 @@
num++;
printf("%8" FMT64 "u :::: %s.%s%s\n",
m->num_unwind_java_frames_gc,
- m->get_method()->get_class()->name->bytes,
+ m->get_method()->get_class()->get_name()->bytes,
m->get_method()->get_name()->bytes,
m->get_method()->get_descriptor()->bytes);
}
@@ -317,7 +319,7 @@
num++;
printf("%8" FMT64 "u :::: %s.%s%s\n",
m->num_unwind_java_frames_non_gc,
- m->get_method()->get_class()->name->bytes,
+ m->get_method()->get_class()->get_name()->bytes,
m->get_method()->get_name()->bytes,
m->get_method()->get_descriptor()->bytes);
}
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/type.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/type.cpp?view=diff&rev=472771&r1=472770&r2=472771
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/type.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/type.cpp Wed Nov 8 20:52:12 2006
@@ -163,12 +163,12 @@
default:
ABORT("Unexpected data type");
}
- td = new TypeDesc(k, NULL, NULL, NULL, c->class_loader, c);
+ td = new TypeDesc(k, NULL, NULL, NULL, c->get_class_loader(), c);
} else if (class_is_array(c)) {
- td = new TypeDesc(K_Vector, NULL, NULL, NULL, c->class_loader, c);
+ td = new TypeDesc(K_Vector, NULL, NULL, NULL, c->get_class_loader(), c);
} else {
Kind k = K_Object;
- td = new TypeDesc(k, NULL, NULL, NULL, c->class_loader, c);
+ td = new TypeDesc(k, NULL, NULL, NULL, c->get_class_loader(), c);
}
assert(td);
return td;
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions.cpp?view=diff&rev=472771&r1=472770&r2=472771
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions.cpp Wed Nov 8 20:52:12 2006
@@ -34,6 +34,7 @@
#include "object_handles.h"
#include "vm_arrays.h"
#include "vm_strings.h"
+#include "cci.h"
bool exn_raised()
@@ -406,7 +407,7 @@
return;
tmn_suspend_disable();
- const char *exceptionNameChars = exc->object->vt()->clss->name->bytes;
+ const char* exceptionNameChars = exc->object->vt()->clss->get_name()->bytes;
tmn_suspend_enable();
const char *messageChars = GetStringUTFChars(jenv, message, false);
fprintf(f, "\n%s : %s\n", exceptionNameChars, messageChars);
@@ -625,7 +626,7 @@
tmn_suspend_disable();
fprintf(f, "** During %s uncaught exception: %s\n", context_message,
- exc->object->vt()->clss->name->bytes);
+ exc->object->vt()->clss->get_name()->bytes);
tmn_suspend_enable();
exn_print_stack_trace(f, exc);
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_impl.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_impl.cpp?view=diff&rev=472771&r1=472770&r2=472771
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_impl.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_impl.cpp Wed Nov 8 20:52:12 2006
@@ -55,7 +55,7 @@
// Get the method for the constructor
String *init_name = env->Init_String;
String *init_descr = env->string_pool.lookup(signature);
- Method *exc_init = class_lookup_method(exc_class, init_name, init_descr);
+ Method *exc_init = exc_class->lookup_method(init_name, init_descr);
return exc_init;
}
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp?view=diff&rev=472771&r1=472770&r2=472771
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp Wed Nov 8 20:52:12 2006
@@ -42,6 +42,7 @@
#include "stack_iterator.h"
#include "vm_stats.h"
#include "jvmti_break_intf.h"
+#include "cci.h"
#ifdef _IPF_
#elif defined _EM64T_
@@ -193,7 +194,7 @@
exn_class = (*exn_obj)->vt()->clss;
#ifdef VM_STATS
- ((Class *) exn_class)->num_throws++;
+ exn_class->class_thrown();
VM_Statistics::get_vm_stats().num_exceptions++;
#endif // VM_STATS
@@ -529,7 +530,8 @@
if (VM_Global_State::loader_env->compress_references)
cs = lil_parse_onto_end(cs,
"jc i0=%0i:ref,%n;"
- "o0=i0;" "j %o;" ":%g;" "o0=0:ref;" ":%g;", Class::heap_base);
+ "o0=i0;" "j %o;" ":%g;" "o0=0:ref;" ":%g;",
+ VM_Global_State::loader_env->heap_base);
else
cs = lil_parse_onto_end(cs, "o0=i0;");
assert(cs);
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/dll_gc.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/dll_gc.cpp?view=diff&rev=472771&r1=472770&r2=472771
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/dll_gc.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/dll_gc.cpp Wed Nov 8 20:52:12 2006
@@ -19,8 +19,6 @@
* @version $Revision: 1.1.2.2.4.3 $
*/
-
-
#define LOG_DOMAIN "vm.core"
#include "cxxlog.h"
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/root_set_enum_common.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/root_set_enum_common.cpp?view=diff&rev=472771&r1=472770&r2=472771
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/root_set_enum_common.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/root_set_enum_common.cpp Wed Nov 8 20:52:12 2006
@@ -29,7 +29,9 @@
#include "vm_stats.h"
#include "m2n.h"
#include "open/vm_util.h"
+#include "open/gc.h"
#include "finalize.h"
+#include "cci.h"
void vm_enumerate_interned_strings()
{
@@ -80,24 +82,22 @@
assert(*ppc);
Class* c = jclass_to_struct_Class((jclass)ppc);
- if (c->p_error) {
+ if(c->in_error()) {
vm_enumerate_root_reference(
- (void**)&c->p_error ,FALSE);
+ (void**)c->get_error_cause() ,FALSE);
}
vm_enumerate_root_reference((void**)ppc, FALSE);
- Const_Pool* cp = c->m_failedResolution;
+ ConstPoolEntry* cp = c->get_constant_pool().get_error_chain();
while(cp) {
vm_enumerate_root_reference((void**)(&(cp->error.cause)), FALSE);
cp = cp->error.next;
}
// Finally enumerate the static fields of the class
- unsigned n_fields = c->n_fields;
- if((c->state == ST_Prepared)
- || (c->state == ST_Initializing)
- || (c->state == ST_Initialized)) {
+ unsigned n_fields = c->get_number_of_fields();
+ if(c->is_at_least_prepared()) {
// Class has been prepared, so we can iterate over all its fields.
for(unsigned i = 0; i < n_fields; i++) {
- Field *f = &c->fields[i];
+ Field* f = c->get_field(i);
if(f->is_static()) {
char desc0 = f->get_descriptor()->bytes[0];
if(desc0 == 'L' || desc0 == '[') {
@@ -134,9 +134,10 @@
ManagedObject **p_obj = (ManagedObject **)ref;
ManagedObject* obj = *p_obj;
assert(obj != NULL); // See the comment at the top of the procedure.
- if ((void *)obj != Class::heap_base) {
- assert(((POINTER_SIZE_INT)Class::heap_base <= (POINTER_SIZE_INT)obj) && ((POINTER_SIZE_INT)obj <= (POINTER_SIZE_INT)Class::heap_end));
- (obj->vt())->clss->name->bytes;
+ if ((void *)obj != VM_Global_State::loader_env->heap_base) {
+ assert(((POINTER_SIZE_INT)VM_Global_State::loader_env->heap_base <= (POINTER_SIZE_INT)obj)
+ && ((POINTER_SIZE_INT)obj <= (POINTER_SIZE_INT)VM_Global_State::loader_env->heap_end));
+ (obj->vt())->clss->get_name()->bytes;
}
}
#endif // _DEBUG
@@ -156,11 +157,12 @@
COMPRESSED_REFERENCE compressed_ref = *ref;
ManagedObject* obj = (ManagedObject *)uncompress_compressed_reference(compressed_ref);
bool is_null = (compressed_ref == 0);
- bool is_in_heap = (((POINTER_SIZE_INT)Class::heap_base <= (POINTER_SIZE_INT)obj) && ((POINTER_SIZE_INT)obj <= (POINTER_SIZE_INT)Class::heap_end));
+ bool is_in_heap = (((POINTER_SIZE_INT)VM_Global_State::loader_env->heap_base <= (POINTER_SIZE_INT)obj)
+ && ((POINTER_SIZE_INT)obj <= (POINTER_SIZE_INT)VM_Global_State::loader_env->heap_end));
if (is_null || is_in_heap) {
// Make sure the reference is valid.
if (!is_null) {
- (obj->vt())->clss->name->bytes;
+ (obj->vt())->clss->get_name()->bytes;
}
} else {
ASSERT(0, "Bad slot pointer");
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?view=diff&rev=472771&r1=472770&r2=472771
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm.cpp Wed Nov 8 20:52:12 2006
@@ -70,27 +70,8 @@
// begin Class
/////////////////////////////////////////////////////////////////
-Field* class_resolve_field(Class* clss, unsigned cp_index)
-{
- Compilation_Handle ch;
- ch.env = VM_Global_State::loader_env;
- ch.jit = NULL;
- Field_Handle fh = resolve_field(&ch, (Class_Handle)clss, cp_index);
- return (Field *)fh;
-}
-
-
-Method *class_resolve_method(Class *clss, unsigned cp_index)
-{
- Compilation_Handle ch;
- ch.env = VM_Global_State::loader_env;
- ch.jit = NULL;
- Method_Handle fh = resolve_method(&ch, (Class_Handle)clss, cp_index);
- return (Method *)fh;
-} //class_resolve_static_field
-
-Field *class_resolve_nonstatic_field(Class *clss, unsigned cp_index)
+Field* class_resolve_nonstatic_field(Class* clss, unsigned cp_index)
{
Compilation_Handle ch;
ch.env = VM_Global_State::loader_env;
@@ -99,55 +80,8 @@
if(!fh || field_is_static(fh))
return NULL;
return fh;
-} //class_resolve_static_field
-
-
-Class *class_resolve_class(Class *clss, unsigned cp_index)
-{
- Compilation_Handle ch;
- ch.env = VM_Global_State::loader_env;
- ch.jit = NULL;
- return resolve_class(&ch, clss, cp_index);
-} //class_resolve_class
-
-
-
-
-// A run-time error occurs if called for an index which does not represent
-// 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;
- switch(cp_tag(cp, cp_index)) {
- case CONSTANT_String:
- return JAVA_TYPE_STRING;
- case CONSTANT_Integer:
- return JAVA_TYPE_INT;
- case CONSTANT_Float:
- return JAVA_TYPE_FLOAT;
- case CONSTANT_Long:
- return JAVA_TYPE_LONG;
- case CONSTANT_Double:
- return JAVA_TYPE_DOUBLE;
- case CONSTANT_Class:
- return JAVA_TYPE_CLASS;
- default:
- DIE("non-constant type is requested from constant pool : " << cp_tag(cp, cp_index));
- }
- return JAVA_TYPE_INVALID;
-} //class_get_cp_const_type
-
-
-
-// Returns an address of an int, float, etc.
-// For a string it returns a pointer to the utf8 representation of the string.
-const void *class_get_addr_of_constant(Class *clss, unsigned cp_index)
-{
- Const_Pool *cp = clss->const_pool;
- assert(cp_tag(cp, cp_index) != CONSTANT_String);
+} // class_resolve_nonstatic_field
- return (void *)(cp + cp_index);
-} //class_get_addr_of_constant
/////////////////////////////////////////////////////////////////
// end Class
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp?view=diff&rev=472771&r1=472770&r2=472771
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp Wed Nov 8 20:52:12 2006
@@ -75,7 +75,7 @@
delete p_method_call_lock;
}
-Class * preload_class(Global_Env * vm_env, const char * classname) {
+Class* preload_class(Global_Env * vm_env, const char * classname) {
String * s = vm_env->string_pool.lookup(classname);
return vm_env->LoadCoreClass(s);
}
@@ -88,13 +88,10 @@
String * s = vm_env->string_pool.lookup(classname);
ClassLoader * cl = vm_env->bootstrap_class_loader;
Class *clss = cl->NewClass(vm_env, s);
- clss->is_primitive = 1;
- clss->class_loader = cl;
- clss->access_flags = ACC_ABSTRACT | ACC_FINAL | ACC_PUBLIC;
- clss->is_verified = 2;
+ clss->setup_as_primitive(cl);
cl->InsertClass(clss);
- class_prepare(vm_env, clss);
+ clss->prepare(vm_env);
return clss;
}
@@ -123,8 +120,8 @@
// and set its "vm_class" field to point back to that structure.
void create_instance_for_class(Global_Env * vm_env, Class *clss)
{
- clss->class_loader->AllocateAndReportInstance(vm_env, clss);
-}
+ clss->get_class_loader()->AllocateAndReportInstance(vm_env, clss);
+} //create_instance_for_class
/**
* Loads DLLs.
@@ -276,6 +273,9 @@
vm_env->StartVMBootstrap();
vm_env->JavaLangObject_Class = preload_class(vm_env, vm_env->JavaLangObject_String);
vm_env->java_io_Serializable_Class = preload_class(vm_env, vm_env->Serializable_String);
+ Class* AnnotatedElement_Class = preload_class(vm_env, "java/lang/reflect/AnnotatedElement");
+ Class* GenericDeclaration_Class = preload_class(vm_env, "java/lang/reflect/GenericDeclaration");
+ Class* Type_Class = preload_class(vm_env, "java/lang/reflect/Type");
vm_env->JavaLangClass_Class = preload_class(vm_env, vm_env->JavaLangClass_String);
vm_env->FinishVMBootstrap();
@@ -293,15 +293,10 @@
}
jvmti_send_class_load_event(vm_env, booted);
jvmti_send_class_prepare_event(booted);
- }
+ }
-#ifdef VM_STATS
- // Account for the classes loaded before vm_env->JavaLangObject_Class is set.
- vm_env->JavaLangObject_Class->num_allocations += num;
- vm_env->JavaLangObject_Class->num_bytes_allocated += (num * vm_env->JavaLangClass_Class->instance_data_size);
-#endif //VM_STATS
TRACE("bootstrapping initial java classes complete");
-}
+} // bootstrap_initial_java_classes
/**
* Loads hot classes.
@@ -331,24 +326,12 @@
vm_env->ArrayOfFloat_Class = preload_class(vm_env, "[F");
vm_env->ArrayOfDouble_Class = preload_class(vm_env, "[D");
-#ifndef POINTER64
- // In IA32, Arrays of Doubles need to be eight byte aligned to improve
- // performance. In IPF all objects (arrays, class data structures, heap objects)
- // get aligned on eight byte boundaries. So, this special code is not needed.
- vm_env->ArrayOfDouble_Class->alignment = ((GC_OBJECT_ALIGNMENT < 8) ? 8: GC_OBJECT_ALIGNMENT);
- // The alignment is either 4 or it is a multiple of 8. Things like 12 aren't allowed.
- assert ((GC_OBJECT_ALIGNMENT == 4) || ((GC_OBJECT_ALIGNMENT % 8) == 0));
- // align doubles on 8, clear alignment field and put in 8.
- set_prop_alignment_mask(vm_env->ArrayOfDouble_Class, 8);
- // Set high bit in size so that gc knows there are constraints
-#endif
-
TRACE2("init", "preloading string class");
vm_env->JavaLangString_Class = preload_class(vm_env, vm_env->JavaLangString_String);
vm_env->strings_are_compressed =
(class_lookup_field_recursive(vm_env->JavaLangString_Class, "bvalue", "[B") != NULL);
- vm_env->JavaLangString_VTable = vm_env->JavaLangString_Class->vtable;
- vm_env->JavaLangString_allocation_handle = vm_env->JavaLangString_Class->allocation_handle;
+ vm_env->JavaLangString_VTable = vm_env->JavaLangString_Class->get_vtable();
+ vm_env->JavaLangString_allocation_handle = vm_env->JavaLangString_Class->get_allocation_handle();
TRACE2("init", "preloading exceptions");
vm_env->java_lang_Throwable_Class =
@@ -488,7 +471,7 @@
assert(!hythread_is_suspend_enabled());
vm_env = jni_get_vm_env(jni_env);
-
+
thread_class = vm_env->java_lang_Thread_Class;
class_initialize(thread_class);
if (exn_raised()) return TM_ERROR_INTERNAL;
@@ -504,7 +487,8 @@
if (constructor == NULL) {
// Initialize created thread object.
- constructor = class_lookup_method_init(thread_class, descriptor);
+ constructor = thread_class->lookup_method(vm_env->Init_String,
+ vm_env->string_pool.lookup(descriptor));
if (constructor == NULL) {
TRACE("Failed to find thread's constructor " << descriptor << " , exception = " << exn_get());
return JNI_ERR;
@@ -649,9 +633,9 @@
Slot::init(gc_heap_base_address(), gc_heap_ceiling_address());
// TODO: find another way to initialize the following.
- Class::heap_base = (Byte *)gc_heap_base_address();
- Class::heap_end = (Byte *)gc_heap_ceiling_address();
- Class::managed_null = (vm_references_are_compressed() ? Class::heap_base : NULL);
+ vm_env->heap_base = (Byte *)gc_heap_base_address();
+ vm_env->heap_end = (Byte *)gc_heap_ceiling_address();
+ vm_env->managed_null = (vm_references_are_compressed() ? vm_env->heap_base : NULL);
// 20030404 This handshaking protocol isn't quite correct. It doesn't
// work at the moment because JIT has not yet been modified to support
@@ -692,7 +676,6 @@
vm_env->popFrameException->object =
class_alloc_new_object(vm_env->java_lang_Error_Class);
-
// Precompile StackOverflowError.
class_alloc_new_object_and_run_default_constructor(vm_env->java_lang_StackOverflowError_Class);
// Precompile ThreadDeathError.
@@ -701,13 +684,13 @@
hythread_suspend_enable();
// Mark j.l.Throwable() constructor as a side effects free.
- Method * m = class_lookup_method(vm_env->java_lang_Throwable_Class,
+ Method * m = vm_env->java_lang_Throwable_Class->lookup_method(
vm_env->Init_String, vm_env->VoidVoidDescriptor_String);
assert(m);
m->set_side_effects(MSE_False);
// Mark j.l.Throwable(j.l.String) constructor as a side effects free.
- m = class_lookup_method(vm_env->java_lang_Throwable_Class,
+ m = vm_env->java_lang_Throwable_Class->lookup_method(
vm_env->Init_String, vm_env->FromStringConstructorDescriptor_String);
assert(m);
m->set_side_effects(MSE_False);
@@ -716,7 +699,7 @@
global_object_handles_init(jni_env);
Class * aoObjectArray = preload_class(vm_env, "[Ljava/lang/Object;");
- cached_object_array_vtable_ptr = aoObjectArray->vtable;
+ cached_object_array_vtable_ptr = aoObjectArray->get_vtable();
// the following is required for creating exceptions
preload_class(vm_env, "[Ljava/lang/VMClassRegistry;");
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp?view=diff&rev=472771&r1=472770&r2=472771
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp Wed Nov 8 20:52:12 2006
@@ -23,6 +23,7 @@
#include "open/hythread.h"
#include "open/jthread.h"
+#include "open/gc.h"
#include "jni.h"
#include "jni_direct.h"
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/compile.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/compile.cpp?view=diff&rev=472771&r1=472770&r2=472771
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/compile.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/compile.cpp Wed Nov 8 20:52:12 2006
@@ -39,6 +39,8 @@
#include "interpreter.h"
#include "jvmti_internal.h"
#include "jvmti_break_intf.h"
+#include "cci.h"
+#include "open/gc.h"
#include "vm_stats.h"
#include "dump.h"
@@ -53,11 +55,23 @@
}
+int get_index_of_jit(JIT *jit)
+{
+ int idx;
+ JIT **j;
+ for (j = jit_compilers, idx = 0; *j; j++, idx++) {
+ if (*j == jit) {
+ return idx;
+ }
+ }
+ return -999;
+} //get_index_of_jit
+
////////////////////////////////////////////////////////////////////////
// begin Forward declarations
// A MethodInstrumentationProc that records calls in a call graph weighted by the call counts between methods.
-void count_method_calls(CodeChunkInfo *callee);
+void count_method_calls(CodeChunkInfo* callee);
// end Forward declarations
////////////////////////////////////////////////////////////////////////
@@ -76,7 +90,6 @@
_relocatable = TRUE;
_num_target_exception_handlers = 0;
_target_exception_handlers = NULL;
- _has_been_loaded_for_vtune = false;
_callee_info = _static_callee_info;
_max_callees = NUM_STATIC_CALLEE_ENTRIES;
_num_callees = 0;
@@ -87,7 +100,6 @@
_jit_info_block_size = 0;
_code_block_alignment = 0;
_data_blocks = NULL;
- _dynopt_info = NULL;
_next = NULL;
#ifdef VM_STATS
num_throws = 0;
@@ -97,35 +109,37 @@
#endif
} //CodeChunkInfo::CodeChunkInfo
-
-void CodeChunkInfo::initialize_code_chunk(CodeChunkInfo *chunk)
+int CodeChunkInfo::get_jit_index() const
{
- memset(chunk, 0, sizeof(CodeChunkInfo));
- chunk->_callee_info = chunk->_static_callee_info;
- chunk->_max_callees = NUM_STATIC_CALLEE_ENTRIES;
- chunk->_relocatable = TRUE;
-} //CodeChunkInfo::initialize_code_chunk
-
-
+ return get_index_of_jit(_jit);
+}
-unsigned CodeChunkInfo::get_num_target_exception_handlers()
+unsigned CodeChunkInfo::get_num_target_exception_handlers() const
{
if (_id==0) {
return _num_target_exception_handlers;
} else {
return _method->get_num_target_exception_handlers(_jit);
}
-} //get_num_target_exception_handlers
-
+}
-Target_Exception_Handler_Ptr CodeChunkInfo::get_target_exception_handler_info(unsigned eh_num)
+Target_Exception_Handler_Ptr CodeChunkInfo::get_target_exception_handler_info(unsigned eh_num) const
{
if (_id==0) {
return _target_exception_handlers[eh_num];
} else {
return _method->get_target_exception_handler_info(_jit, eh_num);
}
-} //get_target_exception_handler_info
+}
+
+
+//void CodeChunkInfo::initialize_code_chunk(CodeChunkInfo *chunk)
+//{
+// memset(chunk, 0, sizeof(CodeChunkInfo));
+// chunk->_callee_info = chunk->_static_callee_info;
+// chunk->_max_callees = NUM_STATIC_CALLEE_ENTRIES;
+// chunk->_relocatable = TRUE;
+//} //CodeChunkInfo::initialize_code_chunk
// 20040224 Support for recording which methods (actually, CodeChunkInfo's) call which other methods.
@@ -180,10 +194,10 @@
} //CodeChunkInfo::record_call_to_callee
-uint64 CodeChunkInfo::num_calls_to(CodeChunkInfo *other_chunk)
+uint64 CodeChunkInfo::num_calls_to(CodeChunkInfo *other_chunk) const
{
assert(other_chunk);
- for (unsigned i = 0; i < _num_callees; i++) {
+ for (unsigned i = 0; i < _num_callees; i++) {
Callee_Info *info = &(_callee_info[i]);
CodeChunkInfo *callee = info->callee;
assert(callee);
@@ -196,7 +210,7 @@
} //CodeChunkInfo::num_calls_to
-void CodeChunkInfo::print_name()
+void CodeChunkInfo::print_name() const
{
Method *meth = get_method();
assert(meth);
@@ -207,7 +221,7 @@
} //CodeChunkInfo::print_name
-void CodeChunkInfo::print_name(FILE *file)
+void CodeChunkInfo::print_name(FILE *file) const
{
Method *meth = get_method();
assert(meth);
@@ -218,7 +232,7 @@
} //CodeChunkInfo::print_name
-void CodeChunkInfo::print_info(bool print_ellipses)
+void CodeChunkInfo::print_info(bool print_ellipses) const
{
size_t code_size = get_code_block_size();
print_name();
@@ -226,12 +240,12 @@
} //CodeChunkInfo::print_info
-void CodeChunkInfo::print_callee_info()
+void CodeChunkInfo::print_callee_info() const
{
- for (unsigned i = 0; i < _num_callees; i++) {
+ for (unsigned i = 0; i < _num_callees; i++) {
Callee_Info *info = &(_callee_info[i]);
- // Don't print the "back edges" (e.g., b calls a whenever a calls b) added to make the graph symmetric
- if (info->caller_ip != NULL) {
+ // Don't print the "back edges" (e.g., b calls a whenever a calls b) added to make the graph symmetric
+ if (info->caller_ip != NULL) {
CodeChunkInfo *callee = info->callee;
assert(callee);
unsigned call_offset = (unsigned)((char *)info->caller_ip - (char *)_code_block);
@@ -239,11 +253,10 @@
printf("%10" FMT64 "u calls at %u to ", info->num_calls, call_offset);
callee->print_name();
printf("\n");
- }
+ }
}
} //CodeChunkInfo::print_callee_info
-
// end CodeChunkInfo
////////////////////////////////////////////////////////////////////////
@@ -293,19 +306,6 @@
} //vm_initialize_all_jits
-int get_index_of_jit(JIT *jit)
-{
- int idx;
- JIT **j;
- for (j = jit_compilers, idx = 0; *j; j++, idx++) {
- if (*j == jit) {
- return idx;
- }
- }
- return -999;
-} //get_index_of_jit
-
-
// end JIT management
////////////////////////////////////////////////////////////////////////
@@ -371,10 +371,10 @@
//***** Part 2: Initialise object handles
if (is_static) {
- void *jlc = &((Class*)clss)->class_handle;
+ void *jlc = clss->get_class_handle();
cs = lil_parse_onto_end(cs,
- "ld l1,[%0i:pint];"
- "ld l1,[l1+0:ref];",
+ //"ld l1,[%0i:pint];"
+ "ld l1,[%0i:ref];",
jlc);
assert(cs);
cs = oh_gen_init_handle(cs, "l0", 0, "l1", false);
@@ -448,7 +448,7 @@
":%g;"
"o%4i=0;"
":%g;",
- i, Class::managed_null,
+ i, VM_Global_State::loader_env->managed_null,
arg_base+i, handle_offset, arg_base+i);
} else {
cs = lil_parse_onto_end(cs,
@@ -536,7 +536,7 @@
"jc l1!=0,done_translating_ret;"
"l1=%0i:ref;"
":done_translating_ret;",
- Class::managed_null);
+ VM_Global_State::loader_env->managed_null);
}
assert(cs);
}
@@ -597,15 +597,16 @@
// begin Support for stub override code sequences
-static int get_override_index(Method *method)
+static int get_override_index(Method* method)
{
- const char *clss_name = &(method->get_class()->name->bytes[0]);
- const char *meth_name = method->get_name()->bytes;
- const char *meth_desc = method->get_descriptor()->bytes;
+ const char* clss_name = method->get_class()->get_name()->bytes;
+ const char* meth_name = method->get_name()->bytes;
+ const char* meth_desc = method->get_descriptor()->bytes;
for (int i = 0; i < sizeof_stub_override_entries; i++) {
- if ((strcmp(clss_name, stub_override_entries[i].class_name) == 0) &&
- (strcmp(meth_name, stub_override_entries[i].method_name) == 0) &&
- (strcmp(meth_desc, stub_override_entries[i].descriptor) == 0)) {
+ if ((strcmp(clss_name, stub_override_entries[i].class_name) == 0)
+ && (strcmp(meth_name, stub_override_entries[i].method_name) == 0)
+ && (strcmp(meth_desc, stub_override_entries[i].descriptor) == 0))
+ {
return i;
}
}
@@ -659,19 +660,19 @@
Class* cl = method->get_class();
NativeStubOverride nso = nso_find_method_override(VM_Global_State::loader_env,
- cl->name, method->get_name(),
+ cl->get_name(), method->get_name(),
method->get_descriptor());
NativeCodePtr stub = compile_create_jni_stub(method, func, nso);
-
if (!stub)
return JIT_FAILURE;
- cl->m_lock->_lock();
+
+ method->lock();
method->set_code_addr(stub);
- cl->m_lock->_unlock();
+ method->unlock();
return JIT_SUCCESS;
-} //compile_prepare_native_method
+} // compile_prepare_native_method
JIT_Result compile_do_compilation_jit(Method* method, JIT* jit)
@@ -797,10 +798,13 @@
jthrowable old_exc = exn_get();
exn_clear();
- const char* c = method->get_class()->name->bytes;
+ const char* c = method->get_class()->get_name()->bytes;
const char* m = method->get_name()->bytes;
const char* d = method->get_descriptor()->bytes;
- size_t sz = 25+strlen(c)+strlen(m)+strlen(d);
+ size_t sz = 25 +
+ method->get_class()->get_name()->len +
+ method->get_name()->len +
+ method->get_descriptor()->len;
char* msg_raw = (char*)STD_MALLOC(sz);
assert(msg_raw);
sprintf(msg_raw, "Error compiling method %s.%s%s", c, m, d);
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?view=diff&rev=472771&r1=472770&r2=472771
==============================================================================
--- 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 Wed Nov 8 20:52:12 2006
@@ -71,6 +71,9 @@
#define OFFSET(Struct, Field) \
((POINTER_SIZE_SINT) (&(((Struct *) NULL)->Field) - NULL))
+#define OFFSET_INST(inst_ptr, Field) \
+ ((POINTER_SIZE_SINT) ((char*)(&inst_ptr->Field) - (char*)inst_ptr))
+
// macro that gets the size of a field within a struct or class
#define SIZE(Struct, Field) \
(sizeof(((Struct *) NULL)->Field))
@@ -157,19 +160,19 @@
static ManagedObject * rth_ldc_ref_helper(Class *c, unsigned cp_index)
{
ASSERT_THROW_AREA;
- Const_Pool *cp = c->const_pool;
- if (cp_is_string(cp, cp_index))
+ ConstantPool& cp = c->get_constant_pool();
+ if(cp.is_string(cp_index))
{
return vm_instantiate_cp_string_slow(c, cp_index);
}
- else if (cp_is_class(cp, cp_index))
+ else if (cp.is_class(cp_index))
{
assert(!hythread_is_suspend_enabled());
hythread_suspend_enable();
Class *objClass = NULL;
BEGIN_RAISE_AREA;
- objClass = class_resolve_class(c, cp_index);
+ objClass = c->_resolve_class(VM_Global_State::loader_env, cp_index);
END_RAISE_AREA;
hythread_suspend_disable();
@@ -253,22 +256,25 @@
// Null check
if (null!=RTTN_NoNullCheck) {
if (null==RTTN_NullMember) {
- cs = lil_parse_onto_end(cs, "jc i0!=%0i:ref,null_check_faild;", Class::managed_null);
+ cs = lil_parse_onto_end(cs, "jc i0!=%0i:ref,null_check_faild;",
+ VM_Global_State::loader_env->managed_null);
cs = lil_parse_onto_end(cs, (res==RTTR_ReturnOutcome ? "r=1:g4; ret;" : "r=i0; ret;"));
cs = lil_parse_onto_end(cs, ":null_check_faild;");
} else {
- cs = lil_parse_onto_end(cs, "jc i0=%0i:ref,failed;", Class::managed_null);
+ cs = lil_parse_onto_end(cs, "jc i0=%0i:ref,failed;",
+ VM_Global_State::loader_env->managed_null);
}
assert(cs);
}
// Fast sequence
- const POINTER_SIZE_INT is_fast_off = (POINTER_SIZE_INT)&((Class*)NULL)->is_suitable_for_fast_instanceof;
- const POINTER_SIZE_INT depth_off = (POINTER_SIZE_INT)&((Class*)NULL)->depth;
+ Class* dummy = NULL;
+ const size_t is_fast_off = Class::get_offset_of_fast_instanceof_flag(dummy);
+ const size_t depth_off = Class::get_offset_of_depth(dummy);
const POINTER_SIZE_INT supertable_off = (POINTER_SIZE_INT)&((VTable*)NULL)->superclasses;
bool do_slow = true;
if (type) {
- if (type->is_suitable_for_fast_instanceof) {
+ if(type->get_fast_instanceof_flag()) {
cs = lil_parse_onto_end(cs,
vm_vtable_pointers_are_compressed() ? "ld l0,[i0+%0i:g4],zx;" : "ld l0,[i0+%0i:pint];",
vtable_off);
@@ -276,7 +282,7 @@
cs = lil_parse_onto_end(cs,
"ld l0,[l0+%1i:pint];"
"jc l0!=%2i,failed;",
- vtable_add+supertable_off+sizeof(Class*)*(type->depth-1), type);
+ vtable_add+supertable_off+sizeof(Class*)*(type->get_depth()-1), type);
do_slow = false;
assert(cs);
}
@@ -304,7 +310,7 @@
//*** Slow sequence
const POINTER_SIZE_INT clss_off = (POINTER_SIZE_INT)&((VTable*)NULL)->clss;
- Boolean (*p_subclass)(Class_Handle, Class_Handle) = class_is_subclass;
+ Boolean (*p_subclass)(Class_Handle, Class_Handle) = class_is_subtype;
if (do_slow) {
cs = lil_parse_onto_end(cs,
":slowpath;"
@@ -348,13 +354,13 @@
VM_Statistics::get_vm_stats().num_type_checks ++;
if (sub->clss == super)
VM_Statistics::get_vm_stats().num_type_checks_equal_type ++;
- if (super->is_suitable_for_fast_instanceof)
+ if (super->get_fast_instanceof_flag())
VM_Statistics::get_vm_stats().num_type_checks_fast_decision ++;
- else if (super->is_array)
+ else if (super->is_array())
VM_Statistics::get_vm_stats().num_type_checks_super_is_array ++;
- else if (class_is_interface(super))
+ else if (super->is_interface())
VM_Statistics::get_vm_stats().num_type_checks_super_is_interface ++;
- else if (super->depth >= vm_max_fast_instanceof_depth())
+ else if (super->get_depth() >= vm_max_fast_instanceof_depth())
VM_Statistics::get_vm_stats().num_type_checks_super_is_too_deep ++;
}
@@ -362,12 +368,12 @@
static void rth_update_checkcast_stats(ManagedObject* o, Class* super)
{
VM_Statistics::get_vm_stats().num_checkcast ++;
- if (o == (ManagedObject*)Class::managed_null) {
+ if (o == (ManagedObject*)VM_Global_State::loader_env->managed_null) {
VM_Statistics::get_vm_stats().num_checkcast_null++;
} else {
if (o->vt()->clss == super)
VM_Statistics::get_vm_stats().num_checkcast_equal_type ++;
- if (super->is_suitable_for_fast_instanceof)
+ if (super->get_fast_instanceof_flag())
VM_Statistics::get_vm_stats().num_checkcast_fast_decision ++;
rth_type_test_update_stats(o->vt(), super);
}
@@ -377,13 +383,13 @@
static void rth_update_instanceof_stats(ManagedObject* o, Class* super)
{
VM_Statistics::get_vm_stats().num_instanceof++;
- super->num_instanceof_slow++;
- if (o == (ManagedObject*)Class::managed_null) {
+ super->instanceof_slow_path_taken();
+ if (o == (ManagedObject*)VM_Global_State::loader_env->managed_null) {
VM_Statistics::get_vm_stats().num_instanceof_null++;
} else {
if (o->vt()->clss == super)
VM_Statistics::get_vm_stats().num_instanceof_equal_type ++;
- if (super->is_suitable_for_fast_instanceof)
+ if (super->get_fast_instanceof_flag())
VM_Statistics::get_vm_stats().num_instanceof_fast_decision ++;
rth_type_test_update_stats(o->vt(), super);
}
@@ -400,7 +406,9 @@
#ifdef VM_STATS
if (dyn_count) {
- cs = lil_parse_onto_end(cs, "inc [%0i:pint]; in2out platform:void; call %1i;", dyn_count, rth_update_checkcast_stats);
+ cs = lil_parse_onto_end(cs,
+ "inc [%0i:pint]; in2out platform:void; call %1i;",
+ dyn_count, rth_update_checkcast_stats);
assert(cs);
}
#endif
@@ -453,7 +461,7 @@
#endif // VM_STATS
Global_Env *env = VM_Global_State::loader_env;
- ManagedObject* null_ref = (ManagedObject*)Class::managed_null;
+ ManagedObject* null_ref = (ManagedObject*)VM_Global_State::loader_env->managed_null;
if (array == null_ref) {
return env->java_lang_NullPointerException_Class;
} else if (((uint32)idx) >= (uint32)get_vector_length(array)) {
@@ -462,17 +470,17 @@
assert(get_vector_vtable(array));
Class* array_class = get_vector_vtable(array)->clss;
assert(array_class);
- assert(array_class->is_array);
+ assert(array_class->is_array());
#ifdef VM_STATS
VTable* vt = get_vector_vtable(array);
if (vt == cached_object_array_vtable_ptr)
VM_Statistics::get_vm_stats().num_aastore_test_object_array++;
- if (elem->vt()->clss == array_class->array_element_class)
+ if (elem->vt()->clss == array_class->get_array_element_class())
VM_Statistics::get_vm_stats().num_aastore_equal_type ++;
- if (array_class->array_element_class->is_suitable_for_fast_instanceof)
+ if (array_class->get_array_element_class()->get_fast_instanceof_flag())
VM_Statistics::get_vm_stats().num_aastore_fast_decision ++;
#endif // VM_STATS
- if (class_is_subtype_fast(elem->vt(), array_class->array_element_class)) {
+ if (class_is_subtype_fast(elem->vt(), array_class->get_array_element_class())) {
STORE_REFERENCE((ManagedObject*)array, get_vector_element_address_ref(array, idx), (ManagedObject*)elem);
} else {
return env->java_lang_ArrayStoreException_Class;
@@ -535,7 +543,7 @@
VM_Statistics::get_vm_stats().num_aastore_test++;
#endif // VM_STATS
- ManagedObject* null_ref = (ManagedObject*)Class::managed_null;
+ ManagedObject* null_ref = (ManagedObject*)VM_Global_State::loader_env->managed_null;
if (array == null_ref) {
return false;
}
@@ -556,15 +564,15 @@
Class* array_class = vt->clss;
assert(array_class);
- assert(array_class->is_array);
+ assert(array_class->is_array());
#ifdef VM_STATS
- if (elem->vt()->clss == array_class->array_element_class)
+ if (elem->vt()->clss == array_class->get_array_element_class())
VM_Statistics::get_vm_stats().num_aastore_test_equal_type ++;
- if (array_class->array_element_class->is_suitable_for_fast_instanceof)
+ if (array_class->get_array_element_class()->get_fast_instanceof_flag())
VM_Statistics::get_vm_stats().num_aastore_test_fast_decision ++;
#endif // VM_STATS
- return (class_is_subtype_fast(elem->vt(), array_class->array_element_class) ? true : false);
+ return (class_is_subtype_fast(elem->vt(), array_class->get_array_element_class()) ? true : false);
} //rth_aastore_test
static NativeCodePtr rth_get_lil_aastore_test(int * dyn_count)
@@ -641,37 +649,8 @@
// Or NULL if no such interface exists for obj
static void* rth_get_interface_vtable(ManagedObject* obj, Class* iid)
{
- assert(obj && obj->vt());
- Class* clss = obj->vt()->clss;
- assert(clss);
- unsigned num_intfc = clss->n_intfc_table_entries;
-#ifdef VM_STATS
- VM_Statistics::get_vm_stats().num_invokeinterface_calls++;
- switch(num_intfc) {
- case 1: VM_Statistics::get_vm_stats().num_invokeinterface_calls_size_1++; break;
- case 2: VM_Statistics::get_vm_stats().num_invokeinterface_calls_size_2++; break;
- default: VM_Statistics::get_vm_stats().num_invokeinterface_calls_size_many++; break;
- }
- if(num_intfc > VM_Statistics::get_vm_stats().invokeinterface_calls_size_max)
- VM_Statistics::get_vm_stats().invokeinterface_calls_size_max = num_intfc;
-#endif
- for(unsigned i = 0; i < num_intfc; i++) {
- Class* intfc = clss->intfc_table_descriptors[i];
- if(intfc == iid) {
-#ifdef VM_STATS
- switch(i) {
- case 0: VM_Statistics::get_vm_stats().num_invokeinterface_calls_searched_1++; break;
- case 1: VM_Statistics::get_vm_stats().num_invokeinterface_calls_searched_2++; break;
- default: VM_Statistics::get_vm_stats().num_invokeinterface_calls_searched_many++; break;
- }
- if(i > VM_Statistics::get_vm_stats().invokeinterface_calls_searched_max)
- VM_Statistics::get_vm_stats().invokeinterface_calls_searched_max = i;
-#endif
- unsigned char **table = clss->vtable->intfc_table->entry[i].table;
- return (void *)table;
- }
- }
- return NULL;
+ assert(obj && obj->vt() && obj->vt()->clss);
+ return obj->vt()->clss->helper_get_interface_vtable(obj, iid);
}
// Get interface vtable helper
@@ -698,7 +677,8 @@
":null;"
"r=0;"
"ret;",
- Class::managed_null, p_get_ivtable, lil_npc_to_fp(exn_get_rth_throw_incompatible_class_change_exception()));
+ VM_Global_State::loader_env->managed_null, p_get_ivtable,
+ lil_npc_to_fp(exn_get_rth_throw_incompatible_class_change_exception()));
assert(cs && lil_is_valid(cs));
addr = LilCodeGenerator::get_platform()->compile(cs);
@@ -718,10 +698,10 @@
{
#ifdef VM_STATS
VM_Statistics::get_vm_stats().num_is_class_initialized++;
- clss->num_class_init_checks++;
+ clss->initialization_checked();
#endif // VM_STATS
assert(!hythread_is_suspend_enabled());
- return clss->state == ST_Initialized;
+ return clss->is_initialized();
} //is_class_initialized
void vm_rt_class_initialize(Class *clss)
@@ -2042,44 +2022,34 @@
}
-ManagedObject *class_alloc_new_object(Class *c)
+ManagedObject* class_alloc_new_object(Class* c)
{
ASSERT_RAISE_AREA;
assert(!hythread_is_suspend_enabled());
- //hythread_suspend_disable();
- assert(strcmp(c->name->bytes, "java/lang/Class"));
-#ifdef VM_STATS
- VM_Statistics::get_vm_stats().num_class_alloc_new_object++;
- c->num_allocations++;
- c->num_bytes_allocated += get_instance_data_size(c);
-#endif //VM_STATS
- ManagedObject* o = (ManagedObject *)
- gc_alloc(c->instance_data_size,
- c->allocation_handle, vm_get_gc_thread_local());
- if (!o) {
+ assert(strcmp(c->get_name()->bytes, "java/lang/Class"));
+
+ ManagedObject* obj = c->allocate_instance();
+ if(!obj) {
exn_raise_object(
VM_Global_State::loader_env->java_lang_OutOfMemoryError);
- //hythread_suspend_enable();
- return 0; // whether this return is reached or not is solved via is_unwindable state
+ return NULL; // whether this return is reached or not is solved via is_unwindable state
}
- //hythread_suspend_enable();
- return o;
-} //class_alloc_new_object
+ return obj;
+} // class_alloc_new_object
ManagedObject *class_alloc_new_object_using_vtable(VTable *vtable)
{
ASSERT_RAISE_AREA;
assert(!hythread_is_suspend_enabled());
- assert(strcmp(vtable->clss->name->bytes, "java/lang/Class"));
+ assert(strcmp(vtable->clss->get_name()->bytes, "java/lang/Class"));
#ifdef VM_STATS
VM_Statistics::get_vm_stats().num_class_alloc_new_object++;
- vtable->clss->num_allocations++;
- vtable->clss->num_bytes_allocated += vtable->allocated_size;
+ vtable->clss->instance_allocated(vtable->allocated_size);
#endif //VM_STATS
// From vm_types.h: this is the same as instance_data_size with the constraint bit cleared.
- ManagedObject* o = (ManagedObject *) vm_alloc_and_report_ti(
- vtable->allocated_size, vtable->clss->allocation_handle,
- vm_get_gc_thread_local(), vtable->clss);
+ ManagedObject* o = (ManagedObject*) vm_alloc_and_report_ti(
+ vtable->allocated_size, vtable->clss->get_allocation_handle(),
+ vm_get_gc_thread_local(), vtable->clss);
if (!o) {
exn_raise_object(
VM_Global_State::loader_env->java_lang_OutOfMemoryError);
@@ -2088,48 +2058,42 @@
return o;
} //class_alloc_new_object_using_vtable
-ManagedObject *class_alloc_new_object_and_run_default_constructor(Class *clss)
+ManagedObject* class_alloc_new_object_and_run_default_constructor(Class* clss)
{
return class_alloc_new_object_and_run_constructor(clss, 0, 0);
-} //class_alloc_new_object_and_run_default_constructor
+} // class_alloc_new_object_and_run_default_constructor
-ManagedObject *
-class_alloc_new_object_and_run_constructor(Class *clss,
- Method *constructor,
- uint8 *constructor_args)
+ManagedObject*
+class_alloc_new_object_and_run_constructor(Class* clss,
+ Method* constructor,
+ uint8* constructor_args)
{
ASSERT_RAISE_AREA;
assert(!hythread_is_suspend_enabled());
- assert(strcmp(clss->name->bytes, "java/lang/Class"));
-
+ assert(strcmp(clss->get_name()->bytes, "java/lang/Class"));
+
ObjectHandle obj = oh_allocate_local_handle();
- obj->object = (ManagedObject*)
- gc_alloc(clss->instance_data_size, clss->allocation_handle, vm_get_gc_thread_local());
- if (!obj->object) {
+ obj->object = clss->allocate_instance();
+ if(!obj->object) {
exn_raise_object(
VM_Global_State::loader_env->java_lang_OutOfMemoryError);
- return 0; // should never be reached
+ return NULL;
}
-#ifdef VM_STATS
- clss->num_allocations++;
- clss->num_bytes_allocated += get_instance_data_size(clss);
-#endif //VM_STATS
if(!constructor) {
// Get the default constructor
- Global_Env *env = VM_Global_State::loader_env;
- constructor = class_lookup_method(clss, env->Init_String, env->VoidVoidDescriptor_String);
+ Global_Env* env = VM_Global_State::loader_env;
+ constructor = clss->lookup_method(env->Init_String, env->VoidVoidDescriptor_String);
assert(constructor);
}
-
// Every argument is at least 4 bytes long
int num_args_estimate = constructor->get_num_arg_bytes() / 4;
- jvalue *args = (jvalue*)STD_MALLOC(num_args_estimate * sizeof(jvalue));
- args[0].l = (jobject) obj;
+ jvalue* args = (jvalue*)STD_MALLOC(num_args_estimate * sizeof(jvalue));
+ args[0].l = (jobject)obj;
int arg_num = 1;
- uint8 *argp = constructor_args;
+ uint8* argp = constructor_args;
Arg_List_Iterator iter = constructor->get_argument_list();
Java_Type typ;
while((typ = curr_arg(iter)) != JAVA_TYPE_END) {
@@ -2185,7 +2149,7 @@
}
assert(!hythread_is_suspend_enabled());
vm_execute_java_method_array((jmethodID) constructor, 0, args);
-
+
if (exn_raised()) {
DIE("class constructor has thrown an exception");
}
@@ -2208,17 +2172,17 @@
static void update_general_type_checking_stats(VTable *sub, Class *super)
{
#ifdef VM_STATS
- VM_Statistics::get_vm_stats().num_type_checks ++;
+ VM_Statistics::get_vm_stats().num_type_checks++;
if (sub->clss == super)
- VM_Statistics::get_vm_stats().num_type_checks_equal_type ++;
- if (super->is_suitable_for_fast_instanceof)
- VM_Statistics::get_vm_stats().num_type_checks_fast_decision ++;
- else if (super->is_array)
- VM_Statistics::get_vm_stats().num_type_checks_super_is_array ++;
- else if (class_is_interface(super))
- VM_Statistics::get_vm_stats().num_type_checks_super_is_interface ++;
- else if (super->depth >= vm_max_fast_instanceof_depth())
- VM_Statistics::get_vm_stats().num_type_checks_super_is_too_deep ++;
+ VM_Statistics::get_vm_stats().num_type_checks_equal_type++;
+ if (super->get_fast_instanceof_flag())
+ VM_Statistics::get_vm_stats().num_type_checks_fast_decision++;
+ else if (super->is_array())
+ VM_Statistics::get_vm_stats().num_type_checks_super_is_array++;
+ else if (super->is_interface())
+ VM_Statistics::get_vm_stats().num_type_checks_super_is_interface++;
+ else if (super->get_depth() >= vm_max_fast_instanceof_depth())
+ VM_Statistics::get_vm_stats().num_type_checks_super_is_too_deep++;
#endif // VM_STATS
}
@@ -2226,14 +2190,14 @@
{
#ifdef VM_STATS
VM_Statistics::get_vm_stats().num_instanceof++;
- super->num_instanceof_slow++;
- if (obj == (ManagedObject *)Class::managed_null)
+ super->instanceof_slow_path_taken();
+ if (obj == (ManagedObject*)VM_Global_State::loader_env->managed_null)
VM_Statistics::get_vm_stats().num_instanceof_null++;
else
{
if (obj->vt()->clss == super)
VM_Statistics::get_vm_stats().num_instanceof_equal_type ++;
- if (super->is_suitable_for_fast_instanceof)
+ if (super->get_fast_instanceof_flag())
VM_Statistics::get_vm_stats().num_instanceof_fast_decision ++;
update_general_type_checking_stats(obj->vt(), super);
}
@@ -2244,13 +2208,13 @@
{
#ifdef VM_STATS
VM_Statistics::get_vm_stats().num_checkcast ++;
- if (obj == (ManagedObject *)Class::managed_null)
+ if (obj == (ManagedObject*)VM_Global_State::loader_env->managed_null)
VM_Statistics::get_vm_stats().num_checkcast_null++;
else
{
if (obj->vt()->clss == super)
VM_Statistics::get_vm_stats().num_checkcast_equal_type ++;
- if (super->is_suitable_for_fast_instanceof)
+ if (super->get_fast_instanceof_flag())
VM_Statistics::get_vm_stats().num_checkcast_fast_decision ++;
update_general_type_checking_stats(obj->vt(), super);
}
@@ -2385,12 +2349,13 @@
object_get_vtable_offset());
}
+ Class* dummy = NULL;
cs2 = lil_parse_onto_end
(cs2,
"ld l1, [i1 + %0i: g4],zx;"
"ld l2, [l0 + %1i*l1 + %2i: pint];"
"jc i1 != l2, failed;",
- OFFSET(Class, depth),
+ Class::get_offset_of_depth(dummy),
sizeof(Class*),
OFFSET(VTable, superclasses) - sizeof(Class*) + (vm_vtable_pointers_are_compressed() ? vm_get_vtable_base() : 0)
);
@@ -2430,12 +2395,8 @@
// creates a LIL code stub for checkcast or instanceof
// can be used by both IA32 and IPF code
-LilCodeStub *gen_lil_typecheck_stub(bool is_checkcast) {
-
- // assert that some sizes are what we expect them to be
- assert(SIZE(Class, is_suitable_for_fast_instanceof) == 4);
- assert(SIZE(Class, depth) == 4);
-
+LilCodeStub *gen_lil_typecheck_stub(bool is_checkcast)
+{
LilCodeStub* cs = NULL;
// check if object address is NULL
@@ -2446,7 +2407,7 @@
"jc i0!=%0i:ref,nonnull;"
"r=i0;" // return obj if obj==NULL
"ret;",
- Class::managed_null);
+ VM_Global_State::loader_env->managed_null);
}
else {
// args: ManagedObject *obj, Class *super; returns a boolean
@@ -2455,9 +2416,10 @@
"jc i0!=%0i:ref,nonnull;"
"r=0:g4;" // return FALSE if obj==NULL
"ret;",
- Class::managed_null);
+ VM_Global_State::loader_env->managed_null);
}
+ Class* dummy = NULL;
// check whether the fast or the slow path is appropriate
cs = lil_parse_onto_end
(cs,
@@ -2466,7 +2428,7 @@
// check if super->is_suitable_for_fast_instanceof
"ld l0, [i1 + %0i: g4];"
"jc l0!=0:g4, fast;",
- OFFSET(Class, is_suitable_for_fast_instanceof));
+ Class::get_offset_of_fast_instanceof_flag(dummy));
// append the slow path right here
cs = gen_lil_typecheck_slowpath(cs, is_checkcast);
@@ -2506,7 +2468,7 @@
"jc i0!=%0i,nonnull;"
"r=i0;" // return obj if obj==NULL
"ret;",
- Class::managed_null);
+ VM_Global_State::loader_env->managed_null);
}
else {
// args: ManagedObject *obj, Class *super; returns a boolean
@@ -2515,7 +2477,7 @@
"jc i0!=%0i,nonnull;"
"r=0:g4;" // return FALSE if obj==NULL
"ret;",
- Class::managed_null);
+ VM_Global_State::loader_env->managed_null);
}
/* fast case; check whether
@@ -2550,7 +2512,7 @@
"ld l1, [l0 + %0i: ref];"
"jc l1 != %1i, failed;",
OFFSET(VTable, superclasses) + (vm_vtable_pointers_are_compressed() ? vm_get_vtable_base() : 0)
- + sizeof(Class*) * (superclass->depth-1),
+ + sizeof(Class*)*(superclass->get_depth()-1),
(POINTER_SIZE_INT) superclass);
if (is_checkcast) {
@@ -2595,7 +2557,7 @@
{
#ifdef VM_STATS
VM_Statistics::get_vm_stats().num_aastore_test++;
- if (elem == (ManagedObject *)Class::managed_null)
+ if(elem == (ManagedObject*)VM_Global_State::loader_env->managed_null)
{
VM_Statistics::get_vm_stats().num_aastore_test_null ++;
return;
@@ -2607,43 +2569,24 @@
return;
}
Class *array_class = vt->clss;
- if (elem->vt()->clss == array_class->array_element_class)
+ if (elem->vt()->clss == array_class->get_array_element_class())
VM_Statistics::get_vm_stats().num_aastore_test_equal_type ++;
- if (array_class->array_element_class->is_suitable_for_fast_instanceof)
+ if (array_class->get_array_element_class()->get_fast_instanceof_flag())
VM_Statistics::get_vm_stats().num_aastore_test_fast_decision ++;
- update_general_type_checking_stats(elem->vt(), array_class->array_element_class);
+ update_general_type_checking_stats(elem->vt(), array_class->get_array_element_class());
#endif
}
-// Returns TRUE if "sub" represents a class that is a subtype of "super",
-// according to the Java instanceof rules.
-// "sub" must correspond to a non-interface type, since interfaces
-// currently have a null vtable.
-//
-// No VM_STATS calculations are done here. Call class_is_subtype_fast
-// if stats are needed.
- static Boolean class_is_subtype_fast_no_stats(VTable *sub, Class *super)
-{
- assert(sub != NULL); // Might happen if vtable of an interface class is accidentally taken.
- if (super->is_suitable_for_fast_instanceof)
- {
- return sub->superclasses[super->depth-1] == super ? TRUE : FALSE;
- }
- return class_is_subtype(sub->clss, super);
-} // class_is_subtype_fast_no_stats
-
-
-
Boolean class_is_subtype_fast(VTable *sub, Class *super)
{
update_general_type_checking_stats(sub, super);
- return class_is_subtype_fast_no_stats(sub, super);
+ return sub->clss->is_instanceof(super);
} // class_is_subtype_fast
Boolean vm_instanceof_class(Class *s, Class *t) {
- return class_is_subtype(s, t);
+ return s->is_instanceof(t);
}
@@ -2662,8 +2605,7 @@
Class *object_class = env->JavaLangObject_Class;
assert(object_class != NULL);
- if(s->is_array) {
- assert(*s->name->bytes == '[');
+ if(s->is_array()) {
if (t == object_class) {
return TRUE;
}
@@ -2673,26 +2615,25 @@
if(t == env->java_lang_Cloneable_Class) {
return TRUE;
}
- if(!t->is_array) {
+ if(!t->is_array()) {
return FALSE;
}
- return class_is_subtype(s->array_element_class, t->array_element_class);
+ return class_is_subtype(s->get_array_element_class(), t->get_array_element_class());
} else {
- assert(s->name->bytes[0] != '[');
- if(!class_is_interface(t)) {
- for(Class *c = s; c; c = c->super_class) {
+ if(!t->is_interface()) {
+ for(Class *c = s; c; c = c->get_super_class()) {
if(c == t){
return TRUE;
}
}
} else {
- for(Class *c = s; c; c = c->super_class) {
- unsigned n_intf = c->n_superinterfaces;
+ for(Class *c = s; c; c = c->get_super_class()) {
+ unsigned n_intf = c->get_number_of_superinterfaces();
for(unsigned i = 0; i < n_intf; i++) {
- Class *intf = c->superinterfaces[i].clss;
+ Class* intf = c->get_superinterface(i);
assert(intf);
- assert(class_is_interface(intf));
+ assert(intf->is_interface());
if(class_is_subtype(intf, t)) {
return TRUE;
}
@@ -2714,10 +2655,10 @@
#ifdef VM_STATS
VM_Statistics::get_vm_stats().num_instanceof++;
- c->num_instanceof_slow++;
+ c->instanceof_slow_path_taken();
#endif
- ManagedObject *null_ref = (ManagedObject *)Class::managed_null;
+ ManagedObject *null_ref = (ManagedObject *)VM_Global_State::loader_env->managed_null;
if (obj == null_ref) {
#ifdef VM_STATS
VM_Statistics::get_vm_stats().num_instanceof_null++;
@@ -2728,7 +2669,7 @@
#ifdef VM_STATS
if (obj->vt()->clss == c)
VM_Statistics::get_vm_stats().num_instanceof_equal_type ++;
- if (c->is_suitable_for_fast_instanceof)
+ if (c->get_fast_instanceof_flag())
VM_Statistics::get_vm_stats().num_instanceof_fast_decision ++;
#endif // VM_STATS
return class_is_subtype_fast(obj->vt(), c);
@@ -2753,7 +2694,7 @@
VM_Statistics::get_vm_stats().num_aastore_test++;
#endif // VM_STATS
- ManagedObject *null_ref = (ManagedObject *)Class::managed_null;
+ ManagedObject *null_ref = (ManagedObject *)VM_Global_State::loader_env->managed_null;
if (array == null_ref) {
return 0;
}
@@ -2774,15 +2715,15 @@
Class *array_class = vt->clss;
assert(array_class);
- assert(array_class->is_array);
+ assert(array_class->is_array());
#ifdef VM_STATS
- if (elem->vt()->clss == array_class->array_element_class)
+ if (elem->vt()->clss == array_class->get_array_element_class())
VM_Statistics::get_vm_stats().num_aastore_test_equal_type ++;
- if (array_class->array_element_class->is_suitable_for_fast_instanceof)
+ if (array_class->get_array_element_class()->get_fast_instanceof_flag())
VM_Statistics::get_vm_stats().num_aastore_test_fast_decision ++;
#endif // VM_STATS
- return class_is_subtype_fast(elem->vt(), array_class->array_element_class);
+ return class_is_subtype_fast(elem->vt(), array_class->get_array_element_class());
} //vm_aastore_test
@@ -2796,7 +2737,7 @@
#endif // VM_STATS
Global_Env *env = VM_Global_State::loader_env;
- ManagedObject *null_ref = (ManagedObject *)Class::managed_null;
+ ManagedObject *null_ref = (ManagedObject *)VM_Global_State::loader_env->managed_null;
if (array == null_ref) {
return env->java_lang_NullPointerException_Class;
} else if (((uint32)idx) >= (uint32)get_vector_length(array)) {
@@ -2804,15 +2745,15 @@
} else if (elem != null_ref) {
Class *array_class = get_vector_vtable(array)->clss;
assert(array_class);
- assert(array_class->is_array);
+ assert(array_class->is_array());
#ifdef VM_STATS
// XXX - Should update VM_Statistics::get_vm_stats().num_aastore_object_array
- if (elem->vt()->clss == array_class->array_element_class)
+ if (elem->vt()->clss == array_class->get_array_element_class())
VM_Statistics::get_vm_stats().num_aastore_equal_type ++;
- if (array_class->array_element_class->is_suitable_for_fast_instanceof)
+ if (array_class->get_array_element_class()->get_fast_instanceof_flag())
VM_Statistics::get_vm_stats().num_aastore_fast_decision ++;
#endif // VM_STATS
- if (class_is_subtype_fast(elem->vt(), array_class->array_element_class)) {
+ if (class_is_subtype_fast(elem->vt(), array_class->get_array_element_class())) {
STORE_REFERENCE((ManagedObject *)array, get_vector_element_address_ref(array, idx), (ManagedObject *)elem);
} else {
return env->java_lang_ArrayStoreException_Class;
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/native_overrides.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/native_overrides.cpp?view=diff&rev=472771&r1=472770&r2=472771
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/native_overrides.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/native_overrides.cpp Wed Nov 8 20:52:12 2006
@@ -127,15 +127,14 @@
cs = lil_parse_onto_end(cs, "ld l0,[i0+%0i:pint];", (int)env->vm_class_offset);
// Determine if this class supports fast allocation
- size_t offset_is_fast_allocation_possible = (Byte *)&(env->Void_Class->is_fast_allocation_possible) - (Byte *)(env->Void_Class);
- assert(sizeof(env->Void_Class->is_fast_allocation_possible) == 1); // else one byte ld below will fail
+ size_t offset_is_fast_allocation_possible = env->Void_Class->get_offset_of_fast_allocation_flag();
cs = lil_parse_onto_end(cs, "ld l1,[l0+%0i:g1];", (int)offset_is_fast_allocation_possible);
cs = lil_parse_onto_end(cs, "jc l1=0,fallback;");
// Class supports fast allocation, now use frontier allocation technique
size_t offset_gc_local = (Byte *)&(p_TLS_vmthread->_gc_private_information) - (Byte *)p_TLS_vmthread;
- size_t offset_allocation_handle = (Byte *)&(env->Void_Class->allocation_handle) - (Byte *)(env->Void_Class);
- size_t offset_instance_data_size = (Byte *)&(env->Void_Class->instance_data_size) - (Byte *)(env->Void_Class);
+ size_t offset_allocation_handle = env->Void_Class->get_offset_of_allocation_handle();
+ size_t offset_instance_data_size = env->Void_Class->get_offset_of_instance_data_size();
current_offset += (unsigned) offset_gc_local;
limit_offset += (unsigned) offset_gc_local;
@@ -166,7 +165,7 @@
static ManagedObject* get_class_ptr(ManagedObject* obj)
{
- return *(obj->vt()->clss->class_handle);
+ return *(obj->vt()->clss->get_class_handle());
}
LilCodeStub* nso_get_class(LilCodeStub* cs, Method_Handle)
@@ -336,7 +335,9 @@
"ld l0,[i2+%6i:pint];"
"l1 = l1+i4;"
"jc l0:g4<l1,slowpath;", // dst offset + length <= dst length
- Class::managed_null, Class::managed_null, object_get_vtable_offset(), class_get_vtable(env->ArrayOfChar_Class),
+ VM_Global_State::loader_env->managed_null,
+ VM_Global_State::loader_env->managed_null,
+ object_get_vtable_offset(), class_get_vtable(env->ArrayOfChar_Class),
object_get_vtable_offset(), length_offset, length_offset);
assert(cs);
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp?view=diff&rev=472771&r1=472770&r2=472771
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp Wed Nov 8 20:52:12 2006
@@ -48,7 +48,6 @@
#include "m2n.h"
#include "nogc.h"
#include "init.h"
-#include "Verifier_stub.h"
#include "jni_utils.h"
#include "jit_runtime_support.h"
#include "jvmti_direct.h"
@@ -632,7 +631,7 @@
bool ld_result;
if(clss != NULL)
- ld_result = class_verify(env, clss) && class_prepare(env, clss);
+ ld_result = clss->verify(env) && clss->prepare(env);
if(clss && ld_result)
{
@@ -680,10 +679,10 @@
assert(hythread_is_suspend_enabled());
Class* clss = jclass_to_struct_Class(clazz);
if(clss) {
- if(class_is_interface(clss)) {
+ if(clss->is_interface()) {
return 0;
} else {
- Class *super_class = clss->super_class;
+ Class* super_class = clss->get_super_class();
if(super_class) {
assert(hythread_is_suspend_enabled());
return struct_Class_to_jclass(super_class);
@@ -922,8 +921,8 @@
ManagedObject *java_ref1 = h1->object;
ManagedObject *java_ref2 = h2->object;
- TRACE2("jni-same", "IsSameObject: Obj1 = " << java_ref1->vt()->clss->name->bytes <<
- " Obj2 = " << java_ref2->vt()->clss->name->bytes <<
+ TRACE2("jni-same", "IsSameObject: Obj1 = " << java_ref1->vt()->clss->get_name()->bytes <<
+ " Obj2 = " << java_ref2->vt()->clss->get_name()->bytes <<
" objects are " << ((java_ref1 == java_ref2) ? "same" : "different"));
jboolean result = (jboolean)((java_ref1 == java_ref2) ? JNI_TRUE : JNI_FALSE);
@@ -965,9 +964,9 @@
assert(clazz);
Class* clss = jclass_to_struct_Class(clazz);
- if(class_is_interface(clss) || class_is_abstract(clss)) {
+ if(clss->is_interface() || clss->is_abstract()) {
// Can't instantiate interfaces and abtract classes.
- ThrowNew_Quick(env, "java/lang/InstantiationException", clss->name->bytes);
+ ThrowNew_Quick(env, "java/lang/InstantiationException", clss->get_name()->bytes);
return 0;
}
@@ -1050,7 +1049,7 @@
assert(jlo);
assert(jlo->vt());
Class *clss = jlo->vt()->clss;
- TRACE2("jni", "GetObjectClass: class = " << clss->name->bytes);
+ TRACE2("jni", "GetObjectClass: class = " << clss->get_name()->bytes);
new_handle->object= struct_Class_to_java_lang_Class(clss);
tmn_suspend_enable(); //---------------------------------^
@@ -1072,7 +1071,7 @@
Class* clss = jclass_to_struct_Class(clazz);
Class* obj_clss = jclass_to_struct_Class(obj_class);
- Boolean isInstance = class_is_subtype_fast(obj_clss->vtable, clss);
+ Boolean isInstance = obj_clss->is_instanceof(clss);
if(isInstance) {
return JNI_TRUE;
@@ -1271,11 +1270,11 @@
tmn_suspend_disable();
Class* array_clss = ((ObjectHandle)array)->object->vt()->clss;
tmn_suspend_enable();
- assert(array_clss->name->bytes[0]=='[');
+ assert(array_clss->get_name()->bytes[0]=='[');
TRACE2("jni.pin", "pinning array " << array->object);
gc_pin_object((Managed_Object_Handle*)array);
- switch (array_clss->name->bytes[1]) {
+ switch (array_clss->get_name()->bytes[1]) {
case 'B': return GetByteArrayElements(jenv, array, isCopy);
case 'C': return GetCharArrayElements(jenv, array, isCopy);
case 'D': return GetDoubleArrayElements(jenv, array, isCopy);
@@ -1295,8 +1294,8 @@
tmn_suspend_disable();
Class* array_clss = ((ObjectHandle)array)->object->vt()->clss;
tmn_suspend_enable();
- assert(array_clss->name->bytes[0]=='[');
- switch (array_clss->name->bytes[1]) {
+ assert(array_clss->get_name()->bytes[0]=='[');
+ switch (array_clss->get_name()->bytes[1]) {
case 'B': ReleaseByteArrayElements(jenv, array, (jbyte*)carray, mode); break;
case 'C': ReleaseCharArrayElements(jenv, array, (jchar*)carray, mode); break;
case 'D': ReleaseDoubleArrayElements(jenv, array, (jdouble*)carray, mode); break;
@@ -1679,9 +1678,9 @@
}
}
-void global_object_handles_init(JNIEnv * jni_env) {
-
- Global_Env * vm_env = jni_get_vm_env(jni_env);
+void global_object_handles_init(JNIEnv* jni_env)
+{
+ Global_Env* vm_env = jni_get_vm_env(jni_env);
gh_jlc = oh_allocate_global_handle();
gh_jls = oh_allocate_global_handle();
@@ -1704,8 +1703,8 @@
gh_jlfloat = oh_allocate_global_handle();
gh_jldouble = oh_allocate_global_handle();
ObjectHandle h_jlt = oh_allocate_global_handle();
- tmn_suspend_disable();
+ tmn_suspend_disable(); // --------------vvv
gh_jlc->object = struct_Class_to_java_lang_Class(vm_env->JavaLangClass_Class);
gh_jls->object = struct_Class_to_java_lang_Class(vm_env->JavaLangString_Class);
gh_jlcloneable->object = struct_Class_to_java_lang_Class(vm_env->java_lang_Cloneable_Class);
@@ -1717,16 +1716,16 @@
gh_aolong->object = struct_Class_to_java_lang_Class(vm_env->ArrayOfLong_Class);
gh_aofloat->object = struct_Class_to_java_lang_Class(vm_env->ArrayOfFloat_Class);
gh_aodouble->object = struct_Class_to_java_lang_Class(vm_env->ArrayOfDouble_Class);
- tmn_suspend_enable(); //-------------------------------------------------------^
- Class *preload_class(Global_Env* vm_env, const char *classname);
- Class* jlboolean = preload_class(vm_env, "java/lang/Boolean");
- Class* jlbyte = preload_class(vm_env, "java/lang/Byte");
- Class* jlchar = preload_class(vm_env, "java/lang/Character");
- Class* jlshort = preload_class(vm_env, "java/lang/Short");
- Class* jlint = preload_class(vm_env, "java/lang/Integer");
- Class* jllong = preload_class(vm_env, "java/lang/Long");
- Class* jlfloat = preload_class(vm_env, "java/lang/Float");
- Class* jldouble = preload_class(vm_env, "java/lang/Double");
+ tmn_suspend_enable(); // -------------^^^
+
+ Class* jlboolean = vm_env->LoadCoreClass("java/lang/Boolean");
+ Class* jlbyte = vm_env->LoadCoreClass("java/lang/Byte");
+ Class* jlchar = vm_env->LoadCoreClass("java/lang/Character");
+ Class* jlshort = vm_env->LoadCoreClass("java/lang/Short");
+ Class* jlint = vm_env->LoadCoreClass("java/lang/Integer");
+ Class* jllong = vm_env->LoadCoreClass("java/lang/Long");
+ Class* jlfloat = vm_env->LoadCoreClass("java/lang/Float");
+ Class* jldouble = vm_env->LoadCoreClass("java/lang/Double");
tmn_suspend_disable();
gh_jlboolean->object = struct_Class_to_java_lang_Class(jlboolean);
@@ -1739,6 +1738,7 @@
gh_jldouble->object = struct_Class_to_java_lang_Class(jldouble);
h_jlt->object= struct_Class_to_java_lang_Class(vm_env->java_lang_Throwable_Class);
tmn_suspend_enable(); //-------------------------------------------------------^
+
assert(hythread_is_suspend_enabled());
gid_throwable_traceinfo = jni_env->GetFieldID((jclass)h_jlt, "vm_stacktrace", "[J");
@@ -1758,7 +1758,7 @@
gid_stringinit = jni_env->GetMethodID((jclass)gh_jls, "<init>", "([C)V");
gid_string_field_value = jni_env->GetFieldID((jclass)gh_jls, "value", "[C");
-
+
if (vm_env->strings_are_compressed) {
gid_string_field_bvalue = jni_env->GetFieldID((jclass)gh_jls, "bvalue", "[B");
}
@@ -1777,6 +1777,7 @@
#endif //#ifndef USE_NATIVE_ISARRAY
assert(hythread_is_suspend_enabled());
}
+
void unsafe_global_object_handles_init(JNIEnv * jni_env) {
assert(!hythread_is_suspend_enabled());
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_array.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_array.cpp?view=diff&rev=472771&r1=472770&r2=472771
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_array.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_array.cpp Wed Nov 8 20:52:12 2006
@@ -53,13 +53,6 @@
} //GetArrayLength
-#define BITS_PER_BYTE 8
-#define HIGH_BIT_SET_MASK (1<<((sizeof(unsigned) * BITS_PER_BYTE)-1))
-#ifndef NEXT_TO_HIGH_BIT_SET_MASK
-#define NEXT_TO_HIGH_BIT_SET_MASK (1<<((sizeof(unsigned) * BITS_PER_BYTE)-2))
-#endif /* #ifndef NEXT_TO_HIGH_BIT_SET_MAS */
-#define TWO_HIGHEST_BITS_SET_MASK (HIGH_BIT_SET_MASK|NEXT_TO_HIGH_BIT_SET_MASK)
-
jarray JNICALL NewObjectArray(JNIEnv * UNREF env,
jsize length,
jclass elementClass,
@@ -203,8 +196,8 @@
DeleteLocalRef(env, array_jclass);
DeleteLocalRef(env, actual_element_jclass);
- if (!class_is_subtype_fast(actual_element_class->vtable, array_class->array_element_class)) {
- ThrowNew_Quick(env, "java/lang/ArrayStoreException", actual_element_class->name->bytes);
+ if (!actual_element_class->is_instanceof(array_class->get_array_element_class())) {
+ ThrowNew_Quick(env, "java/lang/ArrayStoreException", actual_element_class->get_name()->bytes);
return;
}
}
@@ -240,11 +233,12 @@
assert(hythread_is_suspend_enabled());
Class *clss = VM_Global_State::loader_env->ArrayOfBoolean_Class;
- unsigned sz = vm_array_size(clss->vtable, length);
+ unsigned sz = clss->calculate_array_size(length);
tmn_suspend_disable(); //---------------------------------v
ObjectHandle h = oh_allocate_local_handle();
- Vector_Handle array = gc_alloc(sz, clss->allocation_handle, vm_get_gc_thread_local());
- if (NULL == array)
+ Vector_Handle array = gc_alloc(sz, clss->get_allocation_handle(),
+ vm_get_gc_thread_local());
+ if(NULL == array)
{
tmn_suspend_enable();
return NULL;
@@ -253,8 +247,7 @@
set_vector_length(array, length);
#ifdef VM_STATS
- clss->num_allocations++;
- clss->num_bytes_allocated += sz;
+ clss->instance_allocated(sz);
#endif //VM_STATS
h->object = (ManagedObject *)array;
@@ -273,10 +266,11 @@
Class *clss = VM_Global_State::loader_env->ArrayOfByte_Class;
assert(clss);
- unsigned sz = vm_array_size(clss->vtable, length);
+ unsigned sz = clss->calculate_array_size(length);
tmn_suspend_disable(); //---------------------------------v
ObjectHandle h = oh_allocate_local_handle();
- Vector_Handle array = gc_alloc(sz, clss->allocation_handle, vm_get_gc_thread_local());
+ Vector_Handle array = gc_alloc(sz, clss->get_allocation_handle(),
+ vm_get_gc_thread_local());
if (NULL == array)
{
tmn_suspend_enable();
@@ -286,8 +280,7 @@
set_vector_length(array, length);
#ifdef VM_STATS
- clss->num_allocations++;
- clss->num_bytes_allocated += sz;
+ clss->instance_allocated(sz);
#endif //VM_STATS
h->object = (ManagedObject *)array;
@@ -305,11 +298,12 @@
assert(hythread_is_suspend_enabled());
Class *clss = VM_Global_State::loader_env->ArrayOfChar_Class;
- unsigned sz = vm_array_size(clss->vtable, length);
+ unsigned sz = clss->calculate_array_size(length);
tmn_suspend_disable(); //---------------------------------v
ObjectHandle h = oh_allocate_local_handle();
- Vector_Handle array = gc_alloc(sz, clss->allocation_handle, vm_get_gc_thread_local());
- if (NULL == array)
+ Vector_Handle array = gc_alloc(sz, clss->get_allocation_handle(),
+ vm_get_gc_thread_local());
+ if(NULL == array)
{
tmn_suspend_enable();
return NULL;
@@ -318,8 +312,7 @@
set_vector_length(array, length);
#ifdef VM_STATS
- clss->num_allocations++;
- clss->num_bytes_allocated += sz;
+ clss->instance_allocated(sz);
#endif //VM_STATS
h->object = (ManagedObject *)array;
@@ -337,11 +330,12 @@
assert(hythread_is_suspend_enabled());
Class *clss = VM_Global_State::loader_env->ArrayOfShort_Class;
- unsigned sz = vm_array_size(clss->vtable, length);
+ unsigned sz = clss->calculate_array_size(length);
tmn_suspend_disable(); //---------------------------------v
ObjectHandle h = oh_allocate_local_handle();
- Vector_Handle array = gc_alloc(sz, clss->allocation_handle, vm_get_gc_thread_local());
+ Vector_Handle array = gc_alloc(sz, clss->get_allocation_handle(),
+ vm_get_gc_thread_local());
if (NULL == array)
{
tmn_suspend_enable();
@@ -351,8 +345,7 @@
set_vector_length(array, length);
#ifdef VM_STATS
- clss->num_allocations++;
- clss->num_bytes_allocated += sz;
+ clss->instance_allocated(sz);
#endif //VM_STATS
h->object = (ManagedObject *)array;
@@ -369,10 +362,11 @@
TRACE2("jni", "NewIntArray called");
assert(hythread_is_suspend_enabled());
Class *clss = VM_Global_State::loader_env->ArrayOfInt_Class;
- unsigned sz = vm_array_size(clss->vtable, length);
+ unsigned sz = clss->calculate_array_size(length);
tmn_suspend_disable(); //---------------------------------v
ObjectHandle h = oh_allocate_local_handle();
- Vector_Handle array = gc_alloc(sz, clss->allocation_handle, vm_get_gc_thread_local());
+ Vector_Handle array = gc_alloc(sz, clss->get_allocation_handle(),
+ vm_get_gc_thread_local());
if (NULL == array)
{
tmn_suspend_enable();
@@ -382,8 +376,7 @@
set_vector_length(array, length);
#ifdef VM_STATS
- clss->num_allocations++;
- clss->num_bytes_allocated += sz;
+ clss->instance_allocated(sz);
#endif //VM_STATS
h->object = (ManagedObject *)array;
@@ -400,10 +393,11 @@
TRACE2("jni", "NewLongArray called");
assert(hythread_is_suspend_enabled());
Class *clss = VM_Global_State::loader_env->ArrayOfLong_Class;
- unsigned sz = vm_array_size(clss->vtable, length);
+ unsigned sz = clss->calculate_array_size(length);
tmn_suspend_disable(); //---------------------------------v
ObjectHandle h = oh_allocate_local_handle();
- Vector_Handle array = gc_alloc(sz, clss->allocation_handle, vm_get_gc_thread_local());
+ Vector_Handle array = gc_alloc(sz, clss->get_allocation_handle(),
+ vm_get_gc_thread_local());
if (NULL == array)
{
tmn_suspend_enable();
@@ -413,8 +407,7 @@
set_vector_length(array, length);
#ifdef VM_STATS
- clss->num_allocations++;
- clss->num_bytes_allocated += sz;
+ clss->instance_allocated(sz);
#endif //VM_STATS
h->object = (ManagedObject *)array;
@@ -431,10 +424,11 @@
TRACE2("jni", "NewFloatArray called");
assert(hythread_is_suspend_enabled());
Class *clss = VM_Global_State::loader_env->ArrayOfFloat_Class;
- unsigned sz = vm_array_size(clss->vtable, length);
+ unsigned sz = clss->calculate_array_size(length);
tmn_suspend_disable(); //---------------------------------v
ObjectHandle h = oh_allocate_local_handle();
- Vector_Handle array = gc_alloc(sz, clss->allocation_handle, vm_get_gc_thread_local());
+ Vector_Handle array = gc_alloc(sz, clss->get_allocation_handle(),
+ vm_get_gc_thread_local());
if (NULL == array)
{
tmn_suspend_enable();
@@ -444,8 +438,7 @@
set_vector_length(array, length);
#ifdef VM_STATS
- clss->num_allocations++;
- clss->num_bytes_allocated += sz;
+ clss->instance_allocated(sz);
#endif //VM_STATS
h->object = (ManagedObject *)array;
@@ -462,10 +455,11 @@
TRACE2("jni", "NewDoubleArray called");
assert(hythread_is_suspend_enabled());
Class *clss = VM_Global_State::loader_env->ArrayOfDouble_Class;
- unsigned sz = vm_array_size(clss->vtable, length);
+ unsigned sz = clss->calculate_array_size(length);
tmn_suspend_disable(); //---------------------------------v
ObjectHandle h = oh_allocate_local_handle();
- Vector_Handle array = gc_alloc(sz, clss->allocation_handle, vm_get_gc_thread_local());
+ Vector_Handle array = gc_alloc(sz, clss->get_allocation_handle(),
+ vm_get_gc_thread_local());
if (NULL == array)
{
tmn_suspend_enable();
@@ -475,8 +469,7 @@
set_vector_length(array, length);
#ifdef VM_STATS
- clss->num_allocations++;
- clss->num_bytes_allocated += sz;
+ clss->instance_allocated(sz);
#endif //VM_STATS
h->object = (ManagedObject *)array;
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_field.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_field.cpp?view=diff&rev=472771&r1=472770&r2=472771
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_field.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_field.cpp Wed Nov 8 20:52:12 2006
@@ -51,7 +51,8 @@
ThrowNew_Quick(env, "java/lang/NoSuchFieldError", name);
return 0;
}
- TRACE2("jni", "GetFieldID " << clss->name->bytes << "." << name << " " << sig << " = " << (jfieldID)field);
+ TRACE2("jni", "GetFieldID " << clss->get_name()->bytes
+ << "." << name << " " << sig << " = " << (jfieldID)field);
assert(!field->is_static());
return (jfieldID)field;
@@ -92,7 +93,8 @@
ThrowNew_Quick(env, "java/lang/NoSuchFieldError", name);
return 0;
}
- TRACE2("jni", "GetStaticFieldID " << clss->name->bytes << "." << name << " " << sig << " = " << (jfieldID)field);
+ TRACE2("jni", "GetStaticFieldID " << clss->get_name()->bytes
+ << "." << name << " " << sig << " = " << (jfieldID)field);
assert(field->is_static());
return (jfieldID)field;
@@ -471,7 +473,7 @@
tmn_suspend_disable(); //---------------------------------v
Byte *java_ref = (Byte *)h->object;
- if (Class::compact_fields)
+ if(VM_Global_State::loader_env->compact_fields)
*(jbyte *)(java_ref + offset) = value;
else
*(jint *)(java_ref + offset) = value;
@@ -534,7 +536,7 @@
tmn_suspend_disable(); //---------------------------------v
Byte *java_ref = (Byte *)h->object;
- if (Class::compact_fields)
+ if (VM_Global_State::loader_env->compact_fields)
*(jshort *)(java_ref + offset) = value;
else
*(jint *)(java_ref + offset) = value;
@@ -898,7 +900,7 @@
assert(f->is_static());
jbyte *field_addr = (jbyte *)f->get_address();
jint *field_addr_int = (jint *)f->get_address();
- if (Class::compact_fields)
+ if (VM_Global_State::loader_env->compact_fields)
*field_addr = value;
else
*field_addr_int = value;
@@ -934,7 +936,7 @@
assert(f->is_static());
jshort *field_addr = (jshort *)f->get_address();
jint *field_addr_int = (jint *)f->get_address();
- if (Class::compact_fields)
+ if (VM_Global_State::loader_env->compact_fields)
*field_addr = value;
else
*field_addr_int = value;
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_method.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_method.cpp?view=diff&rev=472771&r1=472770&r2=472771
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_method.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_method.cpp Wed Nov 8 20:52:12 2006
@@ -40,6 +40,23 @@
#include "nogc.h"
+static Method* lookup_method_init(Class* clss, const char* descr)
+{
+ String* method_name = VM_Global_State::loader_env->Init_String;
+ String* method_descr =
+ VM_Global_State::loader_env->string_pool.lookup(descr);
+
+ return clss->lookup_method(method_name, method_descr);
+} // lookup_method_init
+
+
+static Method* lookup_method_clinit(Class* clss)
+{
+ return clss->lookup_method(VM_Global_State::loader_env->Clinit_String,
+ VM_Global_State::loader_env->VoidVoidDescriptor_String);
+} // lookup_method_clinit
+
+
jmethodID JNICALL GetMethodID(JNIEnv *env,
jclass clazz,
const char *name,
@@ -53,7 +70,7 @@
Method *method;
if ('<' == *name) {
if (!strcmp(name + 1, "init>")) {
- method = class_lookup_method_init(clss, descr);
+ method = lookup_method_init(clss, descr);
} else {
ThrowNew_Quick(env, "java/lang/NoSuchMethodError", name);
return NULL;
@@ -66,7 +83,8 @@
ThrowNew_Quick(env, "java/lang/NoSuchMethodError", name);
return NULL;
}
- TRACE2("jni", "GetMethodID " << clss->name->bytes << "." << name << " " << descr << " = " << (jmethodID)method);
+ TRACE2("jni", "GetMethodID " << clss->get_name()->bytes
+ << "." << name << " " << descr << " = " << (jmethodID)method);
return (jmethodID)method;
} //GetMethodID
@@ -85,7 +103,7 @@
Method *method;
if ('<' == *name) {
if (!strcmp(name + 1, "clinit>") && !strcmp(descr, "()V")) {
- method = class_lookup_method_clinit(clss);
+ method = lookup_method_clinit(clss);
} else {
ThrowNew_Quick(env, "java/lang/NoSuchMethodError", name);
return NULL;
@@ -98,7 +116,8 @@
ThrowNew_Quick(env, "java/lang/NoSuchMethodError", name);
return NULL;
}
- TRACE2("jni", "GetStaticMethodID " << clss->name->bytes << "." << name << " " << descr << " = " << (jmethodID)method);
+ TRACE2("jni", "GetStaticMethodID " << clss->get_name()->bytes
+ << "." << name << " " << descr << " = " << (jmethodID)method);
return (jmethodID)method;
} //GetStaticMethodID
@@ -339,8 +358,6 @@
call_method_no_ref_result(env, obj, methodID, args, &result, FALSE);
return result.b;
} //CallByteMethodA
-
-
jchar JNICALL CallCharMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)