comparison src/share/vm/graal/graalCodeInstaller.cpp @ 4693:07bcee8b70a4

Simplify exception debug information and exception handler table creation based on Graal's simplified model of exception handler information (i.e. the dispatch is done in compiled code).
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sat, 25 Feb 2012 00:40:34 +0100
parents fc42b5b6941a
children e29339f342de
comparison
equal deleted inserted replaced
4692:9d48ccb39292 4693:07bcee8b70a4
413 GrowableArray<intptr_t>* pcos = new GrowableArray<intptr_t> (num_handlers); 413 GrowableArray<intptr_t>* pcos = new GrowableArray<intptr_t> (num_handlers);
414 414
415 if (_exception_handlers != NULL) { 415 if (_exception_handlers != NULL) {
416 oop* exception_handlers = (oop*) _exception_handlers->base(T_OBJECT); 416 oop* exception_handlers = (oop*) _exception_handlers->base(T_OBJECT);
417 for (int i = 0; i < _exception_handlers->length(); i++) { 417 for (int i = 0; i < _exception_handlers->length(); i++) {
418 jint pc_offset = CiTargetMethod_Site::pcOffset(exception_handlers[i]); 418 oop exc = exception_handlers[i];
419 int start = i; 419 jint pc_offset = CiTargetMethod_Site::pcOffset(exc);
420 while ((i + 1) < _exception_handlers->length() && CiTargetMethod_Site::pcOffset(exception_handlers[i + 1]) == pc_offset) 420 jint handler_offset = CiTargetMethod_ExceptionHandler::handlerPos(exc);
421 i++; 421
422 422 // Subtable header
423 // empty the arrays 423 _exception_handler_table.add_entry(HandlerTableEntry(1, pc_offset, 0));
424 bcis->trunc_to(0); 424
425 scope_depths->trunc_to(0); 425 // Subtable entry
426 pcos->trunc_to(0); 426 _exception_handler_table.add_entry(HandlerTableEntry(-1, handler_offset, 0));
427 427 }
428 for (int j = start; j <= i; j++) { 428 }
429 oop exc = exception_handlers[j];
430 jint handler_offset = CiTargetMethod_ExceptionHandler::handlerPos(exc);
431 jint handler_bci = CiTargetMethod_ExceptionHandler::handlerBci(exc);
432 jint scope_level = CiTargetMethod_ExceptionHandler::scopeLevel(exc);
433
434 assert(handler_offset != -1, "must have been generated");
435
436 int e = bcis->find(handler_bci);
437 if (e >= 0 && scope_depths->at(e) == scope_level) {
438 // two different handlers are declared to dispatch to the same
439 // catch bci. During parsing we created edges for each
440 // handler but we really only need one. The exception handler
441 // table will also get unhappy if we try to declare both since
442 // it's nonsensical. Just skip this handler.
443 continue;
444 }
445
446 bcis->append(handler_bci);
447 if (handler_bci == -1) {
448 // insert a wildcard handler at scope depth 0 so that the
449 // exception lookup logic with find it.
450 scope_depths->append(0);
451 } else {
452 scope_depths->append(scope_level);
453 }
454 pcos->append(handler_offset);
455
456 // TODO: Check if we need that assert!
457 // stop processing once we hit a catch any
458 // if (handler->is_catch_all()) {
459 // assert(i == handlers->length() - 1, "catch all must be last handler");
460 // }
461
462 }
463 _exception_handler_table.add_subtable(pc_offset, bcis, scope_depths, pcos);
464 }
465 }
466
467 } 429 }
468 430
469 void CodeInstaller::record_scope(jint pc_offset, oop code_pos, GrowableArray<ScopeValue*>* objects) { 431 void CodeInstaller::record_scope(jint pc_offset, oop code_pos, GrowableArray<ScopeValue*>* objects) {
470 oop caller_pos = CiCodePos::caller(code_pos); 432 oop caller_pos = CiCodePos::caller(code_pos);
471 if (caller_pos != NULL) { 433 if (caller_pos != NULL) {