diff options
author | Brian Smith <brian@dbsoft.org> | 2022-04-26 10:13:11 -0500 |
---|---|---|
committer | Brian Smith <brian@dbsoft.org> | 2022-04-26 10:19:04 -0500 |
commit | 3daf711085889bad1bd68651bc4e8790412ae105 (patch) | |
tree | f5b0e4c1befb320cdf158e1839ac5e273373087f /js/xpconnect | |
parent | 7fe702603066e7f122d5dd66a3a1892ac7e06215 (diff) | |
download | uxp-3daf711085889bad1bd68651bc4e8790412ae105.tar.gz |
Issue #1829 - Revert “Issue #1751 -- Remove XP_MACOSX conditionals from the rest of the tree.”
This also removes some PP abuse and takes file entries out of PP when no longer
needed without XP_MACOSX conditionals.
This reverts commit 6f707bde95dab6998ac204f9ee6c925ee230c740.
Diffstat (limited to 'js/xpconnect')
-rw-r--r-- | js/xpconnect/shell/xpcshell.cpp | 11 | ||||
-rw-r--r-- | js/xpconnect/src/Sandbox.cpp | 11 | ||||
-rw-r--r-- | js/xpconnect/src/XPCJSContext.cpp | 7 | ||||
-rw-r--r-- | js/xpconnect/src/XPCShellImpl.cpp | 24 |
4 files changed, 52 insertions, 1 deletions
diff --git a/js/xpconnect/shell/xpcshell.cpp b/js/xpconnect/shell/xpcshell.cpp index 3460e98a15..35e12449f8 100644 --- a/js/xpconnect/shell/xpcshell.cpp +++ b/js/xpconnect/shell/xpcshell.cpp @@ -10,6 +10,9 @@ #include "mozilla/WindowsDllBlocklist.h" #include "nsXULAppAPI.h" +#ifdef XP_MACOSX +#include "xpcshellMacUtils.h" +#endif #ifdef XP_WIN #include <windows.h> #include <shlobj.h> @@ -34,6 +37,10 @@ main(int argc, char** argv, char** envp) gtk_parse_args(&argc, &argv); #endif +#ifdef XP_MACOSX + InitAutoreleasePool(); +#endif + // unbuffer stdout so that output is in the correct order; note that stderr // is unbuffered by default setbuf(stdout, 0); @@ -44,5 +51,9 @@ main(int argc, char** argv, char** envp) int result = XRE_XPCShellMain(argc, argv, envp); +#ifdef XP_MACOSX + FinishAutoreleasePool(); +#endif + return result; } diff --git a/js/xpconnect/src/Sandbox.cpp b/js/xpconnect/src/Sandbox.cpp index 569da5d56f..6888dee376 100644 --- a/js/xpconnect/src/Sandbox.cpp +++ b/js/xpconnect/src/Sandbox.cpp @@ -127,6 +127,17 @@ SandboxDump(JSContext* cx, unsigned argc, Value* vp) if (!cstr) return false; +#if defined(XP_MACOSX) + // Be nice and convert all \r to \n. + char* c = cstr; + char* cEnd = cstr + strlen(cstr); + while (c < cEnd) { + if (*c == '\r') + *c = '\n'; + c++; + } +#endif + fputs(cstr, stdout); fflush(stdout); args.rval().setBoolean(true); diff --git a/js/xpconnect/src/XPCJSContext.cpp b/js/xpconnect/src/XPCJSContext.cpp index 48a3aa26ac..a02c5e103b 100644 --- a/js/xpconnect/src/XPCJSContext.cpp +++ b/js/xpconnect/src/XPCJSContext.cpp @@ -3209,7 +3209,12 @@ XPCJSContext::Initialize() // the web to base this decision primarily on the default stack size that the // underlying platform makes available, but that seems to be what we do. :-( -#if defined(MOZ_ASAN) +#if defined(XP_MACOSX) || defined(DARWIN) + // MacOS has a gargantuan default stack size of 8MB. Go wild with 7MB, + // and give trusted script 180k extra. The stack is huge on mac anyway. + const size_t kStackQuota = 7 * 1024 * 1024; + const size_t kTrustedScriptBuffer = 180 * 1024; +#elif defined(MOZ_ASAN) // ASan requires more stack space due to red-zones, so give it double the // default (1MB on 32-bit, 2MB on 64-bit). ASAN stack frame measurements // were not taken at the time of this writing, so we hazard a guess that diff --git a/js/xpconnect/src/XPCShellImpl.cpp b/js/xpconnect/src/XPCShellImpl.cpp index 72ab89c402..ba56a4a0ee 100644 --- a/js/xpconnect/src/XPCShellImpl.cpp +++ b/js/xpconnect/src/XPCShellImpl.cpp @@ -1276,6 +1276,22 @@ XRE_XPCShellMain(int argc, char** argv, char** envp) argc -= 2; argv += 2; } else { +#ifdef XP_MACOSX + // On OSX, the GreD needs to point to Contents/Resources in the .app + // bundle. Libraries will be loaded at a relative path to GreD, i.e. + // ../MacOS. + nsCOMPtr<nsIFile> tmpDir; + XRE_GetFileFromPath(argv[0], getter_AddRefs(greDir)); + greDir->GetParent(getter_AddRefs(tmpDir)); + tmpDir->Clone(getter_AddRefs(greDir)); + tmpDir->SetNativeLeafName(NS_LITERAL_CSTRING("Resources")); + bool dirExists = false; + tmpDir->Exists(&dirExists); + if (dirExists) { + greDir = tmpDir.forget(); + } + dirprovider.SetGREDirs(greDir); +#else nsAutoString workingDir; if (!GetCurrentWorkingDirectory(workingDir)) { printf("GetCurrentWorkingDirectory failed.\n"); @@ -1286,6 +1302,7 @@ XRE_XPCShellMain(int argc, char** argv, char** envp) printf("NS_NewLocalFile failed.\n"); return 1; } +#endif } if (argc > 1 && !strcmp(argv[1], "-a")) { @@ -1538,6 +1555,13 @@ XPCShellDirProvider::SetGREDirs(nsIFile* greDir) { mGREDir = greDir; mGREDir->Clone(getter_AddRefs(mGREBinDir)); +#ifdef XP_MACOSX + nsAutoCString leafName; + mGREDir->GetNativeLeafName(leafName); + if (leafName.Equals("Resources")) { + mGREBinDir->SetNativeLeafName(NS_LITERAL_CSTRING("MacOS")); + } +#endif } void |