Commit c7bd5c40 authored by Marius Wachtler's avatar Marius Wachtler

ICSlotInfo: remove old invalidator entries

parent fca39ba9
...@@ -73,10 +73,21 @@ void ICInvalidator::invalidateAll() { ...@@ -73,10 +73,21 @@ void ICInvalidator::invalidateAll() {
dependents.clear(); dependents.clear();
} }
void ICSlotInfo::clear() { void ICSlotInfo::clear(bool should_invalidate) {
ic->clear(this); if (should_invalidate)
ic->invalidate(this);
used = false; 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) if (num_inside == 0)
decref_infos.clear(); decref_infos.clear();
} }
...@@ -163,11 +174,6 @@ void ICSlotRewrite::commit(CommitHook* hook, std::vector<void*> gc_references, ...@@ -163,11 +174,6 @@ void ICSlotRewrite::commit(CommitHook* hook, std::vector<void*> gc_references,
assert(original_size == assembler.bytesWritten()); 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++; 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 // 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, ...@@ -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); // if (VERBOSITY()) printf("Commiting to %p-%p\n", start, start + ic->slot_size);
memcpy(slot_start, buf, original_size); memcpy(slot_start, buf, original_size);
for (auto p : ic_entry->gc_references) { ic_entry->clear(false /* don't invalidate */);
Py_DECREF(p);
}
ic_entry->gc_references = std::move(gc_references); ic_entry->gc_references = std::move(gc_references);
ic_entry->used = true; ic_entry->used = true;
ic->times_rewritten++; 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) { if (ic->times_rewritten == IC_MEGAMORPHIC_THRESHOLD) {
static StatCounter megamorphic_ics("megamorphic_ics"); static StatCounter megamorphic_ics("megamorphic_ics");
megamorphic_ics.log(); megamorphic_ics.log();
...@@ -416,7 +426,7 @@ ICInfo* getICInfo(void* rtn_addr) { ...@@ -416,7 +426,7 @@ ICInfo* getICInfo(void* rtn_addr) {
return it->second; return it->second;
} }
void ICInfo::clear(ICSlotInfo* icentry) { void ICInfo::invalidate(ICSlotInfo* icentry) {
assert(icentry); assert(icentry);
uint8_t* start = (uint8_t*)icentry->start_addr; uint8_t* start = (uint8_t*)icentry->start_addr;
...@@ -429,11 +439,6 @@ void ICInfo::clear(ICSlotInfo* icentry) { ...@@ -429,11 +439,6 @@ void ICInfo::clear(ICSlotInfo* icentry) {
writer.jmp(JumpDestination::fromStart(icentry->size)); writer.jmp(JumpDestination::fromStart(icentry->size));
assert(writer.bytesWritten() <= IC_INVALDITION_HEADER_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)); // std::unique_ptr<MCWriter> writer(createMCWriter(start, getSlotSize(), 0));
// writer->emitNop(); // writer->emitNop();
// writer->emitGuardFalse(); // writer->emitGuardFalse();
......
...@@ -71,7 +71,7 @@ public: ...@@ -71,7 +71,7 @@ public:
std::vector<DecrefInfo> decref_infos; std::vector<DecrefInfo> decref_infos;
std::vector<ICInvalidator*> invalidators; // ICInvalidators that reference this slotinfo std::vector<ICInvalidator*> invalidators; // ICInvalidators that reference this slotinfo
void clear(); void clear(bool should_invalidate = true);
}; };
typedef BitSet<16> LiveOutSet; typedef BitSet<16> LiveOutSet;
...@@ -120,10 +120,10 @@ public: ...@@ -120,10 +120,10 @@ public:
const LiveOutSet& getLiveOuts() { return live_outs; } const LiveOutSet& getLiveOuts() { return live_outs; }
std::unique_ptr<ICSlotRewrite> startRewrite(const char* debug_name); std::unique_ptr<ICSlotRewrite> startRewrite(const char* debug_name);
void clear(ICSlotInfo* entry); void invalidate(ICSlotInfo* entry);
void clearAll() { void clearAll() {
for (ICSlotInfo& slot_info : slots) { for (ICSlotInfo& slot_info : slots) {
clear(&slot_info); slot_info.clear();
} }
} }
......
...@@ -297,6 +297,7 @@ public: ...@@ -297,6 +297,7 @@ public:
void addDependent(ICSlotInfo* icentry); void addDependent(ICSlotInfo* icentry);
int64_t version(); int64_t version();
void invalidateAll(); void invalidateAll();
void remove(ICSlotInfo* icentry) { dependents.erase(icentry); }
friend class ICInfo; friend class ICInfo;
friend class ICSlotInfo; 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