comparison src/share/vm/c1x/c1x_Compiler.cpp @ 1429:abc670a709dc

* -XX:TraceC1X=0...5 controls the native c1x tracing * -Dc1x.debug=true turns on the logging proxies and lots of log output on the java side * provide more information about types to the compiler (type hierarchy, etc) * provide exception handler tables to the compiler * add exception handlers to the nmethod * correct implementation of ExceptionObject * exception handling/unwinding entry points * modified versions of handle/unwind exception stubs using standard calling conventions * exception throwing * implicit null pointer exception, implicit div by 0 exception * arraystore/classcast/arrayindex exceptions * checkcast implementation * newarray, anewarray, multinewarray implementation * correct new instance initialization * access to java class mirrors (for ldc) * unresolved methods * class resolving - class patching (asssembly prototype copying)
author Lukas Stadler <lukas.stadler@oracle.com>
date Tue, 31 Aug 2010 22:13:30 -0700
parents 695451afc619
children b61a43cd1255
comparison
equal deleted inserted replaced
1428:695451afc619 1429:abc670a709dc
24 24
25 25
26 # include "incls/_precompiled.incl" 26 # include "incls/_precompiled.incl"
27 # include "incls/_c1x_Compiler.cpp.incl" 27 # include "incls/_c1x_Compiler.cpp.incl"
28 28
29 C1XCompiler* C1XCompiler::_instance = NULL;
30
31
32 C1XCompiler::C1XCompiler() {
33 _initialized = false;
34 assert(_instance == NULL, "only one instance allowed");
35 _instance = this;
36 }
37
38
29 39
30 // Initialization 40 // Initialization
31 void C1XCompiler::initialize() { 41 void C1XCompiler::initialize() {
32 if (_initialized) return; 42 if (_initialized) return;
33 _initialized = true; 43 _initialized = true;
34 TRACE_C1X_1("initialize"); 44 TRACE_C1X_1("C1XCompiler::initialize");
35 45
36 JNIEnv *env = ((JavaThread *)Thread::current())->jni_environment(); 46 JNIEnv *env = ((JavaThread *)Thread::current())->jni_environment();
37 jclass klass = env->FindClass("com/sun/hotspot/c1x/VMEntriesNative"); 47 jclass klass = env->FindClass("com/sun/hotspot/c1x/VMEntriesNative");
38 assert(klass != NULL, "c1x VMEntries class not found"); 48 assert(klass != NULL, "c1x VMEntries class not found");
39 env->RegisterNatives(klass, VMEntries_methods, VMEntries_methods_count() ); 49 env->RegisterNatives(klass, VMEntries_methods, VMEntries_methods_count() );
61 VmIds::cleanupLocalObjects(); 71 VmIds::cleanupLocalObjects();
62 } 72 }
63 73
64 // Print compilation timers and statistics 74 // Print compilation timers and statistics
65 void C1XCompiler::print_timers() { 75 void C1XCompiler::print_timers() {
66 TRACE_C1X_1("print_timers"); 76 TRACE_C1X_1("C1XCompiler::print_timers");
67 } 77 }
68 78
69 oop C1XCompiler::get_RiType(ciType *type, klassOop accessor, TRAPS) { 79 oop C1XCompiler::get_RiType(ciType *type, klassOop accessor, TRAPS) {
70 if (type->is_loaded()) { 80 if (type->is_loaded()) {
71 if (type->is_primitive_type()) { 81 if (type->is_primitive_type()) {
72 return VMExits::createRiTypePrimitive((int)type->basic_type(), THREAD); 82 return VMExits::createRiTypePrimitive((int)type->basic_type(), THREAD);
73 } 83 }
74 klassOop klass = (klassOop)type->get_oop(); 84 KlassHandle klass = (klassOop)type->get_oop();
75 return VMExits::createRiType(VmIds::add<klassOop>(klass), VmIds::toString<Handle>(klass->klass_part()->name(), THREAD), THREAD); 85 Handle name = VmIds::toString<Handle>(klass->name(), THREAD);
86 return createHotSpotTypeResolved(klass, name, CHECK_NULL);
76 } else { 87 } else {
77 symbolOop name = ((ciKlass *)type)->name()->get_symbolOop(); 88 symbolOop name = ((ciKlass *)type)->name()->get_symbolOop();
78 return VMExits::createRiTypeUnresolved(VmIds::toString<Handle>(name, THREAD), VmIds::add<klassOop>(accessor), THREAD); 89 return VMExits::createRiTypeUnresolved(VmIds::toString<Handle>(name, THREAD), VmIds::add<klassOop>(accessor), THREAD);
79 } 90 }
80 } 91 }
87 98
88 // TODO: implement caching 99 // TODO: implement caching
89 return VMExits::createRiField(field_holder, field_name, field_type, offset, THREAD); 100 return VMExits::createRiField(field_holder, field_name, field_type, offset, THREAD);
90 } 101 }
91 102
103
104 oop C1XCompiler::createHotSpotTypeResolved(KlassHandle klass, Handle name, TRAPS) {
105 instanceKlass::cast(HotSpotTypeResolved::klass())->initialize(CHECK_NULL);
106 oop obj = instanceKlass::cast(HotSpotTypeResolved::klass())->allocate_instance(CHECK_NULL);
107
108 HotSpotTypeResolved::set_vmId(obj, VmIds::add(klass, VmIds::CLASS));
109 HotSpotTypeResolved::set_javaMirrorVmId(obj, VmIds::add(klass->java_mirror(), VmIds::CONSTANT));
110 HotSpotTypeResolved::set_name(obj, name());
111 HotSpotTypeResolved::set_accessFlags(obj, klass->access_flags().as_int());
112 HotSpotTypeResolved::set_isInterface(obj, klass->is_interface());
113 HotSpotTypeResolved::set_isInstanceClass(obj, klass->oop_is_instance());
114
115 if (klass->oop_is_javaArray()) {
116 HotSpotTypeResolved::set_isArrayClass(obj, true);
117 } else {
118 HotSpotTypeResolved::set_isArrayClass(obj, false);
119 HotSpotTypeResolved::set_isInitialized(obj, instanceKlass::cast(klass())->is_initialized());
120 HotSpotTypeResolved::set_instanceSize(obj, instanceKlass::cast(klass())->size_helper() * HeapWordSize);
121 HotSpotTypeResolved::set_hasFinalizer(obj, klass->has_finalizer());
122 }
123
124 // TODO replace these with correct values
125 HotSpotTypeResolved::set_hasSubclass(obj, false);
126 HotSpotTypeResolved::set_hasFinalizableSubclass(obj, false);
127
128 return obj;
129 }
130
131
132