Example #1
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();
  tvIncRefGen(tv);
  return *tv;
}
Example #2
0
member_rval::ptr_u APCLocalArray::NvGetStr(const ArrayData* ad,
                                           const StringData* key) {
  auto a = asApcArray(ad);
  auto index = a->getIndex(key);
  if (index == -1) return nullptr;
  return GetValueRef(a, index);
}
Example #3
0
ArrayData *APCLocalArray::Escalate(const ArrayData* ad) {
  auto smap = asApcArray(ad);
  auto ret = smap->loadElems();
  assert(!ret->isStatic());
  assert(ret->hasExactlyOneRef());
  return ret;
}
Example #4
0
const TypedValue* APCLocalArray::NvGetStr(const ArrayData* ad,
                                    const StringData* key) {
  auto a = asApcArray(ad);
  auto index = a->getIndex(key);
  if (index == -1) return nullptr;
  return GetValueRef(a, index).asTypedValue();
}
Example #5
0
bool APCLocalArray::IsVectorData(const ArrayData* ad) {
  auto a = asApcArray(ad);
  const auto n = a->size();
  for (ssize_t i = 0; i < n; i++) {
    if (a->getIndex(i) != i) return false;
  }
  return true;
}
Example #6
0
void APCLocalArray::NvGetKey(const ArrayData* ad,
                             TypedValue* out,
                             ssize_t pos) {
  auto a = asApcArray(ad);
  Variant k = a->m_arr->getKey(pos);
  TypedValue* tv = k.asTypedValue();
  // copy w/out clobbering out->_count.
  out->m_type = tv->m_type;
  out->m_data.num = tv->m_data.num;
  if (tv->m_type != KindOfInt64) out->m_data.pstr->incRefCount();
}
Example #7
0
ArrayData* APCLocalArray::EscalateForSort(ArrayData* ad, SortFunction sf) {
  auto a = asApcArray(ad);
  ArrayData* elems = a->loadElems();
  ArrayData* ret = elems->escalateForSort(sf);
  if (ret != elems) {
    elems->release();
  }
  assert(ret->getCount() == 0);
  assert(!ret->isStatic());
  return ret;
}
Example #8
0
void APCLocalArray::Release(ArrayData* ad) {
  assert(ad->hasExactlyOneRef());
  auto const a = asApcArray(ad);
  auto size = a->heapSize();

  for (auto tv = a->localCache(), end = tv + a->m_size; tv < end; ++tv) {
    tvDecRefGen(tv);
  }
  a->m_arr->unreference();
  MM().removeApcArray(a);
  MM().objFree(a, size);
}
Example #9
0
member_rval::ptr_u APCLocalArray::GetValueRef(const ArrayData* adIn,
                                              ssize_t pos) {
  auto const ad = asApcArray(adIn);
  assert(unsigned(pos) < ad->getSize());
  auto const elms = ad->localCache();
  auto const tv = &elms[pos];
  if (tv->m_type != KindOfUninit) return tv;
  auto const sv = ad->m_arr->getValue(pos);
  tvAsVariant(tv) = sv->toLocal();
  assert(tv->m_type != KindOfUninit);
  return tv;
}
Example #10
0
const Variant& APCLocalArray::GetValueRef(const ArrayData* adIn, ssize_t pos) {
  auto const ad = asApcArray(adIn);
  auto const sv = ad->m_arr->getValue(pos);
  if (LIKELY(ad->m_localCache != nullptr)) {
    assert(unsigned(pos) < ad->m_arr->capacity());
    TypedValue* tv = &ad->m_localCache[pos];
    if (tv->m_type != KindOfUninit) {
      return tvAsCVarRef(tv);
    }
  } else {
    static_assert(KindOfUninit == 0, "must be 0 since we use req::calloc");
    unsigned cap = ad->m_arr->capacity();
    ad->m_localCache = req::calloc_raw_array<TypedValue>(cap);
  }
  auto const tv = &ad->m_localCache[pos];
  tvAsVariant(tv) = sv->toLocal();
  assert(tv->m_type != KindOfUninit);
  return tvAsCVarRef(tv);
}
Example #11
0
ssize_t APCLocalArray::IterEnd(const ArrayData* ad) {
  auto a = asApcArray(ad);
  auto n = a->m_size;
  return n;
}
Example #12
0
ssize_t APCLocalArray::IterAdvance(const ArrayData* ad, ssize_t prev) {
  auto a = asApcArray(ad);
  return a->iterAdvanceImpl(prev);
}
Example #13
0
member_rval::ptr_u APCLocalArray::NvGetInt(const ArrayData* ad, int64_t k) {
  auto a = asApcArray(ad);
  auto index = a->getIndex(k);
  if (index == -1) return nullptr;
  return GetValueRef(a, index);
}
Example #14
0
ssize_t APCLocalArray::IterLast(const ArrayData* ad) {
  auto a = asApcArray(ad);
  auto n = a->m_size;
  return n > 0 ? ssize_t(n - 1) : 0;
}
Example #15
0
ArrayData* APCLocalArray::EscalateForSort(ArrayData* ad) {
  auto a = asApcArray(ad);
  auto ret = a->loadElems()->escalateForSort();
  assert(!ret->isStatic());
  return ret;
}
Example #16
0
ssize_t APCLocalArray::IterRewind(const ArrayData* ad, ssize_t prev) {
  auto a = asApcArray(ad);
  assert(prev >= 0 && prev < a->m_size);
  ssize_t next = prev - 1;
  return next >= 0 ? next : a->m_size;
}
Example #17
0
const TypedValue* APCLocalArray::NvGetInt(const ArrayData* ad, int64_t k) {
  auto a = asApcArray(ad);
  auto index = a->getIndex(k);
  if (index == -1) return nullptr;
  return GetValueRef(a, index).asTypedValue();
}
Example #18
0
bool APCLocalArray::ExistsInt(const ArrayData* ad, int64_t k) {
  return asApcArray(ad)->getIndex(k) != -1;
}
Example #19
0
void APCLocalArray::Release(ArrayData* ad) {
  assert(ad->hasExactlyOneRef());
  auto const a = asApcArray(ad);
  a->~APCLocalArray();
  MM().freeSmallSize(a, sizeof(APCLocalArray));
}
Example #20
0
void APCLocalArray::Release(ArrayData* ad) {
  auto const a = asApcArray(ad);
  a->~APCLocalArray();
  MM().smartFreeSize(a, sizeof(APCLocalArray));
}
Example #21
0
bool APCLocalArray::ExistsStr(const ArrayData* ad, const StringData* k) {
  auto a = asApcArray(ad);
  return a->getIndex(k) != -1;
}