llvm.org GIT mirror llvm / 58c3aa2
Add support for other typeinfo encodings in the ExceptionDemo. The old jit always uses DW_EH_PE_absptr, but MCJIT can use other encodings. This is in preparation for adding EH support to MCJIT, but not directly related, so I am committing it first. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180883 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
1 changed file(s) with 41 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
417417 return result;
418418 }
419419
420 unsigned getEncodingSize(uint8_t Encoding) {
421 if (Encoding == llvm::dwarf::DW_EH_PE_omit)
422 return 0;
423
424 switch (Encoding & 0x0F) {
425 case llvm::dwarf::DW_EH_PE_absptr:
426 return sizeof(uintptr_t);
427 case llvm::dwarf::DW_EH_PE_udata2:
428 return sizeof(uint16_t);
429 case llvm::dwarf::DW_EH_PE_udata4:
430 return sizeof(uint32_t);
431 case llvm::dwarf::DW_EH_PE_udata8:
432 return sizeof(uint64_t);
433 case llvm::dwarf::DW_EH_PE_sdata2:
434 return sizeof(int16_t);
435 case llvm::dwarf::DW_EH_PE_sdata4:
436 return sizeof(int32_t);
437 case llvm::dwarf::DW_EH_PE_sdata8:
438 return sizeof(int64_t);
439 default:
440 // not supported
441 abort();
442 }
443 }
420444
421445 /// Read a pointer encoded value and advance pointer
422446 /// See Variable Length Data in:
522546 /// @returns whether or not a type info was found. False is returned if only
523547 /// a cleanup was found
524548 static bool handleActionValue(int64_t *resultAction,
525 struct OurExceptionType_t **classInfo,
549 uint8_t TTypeEncoding,
550 const uint8_t *ClassInfo,
526551 uintptr_t actionEntry,
527552 uint64_t exceptionClass,
528553 struct _Unwind_Exception *exceptionObject) {
571596
572597 // Note: A typeOffset == 0 implies that a cleanup llvm.eh.selector
573598 // argument has been matched.
574 if ((typeOffset > 0) &&
575 (type == (classInfo[-typeOffset])->type)) {
599 if (typeOffset > 0) {
576600 #ifdef DEBUG
577601 fprintf(stderr,
578602 "handleActionValue(...):actionValue <%d> found.\n",
579603 i);
580604 #endif
581 *resultAction = i + 1;
582 ret = true;
583 break;
605 unsigned EncSize = getEncodingSize(TTypeEncoding);
606 const uint8_t *EntryP = ClassInfo - typeOffset * EncSize;
607 uintptr_t P = readEncodedPointer(&EntryP, TTypeEncoding);
608 struct OurExceptionType_t *ThisClassInfo =
609 reinterpret_cast(P);
610 if (ThisClassInfo->type == type) {
611 *resultAction = i + 1;
612 ret = true;
613 break;
614 }
584615 }
585616
586617 #ifdef DEBUG
632663 // emitted dwarf code)
633664 uintptr_t funcStart = _Unwind_GetRegionStart(context);
634665 uintptr_t pcOffset = pc - funcStart;
635 struct OurExceptionType_t **classInfo = NULL;
666 const uint8_t *ClassInfo = NULL;
636667
637668 // Note: See JITDwarfEmitter::EmitExceptionTable(...) for corresponding
638669 // dwarf emission
652683 // were flagged by type info arguments to llvm.eh.selector
653684 // intrinsic
654685 classInfoOffset = readULEB128(&lsda);
655 classInfo = (struct OurExceptionType_t**) (lsda + classInfoOffset);
686 ClassInfo = lsda + classInfoOffset;
656687 }
657688
658689 // Walk call-site table looking for range that
713744
714745 if (actionEntry) {
715746 exceptionMatched = handleActionValue(&actionValue,
716 classInfo,
747 ttypeEncoding,
748 ClassInfo,
717749 actionEntry,
718750 exceptionClass,
719751 exceptionObject);