Commits

ebo  committed 0a15f71

Added some more stack manipulating opcodes

  • Participants
  • Parent commits c2e2659

Comments (0)

Files changed (1)

 new file mode 100644
 --- /dev/null
 +++ b/JIT/jit_tracer.cc
-@@ -0,0 +1,691 @@
+@@ -0,0 +1,741 @@
 +#include "Python.h"
 +#include "opcode.h"
 +
 +    case LOAD_FAST:
 +    case LOAD_CONST:
 +    case JUMP_ABSOLUTE:
++    case POP_TOP:
++    case ROT_TWO:
++    case ROT_THREE:
++    case DUP_TOP:
++    case DUP_TOP_TWO:
 +
 +    case INPLACE_ADD:
 +    case INPLACE_SUBTRACT:
 +        stack.Push(v);
 +        continue;
 +
++      case POP_TOP:
++        v = stack.Pop();
++        this->createDecRef(v);
++        continue;
++
++      case ROT_TWO:
++        v = stack.Pop();
++        w = stack.Pop();
++        stack.Push(v);
++        stack.Push(w);
++        continue;
++
++      case ROT_THREE:
++        v = stack.Pop();
++        w = stack.Pop();
++        x = stack.Pop();
++        stack.Push(v);
++        stack.Push(x);
++        stack.Push(w);
++        continue;
++
++      case DUP_TOP:
++        v = stack.Top();
++        this->createIncRef(v);
++        stack.Push(v);
++        continue;
++
++      case DUP_TOP_TWO:
++        x = stack.Pop();
++        this->createIncRef(x);
++        w = stack.Pop();
++        this->createIncRef(w);
++        stack.Push(w);
++        stack.Push(x);
++        stack.Push(w);
++        stack.Push(x);
++        continue;
++
 +      case INPLACE_ADD:
 +      case INPLACE_SUBTRACT:
 +      case INPLACE_MULTIPLY:
 +      case INPLACE_FLOOR_DIVIDE:
 +      case INPLACE_TRUE_DIVIDE:
 +        this->createBinaryOp(true, stack, locals, entry);
-+        break;
++        continue;
 +
 +      case BINARY_ADD:
 +      case BINARY_SUBTRACT:
 +      case BINARY_FLOOR_DIVIDE:
 +      case BINARY_TRUE_DIVIDE:
 +        this->createBinaryOp(false, stack, locals, entry);
-+        break;
++        continue;
 +
 +      case COMPARE_OP:
 +        w = stack.Pop();
 +    arg_->XDecRef(fbuilder);
 +  }
 +
++  void
++  JITDecRef::emit(JITFunctionBuilder &fbuilder)
++  {
++    arg_->DecRef(fbuilder);
++  }
++
 +  const int JITOpcodeInfo::ID = 0;
 +  const int JITStackValue::ID = 0;
 +  const int JITLocalValue::ID = 0;
 +  const int JITCompareOp::ID = 0;
 +  const int JITIncRef::ID = 0;
 +  const int JITXDecRef::ID = 0;
++  const int JITDecRef::ID = 0;
 +  const int JITGuardNull::ID = 0;
 +  const int JITGuardType::ID = 0;
 +  const int JITGuardTrue::ID = 0;
 new file mode 100644
 --- /dev/null
 +++ b/JIT/jit_tracer.h
-@@ -0,0 +1,730 @@
+@@ -0,0 +1,759 @@
 +// -*- C++ -*-
 +#ifndef PYTHON_JIT_TRACER_H_
 +#define PYTHON_JIT_TRACER_H_
 +    JITValue *arg_;
 +  };
 +
++  class JITDecRef : public JITOpcode {
++  public:
++    JITDecRef(JITValue *arg) : arg_(arg)
++    {}
++
++    virtual void dump()
++    {
++      std::cout << "DECREF\n";
++    }
++
++    virtual void emit(JITFunctionBuilder &builder);
++
++    virtual uintptr_t type()
++    {
++      return reinterpret_cast<uintptr_t>(&ID);
++    }
++    static const int ID;
++
++  private:
++    JITValue *arg_;
++  };
++
 +  class JITGuardType : public JITOpcode {
 +  public:
 +    JITGuardType(JITValue *arg, BLACKHOLE reason, int lasti,
 +      return r;
 +    }
 +
++    JITDecRef *createDecRef(JITValue *v)
++    {
++      JITDecRef *r = new JITDecRef(v);
++      trace_.push_back(r);
++      return r;
++    }
++
 +    JITXDecRef *createXDecRef(JITValue *v)
 +    {
 +      JITXDecRef *r = new JITXDecRef(v);