comparison src/share/vm/c1x/c1x_VMExits.cpp @ 1423:760213a60e8b

* rewrite of the code installation * partial support for safepoints * macro-based CiTargetMethod interface * code stub support
author Lukas Stadler <lukas.stadler@oracle.com>
date Mon, 16 Aug 2010 18:59:36 -0700
parents 3483ec571caf
children abc670a709dc
comparison
equal deleted inserted replaced
1422:3483ec571caf 1423:760213a60e8b
23 */ 23 */
24 24
25 # include "incls/_precompiled.incl" 25 # include "incls/_precompiled.incl"
26 # include "incls/_c1x_VMExits.cpp.incl" 26 # include "incls/_c1x_VMExits.cpp.incl"
27 27
28 // these are *local* handles, and they need to be cleared before compileMethod returns
28 KlassHandle VMExits::_vmExitsKlass; 29 KlassHandle VMExits::_vmExitsKlass;
29 Handle VMExits::_vmExitsObject; 30 Handle VMExits::_vmExitsObject;
31
32 // this is a *global* handle
33 jobject VMExits::_vmExitsPermObject;
30 34
31 KlassHandle &VMExits::vmExitsKlass() { 35 KlassHandle &VMExits::vmExitsKlass() {
32 if (_vmExitsKlass.is_null()) { 36 if (_vmExitsKlass.is_null()) {
33 _vmExitsKlass = SystemDictionary::resolve_or_null(vmSymbols::com_sun_hotspot_c1x_VMExits(), SystemDictionary::java_system_loader(), NULL, Thread::current()); 37 _vmExitsKlass = SystemDictionary::resolve_or_null(vmSymbols::com_sun_hotspot_c1x_VMExits(), SystemDictionary::java_system_loader(), NULL, Thread::current());
34 if (_vmExitsKlass.is_null()) { 38 if (_vmExitsKlass.is_null()) {
38 return _vmExitsKlass; 42 return _vmExitsKlass;
39 } 43 }
40 44
41 Handle &VMExits::instance() { 45 Handle &VMExits::instance() {
42 if (_vmExitsObject.is_null()) { 46 if (_vmExitsObject.is_null()) {
43 KlassHandle compiler_klass = SystemDictionary::resolve_or_null(vmSymbols::com_sun_hotspot_c1x_Compiler(), SystemDictionary::java_system_loader(), NULL, Thread::current()); 47 if (JNIHandles::resolve(_vmExitsPermObject) == NULL) {
44 JavaValue result(T_OBJECT); 48 KlassHandle compiler_klass = SystemDictionary::resolve_or_null(vmSymbols::com_sun_hotspot_c1x_Compiler(), SystemDictionary::java_system_loader(), NULL, Thread::current());
45 JavaCallArguments args; 49 JavaValue result(T_OBJECT);
46 JavaCalls::call_static(&result, compiler_klass(), vmSymbols::getVMExits_name(), vmSymbols::getVMExits_signature(), &args, Thread::current()); 50 JavaCallArguments args;
47 check_pending_exception("Couldn't get VMExits"); 51 JavaCalls::call_static(&result, compiler_klass(), vmSymbols::getVMExits_name(), vmSymbols::getVMExits_signature(), &args, Thread::current());
48 oop res = (oop)result.get_jobject(); 52 check_pending_exception("Couldn't get VMExits");
49 _vmExitsObject = res; 53 oop res = (oop)result.get_jobject();
54 _vmExitsPermObject = JNIHandles::make_global(res);
55 }
56 _vmExitsObject = JNIHandles::resolve(_vmExitsPermObject);
50 } 57 }
51 return _vmExitsObject; 58 return _vmExitsObject;
52 } 59 }
53 60
54 void VMExits::compileMethod(methodOop method, int entry_bci) { 61 void VMExits::compileMethod(jlong methodVmId, Handle name, int entry_bci) {
55 assert(method != NULL, "just checking"); 62 assert(!name.is_null(), "just checking");
56 oop reflected_method = C1XObjects::getReflectedMethod(method, Thread::current()); 63 Thread* THREAD = Thread::current();
57 JavaValue result(T_VOID); 64 JavaValue result(T_VOID);
58 JavaCallArguments args; 65 JavaCallArguments args;
59 args.push_oop(instance()); 66 args.push_oop(instance());
60 args.push_oop(reflected_method); 67 args.push_long(methodVmId);
68 args.push_oop(name);
61 args.push_int(entry_bci); 69 args.push_int(entry_bci);
62 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::compileMethod_name(), vmSymbols::compileMethod_signature(), &args, Thread::current()); 70 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::compileMethod_name(), vmSymbols::compileMethod_signature(), &args, THREAD);
63 check_pending_exception("Error while calling compileMethod"); 71 check_pending_exception("Error while calling compileMethod");
64 } 72
65 73 // TODO hack hack
66 oop VMExits::createRiMethod(methodOop m, TRAPS) { 74 _vmExitsKlass = KlassHandle();
67 assert(m != NULL, "just checking"); 75 _vmExitsObject = Handle();
68 oop reflected_method = C1XObjects::getReflectedMethod(m, CHECK_0); 76 }
69 JavaValue result(T_OBJECT); 77
70 JavaCallArguments args; 78 oop VMExits::createRiMethod(jlong vmId, Handle name, TRAPS) {
71 args.push_oop(instance()); 79 assert(!name.is_null(), "just checking");
72 args.push_oop(reflected_method); 80 JavaValue result(T_OBJECT);
81 JavaCallArguments args;
82 args.push_oop(instance());
83 args.push_long(vmId);
84 args.push_oop(name);
73 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createRiMethod_name(), vmSymbols::createRiMethod_signature(), &args, THREAD); 85 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createRiMethod_name(), vmSymbols::createRiMethod_signature(), &args, THREAD);
74 check_pending_exception("Error while calling createRiMethod"); 86 check_pending_exception("Error while calling createRiMethod");
75 return (oop)result.get_jobject(); 87 return (oop)result.get_jobject();
76 } 88 }
77 89
78 oop VMExits::createRiField(oop field_holder, symbolOop field_name, oop field_type, int index, TRAPS) { 90 oop VMExits::createRiField(Handle holder, Handle name, Handle type, int index, TRAPS) {
79 assert(field_holder != NULL && field_name != NULL && field_type != NULL, "just checking"); 91 assert(!holder.is_null(), "just checking");
80 oop name = C1XObjects::getReflectedSymbol(field_name, CHECK_0); 92 assert(!name.is_null(), "just checking");
81 JavaValue result(T_OBJECT); 93 assert(!type.is_null(), "just checking");
82 JavaCallArguments args; 94 JavaValue result(T_OBJECT);
83 args.push_oop(instance()); 95 JavaCallArguments args;
84 args.push_oop(field_holder); 96 args.push_oop(instance());
85 args.push_oop(name); 97 args.push_oop(holder);
86 args.push_oop(field_type); 98 args.push_oop(name);
99 args.push_oop(type);
87 args.push_int(index); 100 args.push_int(index);
88 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createRiField_name(), vmSymbols::createRiField_signature(), &args, THREAD); 101 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createRiField_name(), vmSymbols::createRiField_signature(), &args, THREAD);
89 check_pending_exception("Error while calling createRiField"); 102 check_pending_exception("Error while calling createRiField");
90 return (oop)result.get_jobject(); 103 return (oop)result.get_jobject();
91 } 104 }
92 105
93 oop VMExits::createRiType(klassOop k, TRAPS) { 106 oop VMExits::createRiType(jlong vmId, Handle name, TRAPS) {
94 assert(k != NULL, "just checking"); 107 assert(!name.is_null(), "just checking");
95 JavaValue result(T_OBJECT); 108 JavaValue result(T_OBJECT);
96 JavaCallArguments args; 109 JavaCallArguments args;
97 args.push_oop(instance()); 110 args.push_oop(instance());
98 args.push_oop(C1XObjects::getReflectedClass(k)); 111 args.push_long(vmId);
112 args.push_oop(name);
99 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createRiType_name(), vmSymbols::createRiType_signature(), &args, THREAD); 113 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createRiType_name(), vmSymbols::createRiType_signature(), &args, THREAD);
100 check_pending_exception("Error while calling createRiType"); 114 check_pending_exception("Error while calling createRiType");
101 return (oop)result.get_jobject(); 115 return (oop)result.get_jobject();
102 } 116 }
103 117
109 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createRiTypePrimitive_name(), vmSymbols::createRiTypePrimitive_signature(), &args, THREAD); 123 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createRiTypePrimitive_name(), vmSymbols::createRiTypePrimitive_signature(), &args, THREAD);
110 check_pending_exception("Error while calling createRiTypePrimitive"); 124 check_pending_exception("Error while calling createRiTypePrimitive");
111 return (oop)result.get_jobject(); 125 return (oop)result.get_jobject();
112 } 126 }
113 127
114 oop VMExits::createRiTypeUnresolved(symbolOop name, klassOop accessor, TRAPS) { 128 oop VMExits::createRiTypeUnresolved(Handle name, jlong accessingClassVmId, TRAPS) {
115 // assert(name != NULL && accessor != NULL, "just checking"); 129 assert(!name.is_null(), "just checking");
116 JavaValue result(T_OBJECT); 130 JavaValue result(T_OBJECT);
117 JavaCallArguments args; 131 JavaCallArguments args;
118 args.push_oop(instance()); 132 args.push_oop(instance());
119 args.push_oop(C1XObjects::getReflectedSymbol(name, THREAD)); 133 args.push_oop(name);
120 args.push_oop(C1XObjects::getReflectedClass(accessor)); 134 args.push_long(accessingClassVmId);
121 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createRiTypeUnresolved_name(), vmSymbols::createRiTypeUnresolved_signature(), &args, THREAD); 135 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createRiTypeUnresolved_name(), vmSymbols::createRiTypeUnresolved_signature(), &args, THREAD);
122 check_pending_exception("Error while calling createRiTypeUnresolved"); 136 check_pending_exception("Error while calling createRiTypeUnresolved");
123 return (oop)result.get_jobject(); 137 return (oop)result.get_jobject();
124 } 138 }
125 139
126 oop VMExits::createRiConstantPool(constantPoolOop cp, TRAPS) { 140 oop VMExits::createRiConstantPool(jlong vmId, TRAPS) {
127 assert(cp != NULL, "just checking"); 141 JavaValue result(T_OBJECT);
128 JavaValue result(T_OBJECT); 142 JavaCallArguments args;
129 JavaCallArguments args; 143 args.push_oop(instance());
130 args.push_oop(instance()); 144 args.push_long(vmId);
131 args.push_oop(C1XObjects::getReflectedClass(cp->klass()));
132 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createRiConstantPool_name(), vmSymbols::createRiConstantPool_signature(), &args, THREAD); 145 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createRiConstantPool_name(), vmSymbols::createRiConstantPool_signature(), &args, THREAD);
133 check_pending_exception("Error while calling createRiConstantPool"); 146 check_pending_exception("Error while calling createRiConstantPool");
134 return (oop)result.get_jobject(); 147 return (oop)result.get_jobject();
135 } 148 }
136 149
137 oop VMExits::createRiSignature(symbolOop symbol, TRAPS) { 150 oop VMExits::createRiSignature(Handle name, TRAPS) {
138 assert(symbol != NULL, "just checking"); 151 assert(!name.is_null(), "just checking");
139 JavaValue result(T_OBJECT); 152 JavaValue result(T_OBJECT);
140 JavaCallArguments args; 153 JavaCallArguments args;
141 args.push_oop(instance()); 154 args.push_oop(instance());
142 args.push_oop(C1XObjects::getReflectedSymbol(symbol, THREAD)); 155 args.push_oop(name);
143 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createRiSignature_name(), vmSymbols::createRiSignature_signature(), &args, THREAD); 156 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createRiSignature_name(), vmSymbols::createRiSignature_signature(), &args, THREAD);
144 check_pending_exception("Error while calling createRiSignature"); 157 check_pending_exception("Error while calling createRiSignature");
145 return (oop)result.get_jobject(); 158 return (oop)result.get_jobject();
146 } 159 }
147 160
186 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createCiConstantDouble_name(), vmSymbols::createCiConstantDouble_signature(), &args, THREAD); 199 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createCiConstantDouble_name(), vmSymbols::createCiConstantDouble_signature(), &args, THREAD);
187 check_pending_exception("Error while calling createCiConstantDouble"); 200 check_pending_exception("Error while calling createCiConstantDouble");
188 return (oop)result.get_jobject(); 201 return (oop)result.get_jobject();
189 } 202 }
190 203
191 oop VMExits::createCiConstantObject(oop value, TRAPS) { 204 oop VMExits::createCiConstantObject(jlong vmId, TRAPS) {
192 JavaValue result(T_OBJECT); 205 JavaValue result(T_OBJECT);
193 JavaCallArguments args; 206 JavaCallArguments args;
194 args.push_oop(instance()); 207 args.push_oop(instance());
195 args.push_oop(value); 208 args.push_long(vmId);
196 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createCiConstantObject_name(), vmSymbols::createCiConstantObject_signature(), &args, THREAD); 209 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createCiConstantObject_name(), vmSymbols::createCiConstantLong_signature(), &args, THREAD);
197 check_pending_exception("Error while calling createCiConstantObject"); 210 check_pending_exception("Error while calling createCiConstantObject");
198 return (oop)result.get_jobject(); 211 return (oop)result.get_jobject();
199 } 212 }