class IndirectReferenceTableTest : public CommonRuntimeTest { protected:
IndirectReferenceTableTest() {
use_boot_image_ = true; // Make the Runtime creation cheaper.
}
};
// Table should be empty now.
EXPECT_EQ(0U, irt.Capacity());
// Check that the entry off the end of the list is not valid. // (CheckJNI shall abort for such entries.)
EXPECT_FALSE(irt.IsValidReference(iref0, &error_msg));
ASSERT_EQ(0U, irt.Capacity()) << "not empty after split remove";
// Add an entry, remove it, add a new entry, and try to use the original // iref. They have the same slot number but are for different objects. // With the extended checks in place, this should fail.
iref0 = irt.Add(obj0.Get(), &error_msg);
EXPECT_TRUE(iref0 != nullptr);
CheckDump(&irt, 1, 1);
ASSERT_TRUE(irt.Remove(iref0));
CheckDump(&irt, 0, 0);
iref1 = irt.Add(obj1.Get(), &error_msg);
EXPECT_TRUE(iref1 != nullptr);
CheckDump(&irt, 1, 1);
ASSERT_FALSE(irt.Remove(iref0)) << "mismatched del succeeded";
CheckDump(&irt, 1, 1);
ASSERT_TRUE(irt.Remove(iref1)) << "switched del failed";
ASSERT_EQ(0U, irt.Capacity()) << "switching del not empty";
CheckDump(&irt, 0, 0);
// Same as above, but with the same object. A more rigorous checker // (e.g. with slot serialization) will catch this.
iref0 = irt.Add(obj0.Get(), &error_msg);
EXPECT_TRUE(iref0 != nullptr);
CheckDump(&irt, 1, 1);
ASSERT_TRUE(irt.Remove(iref0));
CheckDump(&irt, 0, 0);
iref1 = irt.Add(obj0.Get(), &error_msg);
EXPECT_TRUE(iref1 != nullptr);
CheckDump(&irt, 1, 1); if (iref0 != iref1) { // Try 0, should not work.
ASSERT_FALSE(irt.Remove(iref0)) << "temporal del succeeded";
}
ASSERT_TRUE(irt.Remove(iref1)) << "temporal cleanup failed";
ASSERT_EQ(0U, irt.Capacity()) << "temporal del not empty";
CheckDump(&irt, 0, 0);
// Stale reference is not valid.
iref0 = irt.Add(obj0.Get(), &error_msg);
EXPECT_TRUE(iref0 != nullptr);
CheckDump(&irt, 1, 1);
ASSERT_TRUE(irt.Remove(iref0));
EXPECT_FALSE(irt.IsValidReference(iref0, &error_msg)) << "stale lookup succeeded";
CheckDump(&irt, 0, 0);
// Test deleting all but the last entry. // We shall delete these. staticconst size_t kTableInitial = kTableMax / 2;
IndirectRef manyRefs[kTableInitial]; for (size_t i = 0; i < kTableInitial; i++) {
manyRefs[i] = irt.Add(obj0.Get(), &error_msg);
ASSERT_TRUE(manyRefs[i] != nullptr) << "Failed adding " << i;
CheckDump(&irt, i + 1, 1);
} // We shall keep this one.
iref0 = irt.Add(obj0.Get(), &error_msg);
ASSERT_TRUE(iref0 != nullptr);
ASSERT_EQ(kTableInitial + 1, irt.Capacity());
CheckDump(&irt, kTableInitial + 1, 1); // Delete all but the last entry. for (size_t i = 0; i < kTableInitial; i++) {
ASSERT_TRUE(irt.Remove(manyRefs[i])) << "failed removing " << i;
CheckDump(&irt, kTableInitial - i, 1);
} // Because of removal order, should have 11 entries, 10 of them holes.
ASSERT_EQ(kTableInitial + 1, irt.Capacity());
ASSERT_TRUE(irt.Remove(iref0)) << "multi-remove final failed";
ASSERT_EQ(0U, irt.Capacity()) << "multi-del not empty";
CheckDump(&irt, 0, 0);
}
} // namespace art
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet am 2026-06-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.