MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / binarySearch

Method binarySearch

src/codeCache.cpp:133–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131}
132
133const char* CodeCache::binarySearch(const void* address) {
134 int low = 0;
135 int high = _count - 1;
136
137 while (low <= high) {
138 int mid = (unsigned int)(low + high) >> 1;
139 if (_blobs[mid]._end <= address) {
140 low = mid + 1;
141 } else if (_blobs[mid]._start > address) {
142 high = mid - 1;
143 } else {
144 return _blobs[mid]._name;
145 }
146 }
147
148 // Symbols with zero size can be valid functions: e.g. ASM entry points or kernel code.
149 // Also, in some cases (endless loop) the return address may point beyond the function.
150 if (low > 0 && (_blobs[low - 1]._start == _blobs[low - 1]._end || _blobs[low - 1]._end == address)) {
151 return _blobs[low - 1]._name;
152 }
153 return _name;
154}
155
156const void* CodeCache::findSymbol(const char* name) {
157 CodeBlob* blob = findBlob(name);

Callers 3

findNativeMethodMethod · 0.80
walkVMMethod · 0.80
containsMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected