Debian Codegraph @

js/src/jit/Invalidation.h

raw
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #ifndef jit_Invalidation_h
8 #define jit_Invalidation_h
9
10 #include "jit/IonTypes.h"
11 #include "js/AllocPolicy.h"
12 #include "js/GCVector.h"
13
14 namespace js {
15 namespace jit {
16
17 class IonScript;
18
19 class RecompileInfo {
20 JSScript* script_;
21 IonCompilationId id_;
22
23 public:
24 RecompileInfo(JSScript* script, IonCompilationId id)
25 : script_(script), id_(id) {}
26
27 JSScript* script() const { return script_; }
28
29 IonScript* maybeIonScriptToInvalidate() const;
30
31 bool traceWeak(JSTracer* trc);
32
33 bool operator==(const RecompileInfo& other) const {
34 return script_ == other.script_ && id_ == other.id_;
35 }
36 };
37
38 // The RecompileInfoVector has a MinInlineCapacity of one so that invalidating a
39 // single IonScript doesn't require an allocation.
40 using RecompileInfoVector = JS::GCVector<RecompileInfo, 1, SystemAllocPolicy>;
41
42 // Called from Zone::discardJitCode().
43 void InvalidateAll(JS::GCContext* gcx, JS::Zone* zone);
44 void FinishInvalidation(JS::GCContext* gcx, JSScript* script);
45
46 // Add compilations involving |script| (outer script or inlined) to the vector.
47 void AddPendingInvalidation(jit::RecompileInfoVector& invalid,
48 JSScript* script);
49
50 // Walk the stack and invalidate active Ion frames for the invalid scripts.
51 void Invalidate(JSContext* cx, const RecompileInfoVector& invalid,
52 bool resetUses = true, bool cancelOffThread = true);
53 void Invalidate(JSContext* cx, JSScript* script, bool resetUses = true,
54 bool cancelOffThread = true);
55
56 } // namespace jit
57 } // namespace js
58
59 #endif /* jit_Invalidation_h */