Mercurial > hg > graal-compiler
comparison src/share/vm/c1x/c1x_Compiler.cpp @ 1432:b61a43cd1255
sourcecode formatting
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Wed, 01 Sep 2010 17:13:38 -0700 |
parents | abc670a709dc |
children | efba53f86c4f |
comparison
equal
deleted
inserted
replaced
1431:c01535d7fcc6 | 1432:b61a43cd1255 |
---|---|
20 * CA 95054 USA or visit www.sun.com if you need additional information or | 20 * CA 95054 USA or visit www.sun.com if you need additional information or |
21 * have any questions. | 21 * have any questions. |
22 * | 22 * |
23 */ | 23 */ |
24 | 24 |
25 | |
26 # include "incls/_precompiled.incl" | 25 # include "incls/_precompiled.incl" |
27 # include "incls/_c1x_Compiler.cpp.incl" | 26 # include "incls/_c1x_Compiler.cpp.incl" |
28 | 27 |
29 C1XCompiler* C1XCompiler::_instance = NULL; | 28 C1XCompiler* C1XCompiler::_instance = NULL; |
30 | |
31 | 29 |
32 C1XCompiler::C1XCompiler() { | 30 C1XCompiler::C1XCompiler() { |
33 _initialized = false; | 31 _initialized = false; |
34 assert(_instance == NULL, "only one instance allowed"); | 32 assert(_instance == NULL, "only one instance allowed"); |
35 _instance = this; | 33 _instance = this; |
36 } | 34 } |
37 | 35 |
38 | |
39 | |
40 // Initialization | 36 // Initialization |
41 void C1XCompiler::initialize() { | 37 void C1XCompiler::initialize() { |
42 if (_initialized) return; | 38 if (_initialized) return; |
43 _initialized = true; | 39 _initialized = true; |
44 TRACE_C1X_1("C1XCompiler::initialize"); | 40 TRACE_C1X_1("C1XCompiler::initialize"); |
45 | 41 |
46 JNIEnv *env = ((JavaThread *)Thread::current())->jni_environment(); | 42 JNIEnv *env = ((JavaThread *) Thread::current())->jni_environment(); |
47 jclass klass = env->FindClass("com/sun/hotspot/c1x/VMEntriesNative"); | 43 jclass klass = env->FindClass("com/sun/hotspot/c1x/VMEntriesNative"); |
48 assert(klass != NULL, "c1x VMEntries class not found"); | 44 assert(klass != NULL, "c1x VMEntries class not found"); |
49 env->RegisterNatives(klass, VMEntries_methods, VMEntries_methods_count() ); | 45 env->RegisterNatives(klass, VMEntries_methods, VMEntries_methods_count()); |
50 | 46 |
51 check_pending_exception("Could not register natives"); | 47 check_pending_exception("Could not register natives"); |
52 | 48 |
53 c1x_compute_offsets(); | 49 c1x_compute_offsets(); |
54 } | 50 } |
55 | 51 |
56 // Compilation entry point for methods | 52 // Compilation entry point for methods |
57 void C1XCompiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) { | 53 void C1XCompiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) { |
58 initialize(); | 54 initialize(); |
59 | |
60 VM_ENTRY_MARK; | 55 VM_ENTRY_MARK; |
61 ResourceMark rm; | 56 ResourceMark rm; |
62 HandleMark hm; | 57 HandleMark hm; |
63 | 58 |
64 VmIds::initializeObjects(); | 59 VmIds::initializeObjects(); |
65 | 60 |
66 CompilerThread::current()->set_compiling(true); | 61 CompilerThread::current()->set_compiling(true); |
67 methodOop method = (methodOop)target->get_oop(); | 62 methodOop method = (methodOop) target->get_oop(); |
68 VMExits::compileMethod(VmIds::add<methodOop>(method), VmIds::toString<Handle>(method->name(), THREAD), entry_bci); | 63 VMExits::compileMethod(VmIds::add<methodOop>(method), VmIds::toString<Handle>(method->name(), THREAD), entry_bci); |
69 CompilerThread::current()->set_compiling(false); | 64 CompilerThread::current()->set_compiling(false); |
70 | 65 |
71 VmIds::cleanupLocalObjects(); | 66 VmIds::cleanupLocalObjects(); |
72 } | 67 } |
77 } | 72 } |
78 | 73 |
79 oop C1XCompiler::get_RiType(ciType *type, klassOop accessor, TRAPS) { | 74 oop C1XCompiler::get_RiType(ciType *type, klassOop accessor, TRAPS) { |
80 if (type->is_loaded()) { | 75 if (type->is_loaded()) { |
81 if (type->is_primitive_type()) { | 76 if (type->is_primitive_type()) { |
82 return VMExits::createRiTypePrimitive((int)type->basic_type(), THREAD); | 77 return VMExits::createRiTypePrimitive((int) type->basic_type(), THREAD); |
83 } | 78 } |
84 KlassHandle klass = (klassOop)type->get_oop(); | 79 KlassHandle klass = (klassOop) type->get_oop(); |
85 Handle name = VmIds::toString<Handle>(klass->name(), THREAD); | 80 Handle name = VmIds::toString<Handle>(klass->name(), THREAD); |
86 return createHotSpotTypeResolved(klass, name, CHECK_NULL); | 81 return createHotSpotTypeResolved(klass, name, CHECK_NULL); |
87 } else { | 82 } else { |
88 symbolOop name = ((ciKlass *)type)->name()->get_symbolOop(); | 83 symbolOop name = ((ciKlass *) type)->name()->get_symbolOop(); |
89 return VMExits::createRiTypeUnresolved(VmIds::toString<Handle>(name, THREAD), VmIds::add<klassOop>(accessor), THREAD); | 84 return VMExits::createRiTypeUnresolved(VmIds::toString<Handle>(name, THREAD), VmIds::add<klassOop>(accessor), THREAD); |
90 } | 85 } |
91 } | 86 } |
92 | 87 |
93 oop C1XCompiler::get_RiField(ciField *field, TRAPS) { | 88 oop C1XCompiler::get_RiField(ciField *field, TRAPS) { |
97 int offset = field->offset(); | 92 int offset = field->offset(); |
98 | 93 |
99 // TODO: implement caching | 94 // TODO: implement caching |
100 return VMExits::createRiField(field_holder, field_name, field_type, offset, THREAD); | 95 return VMExits::createRiField(field_holder, field_name, field_type, offset, THREAD); |
101 } | 96 } |
102 | |
103 | 97 |
104 oop C1XCompiler::createHotSpotTypeResolved(KlassHandle klass, Handle name, TRAPS) { | 98 oop C1XCompiler::createHotSpotTypeResolved(KlassHandle klass, Handle name, TRAPS) { |
105 instanceKlass::cast(HotSpotTypeResolved::klass())->initialize(CHECK_NULL); | 99 instanceKlass::cast(HotSpotTypeResolved::klass())->initialize(CHECK_NULL); |
106 oop obj = instanceKlass::cast(HotSpotTypeResolved::klass())->allocate_instance(CHECK_NULL); | 100 oop obj = instanceKlass::cast(HotSpotTypeResolved::klass())->allocate_instance(CHECK_NULL); |
107 | 101 |
126 HotSpotTypeResolved::set_hasFinalizableSubclass(obj, false); | 120 HotSpotTypeResolved::set_hasFinalizableSubclass(obj, false); |
127 | 121 |
128 return obj; | 122 return obj; |
129 } | 123 } |
130 | 124 |
131 | |
132 |