Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

make trace object creation lazy

  • Loading branch information...
commit 2e2fa927a958fc7854924dd2a8ea258bc8408e11 1 parent 70610a8
@alex authored
Showing with 18 additions and 5 deletions.
  1. +14 −2 client/tracebin/recorder.py
  2. +4 −3 client/tracebin/traces.py
View
16 client/tracebin/recorder.py
@@ -1,3 +1,4 @@
+import ctypes
import io
import inspect
import mmap
@@ -30,7 +31,8 @@ def record(**kwargs):
class Recorder(object):
def __init__(self):
self.log = Logger()
- self.traces = []
+ self._traces = []
+ self._pending_traces = []
self.aborts = []
self.calls = None
self.options = {
@@ -88,6 +90,14 @@ def disable(self, profile):
self._find_calls()
del self._end_time
+ @property
+ def traces(self):
+ for data in self._pending_traces:
+ cls, args = data[0], data[1:]
+ self._traces.append(cls(*args))
+ del self._pending_traces[:]
+ return self._traces
+
def _new_mmap(self):
self._current_profile_mmap = mmap.mmap(-1, 4 * 1024 * 1024)
self._profile_mmaps.append(self._current_profile_mmap)
@@ -145,7 +155,9 @@ def on_compile(self, jitdriver_name, kind, greenkey, ops, asm_ptr, asm_len):
return
if jitdriver_name == "pypyjit":
- self.traces.append(PythonTrace(greenkey, ops, asm_ptr, asm_len))
+ self._pending_traces.append(
+ (PythonTrace, greenkey, ops, ctypes.string_at(asm_ptr, asm_len))
+ )
else:
self.log.warning("[compile] Unhandled jitdriver: %s" % jitdriver_name)
View
7 client/tracebin/traces.py
@@ -4,8 +4,9 @@
class BaseTrace(object):
- def __init__(self, ops):
+ def __init__(self, ops, asm):
super(BaseTrace, self).__init__()
+ self.asm = asm
self.sections = [
TraceSection(label, self.split_section(ops))
for label, ops in self.split_trace(ops)
@@ -24,8 +25,8 @@ def split_trace(cls, ops):
return sections
class PythonTrace(BaseTrace):
- def __init__(self, greenkey, ops, asm_start, asm_len):
- super(PythonTrace, self).__init__(ops)
+ def __init__(self, greenkey, ops, asm):
+ super(PythonTrace, self).__init__(ops, asm)
self.root_file = greenkey[0].co_filename
self.root_function = greenkey[0].co_name
Please sign in to comment.
Something went wrong with that request. Please try again.