Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 514f9790 authored by Stephen Hines's avatar Stephen Hines
Browse files

Call .rs.dtor() when tearing down Scripts.

BUG=5186750

This allows us to properly reference count any globals (static or extern) that
need to potentially be cleaned up.

Change-Id: I03d2c38c1e7a4ca96c40003d2eeecb6f395d5835
parent 9b718682
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ using namespace android::renderscript;
struct DrvScript {
    int (*mRoot)();
    void (*mInit)();
    void (*mFreeChildren)();

    BCCScriptRef mBccScript;

@@ -125,6 +126,7 @@ bool rsdScriptInit(const Context *rsc,

    drv->mRoot = reinterpret_cast<int (*)()>(bccGetFuncAddr(drv->mBccScript, "root"));
    drv->mInit = reinterpret_cast<void (*)()>(bccGetFuncAddr(drv->mBccScript, "init"));
    drv->mFreeChildren = reinterpret_cast<void (*)()>(bccGetFuncAddr(drv->mBccScript, ".rs.dtor"));

    exportFuncCount = drv->ME->getExportFuncCount();
    if (exportFuncCount > 0) {
@@ -430,6 +432,13 @@ void rsdScriptInvokeInit(const Context *dc, Script *script) {
    }
}

void rsdScriptInvokeFreeChildren(const Context *dc, Script *script) {
    DrvScript *drv = (DrvScript *)script->mHal.drv;

    if (drv->mFreeChildren) {
        drv->mFreeChildren();
    }
}

void rsdScriptInvokeFunction(const Context *dc, Script *script,
                            uint32_t slot,
+2 −0
Original line number Diff line number Diff line
@@ -43,6 +43,8 @@ int rsdScriptInvokeRoot(const android::renderscript::Context *dc,
                        android::renderscript::Script *script);
void rsdScriptInvokeInit(const android::renderscript::Context *dc,
                         android::renderscript::Script *script);
void rsdScriptInvokeFreeChildren(const android::renderscript::Context *dc,
                                 android::renderscript::Script *script);

void rsdScriptSetGlobalVar(const android::renderscript::Context *,
                           const android::renderscript::Script *,
+1 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ static RsdHalFunctions FunctionTable = {
        rsdScriptInvokeRoot,
        rsdScriptInvokeForEach,
        rsdScriptInvokeInit,
        rsdScriptInvokeFreeChildren,
        rsdScriptSetGlobalVar,
        rsdScriptSetGlobalBind,
        rsdScriptSetGlobalObj,
+6 −0
Original line number Diff line number Diff line
@@ -72,6 +72,12 @@ void Script::setVarObj(uint32_t slot, ObjectBase *val) {
    mRSC->mHal.funcs.script.setGlobalObj(mRSC, this, slot, val);
}

bool Script::freeChildren() {
    incSysRef();
    mRSC->mHal.funcs.script.invokeFreeChildren(mRSC, this);
    return decSysRef();
}

namespace android {
namespace renderscript {

+2 −0
Original line number Diff line number Diff line
@@ -73,6 +73,8 @@ public:
    void setVar(uint32_t slot, const void *val, size_t len);
    void setVarObj(uint32_t slot, ObjectBase *val);

    virtual bool freeChildren();

    virtual void runForEach(Context *rsc,
                            const Allocation * ain,
                            Allocation * aout,
Loading