Commit c7bd5c40 authored by Marius Wachtler's avatar Marius Wachtler

ICSlotInfo: remove old invalidator entries

parent fca39ba9
......@@ -73,10 +73,21 @@ void ICInvalidator::invalidateAll() {
dependents.clear();
}
void ICSlotInfo::clear() {
ic->clear(this);
void ICSlotInfo::clear(bool should_invalidate) {
if (should_invalidate)
ic->invalidate(this);
used = false;
for (auto p : gc_references) {
Py_DECREF(p);
}
gc_references.clear();
for (auto&& invalidator : invalidators) {
invalidator->remove(this);
}
invalidators.clear();
if (num_inside == 0)
decref_infos.clear();
}
......@@ -163,11 +174,6 @@ void ICSlotRewrite::commit(CommitHook* hook, std::vector<void*> gc_references,
assert(original_size == assembler.bytesWritten());
}
for (int i = 0; i < dependencies.size(); i++) {
ICInvalidator* invalidator = dependencies[i].first;
invalidator->addDependent(ic_entry);
}
ic->next_slot_to_try++;
// we can create a new IC slot if this is the last slot in the IC in addition we are checking that the new slot is
......@@ -202,13 +208,17 @@ void ICSlotRewrite::commit(CommitHook* hook, std::vector<void*> gc_references,
// if (VERBOSITY()) printf("Commiting to %p-%p\n", start, start + ic->slot_size);
memcpy(slot_start, buf, original_size);
for (auto p : ic_entry->gc_references) {
Py_DECREF(p);
}
ic_entry->clear(false /* don't invalidate */);
ic_entry->gc_references = std::move(gc_references);
ic_entry->used = true;
ic->times_rewritten++;
for (int i = 0; i < dependencies.size(); i++) {
ICInvalidator* invalidator = dependencies[i].first;
invalidator->addDependent(ic_entry);
}
if (ic->times_rewritten == IC_MEGAMORPHIC_THRESHOLD) {
static StatCounter megamorphic_ics("megamorphic_ics");
megamorphic_ics.log();
......@@ -416,7 +426,7 @@ ICInfo* getICInfo(void* rtn_addr) {
return it->second;
}
void ICInfo::clear(ICSlotInfo* icentry) {
void ICInfo::invalidate(ICSlotInfo* icentry) {
assert(icentry);
uint8_t* start = (uint8_t*)icentry->start_addr;
......@@ -429,11 +439,6 @@ void ICInfo::clear(ICSlotInfo* icentry) {
writer.jmp(JumpDestination::fromStart(icentry->size));
assert(writer.bytesWritten() <= IC_INVALDITION_HEADER_SIZE);
for (auto p : icentry->gc_references) {
Py_DECREF(p);
}
icentry->gc_references.clear();
// std::unique_ptr<MCWriter> writer(createMCWriter(start, getSlotSize(), 0));
// writer->emitNop();
// writer->emitGuardFalse();
......
......@@ -71,7 +71,7 @@ public:
std::vector<DecrefInfo> decref_infos;
std::vector<ICInvalidator*> invalidators; // ICInvalidators that reference this slotinfo
void clear();
void clear(bool should_invalidate = true);
};
typedef BitSet<16> LiveOutSet;
......@@ -120,10 +120,10 @@ public:
const LiveOutSet& getLiveOuts() { return live_outs; }
std::unique_ptr<ICSlotRewrite> startRewrite(const char* debug_name);
void clear(ICSlotInfo* entry);
void invalidate(ICSlotInfo* entry);
void clearAll() {
for (ICSlotInfo& slot_info : slots) {
clear(&slot_info);
slot_info.clear();
}
}
......
......@@ -297,6 +297,7 @@ public:
void addDependent(ICSlotInfo* icentry);
int64_t version();
void invalidateAll();
void remove(ICSlotInfo* icentry) { dependents.erase(icentry); }
friend class ICInfo;
friend class ICSlotInfo;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment