1. 09 May, 2016 6 commits
    • Kevin Modzelewski's avatar
      Undo a bunch of "Pyston change"s in from_cpython · dacfd456
      Kevin Modzelewski authored
      Haven't been able to test them all extensively but I tried
      to only pick things refcount-related.
      dacfd456
    • Kevin Modzelewski's avatar
      Merge pull request #1165 from kmod/reftests3 · a1a6e36a
      Kevin Modzelewski authored
      Another run-arbitrary-code-during-unwinding issue
      a1a6e36a
    • Kevin Modzelewski's avatar
      Disable part of test_os.py · 0f848172
      Kevin Modzelewski authored
      The part that tests that certain dicts compare a given way.  We don't
      have consistent dict comparisons yet (#1135)
      0f848172
    • Kevin Modzelewski's avatar
      Change from "bool is_unwinding" to "int num_uncaught" · 6e93f476
      Kevin Modzelewski authored
      Since the unwinder now supports throwing exceptions inside destructors (as long
      as they don't propagate out).
      
      This is the same change that C++17 makes, from "bool uncaught_exception()" to
      "int uncaught_exceptions()".
      6e93f476
    • Kevin Modzelewski's avatar
      Another run-arbitrary-code-during-unwinding issue · ef322709
      Kevin Modzelewski authored
      This time it was from trying to look at the result of isUnwinding()
      to determine if the function terminated successfully or via an exception.
      (And in the exception case, to decref some values that would have been returned.)
      
      This got tripped up in a case where we through an exception, this triggers
      an AUTO_DECREF which takes an object to zero decrefs, which has a custom destructor,
      and calls code that ends up calling isUnwinding().  This is all happening from inside
      a C++ destructor, so this counts as isUnwinding().
      
      We had some code to try to keep isUnwinding() meaning what we wanted to use it for,
      but it was only for certain cases.  I think we might be able to extend it to more cases,
      but it seems like that would be a losing battle since it's hard to say when "unwinding"
      ends and then we are suddenly not unwinding.
      
      So instead, I just disabled isUnwinding() (except in debug mode where it can be somewhat
      useful for writing "assert(foo || isUnwinding())"), and then used a different way to
      try to determine if the function exited normally.
      ef322709
    • Kevin Modzelewski's avatar
      Merge pull request #1162 from corona10/bitset_begin · cb0fd07e
      Kevin Modzelewski authored
      bitset begin() function fix
      cb0fd07e
  2. 08 May, 2016 7 commits
  3. 07 May, 2016 4 commits
  4. 06 May, 2016 18 commits
  5. 04 May, 2016 5 commits
    • Kevin Modzelewski's avatar
    • Kevin Modzelewski's avatar
      Switch GCArray to PyObject_Malloc · 8618e750
      Kevin Modzelewski authored
      8618e750
    • Kevin Modzelewski's avatar
      Avoid allocations in pyElements() · 67943c23
      Kevin Modzelewski authored
      I had added an allocation to deal with the requirements refcounting
      added.  To remove that allocation, I added a "SmallUniquePtr" class
      which is similar to unique_ptr but it allocates the object in-line.
      
      It's a bit tricky to use since if the containing object gets moved around
      then the pointers become invalid.
      67943c23
    • Kevin Modzelewski's avatar
      Add RewriterVar::replaceAttr() · 27b94e48
      Kevin Modzelewski authored
      Previously, to replace a refcounted object in memory, we would do something like
      
      array->getAttr(offset)->setType(OWNED);
      array->setAttr(offset, new_val);
      
      The problem is that this ends up emitting something like
      x = array[offset];
      Py_DECREF(x);
      array[offset] = new_val;
      
      which is not safe, since x can have a destructor that runs.
      In this particular case, the destructor changed the value of array[offset].
      
      It's actually pretty hard to get the right behavior (decref after setting the
      new value) from outside the rewriter class, so add a new replaceAttr that does
      these steps.
      27b94e48
    • Kevin Modzelewski's avatar
      Add some lifetime information to temporaries in the cfg · ca2ed310
      Kevin Modzelewski authored
      By adding a 'is_kill' flag to AST_Name nodes, which say that
      this is the last use of this name.  This handles some common cases
      of keeping temporaries alive for too long.
      
      For some rare cases, there is no AST_Name that is a last use:
      for example, the iterator object of a for loop is live after
      every time it is used, but dies when exiting the loop.
      
      For those, we insert a `del #foo` instead.
      
      The interpreter and bjit use these flags to remove temporaries
      from the vregs.
      
      The LLVM jit ignores them since it has its own way of handling
      lifetime.  It ignores any `del` statements on temporary names
      as an optimization.
      
      This does not handle decref'ing temporaries on an exception.
      ca2ed310