void ICSlotRewrite::commit(CommitHook* hook, std::vector<void*> gc_references) { bool still_valid = true; for (int i = 0; i < dependencies.size(); i++) { int orig_version = dependencies[i].second; ICInvalidator* invalidator = dependencies[i].first; if (orig_version != invalidator->version()) { still_valid = false; break; } } if (!still_valid) { if (VERBOSITY() >= 3) printf("not committing %s icentry since a dependency got updated before commit\n", debug_name); return; } uint8_t* slot_start = getSlotStart(); uint8_t* continue_point = (uint8_t*)ic->continue_addr; bool do_commit = hook->finishAssembly(continue_point - slot_start); if (!do_commit) return; assert(!assembler.hasFailed()); for (int i = 0; i < dependencies.size(); i++) { ICInvalidator* invalidator = dependencies[i].first; invalidator->addDependent(ic_entry); } ic->next_slot_to_try++; // if (VERBOSITY()) printf("Commiting to %p-%p\n", start, start + ic->slot_size); memcpy(slot_start, buf, ic->getSlotSize()); for (auto p : ic_entry->gc_references) { int& i = ic_gc_references[p]; if (i == 1) ic_gc_references.erase(p); else --i; } ic_entry->gc_references = std::move(gc_references); for (auto p : ic_entry->gc_references) ic_gc_references[p]++; ic->times_rewritten++; if (ic->times_rewritten == IC_MEGAMORPHIC_THRESHOLD) { static StatCounter megamorphic_ics("megamorphic_ics"); megamorphic_ics.log(); } llvm::sys::Memory::InvalidateInstructionCache(slot_start, ic->getSlotSize()); }
void ICSlotRewrite::commit(CommitHook* hook) { bool still_valid = true; for (int i = 0; i < dependencies.size(); i++) { int orig_version = dependencies[i].second; ICInvalidator* invalidator = dependencies[i].first; if (orig_version != invalidator->version()) { still_valid = false; break; } } if (!still_valid) { if (VERBOSITY() >= 3) printf("not committing %s icentry since a dependency got updated before commit\n", debug_name); return; } ICSlotInfo* ic_entry = ic->pickEntryForRewrite(debug_name); if (ic_entry == NULL) return; uint8_t* slot_start = (uint8_t*)ic->start_addr + ic_entry->idx * ic->getSlotSize(); uint8_t* continue_point = (uint8_t*)ic->continue_addr; bool do_commit = hook->finishAssembly(ic_entry, continue_point - slot_start); if (!do_commit) return; assert(assembler->isExactlyFull()); assert(!assembler->hasFailed()); for (int i = 0; i < dependencies.size(); i++) { ICInvalidator* invalidator = dependencies[i].first; invalidator->addDependent(ic_entry); } // if (VERBOSITY()) printf("Commiting to %p-%p\n", start, start + ic->slot_size); memcpy(slot_start, buf, ic->getSlotSize()); ic->times_rewritten++; if (ic->times_rewritten == MEGAMORPHIC_THRESHOLD) { static StatCounter megamorphic_ics("megamorphic_ics"); megamorphic_ics.log(); } llvm::sys::Memory::InvalidateInstructionCache(slot_start, ic->getSlotSize()); }
void ICSlotRewrite::commit(uint64_t decision_path, CommitHook *hook) { bool still_valid = true; for (int i = 0; i < dependencies.size(); i++) { int orig_version = dependencies[i].second; ICInvalidator *invalidator = dependencies[i].first; if (orig_version != invalidator->version()) { still_valid = false; break; } } if (!still_valid) { if (VERBOSITY()) printf("not committing %s icentry since a dependency got updated before commit\n", debug_name); return; } ICSlotInfo *ic_entry = ic->pickEntryForRewrite(decision_path, debug_name); if (ic_entry == NULL) return; for (int i = 0; i < dependencies.size(); i++) { ICInvalidator *invalidator = dependencies[i].first; invalidator->addDependent(ic_entry); } uint8_t* slot_start = (uint8_t*)ic->start_addr + ic_entry->idx * ic->getSlotSize(); uint8_t* continue_point = (uint8_t*)ic->continue_addr; hook->finishAssembly(continue_point - slot_start); assert(assembler->isExactlyFull()); //if (VERBOSITY()) printf("Commiting to %p-%p\n", start, start + ic->slot_size); memcpy(slot_start, buf, ic->getSlotSize()); llvm::sys::Memory::InvalidateInstructionCache(slot_start, ic->getSlotSize()); }