Bug 1533003 - Remove JSScript::initFromModuleContext r=jandem
authorTed Campbell <tcampbell@mozilla.com>
Wed, 06 Mar 2019 17:34:39 +0000
changeset 520609 3fd4fd359c05f3f17d4cc158190cdf8c312d5b9a
parent 520608 0d70e7e3302091699c769aa75d7389b1b3c2b5a8
child 520610 1eb22a2970d35472bedd3372e5f0f3d9400d8dad
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1533003
milestone67.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 1533003 - Remove JSScript::initFromModuleContext r=jandem This removes the redundant set of TreatAsRunOnce which is instead set by CompileOptions before we start compiling. The IsModule flag is now set directly similar to IsForEval. Differential Revision: https://phabricator.services.mozilla.com/D22313
js/src/vm/JSScript.cpp
js/src/vm/JSScript.h
--- a/js/src/vm/JSScript.cpp
+++ b/js/src/vm/JSScript.cpp
@@ -3499,26 +3499,16 @@ void JSScript::initFromFunctionBox(Handl
                   funbox->hasInnerFunctions());
 
   script->setFlag(
       ImmutableFlags::NeedsFunctionEnvironmentObjects,
       (fun->needsCallObject() || fun->needsNamedLambdaEnvironment()));
 }
 
 /* static */
-void JSScript::initFromModuleContext(HandleScript script) {
-  script->setFlag(ImmutableFlags::IsModule);
-
-  // Since modules are only run once, mark the script so that initializers
-  // created within it may be given more precise types.
-  script->setTreatAsRunOnce();
-  MOZ_ASSERT(!script->hasRunOnce());
-}
-
-/* static */
 bool JSScript::fullyInitFromEmitter(JSContext* cx, HandleScript script,
                                     frontend::BytecodeEmitter* bce) {
   /* The counts of indexed things must be checked during code generation. */
   MOZ_ASSERT(bce->atomIndices->count() <= INDEX_LIMIT);
   MOZ_ASSERT(bce->objectList.length <= INDEX_LIMIT);
 
   uint64_t nslots =
       bce->maxFixedSlots + static_cast<uint64_t>(bce->maxStackDepth);
@@ -3584,30 +3574,29 @@ bool JSScript::fullyInitFromEmitter(JSCo
 
   script->setFlag(ImmutableFlags::Strict, bce->sc->strict());
   script->setFlag(ImmutableFlags::ExplicitUseStrict,
                   bce->sc->hasExplicitUseStrict());
   script->setFlag(ImmutableFlags::BindingsAccessedDynamically,
                   bce->sc->bindingsAccessedDynamically());
   script->setFlag(ImmutableFlags::HasSingletons, bce->hasSingletons);
   script->setFlag(ImmutableFlags::IsForEval, bce->sc->isEvalContext());
+  script->setFlag(ImmutableFlags::IsModule, bce->sc->isModuleContext());
 
   script->nfixed_ = bce->maxFixedSlots;
   script->nslots_ = nslots;
   script->bodyScopeIndex_ = bce->bodyScopeIndex;
   script->setFlag(ImmutableFlags::HasNonSyntacticScope,
                   bce->outermostScope()->hasOnChain(ScopeKind::NonSyntactic));
 
   // There shouldn't be any fallible operation after initFromFunctionBox,
   // JSFunction::hasUncompletedScript relies on the fact that the existence
   // of the pointer to JSScript means the pointed JSScript is complete.
   if (bce->sc->isFunctionBox()) {
     initFromFunctionBox(script, bce->sc->asFunctionBox());
-  } else if (bce->sc->isModuleContext()) {
-    initFromModuleContext(script);
   }
 
 #ifdef JS_STRUCTURED_SPEW
   // We want this to happen after line number initialization to allow filtering
   // to work.
   script->setSpewEnabled(StructuredSpewer::enabled(script));
 #endif
 
--- a/js/src/vm/JSScript.h
+++ b/js/src/vm/JSScript.h
@@ -1893,17 +1893,16 @@ class JSScript : public js::gc::TenuredC
                                       uint32_t nscopes, uint32_t nconsts,
                                       uint32_t nobjects, uint32_t ntrynotes,
                                       uint32_t nscopenotes,
                                       uint32_t nresumeoffsets);
 
  private:
   static void initFromFunctionBox(js::HandleScript script,
                                   js::frontend::FunctionBox* funbox);
-  static void initFromModuleContext(js::HandleScript script);
 
  public:
   static bool fullyInitFromEmitter(JSContext* cx, js::HandleScript script,
                                    js::frontend::BytecodeEmitter* bce);
 
   // Initialize the Function.prototype script.
   static bool initFunctionPrototype(JSContext* cx, js::HandleScript script,
                                     JS::HandleFunction functionProto);