Commit 7fc1f4ce authored by Jan de Mooij's avatar Jan de Mooij
Browse files

Bug 1832582 part 2 - Change AnalyzeBytecodeForIon to ScriptUsesEnvironmentChain. r=iain a=pascalc

Now that the analysis is only used for the uses-environment flag, we can
simplify it a bit. This is also faster because we can return immediately
when we know the answer.

Depends on D178650

Differential Revision: https://phabricator.services.mozilla.com/D178651
parent ece40b9c
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -238,14 +238,11 @@ void BytecodeAnalysis::checkWarpSupport(JSOp op) {
  }
}

IonBytecodeInfo js::jit::AnalyzeBytecodeForIon(JSContext* cx,
                                               JSScript* script) {
  IonBytecodeInfo result;

bool js::jit::ScriptUsesEnvironmentChain(JSScript* script) {
  if (script->isModule() || script->initialEnvironmentShape() ||
      (script->function() &&
       script->function()->needsSomeEnvironmentObject())) {
    result.usesEnvironmentChain = true;
    return true;
  }

  AllBytecodesIterable iterator(script);
@@ -267,13 +264,12 @@ IonBytecodeInfo js::jit::AnalyzeBytecodeForIon(JSContext* cx,
      case JSOp::ImplicitThis:
      case JSOp::FunWithProto:
      case JSOp::GlobalOrEvalDeclInstantiation:
        result.usesEnvironmentChain = true;
        break;
        return true;

      default:
        break;
    }
  }

  return result;
  return false;
}
+3 −4
Original line number Diff line number Diff line
@@ -73,10 +73,9 @@ class BytecodeAnalysis {
  void checkWarpSupport(JSOp op);
};

// Bytecode analysis pass necessary for WarpBuilder. The result is cached in
// JitScript.
struct IonBytecodeInfo;
IonBytecodeInfo AnalyzeBytecodeForIon(JSContext* cx, JSScript* script);
// Whether this script uses the frame's environment chain. The result is cached
// in JitScript and used by WarpBuilder.
bool ScriptUsesEnvironmentChain(JSScript* script);

}  // namespace jit
}  // namespace js
+2 −2
Original line number Diff line number Diff line
@@ -454,7 +454,7 @@ bool JitScript::ensureHasCachedBaselineJitData(JSContext* cx,
bool JitScript::ensureHasCachedIonData(JSContext* cx, HandleScript script) {
  MOZ_ASSERT(script->jitScript() == this);

  if (cachedIonBytecodeInfo_.isSome()) {
  if (usesEnvironmentChain_.isSome()) {
    return true;
  }

@@ -462,7 +462,7 @@ bool JitScript::ensureHasCachedIonData(JSContext* cx, HandleScript script) {
    return false;
  }

  cachedIonBytecodeInfo_.emplace(AnalyzeBytecodeForIon(cx, script));
  usesEnvironmentChain_.emplace(ScriptUsesEnvironmentChain(script));
  return true;
}

+2 −14
Original line number Diff line number Diff line
@@ -53,12 +53,6 @@ class IonScript;
class JitScript;
class JitZone;

// Information about a script's bytecode, used by WarpBuilder. This is cached
// in JitScript.
struct IonBytecodeInfo {
  bool usesEnvironmentChain = false;
};

// Magic BaselineScript value indicating Baseline compilation has been disabled.
static constexpr uintptr_t BaselineDisabledScript = 0x1;

@@ -305,7 +299,7 @@ class alignas(uintptr_t) JitScript final : public TrailingArray {

  // Analysis data computed lazily the first time this script is compiled or
  // inlined by WarpBuilder.
  mozilla::Maybe<IonBytecodeInfo> cachedIonBytecodeInfo_;
  mozilla::Maybe<bool> usesEnvironmentChain_;

  // The size of this allocation.
  Offset endOffset_ = 0;
@@ -341,10 +335,6 @@ class alignas(uintptr_t) JitScript final : public TrailingArray {

  Offset endOffset() const { return endOffset_; }

  const IonBytecodeInfo& cachedIonBytecodeInfo() const {
    return cachedIonBytecodeInfo_.ref();
  }

 public:
  JitScript(JSScript* script, Offset fallbackStubsOffset, Offset endOffset,
            const char* profileString);
@@ -429,9 +419,7 @@ class alignas(uintptr_t) JitScript final : public TrailingArray {

  EnvironmentObject* templateEnvironment() const { return templateEnv_.ref(); }

  bool usesEnvironmentChain() const {
    return cachedIonBytecodeInfo().usesEnvironmentChain;
  }
  bool usesEnvironmentChain() const { return *usesEnvironmentChain_; }

  gc::AllocSite* createAllocSite(JSScript* script);