Bug 1541404 part 29 - Perform arguments analysis when creating the TypeScript. r=tcampbell
authorJan de Mooij <jdemooij@mozilla.com>
Wed, 15 May 2019 06:36:39 +0000
changeset 535795 6eea4e18512a82b11c1f8d49a2c084ffecf325ff
parent 535794 e00d479b6a92650637b9347d9ae18bd8da3b9493
child 535796 b1295df1cba04b2fe97a9633420457a63d93856f
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstcampbell
bugs1541404
milestone68.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 1541404 part 29 - Perform arguments analysis when creating the TypeScript. r=tcampbell The code in NewArgumentsObject was wrong because the interpreter code calling it also relies on the analysis having been performed. Differential Revision: https://phabricator.services.mozilla.com/D30899
js/src/jit/BaselineCompiler.cpp
js/src/jit/VMFunctions.cpp
js/src/vm/TypeInference.cpp
--- a/js/src/jit/BaselineCompiler.cpp
+++ b/js/src/jit/BaselineCompiler.cpp
@@ -158,18 +158,17 @@ MethodStatus BaselineCompiler::compile()
           script->filename(), script->lineno(), script->column());
 
   TraceLoggerThread* logger = TraceLoggerForCurrentThread(cx);
   TraceLoggerEvent scriptEvent(TraceLogger_AnnotateScripts, script);
   AutoTraceLog logScript(logger, scriptEvent);
   AutoTraceLog logCompile(logger, TraceLogger_BaselineCompilation);
 
   AutoKeepTypeScripts keepTypes(cx);
-  if (!script->ensureHasTypes(cx, keepTypes) ||
-      !script->ensureHasAnalyzedArgsUsage(cx)) {
+  if (!script->ensureHasTypes(cx, keepTypes)) {
     return Method_Error;
   }
 
   // When code coverage is only enabled for optimizations, or when a Debugger
   // set the collectCoverageInfo flag, we have to create the ScriptCounts if
   // they do not exist.
   if (!script->hasScriptCounts() && cx->realm()->collectCoverage()) {
     if (!script->initScriptCounts(cx)) {
--- a/js/src/jit/VMFunctions.cpp
+++ b/js/src/jit/VMFunctions.cpp
@@ -1048,24 +1048,16 @@ bool GlobalNameConflictsCheckFromIon(JSC
 }
 
 bool InitFunctionEnvironmentObjects(JSContext* cx, BaselineFrame* frame) {
   return frame->initFunctionEnvironmentObjects(cx);
 }
 
 bool NewArgumentsObject(JSContext* cx, BaselineFrame* frame,
                         MutableHandleValue res) {
-  // BaselineCompiler calls ensureHasAnalyzedArgsUsage at compile time. The
-  // interpreters have to do this as part of JSOP_ARGUMENTS.
-  if (frame->runningInInterpreter()) {
-    if (!frame->script()->ensureHasAnalyzedArgsUsage(cx)) {
-      return false;
-    }
-  }
-
   ArgumentsObject* obj = ArgumentsObject::createExpected(cx, frame);
   if (!obj) {
     return false;
   }
   res.setObject(*obj);
   return true;
 }
 
--- a/js/src/vm/TypeInference.cpp
+++ b/js/src/vm/TypeInference.cpp
@@ -3492,16 +3492,27 @@ bool JSScript::makeTypes(JSContext* cx) 
   cx->check(this);
 
   // Scripts that will never run in the Baseline Interpreter or the JITs don't
   // need a TypeScript.
   MOZ_ASSERT(!hasForceInterpreterOp());
 
   AutoEnterAnalysis enter(cx);
 
+  // Run the arguments-analysis if needed. Both the Baseline Interpreter and
+  // Compiler rely on this.
+  if (!ensureHasAnalyzedArgsUsage(cx)) {
+    return false;
+  }
+
+  // If ensureHasAnalyzedArgsUsage allocated the TypeScript we're done.
+  if (types_) {
+    return true;
+  }
+
   UniquePtr<jit::ICScript> icScript(jit::ICScript::create(cx, this));
   if (!icScript) {
     return false;
   }
 
   // We need to call prepareForDestruction on ICScript before we |delete| it.
   auto prepareForDestruction = mozilla::MakeScopeExit(
       [&] { icScript->prepareForDestruction(cx->zone()); });
@@ -3521,16 +3532,17 @@ bool JSScript::makeTypes(JSContext* cx) 
   auto typeScript =
       reinterpret_cast<TypeScript*>(cx->pod_malloc<uint8_t>(allocSize));
   if (!typeScript) {
     return false;
   }
 
   prepareForDestruction.release();
 
+  MOZ_ASSERT(!types_);
   types_ = new (typeScript) TypeScript(this, std::move(icScript), numTypeSets);
 
   // We have a TypeScript so we can set the script's jitCodeRaw_ pointer to the
   // Baseline Interpreter code.
   updateJitCodeRaw(cx->runtime());
 
 #ifdef DEBUG
   StackTypeSet* typeArray = typeScript->typeArrayDontCheckGeneration();