Commit 0009190e authored by Kevin Modzelewski's avatar Kevin Modzelewski

minor improvements

parent 9aef343b
......@@ -1138,21 +1138,25 @@ void Assembler::skipBytes(int num) {
addr += num;
}
ForwardJump::ForwardJump(Assembler& assembler, ConditionCode condition)
template <int MaxJumpSize>
ForwardJumpBase<MaxJumpSize>::ForwardJumpBase(Assembler& assembler, ConditionCode condition)
: assembler(assembler), condition(condition), jmp_inst(assembler.curInstPointer()) {
assembler.jmp_cond(JumpDestination::fromStart(assembler.bytesWritten() + max_jump_size), condition);
assembler.jmp_cond(JumpDestination::fromStart(assembler.bytesWritten() + MaxJumpSize), condition);
jmp_end = assembler.curInstPointer();
}
ForwardJump::~ForwardJump() {
template <int MaxJumpSize>
ForwardJumpBase<MaxJumpSize>::~ForwardJumpBase() {
uint8_t* new_pos = assembler.curInstPointer();
int offset = new_pos - jmp_inst;
RELEASE_ASSERT(offset < max_jump_size, "");
RELEASE_ASSERT(offset < MaxJumpSize, "");
assembler.setCurInstPointer(jmp_inst);
assembler.jmp_cond(JumpDestination::fromStart(assembler.bytesWritten() + offset), condition);
while (assembler.curInstPointer() < jmp_end)
assembler.nop();
assembler.setCurInstPointer(new_pos);
}
template class ForwardJumpBase<128>;
template class ForwardJumpBase<1048576>;
}
}
......@@ -214,19 +214,22 @@ public:
// This class helps generating a forward jump with a relative offset.
// It keeps track of the current assembler offset at construction time and in the destructor patches the
// generated conditional jump with the correct offset depending on the number of bytes emitted in between.
class ForwardJump {
template <int MaxJumpSize=128>
class ForwardJumpBase {
private:
const int max_jump_size = 1048587;
Assembler& assembler;
ConditionCode condition;
uint8_t* jmp_inst;
uint8_t* jmp_end;
public:
ForwardJump(Assembler& assembler, ConditionCode condition);
~ForwardJump();
ForwardJumpBase(Assembler& assembler, ConditionCode condition);
~ForwardJumpBase();
};
#define ForwardJump ForwardJumpBase<128>
#define LargeForwardJump ForwardJumpBase<1048576>
uint8_t* initializePatchpoint2(uint8_t* start_addr, uint8_t* slowpath_start, uint8_t* end_addr, StackInfo stack_info,
const std::unordered_set<int>& live_outs);
}
......
......@@ -414,9 +414,11 @@ Box* ASTInterpreter::executeInner(ASTInterpreter& interpreter, CFGBlock* start_b
interpreter.current_inst = s;
if (interpreter.jit)
interpreter.jit->emitSetCurrentInst(s);
Py_XDECREF(v.o);
if (v.var)
v.var->xdecref();
if (v.o) {
Py_XDECREF(v.o);
if (v.var)
v.var->decref();
}
v = interpreter.visit_stmt(s);
}
}
......
......@@ -529,9 +529,6 @@ extern "C" void Py_Initialize() noexcept {
}
void teardownCodegen() {
if (PROFILE)
g.func_addr_registry.dumpPerfMap();
for (int i = 0; i < g.jit_listeners.size(); i++) {
g.engine->UnregisterJITEventListener(g.jit_listeners[i]);
delete g.jit_listeners[i];
......
......@@ -4325,6 +4325,9 @@ extern "C" void Py_Finalize() noexcept {
// wait_for_thread_shutdown();
if (PROFILE)
g.func_addr_registry.dumpPerfMap();
call_sys_exitfunc();
// initialized = 0;
......
......@@ -57,6 +57,7 @@ def lookupAsHeapAddr(n):
lines = []
while True:
l = _heap_proc.stdout.readline()
assert l, "heapmap subprocess exited? code: %r" % _heap_proc.poll()
if l == '!!!!\n':
break
lines.append(l)
......@@ -95,7 +96,7 @@ if __name__ == "__main__":
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument("func_name", metavar="FUNC_NAME")
parser.add_argument("--collapse-nops", dest="collapse_nops", action="store_true", default=True)
parser.add_argument("--collapse-nops", dest="collapse_nops", action="store", default=5, type=int)
parser.add_argument("--no-collapse-nops", dest="collapse_nops", action="store_false")
parser.add_argument("--heap-map-args", nargs='+', help="""
Command to run that will provide heap map information.
......@@ -157,7 +158,13 @@ equivalent to '--heap-map-args ./pyston_release -i BENCHMARK'.
nops = (nops[0] + count, nops[1] + 1, nops[2], addr)
else:
if nops:
print str(nops[0]).rjust(8), (" %s-%s nop*%d" % (nops[2], nops[3], nops[1])).ljust(70)
if int(nops[3], 16) - int(nops[2], 16) + 1 <= args.collapse_nops:
nop_count = nops[0]
for addr in xrange(int(nops[2], 16), int(nops[3], 16) + 1):
print str(nop_count).rjust(8), (" %s nop" % ("%x: 90" % addr).ljust(29)).ljust(70)
nop_count = 0
else:
print str(nops[0]).rjust(8), (" %s nop*%d" % (("%s-%s" % (nops[2], nops[3])).ljust(29), nops[1])).ljust(70)
nops = None
print str(count).rjust(8), l.ljust(70), extra
......
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