| 465 | } |
| 466 | |
| 467 | void hx::Telemetry::HXTAllocation(void* obj, size_t inSize, const char* type) |
| 468 | { |
| 469 | if (ignoreAllocs>0 || !allocations_enabled) return; |
| 470 | |
| 471 | // Optionally ignore from extern::cffi - very expensive to track allocs |
| 472 | // for every external call, hashes for every SDL event (Lime's |
| 473 | // ExternalInterface.external_handler()), etc |
| 474 | #ifndef HXCPP_PROFILE_EXTERNS |
| 475 | if (stack->getCurrentStackFrame()->position->className==hx::EXTERN_CLASS_NAME) { |
| 476 | alloc_mutex.unlock(); |
| 477 | return; |
| 478 | } |
| 479 | #endif |
| 480 | |
| 481 | int obj_id = __hxt_ptr_id(obj); |
| 482 | |
| 483 | alloc_mutex.lock(); |
| 484 | |
| 485 | // HXT debug: Check for id collision |
| 486 | #ifdef HXCPP_TELEMETRY_DEBUG |
| 487 | std::map<void*, hx::Telemetry*>::iterator exist = alloc_map.find(obj); |
| 488 | if (exist != alloc_map.end()) { |
| 489 | printf("HXT ERR: Object id collision! at on %016lx, id=%016lx\n", obj, obj_id); |
| 490 | throw "uh oh"; |
| 491 | alloc_mutex.Unlock(); |
| 492 | return; |
| 493 | } |
| 494 | #endif |
| 495 | |
| 496 | int stackid = ComputeCallStackId(); |
| 497 | |
| 498 | if (_last_obj!=0) lookup_last_object_type(); |
| 499 | if (type==0) { |
| 500 | _last_obj = (hx::Object*)obj; |
| 501 | _last_loc = allocation_data->size(); |
| 502 | type = "_unresolved"; |
| 503 | } |
| 504 | |
| 505 | allocation_data->push_back(0); // alloc flag |
| 506 | allocation_data->push_back(obj_id); |
| 507 | allocation_data->push_back(GetNameIdx(type)); // defer lookup |
| 508 | allocation_data->push_back((int)inSize); |
| 509 | allocation_data->push_back(stackid); |
| 510 | |
| 511 | alloc_map[obj] = this; |
| 512 | |
| 513 | //__hxcpp_set_hxt_finalizer(obj, (void*)Telemetry::HXTReclaim); |
| 514 | |
| 515 | //printf("Tracking alloc %s at %016lx, id=%016lx, s=%d for telemetry %016lx, ts=%f\n", type, obj, obj_id, inSize, this, __hxcpp_time_stamp()); |
| 516 | |
| 517 | alloc_mutex.unlock(); |
| 518 | } |
| 519 | |
| 520 | void hx::Telemetry::HXTRealloc(void* old_obj, void* new_obj, int new_size) |
| 521 | { |
no test coverage detected