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

Commit 3ba2bf42 authored by Shih-wei Liao's avatar Shih-wei Liao Committed by Android (Google) Code Review
Browse files

Merge "1. LOG 4 fatal error paths (TODO: These 4 places should signal Java...

Merge "1. LOG 4 fatal error paths (TODO: These 4 places should signal Java exceptions.) 2. Prepare on-device linking. 3. Clean up code." into honeycomb
parents fd6f39e1 9d4024d5
Loading
Loading
Loading
Loading
+26 −54
Original line number Original line Diff line number Diff line
@@ -410,40 +410,38 @@ extern unsigned rs_runtime_lib_bc_size;


void ScriptCState::runCompiler(Context *rsc,
void ScriptCState::runCompiler(Context *rsc,
                               ScriptC *s,
                               ScriptC *s,
                               long modWhen,
                               long crc32,
                               const char *resName,
                               const char *resName,
                               const char *cacheDir) {
                               const char *cacheDir) {
    {
    {
        s->mBccScript = bccCreateScript();
        s->mBccScript = bccCreateScript();

        s->mEnviroment.mIsThreadable = true;
        s->mEnviroment.mIsThreadable = true;

        bccRegisterSymbolCallback(s->mBccScript, symbolLookup, s);
        bccRegisterSymbolCallback(s->mBccScript, symbolLookup, s);
        // bccReadBC() reads in the BitCode, if no cache file corresponding to

        // the resName is found. Otherwise, bccReadBC() returns a negative value
        // and the "else" branch will be taken.
        if (bccReadBC(s->mBccScript,
        if (bccReadBC(s->mBccScript,
                      s->mEnviroment.mScriptText,
                      s->mEnviroment.mScriptText,
                      s->mEnviroment.mScriptTextLength,
                      s->mEnviroment.mScriptTextLength,
                      modWhen,
                      /*deprecated*/ 0, /*deprecated*/ 0,
                      crc32,
                      resName, cacheDir) != 0) {
                      resName,
            LOGE("bcc: FAILS to read bitcode");
                      cacheDir) >= 0) {
            // Handle Fatal Error
          //bccLinkBC(s->mBccScript, rs_runtime_lib_bc, rs_runtime_lib_bc_size);
          bccCompileBC(s->mBccScript);
        } else {
          // bccReadBC returns a neagative value: Didn't read any script,
          // So, use cached binary instead
          if (bccLoadBinary(s->mBccScript)) {  // LoadBinary fails ==> Recompile
            bccReadBC(s->mBccScript,
                      s->mEnviroment.mScriptText,
                      s->mEnviroment.mScriptTextLength,
                      modWhen,
                      crc32,
                      resName,
                      cacheDir);
            bccCompileBC(s->mBccScript);
        }
        }

#if 0
        if (bccLinkBC(s->mBccScript,
                      rs_runtime_lib_bc,
                      rs_runtime_lib_bc_size) != 0) {
            LOGE("bcc: FAILS to link bitcode");
            // Handle Fatal Error
        }
        }
#endif

        if (bccCompileBC(s->mBccScript) != 0) {
            LOGE("bcc: FAILS to prepare executable");
            // Handle Fatal Error
        }

        bccGetScriptLabel(s->mBccScript, "root", (BCCvoid**) &s->mProgram.mRoot);
        bccGetScriptLabel(s->mBccScript, "root", (BCCvoid**) &s->mProgram.mRoot);
        bccGetScriptLabel(s->mBccScript, "init", (BCCvoid**) &s->mProgram.mInit);
        bccGetScriptLabel(s->mBccScript, "init", (BCCvoid**) &s->mProgram.mInit);
    }
    }
@@ -535,7 +533,8 @@ void ScriptCState::runCompiler(Context *rsc,




    } else {
    } else {
        // Deal with an error.
        LOGE("bcc: FAILS to prepare executable");
        // Handle Fatal Error
    }
    }
}
}


@@ -559,7 +558,7 @@ void rsi_ScriptCSetText(Context *rsc, const char *text, uint32_t len) {




RsScript rsi_ScriptCCreate(Context *rsc,
RsScript rsi_ScriptCCreate(Context *rsc,
                           const char *packageName,
                           const char *packageName /* deprecated */,
                           const char *resName,
                           const char *resName,
                           const char *cacheDir)
                           const char *cacheDir)
{
{
@@ -569,34 +568,7 @@ RsScript rsi_ScriptCCreate(Context *rsc,
    ss->mScript.clear();
    ss->mScript.clear();
    s->incUserRef();
    s->incUserRef();


    // Open the apk and return the ZipArchive:
    ss->runCompiler(rsc, s.get(), resName, cacheDir);
    //  int dexZipOpenArchive(const char* fileName, ZipArchive* pArchive)
    ZipArchive archive;
    long modWhen;
    long crc32;
    if (!dexZipOpenArchive(packageName, &archive)) {  // Success
      ZipEntry entry = dexZipFindEntry(&archive, resName);

      int method;
      size_t uncompLen;
      size_t compLen;
      off_t offset;
      if (!dexZipGetEntryInfo(&archive,
                              entry,
                              &method,
                              &uncompLen,
                              &compLen,
                              &offset,
                              &modWhen,
                              &crc32)) {
      } else {
        LOGI("Coudn't get entry info for the bitcode in an apk");
      }
    } else {
      LOGI("Couldn't open the archive and read the bitcode");
    }

    ss->runCompiler(rsc, s.get(), modWhen, crc32, resName, cacheDir);
    ss->clear(rsc);
    ss->clear(rsc);
    return s.get();
    return s.get();
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -83,7 +83,7 @@ public:
    void init(Context *rsc);
    void init(Context *rsc);


    void clear(Context *rsc);
    void clear(Context *rsc);
    void runCompiler(Context *rsc, ScriptC *s, long modWhen, long crc32, const char *resName, const char *cacheDir);
    void runCompiler(Context *rsc, ScriptC *s, const char *resName, const char *cacheDir);


    struct SymbolTable_t {
    struct SymbolTable_t {
        const char * mName;
        const char * mName;