Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 : * vim: set ts=8 sts=4 et sw=4 tw=99:
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_CompileWrappers_h
8 : #define jit_CompileWrappers_h
9 :
10 : #include "jscntxt.h"
11 :
12 : namespace js {
13 : namespace jit {
14 :
15 : class JitRuntime;
16 :
17 : // During Ion compilation we need access to various bits of the current
18 : // compartment, runtime and so forth. However, since compilation can run off
19 : // thread while the active thread is mutating the VM, this access needs
20 : // to be restricted. The classes below give the compiler an interface to access
21 : // all necessary information in a threadsafe fashion.
22 :
23 : class CompileRuntime
24 : {
25 : JSRuntime* runtime();
26 :
27 : public:
28 : static CompileRuntime* get(JSRuntime* rt);
29 :
30 : #ifdef JS_GC_ZEAL
31 : const void* addressOfGCZealModeBits();
32 : #endif
33 :
34 : const JitRuntime* jitRuntime();
35 :
36 : // Compilation does not occur off thread when the Gecko Profiler is enabled.
37 : GeckoProfiler& geckoProfiler();
38 :
39 : bool jitSupportsFloatingPoint();
40 : bool hadOutOfMemory();
41 : bool profilingScripts();
42 :
43 : const JSAtomState& names();
44 : const PropertyName* emptyString();
45 : const StaticStrings& staticStrings();
46 : const Value& NaNValue();
47 : const Value& positiveInfinityValue();
48 : const WellKnownSymbols& wellKnownSymbols();
49 : const void* addressOfActiveJSContext();
50 :
51 : #ifdef DEBUG
52 : bool isInsideNursery(gc::Cell* cell);
53 : #endif
54 :
55 : // DOM callbacks must be threadsafe (and will hopefully be removed soon).
56 : const DOMCallbacks* DOMcallbacks();
57 :
58 : bool runtimeMatches(JSRuntime* rt);
59 : };
60 :
61 : class CompileZone
62 : {
63 : Zone* zone();
64 :
65 : public:
66 : static CompileZone* get(Zone* zone);
67 :
68 : CompileRuntime* runtime();
69 : bool isAtomsZone();
70 :
71 : #ifdef DEBUG
72 : const void* addressOfIonBailAfter();
73 : #endif
74 :
75 : const void* addressOfJSContext();
76 : const void* addressOfNeedsIncrementalBarrier();
77 : const void* addressOfFreeList(gc::AllocKind allocKind);
78 : const void* addressOfNurseryPosition();
79 : const void* addressOfNurseryCurrentEnd();
80 :
81 : bool nurseryExists();
82 : void setMinorGCShouldCancelIonCompilations();
83 : };
84 :
85 : class JitCompartment;
86 :
87 : class CompileCompartment
88 : {
89 : JSCompartment* compartment();
90 :
91 : public:
92 : static CompileCompartment* get(JSCompartment* comp);
93 :
94 : CompileZone* zone();
95 : CompileRuntime* runtime();
96 :
97 : const void* addressOfEnumerators();
98 : const void* addressOfRandomNumberGenerator();
99 : const void* addressOfLastCachedNativeIterator();
100 :
101 : const JitCompartment* jitCompartment();
102 :
103 : const GlobalObject* maybeGlobal();
104 :
105 : bool hasAllocationMetadataBuilder();
106 :
107 : // Mirror CompartmentOptions.
108 : void setSingletonsAsValues();
109 : };
110 :
111 : class JitCompileOptions
112 : {
113 : public:
114 : JitCompileOptions();
115 : explicit JitCompileOptions(JSContext* cx);
116 :
117 0 : bool cloneSingletons() const {
118 0 : return cloneSingletons_;
119 : }
120 :
121 : bool profilerSlowAssertionsEnabled() const {
122 : return profilerSlowAssertionsEnabled_;
123 : }
124 :
125 56 : bool offThreadCompilationAvailable() const {
126 56 : return offThreadCompilationAvailable_;
127 : }
128 :
129 : private:
130 : bool cloneSingletons_;
131 : bool profilerSlowAssertionsEnabled_;
132 : bool offThreadCompilationAvailable_;
133 : };
134 :
135 : } // namespace jit
136 : } // namespace js
137 :
138 : #endif // jit_CompileWrappers_h
|