Make fooIsPlausible functions take args by value
Also, checkTv is redundant now, since I added the refcount assertions to tvIsPlausible earlier.
Esse commit está contido em:
@@ -137,7 +137,7 @@ bool SimpleArrayStore::update(K key, const Variant& val, uint length,
|
||||
auto const pos = find(key, length);
|
||||
if (pos != PosType::invalid) {
|
||||
// found, overwrite
|
||||
assert(tvIsPlausible(m_vals + toInt<uint32_t>(pos)));
|
||||
assert(tvIsPlausible(m_vals[toInt<uint32_t>(pos)]));
|
||||
lval(pos) = val;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace {
|
||||
// Helper for converting String, Array, Bool, Null or Obj to Dbl|Int.
|
||||
// Other types (i.e. Int and Double) must be handled outside of this.
|
||||
TypedNum numericConvHelper(Cell cell) {
|
||||
assert(cellIsPlausible(&cell));
|
||||
assert(cellIsPlausible(cell));
|
||||
|
||||
switch (cell.m_type) {
|
||||
case KindOfString:
|
||||
@@ -261,8 +261,8 @@ StringData* stringBitOp(BitOp bop, SzOp sop, StringData* s1, StringData* s2) {
|
||||
|
||||
template<template<class> class BitOp, class StrLenOp>
|
||||
Cell cellBitOp(StrLenOp strLenOp, Cell c1, Cell c2) {
|
||||
assert(cellIsPlausible(&c1));
|
||||
assert(cellIsPlausible(&c2));
|
||||
assert(cellIsPlausible(c1));
|
||||
assert(cellIsPlausible(c2));
|
||||
|
||||
if (IS_STRING_TYPE(c1.m_type) && IS_STRING_TYPE(c2.m_type)) {
|
||||
return make_tv<KindOfString>(
|
||||
@@ -332,7 +332,7 @@ void stringIncDecOp(Op op, Cell& cell) {
|
||||
*/
|
||||
template<class Op>
|
||||
void cellIncDecOp(Op op, Cell& cell) {
|
||||
assert(cellIsPlausible(&cell));
|
||||
assert(cellIsPlausible(cell));
|
||||
|
||||
switch (cell.m_type) {
|
||||
case KindOfInt64:
|
||||
@@ -456,8 +456,8 @@ void cellMulEq(Cell& c1, Cell c2) {
|
||||
}
|
||||
|
||||
void cellDivEq(Cell& c1, Cell c2) {
|
||||
assert(cellIsPlausible(&c1));
|
||||
assert(cellIsPlausible(&c2));
|
||||
assert(cellIsPlausible(c1));
|
||||
assert(cellIsPlausible(c2));
|
||||
if (!isTypedNum(c1)) {
|
||||
cellSet(numericConvHelper(c1), c1);
|
||||
}
|
||||
@@ -489,7 +489,7 @@ void cellDec(Cell& cell) {
|
||||
}
|
||||
|
||||
void cellBitNot(Cell& cell) {
|
||||
assert(cellIsPlausible(&cell));
|
||||
assert(cellIsPlausible(cell));
|
||||
|
||||
switch (cell.m_type) {
|
||||
case KindOfInt64:
|
||||
|
||||
@@ -53,7 +53,7 @@ bool cellRelOp(Op op, Cell cell, bool val) {
|
||||
|
||||
template<class Op>
|
||||
bool cellRelOp(Op op, Cell cell, int64_t val) {
|
||||
assert(cellIsPlausible(&cell));
|
||||
assert(cellIsPlausible(cell));
|
||||
|
||||
switch (cell.m_type) {
|
||||
case KindOfUninit:
|
||||
@@ -85,7 +85,7 @@ bool cellRelOp(Op op, Cell cell, int64_t val) {
|
||||
|
||||
template<class Op>
|
||||
bool cellRelOp(Op op, Cell cell, double val) {
|
||||
assert(cellIsPlausible(&cell));
|
||||
assert(cellIsPlausible(cell));
|
||||
|
||||
switch (cell.m_type) {
|
||||
case KindOfUninit:
|
||||
@@ -112,7 +112,7 @@ bool cellRelOp(Op op, Cell cell, double val) {
|
||||
|
||||
template<class Op>
|
||||
bool cellRelOp(Op op, Cell cell, const StringData* val) {
|
||||
assert(cellIsPlausible(&cell));
|
||||
assert(cellIsPlausible(cell));
|
||||
|
||||
switch (cell.m_type) {
|
||||
case KindOfUninit:
|
||||
@@ -152,7 +152,7 @@ bool cellRelOp(Op op, Cell cell, const StringData* val) {
|
||||
|
||||
template<class Op>
|
||||
bool cellRelOp(Op op, Cell cell, const ArrayData* ad) {
|
||||
assert(cellIsPlausible(&cell));
|
||||
assert(cellIsPlausible(cell));
|
||||
|
||||
switch (cell.m_type) {
|
||||
case KindOfUninit:
|
||||
@@ -180,7 +180,7 @@ bool cellRelOp(Op op, Cell cell, const ArrayData* ad) {
|
||||
|
||||
template<class Op>
|
||||
bool cellRelOp(Op op, Cell cell, const ObjectData* od) {
|
||||
assert(cellIsPlausible(&cell));
|
||||
assert(cellIsPlausible(cell));
|
||||
|
||||
switch (cell.m_type) {
|
||||
case KindOfUninit:
|
||||
@@ -217,8 +217,8 @@ bool cellRelOp(Op op, Cell cell, const ObjectData* od) {
|
||||
|
||||
template<class Op>
|
||||
bool cellRelOp(Op op, Cell c1, Cell c2) {
|
||||
assert(cellIsPlausible(&c1));
|
||||
assert(cellIsPlausible(&c2));
|
||||
assert(cellIsPlausible(c1));
|
||||
assert(cellIsPlausible(c2));
|
||||
|
||||
switch (c2.m_type) {
|
||||
case KindOfUninit:
|
||||
@@ -241,8 +241,8 @@ bool cellRelOp(Op op, Cell c1, Cell c2) {
|
||||
|
||||
template<class Op>
|
||||
bool tvRelOp(Op op, TypedValue tv1, TypedValue tv2) {
|
||||
assert(tvIsPlausible(&tv1));
|
||||
assert(tvIsPlausible(&tv2));
|
||||
assert(tvIsPlausible(tv1));
|
||||
assert(tvIsPlausible(tv2));
|
||||
return cellRelOp(op, *tvToCell(&tv1), *tvToCell(&tv2));
|
||||
}
|
||||
|
||||
@@ -362,8 +362,8 @@ struct Gt {
|
||||
}
|
||||
|
||||
bool cellSame(Cell c1, Cell c2) {
|
||||
assert(cellIsPlausible(&c1));
|
||||
assert(cellIsPlausible(&c2));
|
||||
assert(cellIsPlausible(c1));
|
||||
assert(cellIsPlausible(c2));
|
||||
|
||||
bool const null1 = IS_NULL_TYPE(c1.m_type);
|
||||
bool const null2 = IS_NULL_TYPE(c2.m_type);
|
||||
@@ -399,8 +399,8 @@ bool cellSame(Cell c1, Cell c2) {
|
||||
}
|
||||
|
||||
bool tvSame(TypedValue tv1, TypedValue tv2) {
|
||||
assert(tvIsPlausible(&tv1));
|
||||
assert(tvIsPlausible(&tv2));
|
||||
assert(tvIsPlausible(tv1));
|
||||
assert(tvIsPlausible(tv2));
|
||||
return cellSame(*tvToCell(&tv1), *tvToCell(&tv2));
|
||||
}
|
||||
|
||||
@@ -514,8 +514,8 @@ bool tvGreater(TypedValue tv1, TypedValue tv2) {
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool cellLessOrEqual(Cell c1, Cell c2) {
|
||||
assert(cellIsPlausible(&c1));
|
||||
assert(cellIsPlausible(&c2));
|
||||
assert(cellIsPlausible(c1));
|
||||
assert(cellIsPlausible(c2));
|
||||
|
||||
if ((c1.m_type == KindOfArray && c2.m_type == KindOfArray) ||
|
||||
(c1.m_type == KindOfObject && c2.m_type == KindOfObject)) {
|
||||
@@ -525,8 +525,8 @@ bool cellLessOrEqual(Cell c1, Cell c2) {
|
||||
}
|
||||
|
||||
bool cellGreaterOrEqual(Cell c1, Cell c2) {
|
||||
assert(cellIsPlausible(&c1));
|
||||
assert(cellIsPlausible(&c2));
|
||||
assert(cellIsPlausible(c1));
|
||||
assert(cellIsPlausible(c2));
|
||||
|
||||
if ((c1.m_type == KindOfArray && c2.m_type == KindOfArray) ||
|
||||
(c1.m_type == KindOfObject && c2.m_type == KindOfObject)) {
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace HPHP {
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline bool cellToBool(Cell cell) {
|
||||
assert(cellIsPlausible(&cell));
|
||||
assert(cellIsPlausible(cell));
|
||||
|
||||
switch (cell.m_type) {
|
||||
case KindOfUninit:
|
||||
@@ -40,7 +40,7 @@ inline bool cellToBool(Cell cell) {
|
||||
}
|
||||
|
||||
inline int64_t cellToInt(Cell cell) {
|
||||
assert(cellIsPlausible(&cell));
|
||||
assert(cellIsPlausible(cell));
|
||||
|
||||
switch (cell.m_type) {
|
||||
case KindOfInt64: return cell.m_data.num;
|
||||
|
||||
@@ -25,39 +25,38 @@ namespace HPHP {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool cellIsPlausible(const Cell* cell) {
|
||||
assert(cell);
|
||||
assert(cell->m_type != KindOfRef);
|
||||
bool cellIsPlausible(const Cell cell) {
|
||||
assert(cell.m_type != KindOfRef);
|
||||
|
||||
auto assertPtr = [](void* ptr) {
|
||||
assert(ptr && (uintptr_t(ptr) % sizeof(ptr) == 0));
|
||||
};
|
||||
|
||||
switch (cell->m_type) {
|
||||
switch (cell.m_type) {
|
||||
case KindOfUninit:
|
||||
case KindOfNull:
|
||||
break;
|
||||
case KindOfBoolean:
|
||||
assert(cell->m_data.num == 0 || cell->m_data.num == 1);
|
||||
assert(cell.m_data.num == 0 || cell.m_data.num == 1);
|
||||
break;
|
||||
case KindOfInt64:
|
||||
case KindOfDouble:
|
||||
break;
|
||||
case KindOfStaticString:
|
||||
assertPtr(cell->m_data.pstr);
|
||||
assert(cell->m_data.pstr->isStatic());
|
||||
assertPtr(cell.m_data.pstr);
|
||||
assert(cell.m_data.pstr->isStatic());
|
||||
break;
|
||||
case KindOfString:
|
||||
assertPtr(cell->m_data.pstr);
|
||||
assert(is_refcount_realistic(cell->m_data.pstr->getCount()));
|
||||
assertPtr(cell.m_data.pstr);
|
||||
assert(is_refcount_realistic(cell.m_data.pstr->getCount()));
|
||||
break;
|
||||
case KindOfArray:
|
||||
assertPtr(cell->m_data.parr);
|
||||
assert(is_refcount_realistic(cell->m_data.parr->getCount()));
|
||||
assertPtr(cell.m_data.parr);
|
||||
assert(is_refcount_realistic(cell.m_data.parr->getCount()));
|
||||
break;
|
||||
case KindOfObject:
|
||||
assertPtr(cell->m_data.pobj);
|
||||
assert(!cell->m_data.pobj->isStatic());
|
||||
assertPtr(cell.m_data.pobj);
|
||||
assert(!cell.m_data.pobj->isStatic());
|
||||
break;
|
||||
case KindOfRef:
|
||||
assert(!"KindOfRef found in a Cell");
|
||||
@@ -68,20 +67,18 @@ bool cellIsPlausible(const Cell* cell) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool tvIsPlausible(const TypedValue* tv) {
|
||||
assert(tv);
|
||||
if (tv->m_type == KindOfRef) {
|
||||
assert(tv->m_data.pref);
|
||||
assert(uintptr_t(tv->m_data.pref) % sizeof(void*) == 0);
|
||||
assert(is_refcount_realistic(tv->m_data.pref->getCount()));
|
||||
tv = tv->m_data.pref->tv();
|
||||
bool tvIsPlausible(TypedValue tv) {
|
||||
if (tv.m_type == KindOfRef) {
|
||||
assert(tv.m_data.pref);
|
||||
assert(uintptr_t(tv.m_data.pref) % sizeof(void*) == 0);
|
||||
assert(is_refcount_realistic(tv.m_data.pref->getCount()));
|
||||
tv = *tv.m_data.pref->tv();
|
||||
}
|
||||
return cellIsPlausible(tv);
|
||||
}
|
||||
|
||||
bool refIsPlausible(const Ref* ref) {
|
||||
assert(ref);
|
||||
assert(ref->m_type == KindOfRef);
|
||||
bool refIsPlausible(const Ref ref) {
|
||||
assert(ref.m_type == KindOfRef);
|
||||
return tvIsPlausible(ref);
|
||||
}
|
||||
|
||||
@@ -92,7 +89,7 @@ inline void tvUnboxIfNeeded(TypedValue *tv) {
|
||||
}
|
||||
|
||||
void tvCastToBooleanInPlace(TypedValue* tv) {
|
||||
assert(tvIsPlausible(tv));
|
||||
assert(tvIsPlausible(*tv));
|
||||
tvUnboxIfNeeded(tv);
|
||||
bool b;
|
||||
switch (tv->m_type) {
|
||||
@@ -114,7 +111,7 @@ void tvCastToBooleanInPlace(TypedValue* tv) {
|
||||
}
|
||||
|
||||
void tvCastToDoubleInPlace(TypedValue* tv) {
|
||||
assert(tvIsPlausible(tv));
|
||||
assert(tvIsPlausible(*tv));
|
||||
tvUnboxIfNeeded(tv);
|
||||
|
||||
double d;
|
||||
@@ -143,7 +140,7 @@ void tvCastToDoubleInPlace(TypedValue* tv) {
|
||||
}
|
||||
|
||||
void cellCastToInt64InPlace(Cell* cell) {
|
||||
assert(cellIsPlausible(cell));
|
||||
assert(cellIsPlausible(*cell));
|
||||
|
||||
int64_t i;
|
||||
switch (cell->m_type) {
|
||||
@@ -183,13 +180,13 @@ void cellCastToInt64InPlace(Cell* cell) {
|
||||
}
|
||||
|
||||
void tvCastToInt64InPlace(TypedValue* tv) {
|
||||
assert(tvIsPlausible(tv));
|
||||
assert(tvIsPlausible(*tv));
|
||||
tvUnboxIfNeeded(tv);
|
||||
cellCastToInt64InPlace(tv);
|
||||
}
|
||||
|
||||
double tvCastToDouble(TypedValue* tv) {
|
||||
assert(tvIsPlausible(tv));
|
||||
assert(tvIsPlausible(*tv));
|
||||
if (tv->m_type == KindOfRef) {
|
||||
tv = tv->m_data.pref->tv();
|
||||
}
|
||||
@@ -222,7 +219,7 @@ const StaticString
|
||||
s_Array("Array");
|
||||
|
||||
void tvCastToStringInPlace(TypedValue* tv) {
|
||||
assert(tvIsPlausible(tv));
|
||||
assert(tvIsPlausible(*tv));
|
||||
tvUnboxIfNeeded(tv);
|
||||
StringData * s;
|
||||
switch (tv->m_type) {
|
||||
@@ -257,7 +254,7 @@ static_string:
|
||||
}
|
||||
|
||||
StringData* tvCastToString(TypedValue* tv) {
|
||||
assert(tvIsPlausible(tv));
|
||||
assert(tvIsPlausible(*tv));
|
||||
if (tv->m_type == KindOfRef) {
|
||||
tv = tv->m_data.pref->tv();
|
||||
}
|
||||
@@ -281,7 +278,7 @@ StringData* tvCastToString(TypedValue* tv) {
|
||||
}
|
||||
|
||||
void tvCastToArrayInPlace(TypedValue* tv) {
|
||||
assert(tvIsPlausible(tv));
|
||||
assert(tvIsPlausible(*tv));
|
||||
tvUnboxIfNeeded(tv);
|
||||
ArrayData * a;
|
||||
switch (tv->m_type) {
|
||||
@@ -310,7 +307,7 @@ void tvCastToArrayInPlace(TypedValue* tv) {
|
||||
}
|
||||
|
||||
void tvCastToObjectInPlace(TypedValue* tv) {
|
||||
assert(tvIsPlausible(tv));
|
||||
assert(tvIsPlausible(*tv));
|
||||
tvUnboxIfNeeded(tv);
|
||||
ObjectData* o;
|
||||
switch (tv->m_type) {
|
||||
@@ -344,7 +341,7 @@ void tvCastToObjectInPlace(TypedValue* tv) {
|
||||
}
|
||||
|
||||
bool tvCoerceParamToBooleanInPlace(TypedValue* tv) {
|
||||
assert(tvIsPlausible(tv));
|
||||
assert(tvIsPlausible(*tv));
|
||||
tvUnboxIfNeeded(tv);
|
||||
if (tv->m_type == KindOfArray || tv->m_type == KindOfObject) {
|
||||
return false;
|
||||
@@ -375,7 +372,7 @@ bool tvCanBeCoercedToNumber(TypedValue* tv) {
|
||||
}
|
||||
|
||||
bool tvCoerceParamToInt64InPlace(TypedValue* tv) {
|
||||
assert(tvIsPlausible(tv));
|
||||
assert(tvIsPlausible(*tv));
|
||||
tvUnboxIfNeeded(tv);
|
||||
if (!tvCanBeCoercedToNumber(tv)) {
|
||||
return false;
|
||||
@@ -385,7 +382,7 @@ bool tvCoerceParamToInt64InPlace(TypedValue* tv) {
|
||||
}
|
||||
|
||||
bool tvCoerceParamToDoubleInPlace(TypedValue* tv) {
|
||||
assert(tvIsPlausible(tv));
|
||||
assert(tvIsPlausible(*tv));
|
||||
tvUnboxIfNeeded(tv);
|
||||
if (!tvCanBeCoercedToNumber(tv)) {
|
||||
return false;
|
||||
@@ -395,7 +392,7 @@ bool tvCoerceParamToDoubleInPlace(TypedValue* tv) {
|
||||
}
|
||||
|
||||
bool tvCoerceParamToStringInPlace(TypedValue* tv) {
|
||||
assert(tvIsPlausible(tv));
|
||||
assert(tvIsPlausible(*tv));
|
||||
tvUnboxIfNeeded(tv);
|
||||
switch (tv->m_type) {
|
||||
case KindOfArray:
|
||||
@@ -415,7 +412,7 @@ bool tvCoerceParamToStringInPlace(TypedValue* tv) {
|
||||
}
|
||||
|
||||
bool tvCoerceParamToArrayInPlace(TypedValue* tv) {
|
||||
assert(tvIsPlausible(tv));
|
||||
assert(tvIsPlausible(*tv));
|
||||
tvUnboxIfNeeded(tv);
|
||||
if (tv->m_type == KindOfArray) {
|
||||
return true;
|
||||
@@ -427,7 +424,7 @@ bool tvCoerceParamToArrayInPlace(TypedValue* tv) {
|
||||
}
|
||||
|
||||
bool tvCoerceParamToObjectInPlace(TypedValue* tv) {
|
||||
assert(tvIsPlausible(tv));
|
||||
assert(tvIsPlausible(*tv));
|
||||
tvUnboxIfNeeded(tv);
|
||||
return tv->m_type == KindOfObject;
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ class Variant;
|
||||
* Assertions on Cells and TypedValues. Should usually only happen
|
||||
* inside an assert().
|
||||
*/
|
||||
bool tvIsPlausible(const TypedValue*);
|
||||
bool cellIsPlausible(const Cell*);
|
||||
bool refIsPlausible(const Ref*);
|
||||
bool tvIsPlausible(TypedValue);
|
||||
bool cellIsPlausible(Cell);
|
||||
bool refIsPlausible(Ref);
|
||||
|
||||
/*
|
||||
* Returns: true if the supplied TypedValue is KindOfDouble or
|
||||
@@ -57,7 +57,7 @@ inline bool tvWillBeReleased(TypedValue* tv) {
|
||||
|
||||
// Assumes 'tv' is live
|
||||
inline void tvRefcountedDecRefCell(TypedValue* tv) {
|
||||
assert(tvIsPlausible(tv));
|
||||
assert(tvIsPlausible(*tv));
|
||||
if (IS_REFCOUNTED_TYPE(tv->m_type)) {
|
||||
tvDecRefHelper(tv->m_type, tv->m_data.num);
|
||||
}
|
||||
@@ -80,7 +80,7 @@ inline void tvDecRefObj(TypedValue* tv) {
|
||||
|
||||
// Assumes 'r' is live and points to a RefData
|
||||
inline void tvDecRefRefInternal(RefData* r) {
|
||||
assert(tvIsPlausible(r->tv()));
|
||||
assert(tvIsPlausible(*r->tv()));
|
||||
assert(r->tv()->m_type != KindOfRef);
|
||||
assert(r->m_count > 0);
|
||||
decRefRef(r);
|
||||
@@ -131,7 +131,7 @@ inline RefData* tvBoxHelper(DataType type, uint64_t datum) {
|
||||
|
||||
// Assumes 'tv' is live
|
||||
inline TypedValue* tvBox(TypedValue* tv) {
|
||||
assert(tvIsPlausible(tv));
|
||||
assert(tvIsPlausible(*tv));
|
||||
assert(tv->m_type != KindOfRef);
|
||||
tv->m_data.pref = tvBoxHelper(tv->m_type, tv->m_data.num);
|
||||
tv->m_type = KindOfRef;
|
||||
@@ -142,13 +142,13 @@ inline TypedValue* tvBox(TypedValue* tv) {
|
||||
//
|
||||
// Assumes 'IS_REFCOUNTED_TYPE(tv->m_type)'
|
||||
inline void tvIncRef(TypedValue* tv) {
|
||||
assert(tvIsPlausible(tv));
|
||||
assert(tvIsPlausible(*tv));
|
||||
assert(IS_REFCOUNTED_TYPE(tv->m_type));
|
||||
tv->m_data.pstr->incRefCount();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE inline void tvRefcountedIncRef(TypedValue* tv) {
|
||||
assert(tvIsPlausible(tv));
|
||||
assert(tvIsPlausible(*tv));
|
||||
if (IS_REFCOUNTED_TYPE(tv->m_type)) {
|
||||
tvIncRef(tv);
|
||||
}
|
||||
@@ -165,7 +165,7 @@ inline void tvIncRefNotShared(TypedValue* tv) {
|
||||
// Assumes 'tv' is live
|
||||
// Assumes 'tv.m_type == KindOfRef'
|
||||
inline void tvUnbox(TypedValue* tv) {
|
||||
assert(tvIsPlausible(tv));
|
||||
assert(tvIsPlausible(*tv));
|
||||
assert(tv->m_type == KindOfRef);
|
||||
RefData* r = tv->m_data.pref;
|
||||
TypedValue* innerCell = r->tv();
|
||||
@@ -173,7 +173,7 @@ inline void tvUnbox(TypedValue* tv) {
|
||||
tv->m_type = innerCell->m_type;
|
||||
tvRefcountedIncRef(tv);
|
||||
tvDecRefRefInternal(r);
|
||||
assert(tvIsPlausible(tv));
|
||||
assert(tvIsPlausible(*tv));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -184,7 +184,7 @@ inline void tvUnbox(TypedValue* tv) {
|
||||
* need TypedValue::operator=.)
|
||||
*/
|
||||
inline void tvCopy(const TypedValue& fr, TypedValue& to) {
|
||||
assert(tvIsPlausible(&fr));
|
||||
assert(tvIsPlausible(fr));
|
||||
to.m_data.num = fr.m_data.num;
|
||||
to.m_type = fr.m_type;
|
||||
}
|
||||
@@ -194,11 +194,11 @@ inline void tvCopy(const TypedValue& fr, TypedValue& to) {
|
||||
* same effects as tvCopy, but have some added assertions.
|
||||
*/
|
||||
inline void cellCopy(const Cell& fr, Cell& to) {
|
||||
assert(cellIsPlausible(&fr));
|
||||
assert(cellIsPlausible(fr));
|
||||
tvCopy(fr, to);
|
||||
}
|
||||
inline void refCopy(const Ref& fr, Ref& to) {
|
||||
assert(refIsPlausible(&fr));
|
||||
assert(refIsPlausible(fr));
|
||||
tvCopy(fr, to);
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ inline void tvDup(const TypedValue& fr, TypedValue& to) {
|
||||
* tvDup, with some added assertions.
|
||||
*/
|
||||
inline void cellDup(const Cell& fr, Cell& to) {
|
||||
assert(cellIsPlausible(&fr));
|
||||
assert(cellIsPlausible(fr));
|
||||
tvDup(fr, to);
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ inline void cellDup(const Cell& fr, Cell& to) {
|
||||
* efficient because we don't need to check the type tag.
|
||||
*/
|
||||
inline void refDup(const Ref& fr, Ref& to) {
|
||||
assert(refIsPlausible(&fr));
|
||||
assert(refIsPlausible(fr));
|
||||
to.m_data.num = fr.m_data.num;
|
||||
to.m_type = KindOfRef;
|
||||
tvIncRefNotShared(&to);
|
||||
@@ -265,7 +265,7 @@ inline const Cell* tvToCell(const TypedValue* tv) {
|
||||
|
||||
// assert that tv is cell
|
||||
inline Cell* tvAssertCell(TypedValue* tv) {
|
||||
assert(cellIsPlausible(tv));
|
||||
assert(cellIsPlausible(*tv));
|
||||
return tv;
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ inline Cell* tvAssertCell(TypedValue* tv) {
|
||||
* `to' must contain a live php value; use cellDup when it doesn't.
|
||||
*/
|
||||
inline void tvSet(const Cell& fr, TypedValue& inTo) {
|
||||
assert(cellIsPlausible(&fr));
|
||||
assert(cellIsPlausible(fr));
|
||||
Cell* to = tvToCell(&inTo);
|
||||
auto const oldType = to->m_type;
|
||||
auto const oldDatum = to->m_data.num;
|
||||
@@ -299,7 +299,7 @@ inline void tvSet(const Cell& fr, TypedValue& inTo) {
|
||||
* Post: `to' is a Cell.
|
||||
*/
|
||||
inline void tvSetIgnoreRef(const Cell& fr, TypedValue& to) {
|
||||
assert(cellIsPlausible(&fr));
|
||||
assert(cellIsPlausible(fr));
|
||||
auto const oldType = to.m_type;
|
||||
auto const oldDatum = to.m_data.num;
|
||||
cellDup(fr, to);
|
||||
@@ -314,8 +314,8 @@ inline void tvSetIgnoreRef(const Cell& fr, TypedValue& to) {
|
||||
* assertions on `to'.
|
||||
*/
|
||||
inline void cellSet(const Cell& fr, Cell& to) {
|
||||
assert(cellIsPlausible(&fr));
|
||||
assert(cellIsPlausible(&to));
|
||||
assert(cellIsPlausible(fr));
|
||||
assert(cellIsPlausible(to));
|
||||
tvSetIgnoreRef(fr, to);
|
||||
}
|
||||
|
||||
@@ -346,7 +346,7 @@ inline void tvUnset(TypedValue * to) {
|
||||
|
||||
// Assumes `fr' is dead and binds it using KindOfIndirect to `to'.
|
||||
inline void tvBindIndirect(TypedValue* fr, TypedValue* to) {
|
||||
assert(tvIsPlausible(to));
|
||||
assert(tvIsPlausible(*to));
|
||||
fr->m_type = KindOfIndirect;
|
||||
fr->m_data.pind = to;
|
||||
}
|
||||
@@ -365,7 +365,7 @@ inline const TypedValue* tvDerefIndirect(const TypedValue* tv) {
|
||||
* ref-counted type and the object pointed to is static.
|
||||
*/
|
||||
inline bool tvIsStatic(const TypedValue* tv) {
|
||||
assert(tvIsPlausible(tv));
|
||||
assert(tvIsPlausible(*tv));
|
||||
return !IS_REFCOUNTED_TYPE(tv->m_type) ||
|
||||
tv->m_data.pref->m_count == RefCountStaticValue;
|
||||
}
|
||||
@@ -381,7 +381,7 @@ inline Variant& tvAsVariant(TypedValue* tv) {
|
||||
// Avoid treating uninitialized TV's as variants. We have some slightly
|
||||
// perverse, but defensible uses where we pass in NULL (and later check
|
||||
// a Variant* against NULL) so tolerate it.
|
||||
assert(nullptr == tv || tvIsPlausible(tv));
|
||||
assert(nullptr == tv || tvIsPlausible(*tv));
|
||||
return *(Variant*)(tv);
|
||||
}
|
||||
|
||||
@@ -398,25 +398,25 @@ inline const Variant& tvAsCVarRef(const TypedValue* tv) {
|
||||
|
||||
// Assumes 'tv' is live
|
||||
inline Variant& cellAsVariant(Cell& cell) {
|
||||
assert(cellIsPlausible(&cell));
|
||||
assert(cellIsPlausible(cell));
|
||||
return *(Variant*)(&cell);
|
||||
}
|
||||
|
||||
// Assumes 'tv' is live
|
||||
inline const Variant& cellAsCVarRef(const Cell& cell) {
|
||||
assert(cellIsPlausible(&cell));
|
||||
assert(cellIsPlausible(cell));
|
||||
return *(const Variant*)(&cell);
|
||||
}
|
||||
|
||||
// Assumes 'tv' is live
|
||||
inline Variant& refAsVariant(Ref& ref) {
|
||||
assert(refIsPlausible(&ref));
|
||||
assert(refIsPlausible(ref));
|
||||
return *(Variant*)(&ref);
|
||||
}
|
||||
|
||||
// Assumes 'tv' is live
|
||||
inline const Variant& refAsCVarRef(const Ref& ref) {
|
||||
assert(refIsPlausible(&ref));
|
||||
assert(refIsPlausible(ref));
|
||||
return *(const Variant*)(&ref);
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ void c_ExternalThreadEventWaitHandle::process() {
|
||||
throw;
|
||||
}
|
||||
|
||||
assert(cellIsPlausible(&result));
|
||||
assert(cellIsPlausible(result));
|
||||
setResult(result);
|
||||
tvRefcountedDecRefCell(&result);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ c_BlockableWaitHandle* c_WaitableWaitHandle::addParent(c_BlockableWaitHandle* pa
|
||||
}
|
||||
|
||||
void c_WaitableWaitHandle::setResult(const Cell& result) {
|
||||
assert(cellIsPlausible(&result));
|
||||
assert(cellIsPlausible(result));
|
||||
|
||||
setState(STATE_SUCCEEDED);
|
||||
cellDup(result, m_resultOrException);
|
||||
|
||||
@@ -6724,7 +6724,7 @@ inline void OPTBLD_INLINE VMExecutionContext::iopUnpackCont(PC& pc) {
|
||||
c_Continuation* cont = frame_continuation(m_fp);
|
||||
|
||||
// check sanity of received value
|
||||
assert(tvIsPlausible(m_stack.topC()));
|
||||
assert(tvIsPlausible(*m_stack.topC()));
|
||||
|
||||
// Return the label in a stack cell
|
||||
TypedValue* label = m_stack.allocTV();
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace HPHP {
|
||||
|
||||
inline ALWAYS_INLINE
|
||||
void SETOP_BODY(TypedValue* lhs, unsigned char op, Cell* rhs) {
|
||||
assert(cellIsPlausible(rhs));
|
||||
assert(cellIsPlausible(*rhs));
|
||||
lhs = tvToCell(lhs);
|
||||
|
||||
switch (op) {
|
||||
@@ -562,8 +562,7 @@ public:
|
||||
|
||||
inline void ALWAYS_INLINE popC() {
|
||||
assert(m_top != m_base);
|
||||
assert(tvIsPlausible(m_top));
|
||||
assert(m_top->m_type != KindOfRef);
|
||||
assert(cellIsPlausible(*m_top));
|
||||
tvRefcountedDecRefCell(m_top);
|
||||
m_top++;
|
||||
}
|
||||
@@ -576,15 +575,14 @@ public:
|
||||
|
||||
inline void ALWAYS_INLINE popV() {
|
||||
assert(m_top != m_base);
|
||||
assert(m_top->m_type == KindOfRef);
|
||||
assert(m_top->m_data.pref != nullptr);
|
||||
assert(refIsPlausible(*m_top));
|
||||
tvDecRefRef(m_top);
|
||||
m_top++;
|
||||
}
|
||||
|
||||
inline void ALWAYS_INLINE popTV() {
|
||||
assert(m_top != m_base);
|
||||
assert(m_top->m_type == KindOfClass || tvIsPlausible(m_top));
|
||||
assert(m_top->m_type == KindOfClass || tvIsPlausible(*m_top));
|
||||
tvRefcountedDecRef(m_top);
|
||||
m_top++;
|
||||
}
|
||||
|
||||
@@ -945,7 +945,7 @@ Cell* Class::cnsNameToTV(const StringData* clsCnsName,
|
||||
return nullptr;
|
||||
}
|
||||
auto const ret = const_cast<Cell*>(&m_constants[clsCnsInd].m_val);
|
||||
assert(cellIsPlausible(ret));
|
||||
assert(cellIsPlausible(*ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -976,7 +976,7 @@ Cell* Class::clsCnsGet(const StringData* clsCnsName) const {
|
||||
g_vmContext->invokeFuncFew(clsCns, meth86cinit, ActRec::encodeClass(this),
|
||||
nullptr, 1, tv);
|
||||
}
|
||||
assert(cellIsPlausible(clsCns));
|
||||
assert(cellIsPlausible(*clsCns));
|
||||
return clsCns;
|
||||
}
|
||||
|
||||
|
||||
@@ -2532,7 +2532,7 @@ void checkFrame(ActRec* fp, Cell* sp, bool checkLocals) {
|
||||
if (i >= numParams && func->isGenerator() && i < func->numNamedLocals()) {
|
||||
continue;
|
||||
}
|
||||
assert(checkTv(frame_local(fp, i)));
|
||||
assert(tvIsPlausible(*frame_local(fp, i)));
|
||||
}
|
||||
}
|
||||
// We unfortunately can't do the same kind of check for the stack
|
||||
|
||||
@@ -138,7 +138,7 @@ inline static KeyType getKeyTypeIS(const SSATmp* key) {
|
||||
template<KeyType kt>
|
||||
static inline TypedValue* keyPtr(TypedValue& key) {
|
||||
if (kt == KeyType::Any) {
|
||||
assert(tvIsPlausible(&key));
|
||||
assert(tvIsPlausible(key));
|
||||
return &key;
|
||||
} else {
|
||||
return reinterpret_cast<TypedValue*>(key.m_data.num);
|
||||
|
||||
@@ -1014,7 +1014,7 @@ void incDecBodySlow(unsigned char op, TypedValue* fr, TypedValue* to) {
|
||||
fr = tvToCell(fr);
|
||||
}
|
||||
|
||||
assert(cellIsPlausible(fr));
|
||||
assert(cellIsPlausible(*fr));
|
||||
|
||||
switch (static_cast<IncDecOp>(op)) {
|
||||
case PreInc:
|
||||
|
||||
@@ -446,14 +446,8 @@ void collection_setm_sk1_v0(ObjectData* obj, StringData* key,
|
||||
tvRefcountedDecRef(value);
|
||||
}
|
||||
|
||||
bool checkTv(const TypedValue* tv) {
|
||||
return tv && tvIsPlausible(tv) &&
|
||||
(!IS_REFCOUNTED_TYPE(tv->m_type) ||
|
||||
is_refcount_realistic(tv->m_data.pstr->getCount()));
|
||||
}
|
||||
|
||||
void assertTv(const TypedValue* tv) {
|
||||
always_assert(checkTv(tv));
|
||||
always_assert(tvIsPlausible(*tv));
|
||||
}
|
||||
|
||||
int init_closure(ActRec* ar, TypedValue* sp) {
|
||||
|
||||
@@ -223,9 +223,6 @@ void collection_setm_ik1_v0(ObjectData* obj, int64_t key, TypedValue* value);
|
||||
void collection_setm_sk1_v0(ObjectData* obj, StringData* key,
|
||||
TypedValue* value);
|
||||
|
||||
// return true if tv is plausible
|
||||
bool checkTv(const TypedValue* tv);
|
||||
|
||||
// always_assert tv is a plausible TypedValue*
|
||||
void assertTv(const TypedValue* tv);
|
||||
|
||||
|
||||
@@ -928,7 +928,7 @@ Cell* Unit::lookupCns(const StringData* cnsName) {
|
||||
if (LIKELY(handle != 0)) {
|
||||
TypedValue& tv = TargetCache::handleToRef<TypedValue>(handle);
|
||||
if (LIKELY(tv.m_type != KindOfUninit)) {
|
||||
assert(cellIsPlausible(&tv));
|
||||
assert(cellIsPlausible(tv));
|
||||
return &tv;
|
||||
}
|
||||
if (UNLIKELY(tv.m_data.pref != nullptr)) {
|
||||
@@ -936,7 +936,7 @@ Cell* Unit::lookupCns(const StringData* cnsName) {
|
||||
(ClassInfo::ConstantInfo*)(void*)tv.m_data.pref;
|
||||
auto const tvRet = const_cast<Variant&>(
|
||||
ci->getDeferredValue()).asTypedValue();
|
||||
assert(cellIsPlausible(tvRet));
|
||||
assert(cellIsPlausible(*tvRet));
|
||||
return tvRet;
|
||||
}
|
||||
}
|
||||
@@ -950,7 +950,7 @@ Cell* Unit::lookupPersistentCns(const StringData* cnsName) {
|
||||
TargetCache::CacheHandle handle = StringData::GetCnsHandle(cnsName);
|
||||
if (!TargetCache::isPersistentHandle(handle)) return nullptr;
|
||||
auto const ret = &TargetCache::handleToRef<TypedValue>(handle);
|
||||
assert(cellIsPlausible(ret));
|
||||
assert(cellIsPlausible(*ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário