diff --git a/js/xpconnect/loader/mozJSComponentLoader.cpp b/js/xpconnect/loader/mozJSComponentLoader.cpp index ea2de906b662..b9a1ad2ce9d2 100644 --- a/js/xpconnect/loader/mozJSComponentLoader.cpp +++ b/js/xpconnect/loader/mozJSComponentLoader.cpp @@ -63,8 +63,6 @@ static const char kXPConnectServiceContractID[] = "@mozilla.org/js/xpc/XPConnect static const char kObserverServiceContractID[] = "@mozilla.org/observer-service;1"; static const char kJSCachePrefix[] = "jsloader"; -#define HAVE_PR_MEMMAP - /** * Buffer sizes for serialization and deserialization of scripts. * FIXME: bug #411579 (tune this macro!) Last updated: Jan 2008 @@ -507,7 +505,6 @@ mozJSComponentLoader::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) } // Some stack based classes for cleaning up on early return -#ifdef HAVE_PR_MEMMAP class FileAutoCloser { public: @@ -525,16 +522,6 @@ class FileMapAutoCloser private: PRFileMap* mMap; }; -#else -class ANSIFileAutoCloser -{ - public: - explicit ANSIFileAutoCloser(FILE* file) : mFile(file) {} - ~ANSIFileAutoCloser() { fclose(mFile); } - private: - FILE* mFile; -}; -#endif JSObject* mozJSComponentLoader::PrepareObjectForLocation(JSContext* aCx, @@ -752,7 +739,6 @@ mozJSComponentLoader::ObjectForLocation(ComponentLoaderInfo& aInfo, .setSourceIsLazy(!mReuseLoaderGlobal && !!cache); if (realFile) { -#ifdef HAVE_PR_MEMMAP int64_t fileSize; rv = aComponentFile->GetFileSize(&fileSize); if (NS_FAILED(rv)) { @@ -810,58 +796,6 @@ mozJSComponentLoader::ObjectForLocation(ComponentLoaderInfo& aInfo, } PR_MemUnmap(buf, fileSize32); - -#else /* HAVE_PR_MEMMAP */ - - /** - * No memmap implementation, so fall back to - * reading in the file - */ - - FILE* fileHandle; - rv = aComponentFile->OpenANSIFileDesc("r", &fileHandle); - if (NS_FAILED(rv)) { - return NS_ERROR_FILE_NOT_FOUND; - } - - // Ensure file fclose - ANSIFileAutoCloser fileCloser(fileHandle); - - int64_t len; - rv = aComponentFile->GetFileSize(&len); - if (NS_FAILED(rv) || len < 0) { - NS_WARNING("Failed to get file size"); - return NS_ERROR_FAILURE; - } - - char* buf = (char*) malloc(len * sizeof(char)); - if (!buf) { - return NS_ERROR_FAILURE; - } - - size_t rlen = fread(buf, 1, len, fileHandle); - if (rlen != (uint64_t)len) { - free(buf); - NS_WARNING("Failed to read file"); - return NS_ERROR_FAILURE; - } - - if (!mReuseLoaderGlobal) { - script = Compile(cx, options, buf, fileSize32); - } else { - // Note: exceptions will get handled further down; - // don't early return for them here. - AutoObjectVector envChain(cx); - if (envChain.append(obj)) { - CompileFunction(cx, envChain, - options, nullptr, 0, nullptr, - buf, fileSize32, &function); - } - } - - free(buf); - -#endif /* HAVE_PR_MEMMAP */ } else { rv = aInfo.EnsureScriptChannel(); NS_ENSURE_SUCCESS(rv, rv);