2012-08-28 02:41:49 +08:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2013-08-07 09:43:25 +08:00
|
|
|
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
2012-10-19 11:48:42 +08:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2012-08-28 02:41:49 +08:00
|
|
|
|
2013-10-30 21:55:19 +08:00
|
|
|
#ifndef jspubtd_h
|
|
|
|
#define jspubtd_h
|
2012-08-28 02:41:49 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* JS public API typedefs.
|
|
|
|
*/
|
2013-01-09 13:42:21 +08:00
|
|
|
|
2013-10-30 21:55:19 +08:00
|
|
|
#include "mozilla/PodOperations.h"
|
|
|
|
|
2013-01-09 13:42:21 +08:00
|
|
|
#include "jsprototypes.h"
|
2012-08-28 02:41:49 +08:00
|
|
|
#include "jstypes.h"
|
|
|
|
|
2013-10-31 15:15:52 +08:00
|
|
|
#if defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING) || (defined(DEBUG) && !defined(_WIN32))
|
2013-10-30 21:55:19 +08:00
|
|
|
# define JSGC_TRACK_EXACT_ROOTS
|
|
|
|
#endif
|
|
|
|
|
2013-06-27 16:06:05 +08:00
|
|
|
namespace JS {
|
|
|
|
|
2012-08-28 02:41:49 +08:00
|
|
|
/*
|
|
|
|
* Allow headers to reference JS::Value without #including the whole jsapi.h.
|
|
|
|
* Unfortunately, typedefs (hence jsval) cannot be declared.
|
|
|
|
*/
|
2013-06-27 16:06:05 +08:00
|
|
|
class Value;
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
class Rooted;
|
|
|
|
|
2013-10-30 21:55:19 +08:00
|
|
|
class JS_PUBLIC_API(AutoGCRooter);
|
|
|
|
|
2013-06-27 16:06:05 +08:00
|
|
|
struct Zone;
|
|
|
|
|
|
|
|
} /* namespace JS */
|
2012-08-28 02:41:49 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* In release builds, jsid is defined to be an integral type. This
|
|
|
|
* prevents many bugs from being caught at compile time. E.g.:
|
|
|
|
*
|
|
|
|
* jsid id = ...
|
|
|
|
* if (id == JS_TRUE) // error
|
|
|
|
* ...
|
|
|
|
*
|
|
|
|
* size_t n = id; // error
|
|
|
|
*
|
|
|
|
* To catch more errors, jsid is given a struct type in C++ debug builds.
|
|
|
|
* Struct assignment and (in C++) operator== allow correct code to be mostly
|
|
|
|
* oblivious to the change. This feature can be explicitly disabled in debug
|
|
|
|
* builds by defining JS_NO_JSVAL_JSID_STRUCT_TYPES.
|
|
|
|
*/
|
2013-04-12 12:52:50 +08:00
|
|
|
// Needed for cocos2d-js
|
2013-10-30 21:55:19 +08:00
|
|
|
#define JS_NO_JSVAL_JSID_STRUCT_TYPES
|
2012-08-28 02:41:49 +08:00
|
|
|
# if defined(DEBUG) && !defined(JS_NO_JSVAL_JSID_STRUCT_TYPES)
|
|
|
|
# define JS_USE_JSID_STRUCT_TYPES
|
|
|
|
# endif
|
|
|
|
|
|
|
|
# ifdef JS_USE_JSID_STRUCT_TYPES
|
|
|
|
struct jsid
|
|
|
|
{
|
|
|
|
size_t asBits;
|
|
|
|
bool operator==(jsid rhs) const { return asBits == rhs.asBits; }
|
|
|
|
bool operator!=(jsid rhs) const { return asBits != rhs.asBits; }
|
|
|
|
};
|
|
|
|
# define JSID_BITS(id) (id.asBits)
|
|
|
|
# else /* defined(JS_USE_JSID_STRUCT_TYPES) */
|
|
|
|
typedef ptrdiff_t jsid;
|
|
|
|
# define JSID_BITS(id) (id)
|
|
|
|
# endif /* defined(JS_USE_JSID_STRUCT_TYPES) */
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
typedef wchar_t jschar;
|
|
|
|
#else
|
|
|
|
typedef uint16_t jschar;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
2013-08-07 09:43:25 +08:00
|
|
|
* Run-time version enumeration. For compile-time version checking, please use
|
|
|
|
* the JS_HAS_* macros in jsversion.h, or use MOZJS_MAJOR_VERSION,
|
|
|
|
* MOZJS_MINOR_VERSION, MOZJS_PATCH_VERSION, and MOZJS_ALPHA definitions.
|
2012-08-28 02:41:49 +08:00
|
|
|
*/
|
|
|
|
typedef enum JSVersion {
|
|
|
|
JSVERSION_ECMA_3 = 148,
|
|
|
|
JSVERSION_1_6 = 160,
|
|
|
|
JSVERSION_1_7 = 170,
|
|
|
|
JSVERSION_1_8 = 180,
|
|
|
|
JSVERSION_ECMA_5 = 185,
|
|
|
|
JSVERSION_DEFAULT = 0,
|
|
|
|
JSVERSION_UNKNOWN = -1,
|
|
|
|
JSVERSION_LATEST = JSVERSION_ECMA_5
|
|
|
|
} JSVersion;
|
|
|
|
|
|
|
|
/* Result of typeof operator enumeration. */
|
|
|
|
typedef enum JSType {
|
|
|
|
JSTYPE_VOID, /* undefined */
|
|
|
|
JSTYPE_OBJECT, /* object */
|
|
|
|
JSTYPE_FUNCTION, /* function */
|
|
|
|
JSTYPE_STRING, /* string */
|
|
|
|
JSTYPE_NUMBER, /* number */
|
|
|
|
JSTYPE_BOOLEAN, /* boolean */
|
|
|
|
JSTYPE_NULL, /* null */
|
|
|
|
JSTYPE_LIMIT
|
|
|
|
} JSType;
|
|
|
|
|
|
|
|
/* Dense index into cached prototypes and class atoms for standard objects. */
|
|
|
|
typedef enum JSProtoKey {
|
2013-01-09 13:42:21 +08:00
|
|
|
#define PROTOKEY_AND_INITIALIZER(name,code,init) JSProto_##name = code,
|
|
|
|
JS_FOR_EACH_PROTOTYPE(PROTOKEY_AND_INITIALIZER)
|
2012-08-28 02:41:49 +08:00
|
|
|
#undef JS_PROTO
|
|
|
|
JSProto_LIMIT
|
|
|
|
} JSProtoKey;
|
|
|
|
|
|
|
|
/* js_CheckAccess mode enumeration. */
|
|
|
|
typedef enum JSAccessMode {
|
|
|
|
JSACC_PROTO = 0, /* XXXbe redundant w.r.t. id */
|
2012-10-19 11:48:42 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* enum value #1 formerly called JSACC_PARENT,
|
|
|
|
* gap preserved for ABI compatibility.
|
|
|
|
*/
|
2012-08-28 02:41:49 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* enum value #2 formerly called JSACC_IMPORT,
|
|
|
|
* gap preserved for ABI compatibility.
|
|
|
|
*/
|
|
|
|
|
|
|
|
JSACC_WATCH = 3, /* a watchpoint on object foo for id 'bar' */
|
|
|
|
JSACC_READ = 4, /* a "get" of foo.bar */
|
|
|
|
JSACC_WRITE = 8, /* a "set" of foo.bar = baz */
|
|
|
|
JSACC_LIMIT
|
|
|
|
} JSAccessMode;
|
|
|
|
|
|
|
|
#define JSACC_TYPEMASK (JSACC_WRITE - 1)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This enum type is used to control the behavior of a JSObject property
|
|
|
|
* iterator function that has type JSNewEnumerate.
|
|
|
|
*/
|
|
|
|
typedef enum JSIterateOp {
|
|
|
|
/* Create new iterator state over enumerable properties. */
|
|
|
|
JSENUMERATE_INIT,
|
|
|
|
|
|
|
|
/* Create new iterator state over all properties. */
|
|
|
|
JSENUMERATE_INIT_ALL,
|
|
|
|
|
|
|
|
/* Iterate once. */
|
|
|
|
JSENUMERATE_NEXT,
|
|
|
|
|
|
|
|
/* Destroy iterator state. */
|
|
|
|
JSENUMERATE_DESTROY
|
|
|
|
} JSIterateOp;
|
|
|
|
|
|
|
|
/* See JSVAL_TRACE_KIND and JSTraceCallback in jsapi.h. */
|
|
|
|
typedef enum {
|
|
|
|
JSTRACE_OBJECT,
|
|
|
|
JSTRACE_STRING,
|
|
|
|
JSTRACE_SCRIPT,
|
|
|
|
|
|
|
|
/*
|
2013-10-30 21:55:19 +08:00
|
|
|
* Trace kinds internal to the engine. The embedding can only see them if
|
|
|
|
* it implements JSTraceCallback.
|
2012-08-28 02:41:49 +08:00
|
|
|
*/
|
2013-10-30 21:55:19 +08:00
|
|
|
JSTRACE_LAZY_SCRIPT,
|
2013-01-09 13:42:21 +08:00
|
|
|
JSTRACE_IONCODE,
|
2012-08-28 02:41:49 +08:00
|
|
|
JSTRACE_SHAPE,
|
|
|
|
JSTRACE_BASE_SHAPE,
|
|
|
|
JSTRACE_TYPE_OBJECT,
|
|
|
|
JSTRACE_LAST = JSTRACE_TYPE_OBJECT
|
|
|
|
} JSGCTraceKind;
|
|
|
|
|
2013-04-10 11:19:43 +08:00
|
|
|
/* Struct typedefs and class forward declarations. */
|
2012-08-28 02:41:49 +08:00
|
|
|
typedef struct JSClass JSClass;
|
|
|
|
typedef struct JSCompartment JSCompartment;
|
|
|
|
typedef struct JSConstDoubleSpec JSConstDoubleSpec;
|
|
|
|
typedef struct JSContext JSContext;
|
|
|
|
typedef struct JSCrossCompartmentCall JSCrossCompartmentCall;
|
|
|
|
typedef struct JSErrorReport JSErrorReport;
|
|
|
|
typedef struct JSExceptionState JSExceptionState;
|
|
|
|
typedef struct JSFunctionSpec JSFunctionSpec;
|
|
|
|
typedef struct JSIdArray JSIdArray;
|
|
|
|
typedef struct JSLocaleCallbacks JSLocaleCallbacks;
|
|
|
|
typedef struct JSObjectMap JSObjectMap;
|
|
|
|
typedef struct JSPrincipals JSPrincipals;
|
|
|
|
typedef struct JSPropertyDescriptor JSPropertyDescriptor;
|
|
|
|
typedef struct JSPropertyName JSPropertyName;
|
|
|
|
typedef struct JSPropertySpec JSPropertySpec;
|
|
|
|
typedef struct JSRuntime JSRuntime;
|
|
|
|
typedef struct JSSecurityCallbacks JSSecurityCallbacks;
|
|
|
|
typedef struct JSStructuredCloneCallbacks JSStructuredCloneCallbacks;
|
|
|
|
typedef struct JSStructuredCloneReader JSStructuredCloneReader;
|
|
|
|
typedef struct JSStructuredCloneWriter JSStructuredCloneWriter;
|
|
|
|
typedef struct JSTracer JSTracer;
|
|
|
|
|
|
|
|
class JSFlatString;
|
2013-04-10 11:19:43 +08:00
|
|
|
class JSFunction;
|
2013-05-22 17:31:07 +08:00
|
|
|
class JSObject;
|
2013-04-10 11:19:43 +08:00
|
|
|
class JSScript;
|
2013-01-09 13:42:21 +08:00
|
|
|
class JSStableString; // long story
|
2012-08-28 02:41:49 +08:00
|
|
|
class JSString;
|
|
|
|
|
|
|
|
#ifdef JS_THREADSAFE
|
|
|
|
typedef struct PRCallOnceType JSCallOnceType;
|
|
|
|
#else
|
|
|
|
typedef JSBool JSCallOnceType;
|
|
|
|
#endif
|
|
|
|
typedef JSBool (*JSInitCallback)(void);
|
|
|
|
|
2013-08-07 09:43:25 +08:00
|
|
|
namespace JS {
|
|
|
|
namespace shadow {
|
|
|
|
|
|
|
|
struct Runtime
|
|
|
|
{
|
|
|
|
/* Restrict zone access during Minor GC. */
|
|
|
|
bool needsBarrier_;
|
|
|
|
|
|
|
|
#ifdef JSGC_GENERATIONAL
|
|
|
|
/* Allow inlining of Nursery::isInside. */
|
|
|
|
uintptr_t gcNurseryStart_;
|
|
|
|
uintptr_t gcNurseryEnd_;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
Runtime()
|
|
|
|
: needsBarrier_(false)
|
|
|
|
#ifdef JSGC_GENERATIONAL
|
|
|
|
, gcNurseryStart_(0)
|
|
|
|
, gcNurseryEnd_(0)
|
|
|
|
#endif
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace shadow */
|
|
|
|
} /* namespace JS */
|
2012-08-28 02:41:49 +08:00
|
|
|
|
2013-01-09 13:42:21 +08:00
|
|
|
namespace js {
|
2012-08-28 02:41:49 +08:00
|
|
|
|
2013-10-30 21:55:19 +08:00
|
|
|
/*
|
|
|
|
* Parallel operations in general can have one of three states. They may
|
|
|
|
* succeed, fail, or "bail", where bail indicates that the code encountered an
|
|
|
|
* unexpected condition and should be re-run sequentially. Different
|
|
|
|
* subcategories of the "bail" state are encoded as variants of TP_RETRY_*.
|
|
|
|
*/
|
|
|
|
enum ParallelResult { TP_SUCCESS, TP_RETRY_SEQUENTIALLY, TP_RETRY_AFTER_GC, TP_FATAL };
|
|
|
|
|
|
|
|
struct ThreadSafeContext;
|
|
|
|
struct ForkJoinSlice;
|
|
|
|
class ExclusiveContext;
|
|
|
|
|
2013-05-22 17:31:07 +08:00
|
|
|
class Allocator;
|
|
|
|
|
2012-08-28 02:41:49 +08:00
|
|
|
class SkipRoot;
|
|
|
|
|
|
|
|
enum ThingRootKind
|
|
|
|
{
|
|
|
|
THING_ROOT_OBJECT,
|
|
|
|
THING_ROOT_SHAPE,
|
|
|
|
THING_ROOT_BASE_SHAPE,
|
|
|
|
THING_ROOT_TYPE_OBJECT,
|
|
|
|
THING_ROOT_STRING,
|
2013-06-27 16:06:05 +08:00
|
|
|
THING_ROOT_ION_CODE,
|
2012-08-28 02:41:49 +08:00
|
|
|
THING_ROOT_SCRIPT,
|
|
|
|
THING_ROOT_ID,
|
2012-10-19 11:48:42 +08:00
|
|
|
THING_ROOT_PROPERTY_ID,
|
2012-08-28 02:41:49 +08:00
|
|
|
THING_ROOT_VALUE,
|
2012-10-19 11:48:42 +08:00
|
|
|
THING_ROOT_TYPE,
|
2013-01-09 13:42:21 +08:00
|
|
|
THING_ROOT_BINDINGS,
|
2013-08-07 09:43:25 +08:00
|
|
|
THING_ROOT_PROPERTY_DESCRIPTOR,
|
2012-08-28 02:41:49 +08:00
|
|
|
THING_ROOT_LIMIT
|
|
|
|
};
|
|
|
|
|
2012-10-31 10:33:43 +08:00
|
|
|
template <typename T>
|
|
|
|
struct RootKind;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Specifically mark the ThingRootKind of externally visible types, so that
|
|
|
|
* JSAPI users may use JSRooted... types without having the class definition
|
|
|
|
* available.
|
|
|
|
*/
|
2013-01-09 13:42:21 +08:00
|
|
|
template<typename T, ThingRootKind Kind>
|
|
|
|
struct SpecificRootKind
|
|
|
|
{
|
|
|
|
static ThingRootKind rootKind() { return Kind; }
|
|
|
|
};
|
|
|
|
|
|
|
|
template <> struct RootKind<JSObject *> : SpecificRootKind<JSObject *, THING_ROOT_OBJECT> {};
|
2013-08-07 09:43:25 +08:00
|
|
|
template <> struct RootKind<JSFlatString *> : SpecificRootKind<JSFlatString *, THING_ROOT_STRING> {};
|
2013-01-09 13:42:21 +08:00
|
|
|
template <> struct RootKind<JSFunction *> : SpecificRootKind<JSFunction *, THING_ROOT_OBJECT> {};
|
|
|
|
template <> struct RootKind<JSString *> : SpecificRootKind<JSString *, THING_ROOT_STRING> {};
|
|
|
|
template <> struct RootKind<JSScript *> : SpecificRootKind<JSScript *, THING_ROOT_SCRIPT> {};
|
|
|
|
template <> struct RootKind<jsid> : SpecificRootKind<jsid, THING_ROOT_ID> {};
|
|
|
|
template <> struct RootKind<JS::Value> : SpecificRootKind<JS::Value, THING_ROOT_VALUE> {};
|
2012-10-31 10:33:43 +08:00
|
|
|
|
2013-10-30 21:55:19 +08:00
|
|
|
struct ContextFriendFields
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
JSRuntime *const runtime_;
|
2012-08-28 02:41:49 +08:00
|
|
|
|
2013-04-10 11:19:43 +08:00
|
|
|
/* The current compartment. */
|
2013-10-30 21:55:19 +08:00
|
|
|
JSCompartment *compartment_;
|
2013-04-10 11:19:43 +08:00
|
|
|
|
2013-06-27 16:06:05 +08:00
|
|
|
/* The current zone. */
|
|
|
|
JS::Zone *zone_;
|
|
|
|
|
2013-10-30 21:55:19 +08:00
|
|
|
public:
|
2013-04-10 11:19:43 +08:00
|
|
|
explicit ContextFriendFields(JSRuntime *rt)
|
2013-10-30 21:55:19 +08:00
|
|
|
: runtime_(rt), compartment_(NULL), zone_(NULL), autoGCRooters(NULL)
|
|
|
|
{
|
|
|
|
#ifdef JSGC_TRACK_EXACT_ROOTS
|
|
|
|
mozilla::PodArrayZero(thingGCRooters);
|
|
|
|
#endif
|
|
|
|
#if defined(DEBUG) && defined(JS_GC_ZEAL) && defined(JSGC_ROOT_ANALYSIS) && !defined(JS_THREADSAFE)
|
|
|
|
skipGCRooters = NULL;
|
|
|
|
#endif
|
|
|
|
}
|
2012-08-28 02:41:49 +08:00
|
|
|
|
|
|
|
static const ContextFriendFields *get(const JSContext *cx) {
|
|
|
|
return reinterpret_cast<const ContextFriendFields *>(cx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ContextFriendFields *get(JSContext *cx) {
|
|
|
|
return reinterpret_cast<ContextFriendFields *>(cx);
|
|
|
|
}
|
|
|
|
|
2013-10-30 21:55:19 +08:00
|
|
|
#ifdef JSGC_TRACK_EXACT_ROOTS
|
2012-08-28 02:41:49 +08:00
|
|
|
/*
|
|
|
|
* Stack allocated GC roots for stack GC heap pointers, which may be
|
|
|
|
* overwritten if moved during a GC.
|
|
|
|
*/
|
2013-06-27 16:06:05 +08:00
|
|
|
JS::Rooted<void*> *thingGCRooters[THING_ROOT_LIMIT];
|
2012-10-19 11:48:42 +08:00
|
|
|
#endif
|
2012-08-28 02:41:49 +08:00
|
|
|
|
2012-10-19 11:48:42 +08:00
|
|
|
#if defined(DEBUG) && defined(JS_GC_ZEAL) && defined(JSGC_ROOT_ANALYSIS) && !defined(JS_THREADSAFE)
|
2012-08-28 02:41:49 +08:00
|
|
|
/*
|
|
|
|
* Stack allocated list of stack locations which hold non-relocatable
|
|
|
|
* GC heap pointers (where the target is rooted somewhere else) or integer
|
|
|
|
* values which may be confused for GC heap pointers. These are used to
|
|
|
|
* suppress false positives which occur when a rooting analysis treats the
|
|
|
|
* location as holding a relocatable pointer, but have no other effect on
|
|
|
|
* GC behavior.
|
|
|
|
*/
|
|
|
|
SkipRoot *skipGCRooters;
|
|
|
|
#endif
|
2013-10-30 21:55:19 +08:00
|
|
|
|
|
|
|
/* Stack of thread-stack-allocated GC roots. */
|
|
|
|
JS::AutoGCRooter *autoGCRooters;
|
|
|
|
|
|
|
|
friend JSRuntime *GetRuntime(const JSContext *cx);
|
|
|
|
friend JSCompartment *GetContextCompartment(const JSContext *cx);
|
|
|
|
friend JS::Zone *GetContextZone(const JSContext *cx);
|
2012-08-28 02:41:49 +08:00
|
|
|
};
|
|
|
|
|
2013-02-27 16:57:36 +08:00
|
|
|
class PerThreadData;
|
|
|
|
|
|
|
|
struct PerThreadDataFriendFields
|
|
|
|
{
|
2013-05-22 17:31:07 +08:00
|
|
|
private:
|
|
|
|
// Note: this type only exists to permit us to derive the offset of
|
|
|
|
// the perThread data within the real JSRuntime* type in a portable
|
|
|
|
// way.
|
2013-08-07 09:43:25 +08:00
|
|
|
struct RuntimeDummy : JS::shadow::Runtime
|
2013-05-22 17:31:07 +08:00
|
|
|
{
|
|
|
|
struct PerThreadDummy {
|
|
|
|
void *field1;
|
|
|
|
uintptr_t field2;
|
|
|
|
#ifdef DEBUG
|
|
|
|
uint64_t field3;
|
|
|
|
#endif
|
|
|
|
} mainThread;
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2013-02-27 16:57:36 +08:00
|
|
|
PerThreadDataFriendFields();
|
|
|
|
|
2013-10-30 21:55:19 +08:00
|
|
|
#ifdef JSGC_TRACK_EXACT_ROOTS
|
2013-01-09 13:42:21 +08:00
|
|
|
/*
|
|
|
|
* Stack allocated GC roots for stack GC heap pointers, which may be
|
|
|
|
* overwritten if moved during a GC.
|
|
|
|
*/
|
2013-06-27 16:06:05 +08:00
|
|
|
JS::Rooted<void*> *thingGCRooters[THING_ROOT_LIMIT];
|
2013-01-09 13:42:21 +08:00
|
|
|
#endif
|
|
|
|
|
2013-05-22 17:31:07 +08:00
|
|
|
#if defined(DEBUG) && defined(JS_GC_ZEAL) && defined(JSGC_ROOT_ANALYSIS) && !defined(JS_THREADSAFE)
|
|
|
|
/*
|
|
|
|
* Stack allocated list of stack locations which hold non-relocatable
|
|
|
|
* GC heap pointers (where the target is rooted somewhere else) or integer
|
|
|
|
* values which may be confused for GC heap pointers. These are used to
|
|
|
|
* suppress false positives which occur when a rooting analysis treats the
|
|
|
|
* location as holding a relocatable pointer, but have no other effect on
|
|
|
|
* GC behavior.
|
|
|
|
*/
|
|
|
|
SkipRoot *skipGCRooters;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Limit pointer for checking native stack consumption. */
|
|
|
|
uintptr_t nativeStackLimit;
|
|
|
|
|
|
|
|
static const size_t RuntimeMainThreadOffset = offsetof(RuntimeDummy, mainThread);
|
|
|
|
|
|
|
|
static inline PerThreadDataFriendFields *get(js::PerThreadData *pt) {
|
2013-02-27 16:57:36 +08:00
|
|
|
return reinterpret_cast<PerThreadDataFriendFields *>(pt);
|
|
|
|
}
|
2013-01-09 13:42:21 +08:00
|
|
|
|
2013-05-22 17:31:07 +08:00
|
|
|
static inline PerThreadDataFriendFields *getMainThread(JSRuntime *rt) {
|
2013-08-07 09:43:25 +08:00
|
|
|
// mainThread must always appear directly after |JS::shadow::Runtime|.
|
2013-02-27 16:57:36 +08:00
|
|
|
// Tested by a JS_STATIC_ASSERT in |jsfriendapi.cpp|
|
|
|
|
return reinterpret_cast<PerThreadDataFriendFields *>(
|
2013-05-22 17:31:07 +08:00
|
|
|
reinterpret_cast<char*>(rt) + RuntimeMainThreadOffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline const PerThreadDataFriendFields *getMainThread(const JSRuntime *rt) {
|
2013-08-07 09:43:25 +08:00
|
|
|
// mainThread must always appear directly after |JS::shadow::Runtime|.
|
2013-05-22 17:31:07 +08:00
|
|
|
// Tested by a JS_STATIC_ASSERT in |jsfriendapi.cpp|
|
|
|
|
return reinterpret_cast<const PerThreadDataFriendFields *>(
|
|
|
|
reinterpret_cast<const char*>(rt) + RuntimeMainThreadOffset);
|
2013-01-09 13:42:21 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace js */
|
2012-08-28 02:41:49 +08:00
|
|
|
|
2013-10-30 21:55:19 +08:00
|
|
|
#endif /* jspubtd_h */
|