comparison src/share/vm/graal/graalCodeInstaller.cpp @ 3664:6e1abd79e7c8

Register assumptions before anything else. Don't free code blob (it is reused).
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Thu, 17 Nov 2011 19:11:55 +0100
parents 8c46cdb684d4
children e755289380e3 5c8fc9f05960
comparison
equal deleted inserted replaced
3663:8c46cdb684d4 3664:6e1abd79e7c8
233 // constructor used to create a method 233 // constructor used to create a method
234 CodeInstaller::CodeInstaller(Handle target_method, nmethod*& nm, bool install_code) { 234 CodeInstaller::CodeInstaller(Handle target_method, nmethod*& nm, bool install_code) {
235 _env = CURRENT_ENV; 235 _env = CURRENT_ENV;
236 GraalCompiler::initialize_buffer_blob(); 236 GraalCompiler::initialize_buffer_blob();
237 CodeBuffer buffer(JavaThread::current()->get_buffer_blob()); 237 CodeBuffer buffer(JavaThread::current()->get_buffer_blob());
238 238
239 { 239 _oop_recorder = new OopRecorder(_env->arena());
240 No_Safepoint_Verifier no_safepoint; 240 _env->set_oop_recorder(_oop_recorder);
241 initialize_fields(target_method); 241 _env->set_dependencies(_dependencies);
242 initialize_buffer(buffer); 242 _dependencies = new Dependencies(_env);
243 process_exception_handlers(); 243 Handle assumptions_handle = CiTargetMethod::assumptions(HotSpotTargetMethod::targetMethod(target_method));
244 } 244 if (!assumptions_handle.is_null()) {
245 245 objArrayHandle assumptions = (objArrayOop)CiAssumptions::list(assumptions_handle());
246 if (_assumptions != NULL) {
247 objArrayHandle assumptions = (objArrayOop)_assumptions;
248 for (int i = 0; i < assumptions->length(); ++i) { 246 for (int i = 0; i < assumptions->length(); ++i) {
249 Handle assumption = assumptions->obj_at(i); 247 Handle assumption = assumptions->obj_at(i);
250 if (!assumption.is_null()) { 248 if (!assumption.is_null()) {
251 if (assumption->is_a(CiAssumptions_ConcreteSubtype::klass())) { 249 if (assumption->is_a(CiAssumptions_ConcreteSubtype::klass())) {
252 assumption_ConcreteSubtype(assumption); 250 assumption_ConcreteSubtype(assumption);
258 } 256 }
259 } 257 }
260 } 258 }
261 } 259 }
262 260
261 {
262 No_Safepoint_Verifier no_safepoint;
263 initialize_fields(target_method);
264 initialize_buffer(buffer);
265 process_exception_handlers();
266 }
267
263 int stack_slots = (_frame_size / HeapWordSize) + 2; // conversion to words, need to add two slots for ret address and frame pointer 268 int stack_slots = (_frame_size / HeapWordSize) + 2; // conversion to words, need to add two slots for ret address and frame pointer
264 methodHandle method = getMethodFromHotSpotMethod(HotSpotTargetMethod::method(target_method)); 269 methodHandle method = getMethodFromHotSpotMethod(HotSpotTargetMethod::method(target_method));
265 { 270 {
266 nm = GraalEnv::register_method(method, -1, &_offsets, _custom_stack_area_offset, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table, 271 nm = GraalEnv::register_method(method, -1, &_offsets, _custom_stack_area_offset, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table,
267 &_implicit_exception_table, GraalCompiler::instance(), _debug_recorder, _dependencies, NULL, -1, false, false, install_code); 272 &_implicit_exception_table, GraalCompiler::instance(), _debug_recorder, _dependencies, NULL, -1, false, false, install_code);
271 276
272 // constructor used to create a stub 277 // constructor used to create a stub
273 CodeInstaller::CodeInstaller(Handle target_method, jlong& id) { 278 CodeInstaller::CodeInstaller(Handle target_method, jlong& id) {
274 No_Safepoint_Verifier no_safepoint; 279 No_Safepoint_Verifier no_safepoint;
275 _env = CURRENT_ENV; 280 _env = CURRENT_ENV;
276 281
282 _oop_recorder = new OopRecorder(_env->arena());
283 _env->set_oop_recorder(_oop_recorder);
277 initialize_fields(target_method); 284 initialize_fields(target_method);
278 assert(_hotspot_method == NULL && _name != NULL, "installMethod needs NON-NULL name and NULL method"); 285 assert(_hotspot_method == NULL && _name != NULL, "installMethod needs NON-NULL name and NULL method");
279 286
280 // (very) conservative estimate: each site needs a relocation 287 // (very) conservative estimate: each site needs a relocation
281 GraalCompiler::initialize_buffer_blob(); 288 GraalCompiler::initialize_buffer_blob();
294 if (_hotspot_method != NULL) { 301 if (_hotspot_method != NULL) {
295 _parameter_count = getMethodFromHotSpotMethod(_hotspot_method)->size_of_parameters(); 302 _parameter_count = getMethodFromHotSpotMethod(_hotspot_method)->size_of_parameters();
296 } 303 }
297 _name = HotSpotTargetMethod::name(target_method); 304 _name = HotSpotTargetMethod::name(target_method);
298 _sites = (arrayOop) HotSpotTargetMethod::sites(target_method); 305 _sites = (arrayOop) HotSpotTargetMethod::sites(target_method);
299 oop assumptions = CiTargetMethod::assumptions(_citarget_method);
300 if (assumptions != NULL) {
301 _assumptions = (arrayOop) CiAssumptions::list(assumptions);
302 } else {
303 _assumptions = NULL;
304 }
305 _exception_handlers = (arrayOop) HotSpotTargetMethod::exceptionHandlers(target_method); 306 _exception_handlers = (arrayOop) HotSpotTargetMethod::exceptionHandlers(target_method);
306 307
307 _code = (arrayOop) CiTargetMethod::targetCode(_citarget_method); 308 _code = (arrayOop) CiTargetMethod::targetCode(_citarget_method);
308 _code_size = CiTargetMethod::targetCodeSize(_citarget_method); 309 _code_size = CiTargetMethod::targetCodeSize(_citarget_method);
309 _frame_size = CiTargetMethod::frameSize(_citarget_method); 310 _frame_size = CiTargetMethod::frameSize(_citarget_method);
323 char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size); 324 char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size);
324 buffer.insts()->initialize_shared_locs((relocInfo*)locs_buffer, locs_buffer_size / sizeof(relocInfo)); 325 buffer.insts()->initialize_shared_locs((relocInfo*)locs_buffer, locs_buffer_size / sizeof(relocInfo));
325 buffer.initialize_stubs_size(256); 326 buffer.initialize_stubs_size(256);
326 buffer.initialize_consts_size(_constants_size); 327 buffer.initialize_consts_size(_constants_size);
327 328
328 _oop_recorder = new OopRecorder(_env->arena());
329 _env->set_oop_recorder(_oop_recorder);
330 _debug_recorder = new DebugInformationRecorder(_env->oop_recorder()); 329 _debug_recorder = new DebugInformationRecorder(_env->oop_recorder());
331 _debug_recorder->set_oopmaps(new OopMapSet()); 330 _debug_recorder->set_oopmaps(new OopMapSet());
332 _dependencies = new Dependencies(_env); 331
333
334 _env->set_oop_recorder(_oop_recorder);
335 _env->set_debug_info(_debug_recorder); 332 _env->set_debug_info(_debug_recorder);
336 _env->set_dependencies(_dependencies);
337 buffer.initialize_oop_recorder(_oop_recorder); 333 buffer.initialize_oop_recorder(_oop_recorder);
338 334
339 _instructions = buffer.insts(); 335 _instructions = buffer.insts();
340 _constants = buffer.consts(); 336 _constants = buffer.consts();
341 337