the REPLACE function in the paper */
| 405 | |
| 406 | /* the REPLACE function in the paper */ |
| 407 | static void _ARCv0_replace(cache_t *cache, const request_t *req) { |
| 408 | ARCv0_params_t *params = (ARCv0_params_t *)(cache->eviction_params); |
| 409 | |
| 410 | int64_t t1_size = params->T1->get_occupied_byte(params->T1); |
| 411 | int64_t t2_size = params->T2->get_occupied_byte(params->T2); |
| 412 | |
| 413 | bool cond1 = t1_size > 0; |
| 414 | bool cond2 = t1_size > params->p; |
| 415 | bool cond3 = t1_size == params->p && params->curr_obj_in_L2_ghost; |
| 416 | bool cond4 = t2_size == 0; |
| 417 | |
| 418 | if ((cond1 && (cond2 || cond3)) || cond4) { |
| 419 | // delete the LRU in L1 data, move to L1_ghost |
| 420 | cache_obj_t *obj = params->T1->to_evict(params->T1, req); |
| 421 | DEBUG_ASSERT(obj != NULL); |
| 422 | copy_cache_obj_to_request(params->req_local, obj); |
| 423 | #ifdef LAZY_PROMOTION |
| 424 | if (obj->misc.freq > 0) { |
| 425 | params->T2->get(params->T2, params->req_local); |
| 426 | } else { |
| 427 | params->B1->get(params->B1, params->req_local); |
| 428 | } |
| 429 | #else |
| 430 | params->B1->get(params->B1, params->req_local); |
| 431 | #endif |
| 432 | params->T1->evict(params->T1, req); |
| 433 | } else { |
| 434 | // delete the item in L2 data, move to L2_ghost |
| 435 | cache_obj_t *obj = params->T2->to_evict(params->T2, req); |
| 436 | DEBUG_ASSERT(obj != NULL); |
| 437 | copy_cache_obj_to_request(params->req_local, obj); |
| 438 | params->T2->evict(params->T2, req); |
| 439 | params->B2->get(params->B2, params->req_local); |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | /* finding the eviction candidate in _ARCv0_evict_miss_on_all_queues, but do not |
| 444 | * perform eviction */ |
no test coverage detected