Use Cell instead of TypedValue whenever possible
Most of the values stored in TypedValue in ext_asio are always Cells. Let's use Cell type alias to improve code readability, pass them by reference where null is not allowed and use Cell-specific functions from tv_helpers.h.
Esse commit está contido em:
@@ -737,7 +737,7 @@ public:
|
||||
}
|
||||
void invokeContFunc(const HPHP::Func* f,
|
||||
ObjectData* this_,
|
||||
TypedValue* param = nullptr);
|
||||
Cell* param = nullptr);
|
||||
// VM ClassInfo support
|
||||
StringIMap<AtomicSmartPtr<MethodInfoVM> > m_functionInfos;
|
||||
StringIMap<AtomicSmartPtr<ClassInfoVM> > m_classInfos;
|
||||
|
||||
@@ -277,6 +277,12 @@ inline const Cell* tvToCell(const TypedValue* tv) {
|
||||
return LIKELY(tv->m_type != KindOfRef) ? tv : tv->m_data.pref->tv();
|
||||
}
|
||||
|
||||
// assert that tv is cell
|
||||
inline Cell* tvAssertCell(TypedValue* tv) {
|
||||
assert(cellIsPlausible(tv));
|
||||
return tv;
|
||||
}
|
||||
|
||||
/*
|
||||
* Assign the value of the Cell in `fr' to `to', with appropriate
|
||||
* reference count modifications.
|
||||
|
||||
@@ -58,7 +58,7 @@ FORWARD_DECLARE_CLASS_BUILTIN(ExternalThreadEventWaitHandle);
|
||||
* markAsFinished();
|
||||
* }
|
||||
* protected:
|
||||
* void unserialize(TypedValue* result) const {
|
||||
* void unserialize(Cell& result) const {
|
||||
* if (UNLIKELY(m_failed)) {
|
||||
* Object e(SystemLib::AllocInvalidOperationExceptionObject(
|
||||
* "An error has occurred while scheduling the operation"));
|
||||
@@ -71,8 +71,7 @@ FORWARD_DECLARE_CLASS_BUILTIN(ExternalThreadEventWaitHandle);
|
||||
* throw e;
|
||||
* }
|
||||
*
|
||||
* result->m_type = KindOfInt64;
|
||||
* result->m_data.num = m_value;
|
||||
* cellDup(make_tv<KindOfInt64>(m_value), result);
|
||||
* }
|
||||
* private:
|
||||
* int m_value, m_maxValue;
|
||||
@@ -193,7 +192,7 @@ class AsioExternalThreadEvent {
|
||||
* If a result was already initialized, it must be uninitialized (decref
|
||||
* if needed) prior to throwing an exception.
|
||||
*/
|
||||
virtual void unserialize(TypedValue* result) const = 0;
|
||||
virtual void unserialize(Cell& result) const = 0;
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
||||
@@ -160,17 +160,17 @@ void c_ContinuationWaitHandle::run() {
|
||||
|
||||
// continuation finished, retrieve result from its m_value
|
||||
if (m_continuation->done()) {
|
||||
markAsSucceeded(m_continuation->m_value.asTypedValue());
|
||||
markAsSucceeded(*m_continuation->m_value.asCell());
|
||||
return;
|
||||
}
|
||||
|
||||
// set up dependency
|
||||
TypedValue* value = m_continuation->m_value.asTypedValue();
|
||||
Cell* value = m_continuation->m_value.asCell();
|
||||
if (IS_NULL_TYPE(value->m_type)) {
|
||||
// null dependency
|
||||
m_child = nullptr;
|
||||
} else {
|
||||
c_WaitHandle* child = c_WaitHandle::fromTypedValue(value);
|
||||
c_WaitHandle* child = c_WaitHandle::fromCell(value);
|
||||
if (UNLIKELY(!child)) {
|
||||
Object e(SystemLib::AllocInvalidArgumentExceptionObject(
|
||||
"Expected yield argument to be an instance of WaitHandle"));
|
||||
@@ -206,10 +206,10 @@ void c_ContinuationWaitHandle::onUnblocked() {
|
||||
}
|
||||
}
|
||||
|
||||
void c_ContinuationWaitHandle::markAsSucceeded(const TypedValue* result) {
|
||||
void c_ContinuationWaitHandle::markAsSucceeded(const Cell& result) {
|
||||
AsioSession* session = AsioSession::Get();
|
||||
if (UNLIKELY(session->hasOnContinuationSuccessCallback())) {
|
||||
session->onContinuationSuccess(this, tvAsCVarRef(result));
|
||||
session->onContinuationSuccess(this, cellAsCVarRef(result));
|
||||
}
|
||||
|
||||
setResult(result);
|
||||
|
||||
@@ -111,9 +111,9 @@ void c_ExternalThreadEventWaitHandle::process() {
|
||||
// clean up once event is processed
|
||||
auto exit_guard = folly::makeGuard([&] { destroyEvent(); });
|
||||
|
||||
TypedValue result;
|
||||
Cell result;
|
||||
try {
|
||||
m_event->unserialize(&result);
|
||||
m_event->unserialize(result);
|
||||
} catch (const Object& exception) {
|
||||
setException(exception.get());
|
||||
return;
|
||||
@@ -122,8 +122,8 @@ void c_ExternalThreadEventWaitHandle::process() {
|
||||
throw;
|
||||
}
|
||||
|
||||
assert(tvIsPlausible(&result));
|
||||
setResult(&result);
|
||||
assert(cellIsPlausible(&result));
|
||||
setResult(result);
|
||||
tvRefcountedDecRefCell(&result);
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ Object c_GenArrayWaitHandle::ti_create(CArrRef dependencies) {
|
||||
tvUnbox(current);
|
||||
}
|
||||
|
||||
if (!c_WaitHandle::fromTypedValue(current) &&
|
||||
if (!c_WaitHandle::fromCell(tvAssertCell(current)) &&
|
||||
!IS_NULL_TYPE(current->m_type)) {
|
||||
Object e(SystemLib::AllocInvalidArgumentExceptionObject(
|
||||
"Expected dependencies to be an array of WaitHandle instances"));
|
||||
@@ -83,7 +83,7 @@ Object c_GenArrayWaitHandle::ti_create(CArrRef dependencies) {
|
||||
iter_pos != ArrayData::invalid_index;
|
||||
iter_pos = deps->iter_advance(iter_pos)) {
|
||||
|
||||
TypedValue* current = deps->nvGetValueRef(iter_pos);
|
||||
Cell* current = tvAssertCell(deps->nvGetValueRef(iter_pos));
|
||||
if (IS_NULL_TYPE(current->m_type)) {
|
||||
// {uninit,null} yields null
|
||||
tvWriteNull(current);
|
||||
@@ -95,7 +95,7 @@ Object c_GenArrayWaitHandle::ti_create(CArrRef dependencies) {
|
||||
auto child = static_cast<c_WaitHandle*>(current->m_data.pobj);
|
||||
|
||||
if (child->isSucceeded()) {
|
||||
tvSetIgnoreRef(*child->getResult(), *current);
|
||||
cellSet(child->getResult(), *current);
|
||||
} else if (child->isFailed()) {
|
||||
putException(exception, child->getException());
|
||||
} else {
|
||||
@@ -115,10 +115,7 @@ Object c_GenArrayWaitHandle::ti_create(CArrRef dependencies) {
|
||||
}
|
||||
|
||||
if (exception.isNull()) {
|
||||
TypedValue tv;
|
||||
tv.m_type = KindOfArray;
|
||||
tv.m_data.parr = deps.get();
|
||||
return c_StaticResultWaitHandle::Create(&tv);
|
||||
return c_StaticResultWaitHandle::Create(make_tv<KindOfArray>(deps.get()));
|
||||
} else {
|
||||
return c_StaticExceptionWaitHandle::Create(exception.get());
|
||||
}
|
||||
@@ -142,7 +139,7 @@ void c_GenArrayWaitHandle::onUnblocked() {
|
||||
m_iterPos != ArrayData::invalid_index;
|
||||
m_iterPos = m_deps->iter_advance(m_iterPos)) {
|
||||
|
||||
TypedValue* current = m_deps->nvGetValueRef(m_iterPos);
|
||||
Cell* current = tvAssertCell(m_deps->nvGetValueRef(m_iterPos));
|
||||
if (IS_NULL_TYPE(current->m_type)) {
|
||||
// {uninit,null} yields null
|
||||
tvWriteNull(current);
|
||||
@@ -154,7 +151,7 @@ void c_GenArrayWaitHandle::onUnblocked() {
|
||||
auto child = static_cast<c_WaitHandle*>(current->m_data.pobj);
|
||||
|
||||
if (child->isSucceeded()) {
|
||||
tvSetIgnoreRef(*child->getResult(), *current);
|
||||
cellSet(child->getResult(), *current);
|
||||
} else if (child->isFailed()) {
|
||||
putException(m_exception, child->getException());
|
||||
} else {
|
||||
@@ -171,10 +168,7 @@ void c_GenArrayWaitHandle::onUnblocked() {
|
||||
}
|
||||
|
||||
if (m_exception.isNull()) {
|
||||
TypedValue result;
|
||||
result.m_type = KindOfArray;
|
||||
result.m_data.parr = m_deps.get();
|
||||
setResult(&result);
|
||||
setResult(make_tv<KindOfArray>(m_deps.get()));
|
||||
m_deps = nullptr;
|
||||
} else {
|
||||
setException(m_exception.get());
|
||||
@@ -211,7 +205,7 @@ void c_GenArrayWaitHandle::enterContext(context_idx_t ctx_idx) {
|
||||
// recursively import current child
|
||||
{
|
||||
assert(m_iterPos != ArrayData::invalid_index);
|
||||
TypedValue* current = m_deps->nvGetValueRef(m_iterPos);
|
||||
Cell* current = tvAssertCell(m_deps->nvGetValueRef(m_iterPos));
|
||||
|
||||
assert(current->m_type == KindOfObject);
|
||||
assert(dynamic_cast<c_WaitableWaitHandle*>(current->m_data.pobj));
|
||||
@@ -228,7 +222,7 @@ void c_GenArrayWaitHandle::enterContext(context_idx_t ctx_idx) {
|
||||
iter_pos != ArrayData::invalid_index;
|
||||
iter_pos = m_deps->iter_advance(iter_pos)) {
|
||||
|
||||
TypedValue* current = m_deps->nvGetValueRef(iter_pos);
|
||||
Cell* current = tvAssertCell(m_deps->nvGetValueRef(iter_pos));
|
||||
if (IS_NULL_TYPE(current->m_type)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -72,8 +72,8 @@ Object c_GenMapWaitHandle::ti_create(CVarRef dependencies) {
|
||||
iter_pos;
|
||||
iter_pos = deps->iter_next(iter_pos)) {
|
||||
|
||||
TypedValue* current = deps->iter_value(iter_pos);
|
||||
if (UNLIKELY(!c_WaitHandle::fromTypedValue(current))) {
|
||||
Cell* current = tvAssertCell(deps->iter_value(iter_pos));
|
||||
if (UNLIKELY(!c_WaitHandle::fromCell(current))) {
|
||||
Object e(SystemLib::AllocInvalidArgumentExceptionObject(
|
||||
"Expected dependencies to be a map of WaitHandle instances"));
|
||||
throw e;
|
||||
@@ -85,13 +85,13 @@ Object c_GenMapWaitHandle::ti_create(CVarRef dependencies) {
|
||||
iter_pos;
|
||||
iter_pos = deps->iter_next(iter_pos)) {
|
||||
|
||||
TypedValue* current = deps->iter_value(iter_pos);
|
||||
Cell* current = tvAssertCell(deps->iter_value(iter_pos));
|
||||
assert(current->m_type == KindOfObject);
|
||||
assert(dynamic_cast<c_WaitHandle*>(current->m_data.pobj));
|
||||
auto child = static_cast<c_WaitHandle*>(current->m_data.pobj);
|
||||
|
||||
if (child->isSucceeded()) {
|
||||
tvSetIgnoreRef(*child->getResult(), *current);
|
||||
cellSet(child->getResult(), *current);
|
||||
} else if (child->isFailed()) {
|
||||
putException(exception, child->getException());
|
||||
} else {
|
||||
@@ -111,10 +111,7 @@ Object c_GenMapWaitHandle::ti_create(CVarRef dependencies) {
|
||||
}
|
||||
|
||||
if (exception.isNull()) {
|
||||
TypedValue tv;
|
||||
tv.m_type = KindOfObject;
|
||||
tv.m_data.pobj = deps.get();
|
||||
return c_StaticResultWaitHandle::Create(&tv);
|
||||
return c_StaticResultWaitHandle::Create(make_tv<KindOfObject>(deps.get()));
|
||||
} else {
|
||||
return c_StaticExceptionWaitHandle::Create(exception.get());
|
||||
}
|
||||
@@ -138,13 +135,13 @@ void c_GenMapWaitHandle::onUnblocked() {
|
||||
m_iterPos;
|
||||
m_iterPos = m_deps->iter_next(m_iterPos)) {
|
||||
|
||||
TypedValue* current = m_deps->iter_value(m_iterPos);
|
||||
Cell* current = tvAssertCell(m_deps->iter_value(m_iterPos));
|
||||
assert(current->m_type == KindOfObject);
|
||||
assert(dynamic_cast<c_WaitHandle*>(current->m_data.pobj));
|
||||
auto child = static_cast<c_WaitHandle*>(current->m_data.pobj);
|
||||
|
||||
if (child->isSucceeded()) {
|
||||
tvSetIgnoreRef(*child->getResult(), *current);
|
||||
cellSet(child->getResult(), *current);
|
||||
} else if (child->isFailed()) {
|
||||
putException(m_exception, child->getException());
|
||||
} else {
|
||||
@@ -161,10 +158,7 @@ void c_GenMapWaitHandle::onUnblocked() {
|
||||
}
|
||||
|
||||
if (m_exception.isNull()) {
|
||||
TypedValue result;
|
||||
result.m_type = KindOfObject;
|
||||
result.m_data.pobj = m_deps.get();
|
||||
setResult(&result);
|
||||
setResult(make_tv<KindOfObject>(m_deps.get()));
|
||||
m_deps = nullptr;
|
||||
} else {
|
||||
setException(m_exception.get());
|
||||
@@ -201,7 +195,7 @@ void c_GenMapWaitHandle::enterContext(context_idx_t ctx_idx) {
|
||||
// recursively import current child
|
||||
{
|
||||
assert(m_iterPos);
|
||||
TypedValue* current = m_deps->iter_value(m_iterPos);
|
||||
Cell* current = tvAssertCell(m_deps->iter_value(m_iterPos));
|
||||
|
||||
assert(current->m_type == KindOfObject);
|
||||
assert(dynamic_cast<c_WaitableWaitHandle*>(current->m_data.pobj));
|
||||
@@ -218,7 +212,7 @@ void c_GenMapWaitHandle::enterContext(context_idx_t ctx_idx) {
|
||||
iter_pos;
|
||||
iter_pos = m_deps->iter_next(iter_pos)) {
|
||||
|
||||
TypedValue* current = m_deps->iter_value(iter_pos);
|
||||
Cell* current = tvAssertCell(m_deps->iter_value(iter_pos));
|
||||
assert(current->m_type == KindOfObject);
|
||||
assert(dynamic_cast<c_WaitHandle*>(current->m_data.pobj));
|
||||
auto child = static_cast<c_WaitHandle*>(current->m_data.pobj);
|
||||
|
||||
@@ -69,9 +69,9 @@ Object c_GenVectorWaitHandle::ti_create(CVarRef dependencies) {
|
||||
assert(dynamic_cast<c_Vector*>(dependencies.getObjectData()));
|
||||
p_Vector deps = static_cast<c_Vector*>(dependencies.getObjectData())->clone();
|
||||
for (int64_t iter_pos = 0; iter_pos < deps->size(); ++iter_pos) {
|
||||
TypedValue* current = deps->at(iter_pos);
|
||||
Cell* current = deps->at(iter_pos);
|
||||
|
||||
if (UNLIKELY(!c_WaitHandle::fromTypedValue(current))) {
|
||||
if (UNLIKELY(!c_WaitHandle::fromCell(current))) {
|
||||
Object e(SystemLib::AllocInvalidArgumentExceptionObject(
|
||||
"Expected dependencies to be a vector of WaitHandle instances"));
|
||||
throw e;
|
||||
@@ -81,13 +81,13 @@ Object c_GenVectorWaitHandle::ti_create(CVarRef dependencies) {
|
||||
Object exception;
|
||||
for (int64_t iter_pos = 0; iter_pos < deps->size(); ++iter_pos) {
|
||||
|
||||
TypedValue* current = deps->at(iter_pos);
|
||||
Cell* current = tvAssertCell(deps->at(iter_pos));
|
||||
assert(current->m_type == KindOfObject);
|
||||
assert(dynamic_cast<c_WaitHandle*>(current->m_data.pobj));
|
||||
auto child = static_cast<c_WaitHandle*>(current->m_data.pobj);
|
||||
|
||||
if (child->isSucceeded()) {
|
||||
tvSetIgnoreRef(*child->getResult(), *current);
|
||||
cellSet(child->getResult(), *current);
|
||||
} else if (child->isFailed()) {
|
||||
putException(exception, child->getException());
|
||||
} else {
|
||||
@@ -105,10 +105,7 @@ Object c_GenVectorWaitHandle::ti_create(CVarRef dependencies) {
|
||||
}
|
||||
|
||||
if (exception.isNull()) {
|
||||
TypedValue tv;
|
||||
tv.m_type = KindOfObject;
|
||||
tv.m_data.pobj = deps.get();
|
||||
return c_StaticResultWaitHandle::Create(&tv);
|
||||
return c_StaticResultWaitHandle::Create(make_tv<KindOfObject>(deps.get()));
|
||||
} else {
|
||||
return c_StaticExceptionWaitHandle::Create(exception.get());
|
||||
}
|
||||
@@ -130,13 +127,13 @@ void c_GenVectorWaitHandle::initialize(CObjRef exception, c_Vector* deps, int64_
|
||||
void c_GenVectorWaitHandle::onUnblocked() {
|
||||
for (; m_iterPos < m_deps->size(); ++m_iterPos) {
|
||||
|
||||
TypedValue* current = m_deps->at(m_iterPos);
|
||||
Cell* current = tvAssertCell(m_deps->at(m_iterPos));
|
||||
assert(current->m_type == KindOfObject);
|
||||
assert(dynamic_cast<c_WaitHandle*>(current->m_data.pobj));
|
||||
auto child = static_cast<c_WaitHandle*>(current->m_data.pobj);
|
||||
|
||||
if (child->isSucceeded()) {
|
||||
tvSetIgnoreRef(*child->getResult(), *current);
|
||||
cellSet(child->getResult(), *current);
|
||||
} else if (child->isFailed()) {
|
||||
putException(m_exception, child->getException());
|
||||
} else {
|
||||
@@ -153,10 +150,7 @@ void c_GenVectorWaitHandle::onUnblocked() {
|
||||
}
|
||||
|
||||
if (m_exception.isNull()) {
|
||||
TypedValue result;
|
||||
result.m_type = KindOfObject;
|
||||
result.m_data.pobj = m_deps.get();
|
||||
setResult(&result);
|
||||
setResult(make_tv<KindOfObject>(m_deps.get()));
|
||||
m_deps = nullptr;
|
||||
} else {
|
||||
setException(m_exception.get());
|
||||
@@ -192,7 +186,7 @@ void c_GenVectorWaitHandle::enterContext(context_idx_t ctx_idx) {
|
||||
// recursively import current child
|
||||
{
|
||||
assert(m_iterPos < m_deps->size());
|
||||
TypedValue* current = m_deps->at(m_iterPos);
|
||||
Cell* current = tvAssertCell(m_deps->at(m_iterPos));
|
||||
|
||||
assert(current->m_type == KindOfObject);
|
||||
assert(dynamic_cast<c_WaitableWaitHandle*>(current->m_data.pobj));
|
||||
@@ -209,7 +203,7 @@ void c_GenVectorWaitHandle::enterContext(context_idx_t ctx_idx) {
|
||||
iter_pos < m_deps->size();
|
||||
++iter_pos) {
|
||||
|
||||
TypedValue* current = m_deps->at(iter_pos);
|
||||
Cell* current = tvAssertCell(m_deps->at(iter_pos));
|
||||
assert(current->m_type == KindOfObject);
|
||||
assert(dynamic_cast<c_WaitHandle*>(current->m_data.pobj));
|
||||
auto child = static_cast<c_WaitHandle*>(current->m_data.pobj);
|
||||
|
||||
@@ -79,7 +79,7 @@ void c_RescheduleWaitHandle::run() {
|
||||
return;
|
||||
}
|
||||
|
||||
setResult(init_null_variant.asTypedValue());
|
||||
setResult(make_tv<KindOfNull>());
|
||||
}
|
||||
|
||||
String c_RescheduleWaitHandle::getName() {
|
||||
|
||||
@@ -70,7 +70,7 @@ Object c_SetResultToRefWaitHandle::ti_create(CObjRef wait_handle, VRefParam ref)
|
||||
|
||||
// succeeded? set result to ref and give back succeeded wait handle
|
||||
if (wh->isSucceeded()) {
|
||||
tvSet(*wh->getResult(), *var_or_cell);
|
||||
tvSet(wh->getResult(), *var_or_cell);
|
||||
return wh;
|
||||
}
|
||||
|
||||
@@ -124,11 +124,11 @@ void c_SetResultToRefWaitHandle::onUnblocked() {
|
||||
}
|
||||
}
|
||||
|
||||
void c_SetResultToRefWaitHandle::markAsSucceeded(const TypedValue* result) {
|
||||
void c_SetResultToRefWaitHandle::markAsSucceeded(const Cell& result) {
|
||||
RefData* ref = m_ref;
|
||||
|
||||
m_ref = nullptr;
|
||||
tvSetIgnoreRef(*result, *ref->tv());
|
||||
cellSet(result, *ref->tv());
|
||||
decRefRef(ref);
|
||||
|
||||
setResult(result);
|
||||
|
||||
@@ -41,12 +41,12 @@ void c_StaticResultWaitHandle::t___construct() {
|
||||
}
|
||||
|
||||
Object c_StaticResultWaitHandle::ti_create(CVarRef result) {
|
||||
return Create(result.asTypedValue());
|
||||
return Create(*result.asCell());
|
||||
}
|
||||
|
||||
p_StaticResultWaitHandle c_StaticResultWaitHandle::Create(const TypedValue* result) {
|
||||
p_StaticResultWaitHandle c_StaticResultWaitHandle::Create(const Cell& result) {
|
||||
p_StaticResultWaitHandle wh = NEWOBJ(c_StaticResultWaitHandle)();
|
||||
tvReadCell(result, &wh->m_resultOrException);
|
||||
cellDup(result, wh->m_resultOrException);
|
||||
return wh;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ Variant c_WaitHandle::t_join() {
|
||||
|
||||
if (LIKELY(isSucceeded())) {
|
||||
// succeeded? return result
|
||||
return tvAsCVarRef(getResult());
|
||||
return cellAsCVarRef(getResult());
|
||||
} else {
|
||||
// failed? throw exception
|
||||
Object e(getException());
|
||||
|
||||
@@ -89,12 +89,11 @@ c_BlockableWaitHandle* c_WaitableWaitHandle::addParent(c_BlockableWaitHandle* pa
|
||||
return prev;
|
||||
}
|
||||
|
||||
void c_WaitableWaitHandle::setResult(const TypedValue* result) {
|
||||
assert(result);
|
||||
assert(result->m_type != KindOfRef);
|
||||
void c_WaitableWaitHandle::setResult(const Cell& result) {
|
||||
assert(cellIsPlausible(&result));
|
||||
|
||||
setState(STATE_SUCCEEDED);
|
||||
cellDup(*result, m_resultOrException);
|
||||
cellDup(result, m_resultOrException);
|
||||
|
||||
// unref creator
|
||||
if (m_creator) {
|
||||
|
||||
@@ -78,18 +78,18 @@ class c_WaitHandle : public ExtObjectData {
|
||||
|
||||
|
||||
public:
|
||||
static c_WaitHandle* fromTypedValue(TypedValue* tv) {
|
||||
static c_WaitHandle* fromCell(Cell* cell) {
|
||||
return (
|
||||
tv->m_type == KindOfObject &&
|
||||
tv->m_data.pobj->instanceof(s_cls)
|
||||
) ? static_cast<c_WaitHandle*>(tv->m_data.pobj) : nullptr;
|
||||
cell->m_type == KindOfObject &&
|
||||
cell->m_data.pobj->instanceof(s_cls)
|
||||
) ? static_cast<c_WaitHandle*>(cell->m_data.pobj) : nullptr;
|
||||
}
|
||||
bool isFinished() { return getState() <= STATE_FAILED; }
|
||||
bool isSucceeded() { return getState() == STATE_SUCCEEDED; }
|
||||
bool isFailed() { return getState() == STATE_FAILED; }
|
||||
TypedValue* getResult() {
|
||||
Cell& getResult() {
|
||||
assert(isSucceeded());
|
||||
return &m_resultOrException;
|
||||
return m_resultOrException;
|
||||
}
|
||||
ObjectData* getException() {
|
||||
assert(isFailed());
|
||||
@@ -104,7 +104,7 @@ class c_WaitHandle : public ExtObjectData {
|
||||
static const int8_t STATE_SUCCEEDED = 0;
|
||||
static const int8_t STATE_FAILED = 1;
|
||||
|
||||
TypedValue m_resultOrException;
|
||||
Cell m_resultOrException;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -145,7 +145,7 @@ class c_StaticResultWaitHandle : public c_StaticWaitHandle {
|
||||
public: static Object ti_create(CVarRef result);
|
||||
|
||||
public:
|
||||
static p_StaticResultWaitHandle Create(const TypedValue* result);
|
||||
static p_StaticResultWaitHandle Create(const Cell& result);
|
||||
String getName();
|
||||
};
|
||||
|
||||
@@ -207,7 +207,7 @@ class c_WaitableWaitHandle : public c_WaitHandle {
|
||||
void join();
|
||||
|
||||
protected:
|
||||
void setResult(const TypedValue* result);
|
||||
void setResult(const Cell& result);
|
||||
void setException(ObjectData* exception);
|
||||
|
||||
context_idx_t getContextIdx() { return o_subclassData.u8[1]; }
|
||||
@@ -305,7 +305,7 @@ class c_ContinuationWaitHandle : public c_BlockableWaitHandle {
|
||||
|
||||
private:
|
||||
void initialize(c_Continuation* continuation, uint16_t depth);
|
||||
void markAsSucceeded(const TypedValue* result);
|
||||
void markAsSucceeded(const Cell& result);
|
||||
void markAsFailed(CObjRef exception);
|
||||
|
||||
p_Continuation m_continuation;
|
||||
@@ -464,7 +464,7 @@ class c_SetResultToRefWaitHandle : public c_BlockableWaitHandle {
|
||||
|
||||
private:
|
||||
void initialize(c_WaitableWaitHandle* wait_handle, RefData* ref);
|
||||
void markAsSucceeded(const TypedValue* result);
|
||||
void markAsSucceeded(const Cell& result);
|
||||
void markAsFailed(CObjRef exception);
|
||||
|
||||
p_WaitableWaitHandle m_child;
|
||||
|
||||
@@ -234,9 +234,9 @@ void c_Continuation::call_next() {
|
||||
g_vmContext->invokeContFunc(func, this);
|
||||
}
|
||||
|
||||
void c_Continuation::call_send(TypedValue* v) {
|
||||
void c_Continuation::call_send(Cell& v) {
|
||||
const HPHP::Func* func = m_cls->lookupMethod(s_send.get());
|
||||
g_vmContext->invokeContFunc(func, this, v);
|
||||
g_vmContext->invokeContFunc(func, this, &v);
|
||||
}
|
||||
|
||||
void c_Continuation::call_raise(ObjectData* e) {
|
||||
@@ -245,7 +245,7 @@ void c_Continuation::call_raise(ObjectData* e) {
|
||||
|
||||
const HPHP::Func* func = m_cls->lookupMethod(s_raise.get());
|
||||
|
||||
TypedValue arg;
|
||||
Cell arg;
|
||||
arg.m_type = KindOfObject;
|
||||
arg.m_data.pobj = e;
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ public:
|
||||
protected: virtual bool php_sleep(Variant &ret);
|
||||
public:
|
||||
void call_next();
|
||||
void call_send(TypedValue* v);
|
||||
void call_send(Cell& v);
|
||||
void call_raise(ObjectData* e);
|
||||
|
||||
inline void preNext() {
|
||||
|
||||
@@ -1865,7 +1865,7 @@ void VMExecutionContext::invokeFuncFew(TypedValue* retval,
|
||||
|
||||
void VMExecutionContext::invokeContFunc(const Func* f,
|
||||
ObjectData* this_,
|
||||
TypedValue* param /* = NULL */) {
|
||||
Cell* param /* = NULL */) {
|
||||
assert(f);
|
||||
assert(this_);
|
||||
|
||||
@@ -1887,7 +1887,7 @@ void VMExecutionContext::invokeContFunc(const Func* f,
|
||||
ar->setVarEnv(nullptr);
|
||||
|
||||
if (param != nullptr) {
|
||||
tvDup(*param, *m_stack.allocTV());
|
||||
cellDup(*param, *m_stack.allocC());
|
||||
}
|
||||
|
||||
TypedValue retval;
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário