Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/ComputeCxx/Attribute/AttributeID/AttributeID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ OffsetAttributeID AttributeID::resolve_slow(TraversalOptions options) const {
}

if (options & TraversalOptions::EvaluateWeakReferences) {
if (indirect_node->source().expired()) {
if (indirect_node->source().is_freed()) {
if (options & TraversalOptions::AssertNotNil) {
precondition_failure("invalid indirect ref: %u", _value);
}
Expand Down
15 changes: 13 additions & 2 deletions Sources/ComputeCxx/Attribute/AttributeID/WeakAttributeID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace IAG {

bool WeakAttributeID::expired() const {
bool WeakAttributeID::is_expired() const {
uint64_t raw_page_seed = data::table::shared().raw_page_seed(_identifier.page_ptr());
if (raw_page_seed & 0xff00000000) {
auto zone_info = data::zone::info::from_raw_value(uint32_t(raw_page_seed));
Expand All @@ -17,8 +17,19 @@ bool WeakAttributeID::expired() const {
return true;
}

bool WeakAttributeID::is_freed() const {
uint64_t raw_page_seed = data::table::shared().raw_page_seed(_identifier.page_ptr());
if (raw_page_seed & 0xff00000000) {
auto zone_info = data::zone::info::from_raw_value(uint32_t(raw_page_seed));
if (zone_info.zone_id() == _seed) {
return false;
}
}
return true;
}

AttributeID WeakAttributeID::evaluate() const {
return _identifier && !expired() ? _identifier : AttributeID(IAGAttributeNil);
return _identifier && !is_expired() ? _identifier : AttributeID(IAGAttributeNil);
};

} // namespace IAG
11 changes: 9 additions & 2 deletions Sources/ComputeCxx/Attribute/AttributeID/WeakAttributeID.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,16 @@ class WeakAttributeID {
AttributeID identifier() const { return _identifier; };
uint32_t seed() const { return _seed; }

bool expired() const;
/// Returns true if the attribute can no longer be evaluated.
bool is_expired() const;

/// Returns the attribute it is has not expired, otherwise returns the nil
/// Returns true when the attribute's subgraph has been freed (or reused).
///
/// This method may return false if the attribute's subgraph has been
/// invalidated but not yet destroyed.
bool is_freed() const;

/// Returns the attribute if it has not expired, otherwise returns the nil
/// attribute.
AttributeID evaluate() const;
};
Expand Down
10 changes: 5 additions & 5 deletions Sources/ComputeCxx/Graph/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ void Graph::remove_indirect_node(data::ptr<IndirectNode> indirect_node) {
return;
}

if (indirect_node->source().expired()) {
if (indirect_node->source().is_freed()) {
return;
}

Expand Down Expand Up @@ -557,7 +557,7 @@ void Graph::remove_indirect_node(data::ptr<IndirectNode> indirect_node) {
}
break;
} else {
if (source_indirect_node->source().expired()) {
if (source_indirect_node->source().is_freed()) {
break;
}

Expand Down Expand Up @@ -625,7 +625,7 @@ bool Graph::remove_removed_output(AttributeID attribute, AttributeID output, boo
if (output_indirect_node->is_mutable()) {
auto &mutable_output_indirect_node = output_indirect_node->to_mutable();
auto initial_source = mutable_output_indirect_node.initial_source();
if (initial_source.identifier() && !initial_source.identifier().is_nil() && !initial_source.expired()) {
if (initial_source.identifier() && !initial_source.identifier().is_nil() && !initial_source.is_expired()) {
new_source = initial_source;
new_offset = mutable_output_indirect_node.initial_offset();
}
Expand All @@ -637,7 +637,7 @@ bool Graph::remove_removed_output(AttributeID attribute, AttributeID output, boo

output_indirect_node->modify(new_source, new_offset);

if (new_source.identifier() && !new_source.identifier().is_nil() && !new_source.expired()) {
if (new_source.identifier() && !new_source.identifier().is_nil() && !new_source.is_expired()) {
add_input_dependencies(output, new_source.identifier());
}

Expand Down Expand Up @@ -918,7 +918,7 @@ bool Graph::indirect_attribute_reset(data::ptr<IndirectNode> indirect_node, bool

auto initial_source = indirect_node->to_mutable().initial_source();
auto initial_offset = indirect_node->to_mutable().initial_offset();
if (!initial_source.expired()) {
if (!initial_source.is_expired()) {
new_source = initial_source;
new_offset = initial_offset;
} else {
Expand Down
Loading