Bug 1520183 - Add a script flag for JSScript::trackRecordReplayProgress(). r=bhackett
authorJan de Mooij <jdemooij@mozilla.com>
Tue, 15 Jan 2019 15:35:46 +0000
changeset 453977 e68c233270e3f59cc1862f5570a0bd21376e9d34
parent 453976 95aa3315d2c96c782859ca6755107b1fda41454f
child 453978 918042a8eb34fe65335f96b5ae1226409361d4f6
push id76100
push userjdemooij@mozilla.com
push dateTue, 15 Jan 2019 19:17:46 +0000
treeherderautoland@e68c233270e3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs1520183
milestone66.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 1520183 - Add a script flag for JSScript::trackRecordReplayProgress(). r=bhackett This makes it possible to inline this check in JIT code. Differential Revision: https://phabricator.services.mozilla.com/D16564
js/src/vm/JSScript-inl.h
js/src/vm/JSScript.cpp
js/src/vm/JSScript.h
--- a/js/src/vm/JSScript-inl.h
+++ b/js/src/vm/JSScript-inl.h
@@ -171,24 +171,14 @@ inline bool JSScript::ensureHasAnalyzedA
   }
   return js::jit::AnalyzeArgumentsUsage(cx, this);
 }
 
 inline bool JSScript::isDebuggee() const {
   return realm_->debuggerObservesAllExecution() || hasDebugScript();
 }
 
-inline bool JSScript::trackRecordReplayProgress() const {
-  // Progress is only tracked when recording or replaying, and only for
-  // scripts associated with the main thread's runtime. Whether self hosted
-  // scripts execute may depend on performed Ion optimizations (for example,
-  // self hosted TypedObject logic), so they are ignored.
-  return MOZ_UNLIKELY(mozilla::recordreplay::IsRecordingOrReplaying()) &&
-         !runtimeFromAnyThread()->parentRuntime && !selfHosted() &&
-         mozilla::recordreplay::ShouldUpdateProgressCounter(filename());
-}
-
 inline js::jit::ICScript* JSScript::icScript() const {
   MOZ_ASSERT(hasICScript());
   return types_->icScript();
 }
 
 #endif /* vm_JSScript_inl_h */
--- a/js/src/vm/JSScript.cpp
+++ b/js/src/vm/JSScript.cpp
@@ -3126,16 +3126,27 @@ JSScript::JSScript(JS::Realm* realm, uin
   uint8_t* stubEntry = nullptr;
 #endif
 
   return new (script)
       JSScript(cx->realm(), stubEntry, sourceObject, sourceStart, sourceEnd,
                toStringStart, toStringEnd);
 }
 
+static bool ShouldTrackRecordReplayProgress(JSScript* script) {
+  // Progress is only tracked when recording or replaying, and only for
+  // scripts associated with the main thread's runtime. Whether self hosted
+  // scripts execute may depend on performed Ion optimizations (for example,
+  // self hosted TypedObject logic), so they are ignored.
+  return MOZ_UNLIKELY(mozilla::recordreplay::IsRecordingOrReplaying()) &&
+         !script->runtimeFromAnyThread()->parentRuntime &&
+         !script->selfHosted() &&
+         mozilla::recordreplay::ShouldUpdateProgressCounter(script->filename());
+}
+
 /* static */ JSScript* JSScript::Create(
     JSContext* cx, const ReadOnlyCompileOptions& options,
     HandleScriptSourceObject sourceObject, uint32_t sourceStart,
     uint32_t sourceEnd, uint32_t toStringStart, uint32_t toStringEnd) {
   RootedScript script(cx, JSScript::New(cx, sourceObject, sourceStart,
                                         sourceEnd, toStringStart, toStringEnd));
   if (!script) {
     return nullptr;
@@ -3143,16 +3154,19 @@ JSScript::JSScript(JS::Realm* realm, uin
 
   // Record compile options that get checked at runtime.
   script->setFlag(ImmutableFlags::NoScriptRval, options.noScriptRval);
   script->setFlag(ImmutableFlags::SelfHosted, options.selfHostingMode);
   script->setFlag(ImmutableFlags::TreatAsRunOnce, options.isRunOnce);
   script->setFlag(MutableFlags::HideScriptFromDebugger,
                   options.hideScriptFromDebugger);
 
+  script->setFlag(ImmutableFlags::TrackRecordReplayProgress,
+                  ShouldTrackRecordReplayProgress(script));
+
   if (cx->runtime()->lcovOutput().isEnabled()) {
     if (!script->initScriptName(cx)) {
       return nullptr;
     }
   }
 
   return script;
 }
--- a/js/src/vm/JSScript.h
+++ b/js/src/vm/JSScript.h
@@ -1689,16 +1689,20 @@ class JSScript : public js::gc::TenuredC
     // Set if this function has a rest parameter.
     HasRest = 1 << 20,
 
     // See comments below.
     ArgsHasVarBinding = 1 << 21,
 
     // Script came from eval().
     IsForEval = 1 << 22,
+
+    // Whether the record/replay execution progress counter (see RecordReplay.h)
+    // should be updated as this script runs.
+    TrackRecordReplayProgress = 1 << 23,
   };
   // Note: don't make this a bitfield! It makes it hard to read these flags
   // from JIT code.
   uint32_t immutableFlags_ = 0;
 
   // Mutable flags typically store information about runtime or deoptimization
   // behavior of this script. This is only public for the JITs.
  public:
@@ -2727,19 +2731,19 @@ class JSScript : public js::gc::TenuredC
     operator JS::HandleScript() const { return script_; }
     explicit operator bool() const { return script_; }
 
    private:
     void holdScript(JS::HandleFunction fun);
     void dropScript();
   };
 
-  // Return whether the record/replay execution progress counter
-  // (see RecordReplay.h) should be updated as this script runs.
-  inline bool trackRecordReplayProgress() const;
+  bool trackRecordReplayProgress() const {
+    return hasFlag(ImmutableFlags::TrackRecordReplayProgress);
+  }
 };
 
 /* If this fails, add/remove padding within JSScript. */
 static_assert(
     sizeof(JSScript) % js::gc::CellAlignBytes == 0,
     "Size of JSScript must be an integral multiple of js::gc::CellAlignBytes");
 
 namespace js {