| 713 | } |
| 714 | |
| 715 | int NMethod::findScopeOffset(const void* pc) { |
| 716 | intptr_t pc_offset = (const char*)pc - code(); |
| 717 | if (pc_offset < 0 || pc_offset > 0x7fffffff) { |
| 718 | return -1; |
| 719 | } |
| 720 | |
| 721 | const int* scopes_pcs = (const int*) at(_scopes_pcs_offset); |
| 722 | PcDesc* pcd = (PcDesc*) immutableDataAt(scopes_pcs[0]); |
| 723 | PcDesc* pcd_end = (PcDesc*) immutableDataAt(scopes_pcs[1]); |
| 724 | int low = 0; |
| 725 | int high = (pcd_end - pcd) - 1; |
| 726 | |
| 727 | while (low <= high) { |
| 728 | int mid = (unsigned int)(low + high) >> 1; |
| 729 | if (pcd[mid]._pc < pc_offset) { |
| 730 | low = mid + 1; |
| 731 | } else if (pcd[mid]._pc > pc_offset) { |
| 732 | high = mid - 1; |
| 733 | } else { |
| 734 | return pcd[mid]._scope_offset; |
| 735 | } |
| 736 | } |
| 737 | |
| 738 | return pcd + low < pcd_end ? pcd[low]._scope_offset : -1; |
| 739 | } |
| 740 | |
| 741 | int ScopeDesc::readInt() { |
| 742 | unsigned char c = *_stream++; |