comparison src/cpu/x86/vm/frame_x86.cpp @ 1201:24128c2ffa87

6921339: backout 6917766 Reviewed-by: mr
author twisti
date Fri, 29 Jan 2010 08:33:24 -0800
parents ba263cfb7611
children 18a389214829
comparison
equal deleted inserted replaced
1200:ba263cfb7611 1201:24128c2ffa87
1 /* 1 /*
2 * Copyright 1997-2010 Sun Microsystems, Inc. All Rights Reserved. 2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
220 tty->print_cr("patch_pc at address" INTPTR_FORMAT " [" INTPTR_FORMAT " -> " INTPTR_FORMAT "] ", 220 tty->print_cr("patch_pc at address" INTPTR_FORMAT " [" INTPTR_FORMAT " -> " INTPTR_FORMAT "] ",
221 &((address *)sp())[-1], ((address *)sp())[-1], pc); 221 &((address *)sp())[-1], ((address *)sp())[-1], pc);
222 } 222 }
223 ((address *)sp())[-1] = pc; 223 ((address *)sp())[-1] = pc;
224 _cb = CodeCache::find_blob(pc); 224 _cb = CodeCache::find_blob(pc);
225 address original_pc = nmethod::get_deopt_original_pc(this); 225 if (_cb != NULL && _cb->is_nmethod() && ((nmethod*)_cb)->is_deopt_pc(_pc)) {
226 if (original_pc != NULL) { 226 address orig = (((nmethod*)_cb)->get_original_pc(this));
227 assert(original_pc == _pc, "expected original PC to be stored before patching"); 227 assert(orig == _pc, "expected original to be stored before patching");
228 _deopt_state = is_deoptimized; 228 _deopt_state = is_deoptimized;
229 // leave _pc as is 229 // leave _pc as is
230 } else { 230 } else {
231 _deopt_state = not_deoptimized; 231 _deopt_state = not_deoptimized;
232 _pc = pc; 232 _pc = pc;
321 } 321 }
322 frame fr(jfa->last_Java_sp(), jfa->last_Java_fp()); 322 frame fr(jfa->last_Java_sp(), jfa->last_Java_fp());
323 return fr; 323 return fr;
324 } 324 }
325 325
326
327 //------------------------------------------------------------------------------
328 // frame::sender_for_interpreter_frame
329 frame frame::sender_for_interpreter_frame(RegisterMap* map) const { 326 frame frame::sender_for_interpreter_frame(RegisterMap* map) const {
330 // SP is the raw SP from the sender after adapter or interpreter 327 // sp is the raw sp from the sender after adapter or interpreter extension
331 // extension. 328 intptr_t* sp = (intptr_t*) addr_at(sender_sp_offset);
332 intptr_t* sender_sp = this->sender_sp();
333 329
334 // This is the sp before any possible extension (adapter/locals). 330 // This is the sp before any possible extension (adapter/locals).
335 intptr_t* unextended_sp = interpreter_frame_sender_sp(); 331 intptr_t* unextended_sp = interpreter_frame_sender_sp();
336
337 // Stored FP.
338 intptr_t* saved_fp = link();
339 332
340 address sender_pc = this->sender_pc(); 333 address sender_pc = this->sender_pc();
341 CodeBlob* sender_cb = CodeCache::find_blob_unsafe(sender_pc); 334 CodeBlob* sender_cb = CodeCache::find_blob_unsafe(sender_pc);
342 assert(sender_cb, "sanity"); 335 assert(sender_cb, "sanity");
343 nmethod* sender_nm = sender_cb->as_nmethod_or_null(); 336 nmethod* sender_nm = sender_cb->as_nmethod_or_null();
344 337 if (sender_nm != NULL && sender_nm->is_method_handle_return(sender_pc)) {
345 if (sender_nm != NULL) { 338 unextended_sp = (intptr_t*) at(link_offset);
346 // If the sender PC is a deoptimization point, get the original
347 // PC. For MethodHandle call site the unextended_sp is stored in
348 // saved_fp.
349 if (sender_nm->is_deopt_mh_entry(sender_pc)) {
350 DEBUG_ONLY(verify_deopt_mh_original_pc(sender_nm, saved_fp));
351 unextended_sp = saved_fp;
352 }
353 else if (sender_nm->is_deopt_entry(sender_pc)) {
354 DEBUG_ONLY(verify_deopt_original_pc(sender_nm, unextended_sp));
355 }
356 else if (sender_nm->is_method_handle_return(sender_pc)) {
357 unextended_sp = saved_fp;
358 }
359 } 339 }
360 340
361 // The interpreter and compiler(s) always save EBP/RBP in a known 341 // The interpreter and compiler(s) always save EBP/RBP in a known
362 // location on entry. We must record where that location is 342 // location on entry. We must record where that location is
363 // so this if EBP/RBP was live on callout from c2 we can find 343 // so this if EBP/RBP was live on callout from c2 we can find
377 if (true) { 357 if (true) {
378 map->set_location(rbp->as_VMReg()->next(), (address)addr_at(link_offset)); 358 map->set_location(rbp->as_VMReg()->next(), (address)addr_at(link_offset));
379 } 359 }
380 #endif // AMD64 360 #endif // AMD64
381 } 361 }
382 #endif // COMPILER2 362 #endif /* COMPILER2 */
383 363 return frame(sp, unextended_sp, link(), sender_pc);
384 return frame(sender_sp, unextended_sp, saved_fp, sender_pc); 364 }
385 } 365
386 366
387 367 //------------------------------sender_for_compiled_frame-----------------------
388 //------------------------------------------------------------------------------
389 // frame::sender_for_compiled_frame
390 frame frame::sender_for_compiled_frame(RegisterMap* map) const { 368 frame frame::sender_for_compiled_frame(RegisterMap* map) const {
391 assert(map != NULL, "map must be set"); 369 assert(map != NULL, "map must be set");
370 const bool c1_compiled = _cb->is_compiled_by_c1();
392 371
393 // frame owned by optimizing compiler 372 // frame owned by optimizing compiler
373 intptr_t* sender_sp = NULL;
374
394 assert(_cb->frame_size() >= 0, "must have non-zero frame size"); 375 assert(_cb->frame_size() >= 0, "must have non-zero frame size");
395 intptr_t* sender_sp = unextended_sp() + _cb->frame_size(); 376 sender_sp = unextended_sp() + _cb->frame_size();
396 intptr_t* unextended_sp = sender_sp;
397 377
398 // On Intel the return_address is always the word on the stack 378 // On Intel the return_address is always the word on the stack
399 address sender_pc = (address) *(sender_sp-1); 379 address sender_pc = (address) *(sender_sp-1);
400 380
401 // This is the saved value of EBP which may or may not really be an FP. 381 // This is the saved value of ebp which may or may not really be an fp.
402 // It is only an FP if the sender is an interpreter frame (or C1?). 382 // it is only an fp if the sender is an interpreter frame (or c1?)
403 intptr_t* saved_fp = (intptr_t*) *(sender_sp - frame::sender_sp_offset); 383
404 384 intptr_t *saved_fp = (intptr_t*)*(sender_sp - frame::sender_sp_offset);
405 // If we are returning to a compiled MethodHandle call site, the 385
406 // saved_fp will in fact be a saved value of the unextended SP. The 386 intptr_t* unextended_sp = sender_sp;
407 // simplest way to tell whether we are returning to such a call site 387 // If we are returning to a compiled method handle call site,
408 // is as follows: 388 // the saved_fp will in fact be a saved value of the unextended SP.
389 // The simplest way to tell whether we are returning to such a call
390 // site is as follows:
409 CodeBlob* sender_cb = CodeCache::find_blob_unsafe(sender_pc); 391 CodeBlob* sender_cb = CodeCache::find_blob_unsafe(sender_pc);
410 assert(sender_cb, "sanity"); 392 assert(sender_cb, "sanity");
411 nmethod* sender_nm = sender_cb->as_nmethod_or_null(); 393 nmethod* sender_nm = sender_cb->as_nmethod_or_null();
412 394 if (sender_nm != NULL && sender_nm->is_method_handle_return(sender_pc)) {
413 if (sender_nm != NULL) { 395 unextended_sp = saved_fp;
414 // If the sender PC is a deoptimization point, get the original
415 // PC. For MethodHandle call site the unextended_sp is stored in
416 // saved_fp.
417 if (sender_nm->is_deopt_mh_entry(sender_pc)) {
418 DEBUG_ONLY(verify_deopt_mh_original_pc(sender_nm, saved_fp));
419 unextended_sp = saved_fp;
420 }
421 else if (sender_nm->is_deopt_entry(sender_pc)) {
422 DEBUG_ONLY(verify_deopt_original_pc(sender_nm, unextended_sp));
423 }
424 else if (sender_nm->is_method_handle_return(sender_pc)) {
425 unextended_sp = saved_fp;
426 }
427 } 396 }
428 397
429 if (map->update_map()) { 398 if (map->update_map()) {
430 // Tell GC to use argument oopmaps for some runtime stubs that need it. 399 // Tell GC to use argument oopmaps for some runtime stubs that need it.
431 // For C1, the runtime stub might not have oop maps, so set this flag 400 // For C1, the runtime stub might not have oop maps, so set this flag
432 // outside of update_register_map. 401 // outside of update_register_map.
433 map->set_include_argument_oops(_cb->caller_must_gc_arguments(map->thread())); 402 map->set_include_argument_oops(_cb->caller_must_gc_arguments(map->thread()));
434 if (_cb->oop_maps() != NULL) { 403 if (_cb->oop_maps() != NULL) {
435 OopMapSet::update_register_map(this, map); 404 OopMapSet::update_register_map(this, map);
436 } 405 }
437 // Since the prolog does the save and restore of EBP there is no oopmap 406 // Since the prolog does the save and restore of epb there is no oopmap
438 // for it so we must fill in its location as if there was an oopmap entry 407 // for it so we must fill in its location as if there was an oopmap entry
439 // since if our caller was compiled code there could be live jvm state in it. 408 // since if our caller was compiled code there could be live jvm state in it.
440 map->set_location(rbp->as_VMReg(), (address) (sender_sp - frame::sender_sp_offset)); 409 map->set_location(rbp->as_VMReg(), (address) (sender_sp - frame::sender_sp_offset));
441 #ifdef AMD64 410 #ifdef AMD64
442 // this is weird "H" ought to be at a higher address however the 411 // this is weird "H" ought to be at a higher address however the
451 420
452 assert(sender_sp != sp(), "must have changed"); 421 assert(sender_sp != sp(), "must have changed");
453 return frame(sender_sp, unextended_sp, saved_fp, sender_pc); 422 return frame(sender_sp, unextended_sp, saved_fp, sender_pc);
454 } 423 }
455 424
456
457 //------------------------------------------------------------------------------
458 // frame::sender
459 frame frame::sender(RegisterMap* map) const { 425 frame frame::sender(RegisterMap* map) const {
460 // Default is we done have to follow them. The sender_for_xxx will 426 // Default is we done have to follow them. The sender_for_xxx will
461 // update it accordingly 427 // update it accordingly
462 map->set_include_argument_oops(false); 428 map->set_include_argument_oops(false);
463 429