Lines Matching refs:bk
221 /* 'bk' is being introduced (has just been allocated). Find the
225 static void intro_Block ( Block* bk )
227 tl_assert(bk);
228 tl_assert(bk->ap);
234 &keyW, &valW, (UWord)bk->ap );
237 tl_assert(keyW == (UWord)bk->ap);
241 api->ap = bk->ap;
243 (UWord)bk->ap, (UWord)api );
252 tl_assert(api->ap == bk->ap);
260 api->cur_bytes_live += bk->req_szB;
268 api->tot_bytes += bk->req_szB;
272 g_tot_bytes += bk->req_szB;
275 g_cur_bytes_live += bk->req_szB;
283 /* 'bk' is retiring (being freed). Find the relevant APInfo entry for
284 it, which must already exist. Then, fold info from 'bk' into that
291 static void retire_Block ( Block* bk, Bool because_freed )
293 tl_assert(bk);
294 tl_assert(bk->ap);
300 &keyW, &valW, (UWord)bk->ap );
304 tl_assert(api->ap == bk->ap);
308 VG_(printf)("ec %p api->c_by_l %llu bk->rszB %llu\n",
309 bk->ap, api->cur_bytes_live, (ULong)bk->req_szB);
314 tl_assert(api->cur_bytes_live >= bk->req_szB);
316 api->cur_bytes_live -= bk->req_szB;
320 tl_assert(bk->allocd_at <= g_guest_instrs_executed);
321 api->death_ages_sum += (g_guest_instrs_executed - bk->allocd_at);
326 tl_assert(g_cur_bytes_live >= bk->req_szB);
327 g_cur_bytes_live -= bk->req_szB;
331 api->n_reads += bk->n_reads;
332 api->n_writes += bk->n_writes;
342 api->xsize = bk->req_szB;
345 if (bk->histoW) {
354 if (bk->req_szB != api->xsize) {
356 api, api->xsize, bk->req_szB);
377 if (api->xsize_tag == Exactly && api->histo && bk->histoW) {
378 tl_assert(api->xsize == bk->req_szB);
384 api->histo[i] += (UInt)bk->histoW[i];
392 if (bk->histoB) {
393 VG_(printf)("block retiring, histo %lu: ", bk->req_szB);
395 for (i = 0; i < bk->req_szB; i++)
396 VG_(printf)("%u ", (UInt)bk->histoB[i]);
399 VG_(printf)("block retiring, no histo %lu\n", bk->req_szB);
477 Block* bk = VG_(malloc)("dh.new_block.1", sizeof(Block));
478 bk->payload = (Addr)p;
479 bk->req_szB = req_szB;
480 bk->ap = VG_(record_ExeContext)(tid, 0/*first word delta*/);
481 bk->allocd_at = g_guest_instrs_executed;
482 bk->n_reads = 0;
483 bk->n_writes = 0;
485 bk->histoW = NULL;
487 bk->histoW = VG_(malloc)("dh.new_block.2", req_szB * sizeof(UShort));
488 VG_(memset)(bk->histoW, 0, req_szB * sizeof(UShort));
491 Bool present = VG_(addToFM)( interval_tree, (UWord)bk, (UWord)0/*no val*/);
495 intro_Block(bk);
507 Block* bk = find_Block_containing( (Addr)p );
509 if (!bk) {
513 tl_assert(bk->req_szB > 0);
515 bk->payload <= (Addr)p);
516 tl_assert( (Addr)p < bk->payload + bk->req_szB );
518 if (bk->payload != (Addr)p) {
523 p, g_guest_instrs_executed - bk->allocd_at);
525 retire_Block(bk, True/*because_freed*/);
527 VG_(cli_free)( (void*)bk->payload );
528 delete_Block_starting_at( bk->payload );
529 if (bk->histoW) {
530 VG_(free)( bk->histoW );
531 bk->histoW = NULL;
533 VG_(free)( bk );
546 Block* bk = find_Block_containing( (Addr)p_old );
547 if (!bk) {
551 tl_assert(bk->req_szB > 0);
553 tl_assert(bk->payload <= (Addr)p_old);
554 tl_assert( (Addr)p_old < bk->payload + bk->req_szB );
556 if (bk->payload != (Addr)p_old) {
562 if (bk->histoW) {
563 VG_(free)(bk->histoW);
564 bk->histoW = NULL;
568 if (new_req_szB <= bk->req_szB) {
571 apinfo_change_cur_bytes_live(bk->ap,
572 (Long)new_req_szB - (Long)bk->req_szB);
573 bk->req_szB = new_req_szB;
587 VG_(memcpy)(p_new, p_old, bk->req_szB);
594 // now 'bk' is no longer in the tree, but the Block itself
598 apinfo_change_cur_bytes_live(bk->ap,
599 (Long)new_req_szB - (Long)bk->req_szB);
600 bk->payload = (Addr)p_new;
601 bk->req_szB = new_req_szB;
605 = VG_(addToFM)( interval_tree, (UWord)bk, (UWord)0/*no val*/);
685 void inc_histo_for_block ( Block* bk, Addr addr, UWord szB )
688 offMin = addr - bk->payload;
689 tl_assert(offMin < bk->req_szB);
691 if (offMax1 > bk->req_szB)
692 offMax1 = bk->req_szB;
693 //VG_(printf)("%lu %lu (size of block %lu)\n", offMin, offMax1, bk->req_szB);
695 UShort n = bk->histoW[i];
697 bk->histoW[i] = n;
704 Block* bk = find_Block_containing(addr);
705 if (bk) {
706 bk->n_writes += szB;
707 if (bk->histoW)
708 inc_histo_for_block(bk, addr, szB);
715 Block* bk = find_Block_containing(addr);
716 if (bk) {
717 bk->n_reads += szB;
718 if (bk->histoW)
719 inc_histo_for_block(bk, addr, szB);
1279 Block* bk = (Block*)keyW;
1281 tl_assert(bk);
1282 retire_Block(bk, False/*!because_freed*/);