Exemplo n.º 1
0
void InflatedHeaders::deallocate_headers(unsigned int mark) {
    std::vector<bool> chunk_marks(allocator_->chunks_.size(), false);

    diagnostics_.objects_ = 0;

    for(std::vector<int>::size_type i = 0; i < allocator_->chunks_.size(); ++i) {
        InflatedHeader* chunk = allocator_->chunks_[i];

        for(size_t j = 0; j < allocator_->cChunkSize; j++) {
            InflatedHeader* header = &chunk[j];

            if(header->marked_p(mark)) {
                chunk_marks[i] = true;
                diagnostics_.objects_++;
            } else {
                header->clear();
            }
        }
    }

    allocator_->rebuild_freelist(&chunk_marks);

    diagnostics_.bytes_ = allocator_->in_use_ * sizeof(InflatedHeader);
    diagnostics_.modify();
}
Exemplo n.º 2
0
void InflatedHeaders::deallocate_headers(unsigned int mark) {
    std::vector<bool> chunk_marks(allocator_->chunks_.size(), false);
    for(std::vector<int>::size_type i = 0; i < allocator_->chunks_.size(); ++i) {
        InflatedHeader* chunk = allocator_->chunks_[i];

        for(size_t j = 0; j < allocator_->cChunkSize; j++) {
            InflatedHeader* header = &chunk[j];

            if(header->marked_p(mark)) {
                chunk_marks[i] = true;
            } else {
                header->clear();
            }
        }
    }

    allocator_->rebuild_freelist(&chunk_marks);
}
Exemplo n.º 3
0
void Handles::deallocate_handles(std::list<Handle*>* cached, int mark, BakerGC* young) {
    std::vector<bool> chunk_marks(allocator_->chunks_.size(), false);

    for(std::vector<int>::size_type i = 0; i < allocator_->chunks_.size(); ++i) {
        Handle* chunk = allocator_->chunks_[i];

        for(size_t j = 0; j < allocator_->cChunkSize; j++) {
            Handle* handle = &chunk[j];

            Object* obj = handle->object();

            if(!handle->in_use_p()) {
                continue;
            }

            // Strong references will already have been updated.
            if(!handle->weak_p()) {
                chunk_marks[i] = true;
                continue;
            }

            if(young) {
                if(obj->young_object_p()) {
                    // A weakref pointing to a valid young object
                    //
                    // TODO this only works because we run prune_handles right after
                    // a collection. In this state, valid objects are only in current.
                    if(young->in_current_p(obj)) {
                        chunk_marks[i] = true;
                        // A weakref pointing to a forwarded young object
                    } else if(obj->forwarded_p()) {
                        handle->set_object(obj->forward());
                        chunk_marks[i] = true;
                        // A weakref pointing to a dead young object
                    } else {
                        handle->clear();
                    }
                } else {
                    // Not a young object, so won't be GC'd so mark
                    // chunk as still active
                    chunk_marks[i] = true;
                }

                // A weakref pointing to a dead mature object
            } else if(!obj->marked_p(mark)) {
                handle->clear();
            } else {
                chunk_marks[i] = true;
            }
        }
    }

    // Cleanup cached handles
    for(std::list<Handle*>::iterator it = cached->begin(); it != cached->end();) {
        Handle* handle = *it;

        if(handle->in_use_p()) {
            ++it;
        } else {
            it = cached->erase(it);
        }
    }

    allocator_->rebuild_freelist(&chunk_marks);
}