예제 #1
0
ALWAYS_INLINE
TypedValue& getDefaultIfNullCell(TypedValue* tv, TypedValue& def) {
  if (UNLIKELY(nullptr == tv)) {
    // DecRef of def is done unconditionally by the IR, since there's
    // a good chance it will be paired with an IncRef and optimized
    // away.  So we need to IncRef here if it is being returned.
    tvRefcountedIncRef(&def);
    return def;
  }
  TypedValue* ret = tvToCell(tv);
  tvRefcountedIncRef(ret);
  return *ret;
}
예제 #2
0
ArrayData* EmptyArray::Prepend(ArrayData*, const Variant& vin, bool) {
  auto cell = *vin.asCell();
  tvRefcountedIncRef(&cell);
  // TODO(#3888164): we should make it so we don't need KindOfUninit checks
  if (cell.m_type == KindOfUninit) cell.m_type = KindOfNull;
  return EmptyArray::MakePacked(cell).first;
}
예제 #3
0
Cell APCLocalArray::NvGetKey(const ArrayData* ad, ssize_t pos) {
  auto a = asApcArray(ad);
  Variant k = a->m_arr->getKey(pos);
  auto const tv = k.asTypedValue();
  tvRefcountedIncRef(tv);
  return *tv;
}
예제 #4
0
ArrayData* EmptyArray::SetInt(ArrayData*, int64_t k, Cell c, bool) {
  // TODO(#3888164): we should make it so we don't need KindOfUninit checks
  if (c.m_type == KindOfUninit) c.m_type = KindOfNull;
  tvRefcountedIncRef(&c);
  auto const ret = k == 0 ? EmptyArray::MakePacked(c)
                          : EmptyArray::MakeMixed(k, c);
  return ret.array;
}
예제 #5
0
ArrayData* EmptyArray::SetStr(ArrayData*,
                              StringData* k,
                              Cell val,
                              bool copy) {
  tvRefcountedIncRef(&val);
  // TODO(#3888164): we should make it so we don't need KindOfUninit checks
  if (val.m_type == KindOfUninit) val.m_type = KindOfNull;
  return EmptyArray::MakeMixed(k, val).array;
}
예제 #6
0
ArrayData* EmptyArray::SetStr(ArrayData*,
                              StringData* k,
                              const Variant& v,
                              bool copy) {
  auto val = *v.asCell();
  tvRefcountedIncRef(&val);
  // TODO(#3888164): we should make it so we don't need KindOfUninit checks
  if (val.m_type == KindOfUninit) val.m_type = KindOfNull;
  return EmptyArray::MakeMixed(k, val).first;
}
예제 #7
0
ALWAYS_INLINE
TypedValue& getDefaultIfNullCell(TypedValue* tv, TypedValue& def) {
  if (UNLIKELY(nullptr == tv)) {
    // refcount is already correct since def was never decrefed
    return def;
  }
  tvRefcountedDecRef(&def);
  TypedValue* ret = tvToCell(tv);
  tvRefcountedIncRef(ret);
  return *ret;
}
예제 #8
0
Cell incDecBodySlow(IncDecOp op, Cell* fr) {
  assert(cellIsPlausible(*fr));
  assert(fr->m_type != KindOfUninit);

  auto dup = [&]() { tvRefcountedIncRef(fr); return *fr; };

  switch (op) {
  case IncDecOp::PreInc:
    cellInc(*fr);
    return dup();
  case IncDecOp::PostInc: {
    auto const tmp = dup();
    cellInc(*fr);
    return tmp;
  }
  case IncDecOp::PreDec:
    cellDec(*fr);
    return dup();
  case IncDecOp::PostDec: {
    auto const tmp = dup();
    cellDec(*fr);
    return tmp;
  }
  default: break;
  }

  switch (op) {
  case IncDecOp::PreIncO:
    cellIncO(*fr);
    return dup();
  case IncDecOp::PostIncO: {
    auto const tmp = dup();
    cellIncO(*fr);
    return tmp;
  }
  case IncDecOp::PreDecO:
    cellDecO(*fr);
    return dup();
  case IncDecOp::PostDecO: {
    auto const tmp = dup();
    cellDecO(*fr);
    return tmp;
  }
  default: break;
  }
  not_reached();
}
예제 #9
0
ArrayData* EmptyArray::Prepend(ArrayData*, Cell v, bool) {
  tvRefcountedIncRef(&v);
  return EmptyArray::MakePacked(v).array;
}
예제 #10
0
ArrayData* EmptyArray::Append(ArrayData*, Cell v, bool copy) {
  tvRefcountedIncRef(&v);
  return EmptyArray::MakePackedInl(v).array;
}