Commit 1a1afc8c authored by Kevin Modzelewski's avatar Kevin Modzelewski

Stop rewriting ICs after a certain number of rewrites

It's a pretty crude heuristic, but it stops us from endlessly
rewriting "megamorphic" IC sites.

              pyston interp2.py                         :    6.7s baseline: 6.5 (+3.0%)
              pyston raytrace.py                        :    8.3s baseline: 7.9 (+4.3%)
              pyston nbody.py                           :   10.6s baseline: 10.3 (+3.1%)
              pyston fannkuch.py                        :    7.4s baseline: 7.4 (+0.8%)
              pyston chaos.py                           :   24.2s baseline: 24.6 (-1.5%)
              pyston spectral_norm.py                   :   22.7s baseline: 30.4 (-25.4%)
              pyston fasta.py                           :    9.0s baseline: 8.4 (+7.6%)
              pyston pidigits.py                        :    4.4s baseline: 4.3 (+1.7%)
              pyston richards.py                        :    2.7s baseline: 12.5 (-78.7%)
              pyston deltablue.py                       :    2.7s baseline: 2.6 (+0.9%)
              pyston (geomean-0b9f)                     :    7.6s baseline: 9.0 (-15.2%)

There are a number of regressions; I feel like this is something
we'll be tuning a lot.
parent 58d587ba
......@@ -107,6 +107,8 @@ void ICSlotRewrite::commit(CommitHook* hook) {
// if (VERBOSITY()) printf("Commiting to %p-%p\n", start, start + ic->slot_size);
memcpy(slot_start, buf, ic->getSlotSize());
ic->times_rewritten++;
llvm::sys::Memory::InvalidateInstructionCache(slot_start, ic->getSlotSize());
}
......@@ -175,8 +177,8 @@ ICInfo::ICInfo(void* start_addr, void* slowpath_rtn_addr, void* continue_addr, S
assembler::GenericRegister return_register, TypeRecorder* type_recorder)
: next_slot_to_try(0), stack_info(stack_info), num_slots(num_slots), slot_size(slot_size),
calling_conv(calling_conv), live_outs(live_outs.begin(), live_outs.end()), return_register(return_register),
type_recorder(type_recorder), failed(false), start_addr(start_addr), slowpath_rtn_addr(slowpath_rtn_addr),
continue_addr(continue_addr) {
type_recorder(type_recorder), failed(false), times_rewritten(0), start_addr(start_addr),
slowpath_rtn_addr(slowpath_rtn_addr), continue_addr(continue_addr) {
for (int i = 0; i < num_slots; i++) {
slots.push_back(ICSlotInfo(this, i));
}
......@@ -267,6 +269,6 @@ void ICInfo::clear(ICSlotInfo* icentry) {
}
bool ICInfo::shouldAttempt() {
return !failed;
return !failed && times_rewritten < 100;
}
}
......@@ -79,6 +79,8 @@ public:
void commit(CommitHook* hook);
void abort();
const ICInfo* getICInfo() { return ic; }
friend class ICInfo;
};
......@@ -99,6 +101,7 @@ private:
const assembler::GenericRegister return_register;
TypeRecorder* const type_recorder;
bool failed;
int times_rewritten;
// for ICSlotRewrite:
ICSlotInfo* pickEntryForRewrite(const char* debug_name);
......
......@@ -778,9 +778,6 @@ void Rewriter::commit() {
return;
}
static StatCounter rewriter_commits("rewriter_commits");
rewriter_commits.log();
// Add uses for the live_outs
for (int i = 0; i < live_outs.size(); i++) {
live_outs[i]->uses.push_back(actions.size());
......@@ -947,6 +944,9 @@ void Rewriter::commit() {
finished = true;
static StatCounter rewriter_commits("rewriter_commits");
rewriter_commits.log();
// TODO: have to check that we have enough room to write the final jmp
rewrite->commit(this);
......
......@@ -281,7 +281,7 @@ ICSetupInfo* createGenericIC(TypeRecorder* type_recorder, bool has_return_value,
}
ICSetupInfo* createGetattrIC(TypeRecorder* type_recorder) {
return ICSetupInfo::initialize(true, 1, 512, ICSetupInfo::Getattr, type_recorder);
return ICSetupInfo::initialize(true, 2, 512, ICSetupInfo::Getattr, type_recorder);
}
ICSetupInfo* createGetitemIC(TypeRecorder* type_recorder) {
......
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