Pass generator body Func* to c_Continuation::alloc()

Pass generator body Func* to c_Continuation::alloc(), which is then
passed to the new helper that computes ActRec offset.
Esse commit está contido em:
Jan Oravec
2013-06-18 17:09:44 -07:00
commit de Sara Golemon
commit 621a7d9c55
2 arquivos alterados com 23 adições e 13 exclusões
+22 -8
Ver Arquivo
@@ -38,7 +38,7 @@ class c_Continuation : public ExtObjectData {
virtual void sweep();
void operator delete(void* p) {
c_Continuation* this_ = (c_Continuation*)p;
DELETEOBJSZ((char*)(this_->m_arPtr + 1) - (char*)p)(this_);
DELETEOBJSZ(this_->getObjectSize())(this_);
}
explicit c_Continuation(Class* cls = c_Continuation::s_cls);
@@ -71,23 +71,32 @@ public:
String t_getcalledclass();
Variant t___clone();
static c_Continuation* alloc(const Func* origFunc, int nLocals, int nIters) {
static c_Continuation* alloc(const Func* origFunc, const Func* genFunc) {
assert(origFunc);
assert(genFunc);
size_t arOffset = sizeof(c_Continuation) + sizeof(Iter) * nIters +
sizeof(TypedValue) * nLocals;
arOffset += sizeof(TypedValue) - 1;
arOffset &= ~(sizeof(TypedValue) - 1);
c_Continuation* cont =
(c_Continuation*)ALLOCOBJSZ(arOffset + sizeof(ActRec));
size_t arOffset = getArOffset(genFunc);
size_t objectSize = arOffset + sizeof(ActRec);
c_Continuation* cont = (c_Continuation*)ALLOCOBJSZ(objectSize);
new ((void *)cont) c_Continuation();
cont->m_origFunc = const_cast<Func*>(origFunc);
cont->m_arPtr = (ActRec*)(uintptr_t(cont) + arOffset);
memset((void*)((uintptr_t)cont + sizeof(c_Continuation)), 0,
arOffset - sizeof(c_Continuation));
assert(cont->getObjectSize() == objectSize);
return cont;
}
static size_t getArOffset(const Func* genFunc) {
size_t arOffset =
sizeof(c_Continuation) +
sizeof(Iter) * genFunc->numIterators() +
sizeof(TypedValue) * genFunc->numLocals();
arOffset += sizeof(TypedValue) - 1;
arOffset &= ~(sizeof(TypedValue) - 1);
return arOffset;
}
protected: virtual bool php_sleep(Variant &ret);
public:
void call_next();
@@ -114,6 +123,11 @@ public:
}
}
private:
size_t getObjectSize() {
return (char*)(m_arPtr + 1) - (char*)this;
}
public:
/* 32-bit o_id from ObjectData */
int32_t m_label;
+1 -5
Ver Arquivo
@@ -6628,11 +6628,7 @@ inline void OPTBLD_INLINE VMExecutionContext::iopCreateCl(PC& pc) {
static inline c_Continuation* createCont(const Func* origFunc,
const Func* genFunc) {
auto const cont = c_Continuation::alloc(
origFunc,
genFunc->numLocals(),
genFunc->numIterators()
);
auto const cont = c_Continuation::alloc(origFunc, genFunc);
cont->incRefCount();
cont->setNoDestruct();