Bug 1593888 - Fix bootlegging errors in jsrtfuzzing.cpp. r=decoder
authorJeff Walden <jwalden@mit.edu>
Tue, 05 Nov 2019 12:32:44 +0000
changeset 500761 8648a5cd07f3444e93f1f13d15a78aacf8c43d38
parent 500760 89e0d67e037b74f1e2ae8e9d7cbccc5a0f652397
child 500762 76e1783730527839ba2d3850010a064f72fb3f8a
push id114166
push userapavel@mozilla.com
push dateThu, 07 Nov 2019 10:04:01 +0000
treeherdermozilla-inbound@d271c572a9bc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdecoder
bugs1593888
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1593888 - Fix bootlegging errors in jsrtfuzzing.cpp. r=decoder Differential Revision: https://phabricator.services.mozilla.com/D51750
js/src/shell/js.cpp
js/src/shell/jsshell.h
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -466,56 +466,55 @@ struct ShellCompartmentPrivate {
 struct MOZ_STACK_CLASS EnvironmentPreparer
     : public js::ScriptEnvironmentPreparer {
   explicit EnvironmentPreparer(JSContext* cx) {
     js::SetScriptEnvironmentPreparer(cx, this);
   }
   void invoke(JS::HandleObject global, Closure& closure) override;
 };
 
-// Shell state set once at startup.
-static bool enableDeferredMode = false;
-static bool enableCodeCoverage = false;
-static bool enableDisassemblyDumps = false;
-static bool offthreadCompilation = false;
-static bool enableAsmJS = false;
-static bool enableWasm = false;
-static bool enableSharedMemory = SHARED_MEMORY_DEFAULT;
-static bool enableWasmBaseline = false;
-static bool enableWasmIon = false;
-static bool enableWasmCranelift = false;
+bool shell::enableDeferredMode = false;
+bool shell::enableCodeCoverage = false;
+bool shell::enableDisassemblyDumps = false;
+bool shell::offthreadCompilation = false;
+bool shell::enableAsmJS = false;
+bool shell::enableWasm = false;
+bool shell::enableSharedMemory = SHARED_MEMORY_DEFAULT;
+bool shell::enableWasmBaseline = false;
+bool shell::enableWasmIon = false;
+bool shell::enableWasmCranelift = false;
 #ifdef ENABLE_WASM_GC
-static bool enableWasmGc = false;
+bool shell::enableWasmGc = false;
 #endif
-static bool enableWasmVerbose = false;
-static bool enableTestWasmAwaitTier2 = false;
-static bool enableAsyncStacks = false;
-static bool enableStreams = false;
-static bool enableReadableByteStreams = false;
-static bool enableBYOBStreamReaders = false;
-static bool enableWritableStreams = false;
-static bool enableFields = false;
-static bool enableAwaitFix = false;
-static bool enableWeakRefs = false;
+bool shell::enableWasmVerbose = false;
+bool shell::enableTestWasmAwaitTier2 = false;
+bool shell::enableAsyncStacks = false;
+bool shell::enableStreams = false;
+bool shell::enableReadableByteStreams = false;
+bool shell::enableBYOBStreamReaders = false;
+bool shell::enableWritableStreams = false;
+bool shell::enableFields = false;
+bool shell::enableAwaitFix = false;
+bool shell::enableWeakRefs = false;
 #ifdef JS_GC_ZEAL
-static uint32_t gZealBits = 0;
-static uint32_t gZealFrequency = 0;
+uint32_t shell::gZealBits = 0;
+uint32_t shell::gZealFrequency = 0;
 #endif
-static bool printTiming = false;
-static RCFile* gErrFile = nullptr;
-static RCFile* gOutFile = nullptr;
-static bool reportWarnings = true;
-static bool compileOnly = false;
-static bool fuzzingSafe = false;
-static bool disableOOMFunctions = false;
-static bool defaultToSameCompartment = true;
+bool shell::printTiming = false;
+RCFile* shell::gErrFile = nullptr;
+RCFile* shell::gOutFile = nullptr;
+bool shell::reportWarnings = true;
+bool shell::compileOnly = false;
+bool shell::fuzzingSafe = false;
+bool shell::disableOOMFunctions = false;
+bool shell::defaultToSameCompartment = true;
 
 #ifdef DEBUG
-static bool dumpEntrainedVariables = false;
-static bool OOM_printAllocationCount = false;
+bool shell::dumpEntrainedVariables = false;
+bool shell::OOM_printAllocationCount = false;
 #endif
 
 static bool SetTimeoutValue(JSContext* cx, double t);
 
 static void KillWatchdog(JSContext* cx);
 
 static bool ScheduleWatchdog(JSContext* cx, double t);
 
@@ -5896,18 +5895,19 @@ class AutoPipe {
 
   void closeWriter() {
     MOZ_ASSERT(fds_[1] != -1);
     close(fds_[1]);
     fds_[1] = -1;
   }
 };
 
-static int sArgc;
-static char** sArgv;
+int shell::sArgc;
+char** shell::sArgv;
+
 static const char sWasmCompileAndSerializeFlag[] =
     "--wasm-compile-and-serialize";
 static Vector<const char*, 5, js::SystemAllocPolicy> sCompilerProcessFlags;
 
 static bool CompileAndSerializeInSeparateProcess(JSContext* cx,
                                                  const uint8_t* bytecode,
                                                  size_t bytecodeLength,
                                                  wasm::Bytes* serialized) {
@@ -9527,17 +9527,17 @@ static FILE* ErrorFilePointer() {
   if (gErrFile->isOpen()) {
     return gErrFile->fp;
   }
 
   fprintf(stderr, "error file is closed; falling back to stderr\n");
   return stderr;
 }
 
-static bool PrintStackTrace(JSContext* cx, HandleObject stackObj) {
+bool shell::PrintStackTrace(JSContext* cx, HandleObject stackObj) {
   if (!stackObj || !stackObj->is<SavedFrame>()) {
     return true;
   }
 
   JSPrincipals* principals = stackObj->nonCCWRealm()->principals();
   RootedString stackStr(cx);
   if (!BuildStackString(cx, principals, stackObj, &stackStr, 2)) {
     return false;
--- a/js/src/shell/jsshell.h
+++ b/js/src/shell/jsshell.h
@@ -87,16 +87,62 @@ struct RCFile {
   // Starts out with a ref count of zero.
   static RCFile* create(JSContext* cx, const char* filename, const char* mode);
 
   void close();
   bool isOpen() const { return fp; }
   bool release();
 };
 
+// Shell command-line arguments and count.
+extern int sArgc;
+extern char** sArgv;
+
+// Shell state set once at startup.
+extern bool enableDeferredMode;
+extern bool enableCodeCoverage;
+extern bool enableDisassemblyDumps;
+extern bool offthreadCompilation;
+extern bool enableAsmJS;
+extern bool enableWasm;
+extern bool enableSharedMemory;
+extern bool enableWasmBaseline;
+extern bool enableWasmIon;
+extern bool enableWasmCranelift;
+#ifdef ENABLE_WASM_GC
+extern bool enableWasmGc;
+#endif
+extern bool enableWasmVerbose;
+extern bool enableTestWasmAwaitTier2;
+extern bool enableAsyncStacks;
+extern bool enableStreams;
+extern bool enableReadableByteStreams;
+extern bool enableBYOBStreamReaders;
+extern bool enableWritableStreams;
+extern bool enableFields;
+extern bool enableAwaitFix;
+extern bool enableWeakRefs;
+#ifdef JS_GC_ZEAL
+extern uint32_t gZealBits;
+extern uint32_t gZealFrequency;
+#endif
+extern bool printTiming;
+extern RCFile* gErrFile;
+extern RCFile* gOutFile;
+extern bool reportWarnings;
+extern bool compileOnly;
+extern bool fuzzingSafe;
+extern bool disableOOMFunctions;
+extern bool defaultToSameCompartment;
+
+#ifdef DEBUG
+extern bool dumpEntrainedVariables;
+extern bool OOM_printAllocationCount;
+#endif
+
 // Alias the global dstName to namespaceObj.srcName. For example, if dstName is
 // "snarf", namespaceObj represents "os.file", and srcName is "readFile", then
 // this is equivalent to the JS code:
 //
 //   snarf = os.file.readFile;
 //
 // This provides a mechanism for namespacing the various JS shell helper
 // functions without breaking backwards compatibility with things that use the
@@ -185,12 +231,15 @@ struct ShellContext {
 
   // Queued finalization group cleanup jobs.
   using ObjectVector = GCVector<JSObject*, 0, SystemAllocPolicy>;
   JS::PersistentRooted<ObjectVector> finalizationGroupsToCleanUp;
 };
 
 extern ShellContext* GetShellContext(JSContext* cx);
 
+extern MOZ_MUST_USE bool PrintStackTrace(JSContext* cx,
+                                         JS::Handle<JSObject*> stackObj);
+
 } /* namespace shell */
 } /* namespace js */
 
 #endif