Commit 2023c928 authored by Marius Wachtler's avatar Marius Wachtler

rewriter: remove duplicate getAttr calls

parent 97426460
......@@ -416,6 +416,20 @@ void Rewriter::_addAttrGuard(RewriterVar* var, int offset, RewriterVar* val_cons
RewriterVar* RewriterVar::getAttr(int offset, Location dest, assembler::MovType type) {
STAT_TIMER(t0, "us_timer_rewriter", 10);
// if no changing action happened we can reuse get attributes
if (!rewriter->added_changing_action) {
RewriterVar*& result = getattrs[std::make_pair(offset, (int)type)];
if (result) {
if (dest != Location::any())
result->getInReg(dest, true /* allow_constant_in_reg */);
} else {
result = rewriter->createNewVar();
rewriter->addAction([=]() { rewriter->_getAttr(result, this, offset, dest, type); }, { this },
ActionType::NORMAL);
}
return result;
}
RewriterVar* result = rewriter->createNewVar();
rewriter->addAction([=]() { rewriter->_getAttr(result, this, offset, dest, type); }, { this }, ActionType::NORMAL);
return result;
......
......@@ -263,7 +263,8 @@ private:
Location arg_loc;
std::pair<int /*offset*/, int /*size*/> scratch_allocation;
llvm::SmallSet<std::tuple<int, uint64_t, bool>, 4> attr_guards; // used to detect duplicate guards
llvm::SmallSet<std::tuple<int, uint64_t, bool>, 4> attr_guards; // used to detect duplicate guards
llvm::SmallDenseMap<std::pair<int, int>, RewriterVar*> getattrs; // used to detect duplicate getAttrs
// Gets a copy of this variable in a register, spilling/reloading if necessary.
// TODO have to be careful with the result since the interface doesn't guarantee
......
......@@ -177,6 +177,8 @@ JitFragmentWriter::JitFragmentWriter(CFGBlock* block, std::unique_ptr<ICInfo> ic
ic_info(std::move(ic_info)) {
allocatable_regs = bjit_allocatable_regs;
added_changing_action = true;
if (LOG_BJIT_ASSEMBLY)
comment("BJIT: JitFragmentWriter() start");
interp = createNewVar();
......
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