From a6e28342528594f4a9b9a44e25def36ae14c88a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Mon, 4 May 2015 17:32:51 +0200 Subject: [PATCH] VM: refactoring to use the visit_object_array method --- vm/collector.hpp | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/vm/collector.hpp b/vm/collector.hpp index 791446e9fe..9a5439c868 100644 --- a/vm/collector.hpp +++ b/vm/collector.hpp @@ -100,18 +100,12 @@ template struct collector { void trace_partial_objects(cell start, cell card_start, cell card_end) { object* obj = (object*)start; cell end = start + obj->binary_payload_start(); - if (card_start < end) { - start += sizeof(cell); + start += sizeof(cell); - start = std::max(start, card_start); - end = std::min(end, card_end); + start = std::max(start, card_start); + end = std::min(end, card_end); - cell* slot_ptr = (cell*)start; - cell* end_ptr = (cell*)end; - - for (; slot_ptr < end_ptr; slot_ptr++) - visitor.visit_handle(slot_ptr); - } + visitor.visit_object_array((cell*)start, (cell*)end); } template @@ -152,21 +146,20 @@ template struct collector { /* Address of last traced object. */ cell start = 0; - for (cell deck_index = first_deck; deck_index < last_deck; deck_index++) { - if (decks[deck_index] & mask) { - decks[deck_index] &= ~unmask; + for (cell di = first_deck; di < last_deck; di++) { + if (decks[di] & mask) { + decks[di] &= ~unmask; decks_scanned++; - cell first_card = cards_per_deck * deck_index; + cell first_card = cards_per_deck * di; cell last_card = first_card + cards_per_deck; - for (cell card_index = first_card; card_index < last_card; - card_index++) { - if (cards[card_index] & mask) { - cards[card_index] &= ~unmask; + for (cell ci = first_card; ci < last_card; ci++) { + if (cards[ci] & mask) { + cards[ci] &= ~unmask; cards_scanned++; - start = trace_card(gen, card_index, start); + start = trace_card(gen, ci, start); if (!start) { /* At end of generation, no need to scan more cards. */ return;