Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
michael@0 | 2 | * vim: set ts=8 sts=4 et sw=4 tw=99: |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef jspubtd_h |
michael@0 | 8 | #define jspubtd_h |
michael@0 | 9 | |
michael@0 | 10 | /* |
michael@0 | 11 | * JS public API typedefs. |
michael@0 | 12 | */ |
michael@0 | 13 | |
michael@0 | 14 | #include "mozilla/LinkedList.h" |
michael@0 | 15 | #include "mozilla/NullPtr.h" |
michael@0 | 16 | #include "mozilla/PodOperations.h" |
michael@0 | 17 | |
michael@0 | 18 | #include "jsprototypes.h" |
michael@0 | 19 | #include "jstypes.h" |
michael@0 | 20 | |
michael@0 | 21 | #include "js/TypeDecls.h" |
michael@0 | 22 | |
michael@0 | 23 | #if defined(JSGC_USE_EXACT_ROOTING) || defined(JS_DEBUG) |
michael@0 | 24 | # define JSGC_TRACK_EXACT_ROOTS |
michael@0 | 25 | #endif |
michael@0 | 26 | |
michael@0 | 27 | namespace JS { |
michael@0 | 28 | |
michael@0 | 29 | class AutoIdVector; |
michael@0 | 30 | class CallArgs; |
michael@0 | 31 | |
michael@0 | 32 | template <typename T> |
michael@0 | 33 | class Rooted; |
michael@0 | 34 | |
michael@0 | 35 | class JS_PUBLIC_API(AutoGCRooter); |
michael@0 | 36 | |
michael@0 | 37 | class JS_FRIEND_API(CompileOptions); |
michael@0 | 38 | class JS_FRIEND_API(ReadOnlyCompileOptions); |
michael@0 | 39 | class JS_FRIEND_API(OwningCompileOptions); |
michael@0 | 40 | class JS_PUBLIC_API(CompartmentOptions); |
michael@0 | 41 | |
michael@0 | 42 | struct Zone; |
michael@0 | 43 | |
michael@0 | 44 | } /* namespace JS */ |
michael@0 | 45 | |
michael@0 | 46 | /* |
michael@0 | 47 | * Run-time version enumeration. For compile-time version checking, please use |
michael@0 | 48 | * the JS_HAS_* macros in jsversion.h, or use MOZJS_MAJOR_VERSION, |
michael@0 | 49 | * MOZJS_MINOR_VERSION, MOZJS_PATCH_VERSION, and MOZJS_ALPHA definitions. |
michael@0 | 50 | */ |
michael@0 | 51 | enum JSVersion { |
michael@0 | 52 | JSVERSION_ECMA_3 = 148, |
michael@0 | 53 | JSVERSION_1_6 = 160, |
michael@0 | 54 | JSVERSION_1_7 = 170, |
michael@0 | 55 | JSVERSION_1_8 = 180, |
michael@0 | 56 | JSVERSION_ECMA_5 = 185, |
michael@0 | 57 | JSVERSION_DEFAULT = 0, |
michael@0 | 58 | JSVERSION_UNKNOWN = -1, |
michael@0 | 59 | JSVERSION_LATEST = JSVERSION_ECMA_5 |
michael@0 | 60 | }; |
michael@0 | 61 | |
michael@0 | 62 | /* Result of typeof operator enumeration. */ |
michael@0 | 63 | enum JSType { |
michael@0 | 64 | JSTYPE_VOID, /* undefined */ |
michael@0 | 65 | JSTYPE_OBJECT, /* object */ |
michael@0 | 66 | JSTYPE_FUNCTION, /* function */ |
michael@0 | 67 | JSTYPE_STRING, /* string */ |
michael@0 | 68 | JSTYPE_NUMBER, /* number */ |
michael@0 | 69 | JSTYPE_BOOLEAN, /* boolean */ |
michael@0 | 70 | JSTYPE_NULL, /* null */ |
michael@0 | 71 | JSTYPE_LIMIT |
michael@0 | 72 | }; |
michael@0 | 73 | |
michael@0 | 74 | /* Dense index into cached prototypes and class atoms for standard objects. */ |
michael@0 | 75 | enum JSProtoKey { |
michael@0 | 76 | #define PROTOKEY_AND_INITIALIZER(name,code,init,clasp) JSProto_##name = code, |
michael@0 | 77 | JS_FOR_EACH_PROTOTYPE(PROTOKEY_AND_INITIALIZER) |
michael@0 | 78 | #undef PROTOKEY_AND_INITIALIZER |
michael@0 | 79 | JSProto_LIMIT |
michael@0 | 80 | }; |
michael@0 | 81 | |
michael@0 | 82 | /* |
michael@0 | 83 | * This enum type is used to control the behavior of a JSObject property |
michael@0 | 84 | * iterator function that has type JSNewEnumerate. |
michael@0 | 85 | */ |
michael@0 | 86 | enum JSIterateOp { |
michael@0 | 87 | /* Create new iterator state over enumerable properties. */ |
michael@0 | 88 | JSENUMERATE_INIT, |
michael@0 | 89 | |
michael@0 | 90 | /* Create new iterator state over all properties. */ |
michael@0 | 91 | JSENUMERATE_INIT_ALL, |
michael@0 | 92 | |
michael@0 | 93 | /* Iterate once. */ |
michael@0 | 94 | JSENUMERATE_NEXT, |
michael@0 | 95 | |
michael@0 | 96 | /* Destroy iterator state. */ |
michael@0 | 97 | JSENUMERATE_DESTROY |
michael@0 | 98 | }; |
michael@0 | 99 | |
michael@0 | 100 | /* See Value::gcKind() and JSTraceCallback in Tracer.h. */ |
michael@0 | 101 | enum JSGCTraceKind { |
michael@0 | 102 | JSTRACE_OBJECT, |
michael@0 | 103 | JSTRACE_STRING, |
michael@0 | 104 | JSTRACE_SCRIPT, |
michael@0 | 105 | |
michael@0 | 106 | /* |
michael@0 | 107 | * Trace kinds internal to the engine. The embedding can only see them if |
michael@0 | 108 | * it implements JSTraceCallback. |
michael@0 | 109 | */ |
michael@0 | 110 | JSTRACE_LAZY_SCRIPT, |
michael@0 | 111 | JSTRACE_JITCODE, |
michael@0 | 112 | JSTRACE_SHAPE, |
michael@0 | 113 | JSTRACE_BASE_SHAPE, |
michael@0 | 114 | JSTRACE_TYPE_OBJECT, |
michael@0 | 115 | JSTRACE_LAST = JSTRACE_TYPE_OBJECT |
michael@0 | 116 | }; |
michael@0 | 117 | |
michael@0 | 118 | /* Struct forward declarations. */ |
michael@0 | 119 | struct JSClass; |
michael@0 | 120 | struct JSCompartment; |
michael@0 | 121 | struct JSConstDoubleSpec; |
michael@0 | 122 | struct JSCrossCompartmentCall; |
michael@0 | 123 | struct JSErrorReport; |
michael@0 | 124 | struct JSExceptionState; |
michael@0 | 125 | struct JSFunctionSpec; |
michael@0 | 126 | struct JSIdArray; |
michael@0 | 127 | struct JSLocaleCallbacks; |
michael@0 | 128 | struct JSObjectMap; |
michael@0 | 129 | struct JSPrincipals; |
michael@0 | 130 | struct JSPropertyDescriptor; |
michael@0 | 131 | struct JSPropertyName; |
michael@0 | 132 | struct JSPropertySpec; |
michael@0 | 133 | struct JSRuntime; |
michael@0 | 134 | struct JSSecurityCallbacks; |
michael@0 | 135 | struct JSStructuredCloneCallbacks; |
michael@0 | 136 | struct JSStructuredCloneReader; |
michael@0 | 137 | struct JSStructuredCloneWriter; |
michael@0 | 138 | class JS_PUBLIC_API(JSTracer); |
michael@0 | 139 | |
michael@0 | 140 | class JSFlatString; |
michael@0 | 141 | |
michael@0 | 142 | #ifdef JS_THREADSAFE |
michael@0 | 143 | typedef struct PRCallOnceType JSCallOnceType; |
michael@0 | 144 | #else |
michael@0 | 145 | typedef bool JSCallOnceType; |
michael@0 | 146 | #endif |
michael@0 | 147 | typedef bool (*JSInitCallback)(void); |
michael@0 | 148 | |
michael@0 | 149 | /* |
michael@0 | 150 | * Generic trace operation that calls JS_CallTracer on each traceable thing |
michael@0 | 151 | * stored in data. |
michael@0 | 152 | */ |
michael@0 | 153 | typedef void |
michael@0 | 154 | (* JSTraceDataOp)(JSTracer *trc, void *data); |
michael@0 | 155 | |
michael@0 | 156 | void js_FinishGC(JSRuntime *rt); |
michael@0 | 157 | |
michael@0 | 158 | namespace js { |
michael@0 | 159 | namespace gc { |
michael@0 | 160 | class StoreBuffer; |
michael@0 | 161 | void MarkPersistentRootedChains(JSTracer *); |
michael@0 | 162 | } |
michael@0 | 163 | } |
michael@0 | 164 | |
michael@0 | 165 | namespace JS { |
michael@0 | 166 | |
michael@0 | 167 | typedef void (*OffThreadCompileCallback)(void *token, void *callbackData); |
michael@0 | 168 | |
michael@0 | 169 | namespace shadow { |
michael@0 | 170 | |
michael@0 | 171 | struct Runtime |
michael@0 | 172 | { |
michael@0 | 173 | /* Restrict zone access during Minor GC. */ |
michael@0 | 174 | bool needsBarrier_; |
michael@0 | 175 | |
michael@0 | 176 | #ifdef JSGC_GENERATIONAL |
michael@0 | 177 | /* Allow inlining of Nursery::isInside. */ |
michael@0 | 178 | uintptr_t gcNurseryStart_; |
michael@0 | 179 | uintptr_t gcNurseryEnd_; |
michael@0 | 180 | |
michael@0 | 181 | private: |
michael@0 | 182 | js::gc::StoreBuffer *gcStoreBufferPtr_; |
michael@0 | 183 | #endif |
michael@0 | 184 | |
michael@0 | 185 | public: |
michael@0 | 186 | Runtime( |
michael@0 | 187 | #ifdef JSGC_GENERATIONAL |
michael@0 | 188 | js::gc::StoreBuffer *storeBuffer |
michael@0 | 189 | #endif |
michael@0 | 190 | ) |
michael@0 | 191 | : needsBarrier_(false) |
michael@0 | 192 | #ifdef JSGC_GENERATIONAL |
michael@0 | 193 | , gcNurseryStart_(0) |
michael@0 | 194 | , gcNurseryEnd_(0) |
michael@0 | 195 | , gcStoreBufferPtr_(storeBuffer) |
michael@0 | 196 | #endif |
michael@0 | 197 | {} |
michael@0 | 198 | |
michael@0 | 199 | bool needsBarrier() const { |
michael@0 | 200 | return needsBarrier_; |
michael@0 | 201 | } |
michael@0 | 202 | |
michael@0 | 203 | #ifdef JSGC_GENERATIONAL |
michael@0 | 204 | js::gc::StoreBuffer *gcStoreBufferPtr() { return gcStoreBufferPtr_; } |
michael@0 | 205 | #endif |
michael@0 | 206 | |
michael@0 | 207 | static JS::shadow::Runtime *asShadowRuntime(JSRuntime *rt) { |
michael@0 | 208 | return reinterpret_cast<JS::shadow::Runtime*>(rt); |
michael@0 | 209 | } |
michael@0 | 210 | |
michael@0 | 211 | /* Allow inlining of PersistentRooted constructors and destructors. */ |
michael@0 | 212 | private: |
michael@0 | 213 | template <typename Referent> friend class JS::PersistentRooted; |
michael@0 | 214 | friend void js::gc::MarkPersistentRootedChains(JSTracer *); |
michael@0 | 215 | friend void ::js_FinishGC(JSRuntime *rt); |
michael@0 | 216 | |
michael@0 | 217 | mozilla::LinkedList<PersistentRootedFunction> functionPersistentRooteds; |
michael@0 | 218 | mozilla::LinkedList<PersistentRootedId> idPersistentRooteds; |
michael@0 | 219 | mozilla::LinkedList<PersistentRootedObject> objectPersistentRooteds; |
michael@0 | 220 | mozilla::LinkedList<PersistentRootedScript> scriptPersistentRooteds; |
michael@0 | 221 | mozilla::LinkedList<PersistentRootedString> stringPersistentRooteds; |
michael@0 | 222 | mozilla::LinkedList<PersistentRootedValue> valuePersistentRooteds; |
michael@0 | 223 | |
michael@0 | 224 | /* Specializations of this return references to the appropriate list. */ |
michael@0 | 225 | template<typename Referent> |
michael@0 | 226 | inline mozilla::LinkedList<PersistentRooted<Referent> > &getPersistentRootedList(); |
michael@0 | 227 | }; |
michael@0 | 228 | |
michael@0 | 229 | template<> |
michael@0 | 230 | inline mozilla::LinkedList<PersistentRootedFunction> |
michael@0 | 231 | &Runtime::getPersistentRootedList<JSFunction *>() { return functionPersistentRooteds; } |
michael@0 | 232 | |
michael@0 | 233 | template<> |
michael@0 | 234 | inline mozilla::LinkedList<PersistentRootedId> |
michael@0 | 235 | &Runtime::getPersistentRootedList<jsid>() { return idPersistentRooteds; } |
michael@0 | 236 | |
michael@0 | 237 | template<> |
michael@0 | 238 | inline mozilla::LinkedList<PersistentRootedObject> |
michael@0 | 239 | &Runtime::getPersistentRootedList<JSObject *>() { return objectPersistentRooteds; } |
michael@0 | 240 | |
michael@0 | 241 | template<> |
michael@0 | 242 | inline mozilla::LinkedList<PersistentRootedScript> |
michael@0 | 243 | &Runtime::getPersistentRootedList<JSScript *>() { return scriptPersistentRooteds; } |
michael@0 | 244 | |
michael@0 | 245 | template<> |
michael@0 | 246 | inline mozilla::LinkedList<PersistentRootedString> |
michael@0 | 247 | &Runtime::getPersistentRootedList<JSString *>() { return stringPersistentRooteds; } |
michael@0 | 248 | |
michael@0 | 249 | template<> |
michael@0 | 250 | inline mozilla::LinkedList<PersistentRootedValue> |
michael@0 | 251 | &Runtime::getPersistentRootedList<Value>() { return valuePersistentRooteds; } |
michael@0 | 252 | |
michael@0 | 253 | } /* namespace shadow */ |
michael@0 | 254 | } /* namespace JS */ |
michael@0 | 255 | |
michael@0 | 256 | namespace js { |
michael@0 | 257 | |
michael@0 | 258 | /* |
michael@0 | 259 | * Parallel operations in general can have one of three states. They may |
michael@0 | 260 | * succeed, fail, or "bail", where bail indicates that the code encountered an |
michael@0 | 261 | * unexpected condition and should be re-run sequentially. Different |
michael@0 | 262 | * subcategories of the "bail" state are encoded as variants of TP_RETRY_*. |
michael@0 | 263 | */ |
michael@0 | 264 | enum ParallelResult { TP_SUCCESS, TP_RETRY_SEQUENTIALLY, TP_RETRY_AFTER_GC, TP_FATAL }; |
michael@0 | 265 | |
michael@0 | 266 | struct ThreadSafeContext; |
michael@0 | 267 | struct ForkJoinContext; |
michael@0 | 268 | class ExclusiveContext; |
michael@0 | 269 | |
michael@0 | 270 | class Allocator; |
michael@0 | 271 | |
michael@0 | 272 | enum ThingRootKind |
michael@0 | 273 | { |
michael@0 | 274 | THING_ROOT_OBJECT, |
michael@0 | 275 | THING_ROOT_SHAPE, |
michael@0 | 276 | THING_ROOT_BASE_SHAPE, |
michael@0 | 277 | THING_ROOT_TYPE_OBJECT, |
michael@0 | 278 | THING_ROOT_STRING, |
michael@0 | 279 | THING_ROOT_JIT_CODE, |
michael@0 | 280 | THING_ROOT_SCRIPT, |
michael@0 | 281 | THING_ROOT_LAZY_SCRIPT, |
michael@0 | 282 | THING_ROOT_ID, |
michael@0 | 283 | THING_ROOT_VALUE, |
michael@0 | 284 | THING_ROOT_TYPE, |
michael@0 | 285 | THING_ROOT_BINDINGS, |
michael@0 | 286 | THING_ROOT_PROPERTY_DESCRIPTOR, |
michael@0 | 287 | THING_ROOT_CUSTOM, |
michael@0 | 288 | THING_ROOT_LIMIT |
michael@0 | 289 | }; |
michael@0 | 290 | |
michael@0 | 291 | /* |
michael@0 | 292 | * This list enumerates the different types of conceptual stacks we have in |
michael@0 | 293 | * SpiderMonkey. In reality, they all share the C stack, but we allow different |
michael@0 | 294 | * stack limits depending on the type of code running. |
michael@0 | 295 | */ |
michael@0 | 296 | enum StackKind |
michael@0 | 297 | { |
michael@0 | 298 | StackForSystemCode, // C++, such as the GC, running on behalf of the VM. |
michael@0 | 299 | StackForTrustedScript, // Script running with trusted principals. |
michael@0 | 300 | StackForUntrustedScript, // Script running with untrusted principals. |
michael@0 | 301 | StackKindCount |
michael@0 | 302 | }; |
michael@0 | 303 | |
michael@0 | 304 | template <typename T> |
michael@0 | 305 | struct RootKind; |
michael@0 | 306 | |
michael@0 | 307 | /* |
michael@0 | 308 | * Specifically mark the ThingRootKind of externally visible types, so that |
michael@0 | 309 | * JSAPI users may use JSRooted... types without having the class definition |
michael@0 | 310 | * available. |
michael@0 | 311 | */ |
michael@0 | 312 | template<typename T, ThingRootKind Kind> |
michael@0 | 313 | struct SpecificRootKind |
michael@0 | 314 | { |
michael@0 | 315 | static ThingRootKind rootKind() { return Kind; } |
michael@0 | 316 | }; |
michael@0 | 317 | |
michael@0 | 318 | template <> struct RootKind<JSObject *> : SpecificRootKind<JSObject *, THING_ROOT_OBJECT> {}; |
michael@0 | 319 | template <> struct RootKind<JSFlatString *> : SpecificRootKind<JSFlatString *, THING_ROOT_STRING> {}; |
michael@0 | 320 | template <> struct RootKind<JSFunction *> : SpecificRootKind<JSFunction *, THING_ROOT_OBJECT> {}; |
michael@0 | 321 | template <> struct RootKind<JSString *> : SpecificRootKind<JSString *, THING_ROOT_STRING> {}; |
michael@0 | 322 | template <> struct RootKind<JSScript *> : SpecificRootKind<JSScript *, THING_ROOT_SCRIPT> {}; |
michael@0 | 323 | template <> struct RootKind<jsid> : SpecificRootKind<jsid, THING_ROOT_ID> {}; |
michael@0 | 324 | template <> struct RootKind<JS::Value> : SpecificRootKind<JS::Value, THING_ROOT_VALUE> {}; |
michael@0 | 325 | |
michael@0 | 326 | struct ContextFriendFields |
michael@0 | 327 | { |
michael@0 | 328 | protected: |
michael@0 | 329 | JSRuntime *const runtime_; |
michael@0 | 330 | |
michael@0 | 331 | /* The current compartment. */ |
michael@0 | 332 | JSCompartment *compartment_; |
michael@0 | 333 | |
michael@0 | 334 | /* The current zone. */ |
michael@0 | 335 | JS::Zone *zone_; |
michael@0 | 336 | |
michael@0 | 337 | public: |
michael@0 | 338 | explicit ContextFriendFields(JSRuntime *rt) |
michael@0 | 339 | : runtime_(rt), compartment_(nullptr), zone_(nullptr), autoGCRooters(nullptr) |
michael@0 | 340 | { |
michael@0 | 341 | #ifdef JSGC_TRACK_EXACT_ROOTS |
michael@0 | 342 | mozilla::PodArrayZero(thingGCRooters); |
michael@0 | 343 | #endif |
michael@0 | 344 | } |
michael@0 | 345 | |
michael@0 | 346 | static const ContextFriendFields *get(const JSContext *cx) { |
michael@0 | 347 | return reinterpret_cast<const ContextFriendFields *>(cx); |
michael@0 | 348 | } |
michael@0 | 349 | |
michael@0 | 350 | static ContextFriendFields *get(JSContext *cx) { |
michael@0 | 351 | return reinterpret_cast<ContextFriendFields *>(cx); |
michael@0 | 352 | } |
michael@0 | 353 | |
michael@0 | 354 | #ifdef JSGC_TRACK_EXACT_ROOTS |
michael@0 | 355 | /* |
michael@0 | 356 | * Stack allocated GC roots for stack GC heap pointers, which may be |
michael@0 | 357 | * overwritten if moved during a GC. |
michael@0 | 358 | */ |
michael@0 | 359 | JS::Rooted<void*> *thingGCRooters[THING_ROOT_LIMIT]; |
michael@0 | 360 | #endif |
michael@0 | 361 | |
michael@0 | 362 | /* Stack of thread-stack-allocated GC roots. */ |
michael@0 | 363 | JS::AutoGCRooter *autoGCRooters; |
michael@0 | 364 | |
michael@0 | 365 | friend JSRuntime *GetRuntime(const JSContext *cx); |
michael@0 | 366 | friend JSCompartment *GetContextCompartment(const JSContext *cx); |
michael@0 | 367 | friend JS::Zone *GetContextZone(const JSContext *cx); |
michael@0 | 368 | }; |
michael@0 | 369 | |
michael@0 | 370 | /* |
michael@0 | 371 | * Inlinable accessors for JSContext. |
michael@0 | 372 | * |
michael@0 | 373 | * - These must not be available on the more restricted superclasses of |
michael@0 | 374 | * JSContext, so we can't simply define them on ContextFriendFields. |
michael@0 | 375 | * |
michael@0 | 376 | * - They're perfectly ordinary JSContext functionality, so ought to be |
michael@0 | 377 | * usable without resorting to jsfriendapi.h, and when JSContext is an |
michael@0 | 378 | * incomplete type. |
michael@0 | 379 | */ |
michael@0 | 380 | inline JSRuntime * |
michael@0 | 381 | GetRuntime(const JSContext *cx) |
michael@0 | 382 | { |
michael@0 | 383 | return ContextFriendFields::get(cx)->runtime_; |
michael@0 | 384 | } |
michael@0 | 385 | |
michael@0 | 386 | inline JSCompartment * |
michael@0 | 387 | GetContextCompartment(const JSContext *cx) |
michael@0 | 388 | { |
michael@0 | 389 | return ContextFriendFields::get(cx)->compartment_; |
michael@0 | 390 | } |
michael@0 | 391 | |
michael@0 | 392 | inline JS::Zone * |
michael@0 | 393 | GetContextZone(const JSContext *cx) |
michael@0 | 394 | { |
michael@0 | 395 | return ContextFriendFields::get(cx)->zone_; |
michael@0 | 396 | } |
michael@0 | 397 | |
michael@0 | 398 | class PerThreadData; |
michael@0 | 399 | |
michael@0 | 400 | struct PerThreadDataFriendFields |
michael@0 | 401 | { |
michael@0 | 402 | private: |
michael@0 | 403 | // Note: this type only exists to permit us to derive the offset of |
michael@0 | 404 | // the perThread data within the real JSRuntime* type in a portable |
michael@0 | 405 | // way. |
michael@0 | 406 | struct RuntimeDummy : JS::shadow::Runtime |
michael@0 | 407 | { |
michael@0 | 408 | struct PerThreadDummy { |
michael@0 | 409 | void *field1; |
michael@0 | 410 | uintptr_t field2; |
michael@0 | 411 | #ifdef JS_DEBUG |
michael@0 | 412 | uint64_t field3; |
michael@0 | 413 | #endif |
michael@0 | 414 | } mainThread; |
michael@0 | 415 | }; |
michael@0 | 416 | |
michael@0 | 417 | public: |
michael@0 | 418 | |
michael@0 | 419 | PerThreadDataFriendFields(); |
michael@0 | 420 | |
michael@0 | 421 | #ifdef JSGC_TRACK_EXACT_ROOTS |
michael@0 | 422 | /* |
michael@0 | 423 | * Stack allocated GC roots for stack GC heap pointers, which may be |
michael@0 | 424 | * overwritten if moved during a GC. |
michael@0 | 425 | */ |
michael@0 | 426 | JS::Rooted<void*> *thingGCRooters[THING_ROOT_LIMIT]; |
michael@0 | 427 | #endif |
michael@0 | 428 | |
michael@0 | 429 | /* Limit pointer for checking native stack consumption. */ |
michael@0 | 430 | uintptr_t nativeStackLimit[StackKindCount]; |
michael@0 | 431 | |
michael@0 | 432 | static const size_t RuntimeMainThreadOffset = offsetof(RuntimeDummy, mainThread); |
michael@0 | 433 | |
michael@0 | 434 | static inline PerThreadDataFriendFields *get(js::PerThreadData *pt) { |
michael@0 | 435 | return reinterpret_cast<PerThreadDataFriendFields *>(pt); |
michael@0 | 436 | } |
michael@0 | 437 | |
michael@0 | 438 | static inline PerThreadDataFriendFields *getMainThread(JSRuntime *rt) { |
michael@0 | 439 | // mainThread must always appear directly after |JS::shadow::Runtime|. |
michael@0 | 440 | // Tested by a JS_STATIC_ASSERT in |jsfriendapi.cpp| |
michael@0 | 441 | return reinterpret_cast<PerThreadDataFriendFields *>( |
michael@0 | 442 | reinterpret_cast<char*>(rt) + RuntimeMainThreadOffset); |
michael@0 | 443 | } |
michael@0 | 444 | |
michael@0 | 445 | static inline const PerThreadDataFriendFields *getMainThread(const JSRuntime *rt) { |
michael@0 | 446 | // mainThread must always appear directly after |JS::shadow::Runtime|. |
michael@0 | 447 | // Tested by a JS_STATIC_ASSERT in |jsfriendapi.cpp| |
michael@0 | 448 | return reinterpret_cast<const PerThreadDataFriendFields *>( |
michael@0 | 449 | reinterpret_cast<const char*>(rt) + RuntimeMainThreadOffset); |
michael@0 | 450 | } |
michael@0 | 451 | }; |
michael@0 | 452 | |
michael@0 | 453 | } /* namespace js */ |
michael@0 | 454 | |
michael@0 | 455 | #endif /* jspubtd_h */ |