1. Mark Shannon
  2. hotpy_2

Commits

Mark Shannon  committed 09b5a1e Draft

Check for NULL in registers. Further improve exit reporting

  • Participants
  • Parent commits 6a7634a
  • Branches default

Comments (0)

Files changed (4)

File Include/optimiser.h

View file
     unsigned long tracing_frame_stack_overflows;
     unsigned long return_exits;
     unsigned long rare_exits;
+    unsigned long materialisation_exits;
 } HotPyStatistics;
 
 typedef struct _hotpy_options {

File Python/trace_D_O_C.c

View file
 create_object(PyThreadState *tstate, unsigned char **code, PyObject *consts)
 {
     PyObject *o;
+    int i;
     enum deferred_kind k = read_byte(code);
     switch(k) {
     case DK_REAL:
         return NULL;
     case DK_REGISTER:
-        o = tstate->registers[read_int(code)];
+        i = read_int(code);
+        o = tstate->registers[i];
         Py_INCREF(o);
         return o;
     case DK_CONSTANT:

File Python/trace_interpreter.c

View file
         TARGET(RETURN_VALUE)
             PyObject *retval = POP();
             Py_DECREF(trace);
-            _HotPy_Stats.return_exits;
+            _HotPy_Stats.return_exits++;
             return (HotPyReturnValue) { retval, WHY_RETURN};
 
         TARGET_WITH_ARG(BINARY_OP)
         TARGET_WITH_ARG(STORE_REGISTER)
             PyObject *w = tstate->registers[oparg];
             PyObject *v = POP();
+            assert(v);
             tstate->registers[oparg] = v;
             Py_DECREF(w);
             FAST_DISPATCH();
 materialised:
     assert(tstate->execution_context == NULL);
     Py_DECREF(trace);
-    if (PyErr_Occurred())
+    _HotPy_Stats.materialisation_exits++;
+    if (PyErr_Occurred()) {
         return (HotPyReturnValue){ NULL, WHY_EXCEPTION };
-    else
+    }
+    else {
+
         return (HotPyReturnValue){ _HotPy_NextInstruction(tstate->real_frame), WHY_NOT };
+    }
 }
 
 static int

File Python/trace_manager.c

View file
     printf("%ld Return to top-level exits\n", _HotPy_Stats.return_exits);
     printf("%ld Rare exits\n", _HotPy_Stats.rare_exits);
     printf("%ld Cold exits\n", _HotPy_Stats.cold_exits);
+    printf("%ld Materialisation exits\n", _HotPy_Stats.materialisation_exits);
     printf("%ld Non-bool/int exits\n", _HotPy_Stats.not_bool_exits);
     printf("%ld Exception exits\n", _HotPy_Stats.exception_exits);
     printf("%ld Exceptions during trace\n", _HotPy_Stats.exceptions_in_trace);