hphp/runtime/vm/jit/hhbc-translator.cpp
// only handles integer or double inc/dec
only handles integer or double inc/dec
only handles integer or double inc / dec
SSATmp* HhbcTranslator::emitIncDec(bool pre, bool inc, bool over, SSATmp* src) {
  assert(src->isA(Type::Int) || src->isA(Type::Dbl));
  Opcode op;
  if (src->isA(Type::Dbl)) {
    op = inc ? AddDbl : SubDbl;
  } else if (!over) {
    op = inc ? AddInt : SubInt;
  } else {
    op = inc ? AddIntO : SubIntO;
  }
  SSATmp* one = src->isA(Type::Int) ? cns(1) : cns(1.0);
  SSATmp* res = nullptr;
  if (op == AddIntO || op == SubIntO) {
    auto spills = peekSpillValues();
    auto const exit = makeExitImpl(
      bcOff(),
      ExitFlag::Interp,
      spills,
      CustomExit{}
    );
    res = gen(op, exit, src, one);
  } else {
    res = gen(op, src, one);
  }
  push(pre ? res : src);
  return res;
}
SSATmp * HhbcTranslator :: emitIncDec ( bool pre , bool inc , bool over , SSATmp * src ) { assert ( src -> isA ( Type :: Int ) || src -> isA ( Type :: Dbl ) ) ; Opcode op ; if ( src -> isA ( Type :: Dbl ) ) { op = inc ? AddDbl : SubDbl ; } else if ( ! over ) { op = inc ? AddInt : SubInt ; } else { op = inc ? AddIntO : SubIntO ; } SSATmp * one = src -> isA ( Type :: Int ) ? cns ( 1 ) : cns ( 1.0 ) ; SSATmp * res = nullptr ; if ( op == AddIntO || op == SubIntO ) { auto spills = peekSpillValues ( ) ; auto const exit = makeExitImpl ( bcOff ( ) , ExitFlag :: Interp , spills , CustomExit { } ) ; res = gen ( op , exit , src , one ) ; } else { res = gen ( op , src , one ) ; } push ( pre ? res : src ) ; return res ; }
only handles integer or double inc/dec
only handles integer or double inc / dec
// no incref necessary on push since result is an int