Example #1
0
/*
 * Insert a DbgAssertRefCount instruction after each place we produce
 * a refcounted value.  The value must be something we can safely dereference
 * to check the _count field.
 */
static void insertRefCountAsserts(IRInstruction& inst, IRFactory* factory) {
  for (SSATmp& dst : inst.getDsts()) {
    Type t = dst.getType();
    if (t.subtypeOf(Type::Counted | Type::StaticStr | Type::StaticArr)) {
      insertAfter(&inst, factory->gen(DbgAssertRefCount, &dst));
    }
  }
}