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

Method initOffsets

src/vmStructs.cpp:147–438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145}
146
147void VMStructs::initOffsets() {
148 uintptr_t entry = readSymbol("gHotSpotVMStructs");
149 uintptr_t stride = readSymbol("gHotSpotVMStructEntryArrayStride");
150 uintptr_t type_offset = readSymbol("gHotSpotVMStructEntryTypeNameOffset");
151 uintptr_t field_offset = readSymbol("gHotSpotVMStructEntryFieldNameOffset");
152 uintptr_t offset_offset = readSymbol("gHotSpotVMStructEntryOffsetOffset");
153 uintptr_t address_offset = readSymbol("gHotSpotVMStructEntryAddressOffset");
154
155 if (entry != 0 && stride != 0) {
156 for (;; entry += stride) {
157 const char* type = *(const char**)(entry + type_offset);
158 const char* field = *(const char**)(entry + field_offset);
159 if (type == NULL || field == NULL) {
160 break;
161 }
162
163 if (strcmp(type, "Klass") == 0) {
164 if (strcmp(field, "_name") == 0) {
165 _klass_name_offset = *(int*)(entry + offset_offset);
166 }
167 } else if (strcmp(type, "Symbol") == 0) {
168 if (strcmp(field, "_length") == 0) {
169 _symbol_length_offset = *(int*)(entry + offset_offset);
170 } else if (strcmp(field, "_length_and_refcount") == 0) {
171 _symbol_length_and_refcount_offset = *(int*)(entry + offset_offset);
172 } else if (strcmp(field, "_body") == 0) {
173 _symbol_body_offset = *(int*)(entry + offset_offset);
174 }
175 } else if (strcmp(type, "oopDesc") == 0) {
176 if (strcmp(field, "_metadata._klass") == 0) {
177 _oop_klass_offset = *(int*)(entry + offset_offset);
178 }
179 } else if (strcmp(type, "Universe") == 0 || strcmp(type, "CompressedKlassPointers") == 0) {
180 if (strcmp(field, "_narrow_klass._base") == 0 || strcmp(field, "_base") == 0) {
181 _narrow_klass_base_addr = *(char***)(entry + address_offset);
182 } else if (strcmp(field, "_narrow_klass._shift") == 0 || strcmp(field, "_shift") == 0) {
183 _narrow_klass_shift_addr = *(int**)(entry + address_offset);
184 } else if (strcmp(field, "_collectedHeap") == 0) {
185 _collected_heap_addr = *(char***)(entry + address_offset);
186 }
187 } else if (strcmp(type, "CollectedHeap") == 0) {
188 if (strcmp(field, "_reserved") == 0) {
189 _collected_heap_reserved_offset = *(int*)(entry + offset_offset);
190 }
191 } else if (strcmp(type, "MemRegion") == 0) {
192 if (strcmp(field, "_start") == 0) {
193 _region_start_offset = *(int*)(entry + offset_offset);
194 } else if (strcmp(field, "_word_size") == 0) {
195 _region_size_offset = *(int*)(entry + offset_offset);
196 }
197 } else if (strcmp(type, "CompiledMethod") == 0 || strcmp(type, "nmethod") == 0) {
198 if (strcmp(field, "_method") == 0) {
199 _nmethod_method_offset = *(int*)(entry + offset_offset);
200 } else if (strcmp(field, "_verified_entry_offset") == 0) {
201 _nmethod_entry_offset = *(int*)(entry + offset_offset);
202 } else if (strcmp(field, "_verified_entry_point") == 0) {
203 _nmethod_entry_offset = - *(int*)(entry + offset_offset);
204 } else if (strcmp(field, "_state") == 0) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected