Differential D3094 Diff 14018 ps/trunk/libraries/source/spidermonkey/include-win32-debug/jsfriendapi.h
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/libraries/source/spidermonkey/include-win32-debug/jsfriendapi.h
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- | ||||
* vim: set ts=8 sts=4 et sw=4 tw=99: | * vim: set ts=8 sts=4 et sw=4 tw=99: | ||||
* This Source Code Form is subject to the terms of the Mozilla Public | * 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 | * 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/. */ | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||||
#ifndef jsfriendapi_h | #ifndef jsfriendapi_h | ||||
#define jsfriendapi_h | #define jsfriendapi_h | ||||
#include "mozilla/Atomics.h" | #include "mozilla/Atomics.h" | ||||
#include "mozilla/Casting.h" | #include "mozilla/Casting.h" | ||||
#include "mozilla/Maybe.h" | |||||
#include "mozilla/MemoryReporting.h" | #include "mozilla/MemoryReporting.h" | ||||
#include "mozilla/UniquePtr.h" | #include "mozilla/UniquePtr.h" | ||||
#include "jsapi.h" // For JSAutoByteString. See bug 1033916. | #include "jsapi.h" // For JSAutoByteString. See bug 1033916. | ||||
#include "jsbytecode.h" | #include "jsbytecode.h" | ||||
#include "jspubtd.h" | #include "jspubtd.h" | ||||
#include "js/CallArgs.h" | #include "js/CallArgs.h" | ||||
#include "js/CallNonGenericMethod.h" | #include "js/CallNonGenericMethod.h" | ||||
#include "js/Class.h" | #include "js/Class.h" | ||||
#include "js/Utility.h" | |||||
#if JS_STACK_GROWTH_DIRECTION > 0 | #if JS_STACK_GROWTH_DIRECTION > 0 | ||||
# define JS_CHECK_STACK_SIZE(limit, sp) (MOZ_LIKELY((uintptr_t)(sp) < (limit))) | # define JS_CHECK_STACK_SIZE(limit, sp) (MOZ_LIKELY((uintptr_t)(sp) < (limit))) | ||||
#else | #else | ||||
# define JS_CHECK_STACK_SIZE(limit, sp) (MOZ_LIKELY((uintptr_t)(sp) > (limit))) | # define JS_CHECK_STACK_SIZE(limit, sp) (MOZ_LIKELY((uintptr_t)(sp) > (limit))) | ||||
#endif | #endif | ||||
class JSAtom; | class JSAtom; | ||||
struct JSErrorFormatString; | struct JSErrorFormatString; | ||||
class JSLinearString; | class JSLinearString; | ||||
struct JSJitInfo; | struct JSJitInfo; | ||||
class JSErrorReport; | class JSErrorReport; | ||||
namespace JS { | namespace JS { | ||||
template <class T> | template <class T> | ||||
class Heap; | class Heap; | ||||
} /* namespace JS */ | } /* namespace JS */ | ||||
namespace js { | namespace js { | ||||
class JS_FRIEND_API(BaseProxyHandler); | class JS_FRIEND_API(BaseProxyHandler); | ||||
class InterpreterFrame; | class InterpreterFrame; | ||||
} /* namespace js */ | } /* namespace js */ | ||||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | ||||
JS_SetGrayGCRootsTracer(JSRuntime* rt, JSTraceDataOp traceOp, void* data); | JS_SetGrayGCRootsTracer(JSContext* cx, JSTraceDataOp traceOp, void* data); | ||||
extern JS_FRIEND_API(JSObject*) | extern JS_FRIEND_API(JSObject*) | ||||
JS_FindCompilationScope(JSContext* cx, JS::HandleObject obj); | JS_FindCompilationScope(JSContext* cx, JS::HandleObject obj); | ||||
extern JS_FRIEND_API(JSFunction*) | extern JS_FRIEND_API(JSFunction*) | ||||
JS_GetObjectFunction(JSObject* obj); | JS_GetObjectFunction(JSObject* obj); | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
Show All 12 Lines | |||||
JS_NewObjectWithoutMetadata(JSContext* cx, const JSClass* clasp, JS::Handle<JSObject*> proto); | JS_NewObjectWithoutMetadata(JSContext* cx, const JSClass* clasp, JS::Handle<JSObject*> proto); | ||||
extern JS_FRIEND_API(uint32_t) | extern JS_FRIEND_API(uint32_t) | ||||
JS_ObjectCountDynamicSlots(JS::HandleObject obj); | JS_ObjectCountDynamicSlots(JS::HandleObject obj); | ||||
extern JS_FRIEND_API(size_t) | extern JS_FRIEND_API(size_t) | ||||
JS_SetProtoCalled(JSContext* cx); | JS_SetProtoCalled(JSContext* cx); | ||||
extern JS_FRIEND_API(bool) | |||||
JS_ImmutablePrototypesEnabled(); | |||||
extern JS_FRIEND_API(size_t) | extern JS_FRIEND_API(size_t) | ||||
JS_GetCustomIteratorCount(JSContext* cx); | JS_GetCustomIteratorCount(JSContext* cx); | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
JS_NondeterministicGetWeakMapKeys(JSContext* cx, JS::HandleObject obj, JS::MutableHandleObject ret); | JS_NondeterministicGetWeakMapKeys(JSContext* cx, JS::HandleObject obj, JS::MutableHandleObject ret); | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
JS_NondeterministicGetWeakSetKeys(JSContext* cx, JS::HandleObject obj, JS::MutableHandleObject ret); | JS_NondeterministicGetWeakSetKeys(JSContext* cx, JS::HandleObject obj, JS::MutableHandleObject ret); | ||||
Show All 17 Lines | |||||
*/ | */ | ||||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | ||||
JS_TraceShapeCycleCollectorChildren(JS::CallbackTracer* trc, JS::GCCellPtr shape); | JS_TraceShapeCycleCollectorChildren(JS::CallbackTracer* trc, JS::GCCellPtr shape); | ||||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | ||||
JS_TraceObjectGroupCycleCollectorChildren(JS::CallbackTracer* trc, JS::GCCellPtr group); | JS_TraceObjectGroupCycleCollectorChildren(JS::CallbackTracer* trc, JS::GCCellPtr group); | ||||
enum { | enum { | ||||
JS_TELEMETRY_GC_REASON, | JS_TELEMETRY_GC_REASON, | ||||
JS_TELEMETRY_GC_IS_COMPARTMENTAL, | JS_TELEMETRY_GC_IS_ZONE_GC, | ||||
JS_TELEMETRY_GC_MS, | JS_TELEMETRY_GC_MS, | ||||
JS_TELEMETRY_GC_BUDGET_MS, | JS_TELEMETRY_GC_BUDGET_MS, | ||||
JS_TELEMETRY_GC_ANIMATION_MS, | JS_TELEMETRY_GC_ANIMATION_MS, | ||||
JS_TELEMETRY_GC_MAX_PAUSE_MS, | JS_TELEMETRY_GC_MAX_PAUSE_MS, | ||||
JS_TELEMETRY_GC_MARK_MS, | JS_TELEMETRY_GC_MARK_MS, | ||||
JS_TELEMETRY_GC_SWEEP_MS, | JS_TELEMETRY_GC_SWEEP_MS, | ||||
JS_TELEMETRY_GC_COMPACT_MS, | |||||
JS_TELEMETRY_GC_MARK_ROOTS_MS, | JS_TELEMETRY_GC_MARK_ROOTS_MS, | ||||
JS_TELEMETRY_GC_MARK_GRAY_MS, | JS_TELEMETRY_GC_MARK_GRAY_MS, | ||||
JS_TELEMETRY_GC_SLICE_MS, | JS_TELEMETRY_GC_SLICE_MS, | ||||
JS_TELEMETRY_GC_SLOW_PHASE, | JS_TELEMETRY_GC_SLOW_PHASE, | ||||
JS_TELEMETRY_GC_MMU_50, | JS_TELEMETRY_GC_MMU_50, | ||||
JS_TELEMETRY_GC_RESET, | JS_TELEMETRY_GC_RESET, | ||||
JS_TELEMETRY_GC_RESET_REASON, | |||||
JS_TELEMETRY_GC_INCREMENTAL_DISABLED, | JS_TELEMETRY_GC_INCREMENTAL_DISABLED, | ||||
JS_TELEMETRY_GC_NON_INCREMENTAL, | JS_TELEMETRY_GC_NON_INCREMENTAL, | ||||
JS_TELEMETRY_GC_NON_INCREMENTAL_REASON, | |||||
JS_TELEMETRY_GC_SCC_SWEEP_TOTAL_MS, | JS_TELEMETRY_GC_SCC_SWEEP_TOTAL_MS, | ||||
JS_TELEMETRY_GC_SCC_SWEEP_MAX_PAUSE_MS, | JS_TELEMETRY_GC_SCC_SWEEP_MAX_PAUSE_MS, | ||||
JS_TELEMETRY_GC_MINOR_REASON, | JS_TELEMETRY_GC_MINOR_REASON, | ||||
JS_TELEMETRY_GC_MINOR_REASON_LONG, | JS_TELEMETRY_GC_MINOR_REASON_LONG, | ||||
JS_TELEMETRY_GC_MINOR_US, | JS_TELEMETRY_GC_MINOR_US, | ||||
JS_TELEMETRY_GC_NURSERY_BYTES, | |||||
JS_TELEMETRY_GC_PRETENURE_COUNT, | |||||
JS_TELEMETRY_DEPRECATED_LANGUAGE_EXTENSIONS_IN_CONTENT, | JS_TELEMETRY_DEPRECATED_LANGUAGE_EXTENSIONS_IN_CONTENT, | ||||
JS_TELEMETRY_DEPRECATED_LANGUAGE_EXTENSIONS_IN_ADDONS, | JS_TELEMETRY_DEPRECATED_LANGUAGE_EXTENSIONS_IN_ADDONS, | ||||
JS_TELEMETRY_ADDON_EXCEPTIONS | JS_TELEMETRY_ADDON_EXCEPTIONS, | ||||
JS_TELEMETRY_AOT_USAGE, | |||||
JS_TELEMETRY_END | |||||
}; | }; | ||||
typedef void | typedef void | ||||
(*JSAccumulateTelemetryDataCallback)(int id, uint32_t sample, const char* key); | (*JSAccumulateTelemetryDataCallback)(int id, uint32_t sample, const char* key); | ||||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | ||||
JS_SetAccumulateTelemetryCallback(JSRuntime* rt, JSAccumulateTelemetryDataCallback callback); | JS_SetAccumulateTelemetryCallback(JSContext* cx, JSAccumulateTelemetryDataCallback callback); | ||||
extern JS_FRIEND_API(bool) | |||||
JS_GetIsSecureContext(JSCompartment* compartment); | |||||
extern JS_FRIEND_API(JSPrincipals*) | extern JS_FRIEND_API(JSPrincipals*) | ||||
JS_GetCompartmentPrincipals(JSCompartment* compartment); | JS_GetCompartmentPrincipals(JSCompartment* compartment); | ||||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | ||||
JS_SetCompartmentPrincipals(JSCompartment* compartment, JSPrincipals* principals); | JS_SetCompartmentPrincipals(JSCompartment* compartment, JSPrincipals* principals); | ||||
extern JS_FRIEND_API(JSPrincipals*) | extern JS_FRIEND_API(JSPrincipals*) | ||||
Show All 24 Lines | JS_InitializePropertiesFromCompatibleNativeObject(JSContext* cx, | ||||
JS::HandleObject src); | JS::HandleObject src); | ||||
extern JS_FRIEND_API(JSString*) | extern JS_FRIEND_API(JSString*) | ||||
JS_BasicObjectToString(JSContext* cx, JS::HandleObject obj); | JS_BasicObjectToString(JSContext* cx, JS::HandleObject obj); | ||||
namespace js { | namespace js { | ||||
JS_FRIEND_API(bool) | JS_FRIEND_API(bool) | ||||
GetBuiltinClass(JSContext* cx, JS::HandleObject obj, ESClassValue* classValue); | GetBuiltinClass(JSContext* cx, JS::HandleObject obj, ESClass* cls); | ||||
JS_FRIEND_API(const char*) | JS_FRIEND_API(const char*) | ||||
ObjectClassName(JSContext* cx, JS::HandleObject obj); | ObjectClassName(JSContext* cx, JS::HandleObject obj); | ||||
JS_FRIEND_API(void) | JS_FRIEND_API(void) | ||||
ReportOverRecursed(JSContext* maybecx); | ReportOverRecursed(JSContext* maybecx); | ||||
JS_FRIEND_API(bool) | JS_FRIEND_API(bool) | ||||
AddRawValueRoot(JSContext* cx, JS::Value* vp, const char* name); | AddRawValueRoot(JSContext* cx, JS::Value* vp, const char* name); | ||||
JS_FRIEND_API(void) | JS_FRIEND_API(void) | ||||
RemoveRawValueRoot(JSContext* cx, JS::Value* vp); | RemoveRawValueRoot(JSContext* cx, JS::Value* vp); | ||||
JS_FRIEND_API(JSAtom*) | JS_FRIEND_API(JSAtom*) | ||||
GetPropertyNameFromPC(JSScript* script, jsbytecode* pc); | GetPropertyNameFromPC(JSScript* script, jsbytecode* pc); | ||||
#ifdef JS_DEBUG | #ifdef JS_DEBUG | ||||
/* | /* | ||||
* Routines to print out values during debugging. These are FRIEND_API to help | * Routines to print out values during debugging. These are FRIEND_API to help | ||||
* the debugger find them and to support temporarily hacking js::Dump* calls | * the debugger find them and to support temporarily hacking js::Dump* calls | ||||
* into other code. | * into other code. Note that there are overloads that do not require the FILE* | ||||
* parameter, which will default to stderr. | |||||
*/ | */ | ||||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | ||||
DumpString(JSString* str); | DumpString(JSString* str, FILE* fp); | ||||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | ||||
DumpAtom(JSAtom* atom); | DumpAtom(JSAtom* atom, FILE* fp); | ||||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | ||||
DumpObject(JSObject* obj); | DumpObject(JSObject* obj, FILE* fp); | ||||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | ||||
DumpChars(const char16_t* s, size_t n); | DumpChars(const char16_t* s, size_t n, FILE* fp); | ||||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | ||||
DumpValue(const JS::Value& val); | DumpValue(const JS::Value& val, FILE* fp); | ||||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | ||||
DumpId(jsid id); | DumpId(jsid id, FILE* fp); | ||||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | ||||
DumpInterpreterFrame(JSContext* cx, InterpreterFrame* start = nullptr); | DumpInterpreterFrame(JSContext* cx, FILE* fp, InterpreterFrame* start = nullptr); | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
DumpPC(JSContext* cx); | DumpPC(JSContext* cx, FILE* fp); | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
DumpScript(JSContext* cx, JSScript* scriptArg); | DumpScript(JSContext* cx, JSScript* scriptArg, FILE* fp); | ||||
// Versions for use directly in a debugger (default parameters are not handled | |||||
// well in gdb; built-in handles like stderr are not handled well in lldb.) | |||||
extern JS_FRIEND_API(void) DumpString(JSString* str); | |||||
extern JS_FRIEND_API(void) DumpAtom(JSAtom* atom); | |||||
extern JS_FRIEND_API(void) DumpObject(JSObject* obj); | |||||
extern JS_FRIEND_API(void) DumpChars(const char16_t* s, size_t n); | |||||
extern JS_FRIEND_API(void) DumpValue(const JS::Value& val); | |||||
extern JS_FRIEND_API(void) DumpId(jsid id); | |||||
extern JS_FRIEND_API(void) DumpInterpreterFrame(JSContext* cx, InterpreterFrame* start = nullptr); | |||||
extern JS_FRIEND_API(bool) DumpPC(JSContext* cx); | |||||
extern JS_FRIEND_API(bool) DumpScript(JSContext* cx, JSScript* scriptArg); | |||||
#endif | #endif | ||||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | ||||
DumpBacktrace(JSContext* cx, FILE* fp); | |||||
extern JS_FRIEND_API(void) | |||||
DumpBacktrace(JSContext* cx); | DumpBacktrace(JSContext* cx); | ||||
} // namespace js | } // namespace js | ||||
namespace JS { | namespace JS { | ||||
/** Exposed for DumpJSStack */ | /** Exposed for DumpJSStack */ | ||||
extern JS_FRIEND_API(char*) | extern JS_FRIEND_API(char*) | ||||
FormatStackDump(JSContext* cx, char* buf, bool showArgs, bool showLocals, bool showThisProps); | FormatStackDump(JSContext* cx, char* buf, bool showArgs, bool showLocals, bool showThisProps); | ||||
/** | |||||
* Set all of the uninitialized lexicals on an object to undefined. Return | |||||
* true if any lexicals were initialized and false otherwise. | |||||
* */ | |||||
extern JS_FRIEND_API(bool) | |||||
ForceLexicalInitialization(JSContext *cx, HandleObject obj); | |||||
} // namespace JS | } // namespace JS | ||||
/** | /** | ||||
* Copies all own properties from |obj| to |target|. |obj| must be a "native" | * Copies all own properties from |obj| to |target|. |obj| must be a "native" | ||||
* object (that is to say, normal-ish - not an Array or a Proxy). | * object (that is to say, normal-ish - not an Array or a Proxy). | ||||
* | * | ||||
* This function immediately enters a compartment, and does not impose any | * This function immediately enters a compartment, and does not impose any | ||||
* restrictions on the compartment of |cx|. | * restrictions on the compartment of |cx|. | ||||
Show All 16 Lines | |||||
} PropertyCopyBehavior; | } PropertyCopyBehavior; | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
JS_CopyPropertyFrom(JSContext* cx, JS::HandleId id, JS::HandleObject target, | JS_CopyPropertyFrom(JSContext* cx, JS::HandleId id, JS::HandleObject target, | ||||
JS::HandleObject obj, | JS::HandleObject obj, | ||||
PropertyCopyBehavior copyBehavior = CopyNonConfigurableAsIs); | PropertyCopyBehavior copyBehavior = CopyNonConfigurableAsIs); | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
JS_WrapPropertyDescriptor(JSContext* cx, JS::MutableHandle<JSPropertyDescriptor> desc); | JS_WrapPropertyDescriptor(JSContext* cx, JS::MutableHandle<JS::PropertyDescriptor> desc); | ||||
struct JSFunctionSpecWithHelp { | struct JSFunctionSpecWithHelp { | ||||
const char* name; | const char* name; | ||||
JSNative call; | JSNative call; | ||||
uint16_t nargs; | uint16_t nargs; | ||||
uint16_t flags; | uint16_t flags; | ||||
const JSJitInfo* jitInfo; | const JSJitInfo* jitInfo; | ||||
const char* usage; | const char* usage; | ||||
const char* help; | const char* help; | ||||
}; | }; | ||||
#define JS_FN_HELP(name,call,nargs,flags,usage,help) \ | #define JS_FN_HELP(name,call,nargs,flags,usage,help) \ | ||||
{name, call, nargs, (flags) | JSPROP_ENUMERATE | JSFUN_STUB_GSOPS, nullptr, usage, help} | {name, call, nargs, (flags) | JSPROP_ENUMERATE | JSFUN_STUB_GSOPS, nullptr, usage, help} | ||||
#define JS_INLINABLE_FN_HELP(name,call,nargs,flags,native,usage,help) \ | #define JS_INLINABLE_FN_HELP(name,call,nargs,flags,native,usage,help) \ | ||||
{name, call, nargs, (flags) | JSPROP_ENUMERATE | JSFUN_STUB_GSOPS, &js::jit::JitInfo_##native,\ | {name, call, nargs, (flags) | JSPROP_ENUMERATE | JSFUN_STUB_GSOPS, &js::jit::JitInfo_##native,\ | ||||
usage, help} | usage, help} | ||||
#define JS_FS_HELP_END \ | #define JS_FS_HELP_END \ | ||||
{nullptr, nullptr, 0, 0, nullptr, nullptr} | {nullptr, nullptr, 0, 0, nullptr, nullptr} | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
JS_DefineFunctionsWithHelp(JSContext* cx, JS::HandleObject obj, const JSFunctionSpecWithHelp* fs); | JS_DefineFunctionsWithHelp(JSContext* cx, JS::HandleObject obj, const JSFunctionSpecWithHelp* fs); | ||||
namespace js { | namespace js { | ||||
extern JS_FRIEND_DATA(const js::ClassOps) ProxyClassOps; | |||||
extern JS_FRIEND_DATA(const js::ClassExtension) ProxyClassExtension; | |||||
extern JS_FRIEND_DATA(const js::ObjectOps) ProxyObjectOps; | |||||
/* | /* | ||||
* Helper Macros for creating JSClasses that function as proxies. | * Helper Macros for creating JSClasses that function as proxies. | ||||
* | * | ||||
* NB: The macro invocation must be surrounded by braces, so as to | * NB: The macro invocation must be surrounded by braces, so as to | ||||
* allow for potential JSClass extensions. | * allow for potential JSClass extensions. | ||||
*/ | */ | ||||
#define PROXY_MAKE_EXT(isWrappedNative, objectMoved) \ | #define PROXY_MAKE_EXT(objectMoved) \ | ||||
{ \ | { \ | ||||
isWrappedNative, \ | |||||
js::proxy_WeakmapKeyDelegate, \ | js::proxy_WeakmapKeyDelegate, \ | ||||
objectMoved \ | objectMoved \ | ||||
} | } | ||||
#define PROXY_CLASS_WITH_EXT(name, flags, ext) \ | #define PROXY_CLASS_WITH_EXT(name, flags, extPtr) \ | ||||
{ \ | { \ | ||||
name, \ | name, \ | ||||
js::Class::NON_NATIVE | \ | js::Class::NON_NATIVE | \ | ||||
JSCLASS_IS_PROXY | \ | JSCLASS_IS_PROXY | \ | ||||
JSCLASS_DELAY_METADATA_CALLBACK | \ | JSCLASS_DELAY_METADATA_BUILDER | \ | ||||
flags, \ | flags, \ | ||||
nullptr, /* addProperty */ \ | &js::ProxyClassOps, \ | ||||
nullptr, /* delProperty */ \ | |||||
nullptr, /* getProperty */ \ | |||||
nullptr, /* setProperty */ \ | |||||
nullptr, /* enumerate */ \ | |||||
nullptr, /* resolve */ \ | |||||
nullptr, /* mayResolve */ \ | |||||
js::proxy_Finalize, /* finalize */ \ | |||||
nullptr, /* call */ \ | |||||
js::proxy_HasInstance, /* hasInstance */ \ | |||||
nullptr, /* construct */ \ | |||||
js::proxy_Trace, /* trace */ \ | |||||
JS_NULL_CLASS_SPEC, \ | JS_NULL_CLASS_SPEC, \ | ||||
ext, \ | extPtr, \ | ||||
{ \ | &js::ProxyObjectOps \ | ||||
js::proxy_LookupProperty, \ | |||||
js::proxy_DefineProperty, \ | |||||
js::proxy_HasProperty, \ | |||||
js::proxy_GetProperty, \ | |||||
js::proxy_SetProperty, \ | |||||
js::proxy_GetOwnPropertyDescriptor, \ | |||||
js::proxy_DeleteProperty, \ | |||||
js::proxy_Watch, js::proxy_Unwatch, \ | |||||
js::proxy_GetElements, \ | |||||
nullptr, /* enumerate */ \ | |||||
js::proxy_FunToString, \ | |||||
} \ | |||||
} | } | ||||
#define PROXY_CLASS_DEF(name, flags) \ | #define PROXY_CLASS_DEF(name, flags) \ | ||||
PROXY_CLASS_WITH_EXT(name, flags, \ | PROXY_CLASS_WITH_EXT(name, flags, &js::ProxyClassExtension) | ||||
PROXY_MAKE_EXT( \ | |||||
false, /* isWrappedNative */ \ | |||||
js::proxy_ObjectMoved \ | |||||
)) | |||||
/* | /* | ||||
* Proxy stubs, similar to JS_*Stub, for embedder proxy class definitions. | * Proxy stubs, similar to JS_*Stub, for embedder proxy class definitions. | ||||
* | * | ||||
* NB: Should not be called directly. | * NB: Should not be called directly. | ||||
*/ | */ | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
proxy_LookupProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleObject objp, | proxy_LookupProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleObject objp, | ||||
JS::MutableHandle<Shape*> propp); | JS::MutableHandle<Shape*> propp); | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
proxy_DefineProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, | proxy_DefineProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, | ||||
JS::Handle<JSPropertyDescriptor> desc, | JS::Handle<JS::PropertyDescriptor> desc, | ||||
JS::ObjectOpResult& result); | JS::ObjectOpResult& result); | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
proxy_HasProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, bool* foundp); | proxy_HasProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, bool* foundp); | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
proxy_GetProperty(JSContext* cx, JS::HandleObject obj, JS::HandleValue receiver, JS::HandleId id, | proxy_GetProperty(JSContext* cx, JS::HandleObject obj, JS::HandleValue receiver, JS::HandleId id, | ||||
JS::MutableHandleValue vp); | JS::MutableHandleValue vp); | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
proxy_SetProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::HandleValue bp, | proxy_SetProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::HandleValue bp, | ||||
JS::HandleValue receiver, JS::ObjectOpResult& result); | JS::HandleValue receiver, JS::ObjectOpResult& result); | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
proxy_GetOwnPropertyDescriptor(JSContext* cx, JS::HandleObject obj, JS::HandleId id, | proxy_GetOwnPropertyDescriptor(JSContext* cx, JS::HandleObject obj, JS::HandleId id, | ||||
JS::MutableHandle<JSPropertyDescriptor> desc); | JS::MutableHandle<JS::PropertyDescriptor> desc); | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
proxy_DeleteProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, | proxy_DeleteProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, | ||||
JS::ObjectOpResult& result); | JS::ObjectOpResult& result); | ||||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | ||||
proxy_Trace(JSTracer* trc, JSObject* obj); | proxy_Trace(JSTracer* trc, JSObject* obj); | ||||
extern JS_FRIEND_API(JSObject*) | extern JS_FRIEND_API(JSObject*) | ||||
proxy_WeakmapKeyDelegate(JSObject* obj); | proxy_WeakmapKeyDelegate(JSObject* obj); | ||||
Show All 40 Lines | public: | ||||
* Set |*src| and |*length| to refer to the source code for |filename|. | * Set |*src| and |*length| to refer to the source code for |filename|. | ||||
* On success, the caller owns the buffer to which |*src| points, and | * On success, the caller owns the buffer to which |*src| points, and | ||||
* should use JS_free to free it. | * should use JS_free to free it. | ||||
*/ | */ | ||||
virtual bool load(JSContext* cx, const char* filename, char16_t** src, size_t* length) = 0; | virtual bool load(JSContext* cx, const char* filename, char16_t** src, size_t* length) = 0; | ||||
}; | }; | ||||
/** | /** | ||||
* Have |rt| use |hook| to retrieve lazily-retrieved source code. See the | * Have |cx| use |hook| to retrieve lazily-retrieved source code. See the | ||||
* comments for SourceHook. The runtime takes ownership of the hook, and | * comments for SourceHook. The context takes ownership of the hook, and | ||||
* will delete it when the runtime itself is deleted, or when a new hook is | * will delete it when the context itself is deleted, or when a new hook is | ||||
* set. | * set. | ||||
*/ | */ | ||||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | ||||
SetSourceHook(JSRuntime* rt, mozilla::UniquePtr<SourceHook> hook); | SetSourceHook(JSContext* cx, mozilla::UniquePtr<SourceHook> hook); | ||||
/** Remove |rt|'s source hook, and return it. The caller now owns the hook. */ | /** Remove |cx|'s source hook, and return it. The caller now owns the hook. */ | ||||
extern JS_FRIEND_API(mozilla::UniquePtr<SourceHook>) | extern JS_FRIEND_API(mozilla::UniquePtr<SourceHook>) | ||||
ForgetSourceHook(JSRuntime* rt); | ForgetSourceHook(JSContext* cx); | ||||
extern JS_FRIEND_API(JS::Zone*) | extern JS_FRIEND_API(JS::Zone*) | ||||
GetCompartmentZone(JSCompartment* comp); | GetCompartmentZone(JSCompartment* comp); | ||||
typedef bool | typedef bool | ||||
(* PreserveWrapperCallback)(JSContext* cx, JSObject* obj); | (* PreserveWrapperCallback)(JSContext* cx, JSObject* obj); | ||||
typedef enum { | typedef enum { | ||||
CollectNurseryBeforeDump, | CollectNurseryBeforeDump, | ||||
IgnoreNurseryObjects | IgnoreNurseryObjects | ||||
} DumpHeapNurseryBehaviour; | } DumpHeapNurseryBehaviour; | ||||
/** | /** | ||||
* Dump the complete object graph of heap-allocated things. | * Dump the complete object graph of heap-allocated things. | ||||
* fp is the file for the dump output. | * fp is the file for the dump output. | ||||
*/ | */ | ||||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | ||||
DumpHeap(JSRuntime* rt, FILE* fp, DumpHeapNurseryBehaviour nurseryBehaviour); | DumpHeap(JSContext* cx, FILE* fp, DumpHeapNurseryBehaviour nurseryBehaviour); | ||||
#ifdef JS_OLD_GETTER_SETTER_METHODS | #ifdef JS_OLD_GETTER_SETTER_METHODS | ||||
JS_FRIEND_API(bool) obj_defineGetter(JSContext* cx, unsigned argc, JS::Value* vp); | JS_FRIEND_API(bool) obj_defineGetter(JSContext* cx, unsigned argc, JS::Value* vp); | ||||
JS_FRIEND_API(bool) obj_defineSetter(JSContext* cx, unsigned argc, JS::Value* vp); | JS_FRIEND_API(bool) obj_defineSetter(JSContext* cx, unsigned argc, JS::Value* vp); | ||||
#endif | #endif | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
IsSystemCompartment(JSCompartment* comp); | IsSystemCompartment(JSCompartment* comp); | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
IsSystemZone(JS::Zone* zone); | IsSystemZone(JS::Zone* zone); | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
IsAtomsCompartment(JSCompartment* comp); | IsAtomsCompartment(JSCompartment* comp); | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
IsAtomsZone(JS::Zone* zone); | IsAtomsZone(JS::Zone* zone); | ||||
struct WeakMapTracer | struct WeakMapTracer | ||||
{ | { | ||||
JSRuntime* runtime; | JSContext* context; | ||||
explicit WeakMapTracer(JSRuntime* rt) : runtime(rt) {} | explicit WeakMapTracer(JSContext* cx) : context(cx) {} | ||||
// Weak map tracer callback, called once for every binding of every | // Weak map tracer callback, called once for every binding of every | ||||
// weak map that was live at the time of the last garbage collection. | // weak map that was live at the time of the last garbage collection. | ||||
// | // | ||||
// m will be nullptr if the weak map is not contained in a JS Object. | // m will be nullptr if the weak map is not contained in a JS Object. | ||||
// | // | ||||
// The callback should not GC (and will assert in a debug build if it does so.) | // The callback should not GC (and will assert in a debug build if it does so.) | ||||
virtual void trace(JSObject* m, JS::GCCellPtr key, JS::GCCellPtr value) = 0; | virtual void trace(JSObject* m, JS::GCCellPtr key, JS::GCCellPtr value) = 0; | ||||
}; | }; | ||||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | ||||
TraceWeakMaps(WeakMapTracer* trc); | TraceWeakMaps(WeakMapTracer* trc); | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
AreGCGrayBitsValid(JSRuntime* rt); | AreGCGrayBitsValid(JSContext* cx); | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
ZoneGlobalsAreAllGray(JS::Zone* zone); | ZoneGlobalsAreAllGray(JS::Zone* zone); | ||||
typedef void | typedef void | ||||
(*GCThingCallback)(void* closure, JS::GCCellPtr thing); | (*GCThingCallback)(void* closure, JS::GCCellPtr thing); | ||||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | ||||
VisitGrayWrapperTargets(JS::Zone* zone, GCThingCallback callback, void* closure); | VisitGrayWrapperTargets(JS::Zone* zone, GCThingCallback callback, void* closure); | ||||
extern JS_FRIEND_API(JSObject*) | extern JS_FRIEND_API(JSObject*) | ||||
GetWeakmapKeyDelegate(JSObject* key); | GetWeakmapKeyDelegate(JSObject* key); | ||||
JS_FRIEND_API(JS::TraceKind) | |||||
GCThingTraceKind(void* thing); | |||||
/** | /** | ||||
* Invoke cellCallback on every gray JS_OBJECT in the given zone. | * Invoke cellCallback on every gray JSObject in the given zone. | ||||
*/ | */ | ||||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | ||||
IterateGrayObjects(JS::Zone* zone, GCThingCallback cellCallback, void* data); | IterateGrayObjects(JS::Zone* zone, GCThingCallback cellCallback, void* data); | ||||
/** | |||||
* Invoke cellCallback on every gray JSObject in the given zone while cycle | |||||
* collection is in progress. | |||||
*/ | |||||
extern JS_FRIEND_API(void) | |||||
IterateGrayObjectsUnderCC(JS::Zone* zone, GCThingCallback cellCallback, void* data); | |||||
#ifdef JS_HAS_CTYPES | #ifdef JS_HAS_CTYPES | ||||
extern JS_FRIEND_API(size_t) | extern JS_FRIEND_API(size_t) | ||||
SizeOfDataIfCDataObject(mozilla::MallocSizeOf mallocSizeOf, JSObject* obj); | SizeOfDataIfCDataObject(mozilla::MallocSizeOf mallocSizeOf, JSObject* obj); | ||||
#endif | #endif | ||||
extern JS_FRIEND_API(JSCompartment*) | extern JS_FRIEND_API(JSCompartment*) | ||||
GetAnyCompartmentInZone(JS::Zone* zone); | GetAnyCompartmentInZone(JS::Zone* zone); | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | |||||
GetObjectJSClass(JSObject* obj) | GetObjectJSClass(JSObject* obj) | ||||
{ | { | ||||
return js::Jsvalify(GetObjectClass(obj)); | return js::Jsvalify(GetObjectClass(obj)); | ||||
} | } | ||||
JS_FRIEND_API(const Class*) | JS_FRIEND_API(const Class*) | ||||
ProtoKeyToClass(JSProtoKey key); | ProtoKeyToClass(JSProtoKey key); | ||||
// Returns true if the standard class identified by |key| inherits from | |||||
// another standard class (in addition to Object) along its proto chain. | |||||
// | |||||
// In practice, this only returns true for Error subtypes. | |||||
inline bool | |||||
StandardClassIsDependent(JSProtoKey key) | |||||
{ | |||||
const Class* clasp = ProtoKeyToClass(key); | |||||
return clasp && clasp->spec.defined() && clasp->spec.dependent(); | |||||
} | |||||
// Returns the key for the class inherited by a given standard class (that | // Returns the key for the class inherited by a given standard class (that | ||||
// is to say, the prototype of this standard class's prototype). | // is to say, the prototype of this standard class's prototype). | ||||
// | // | ||||
// You must be sure that this corresponds to a standard class with a cached | // You must be sure that this corresponds to a standard class with a cached | ||||
// JSProtoKey before calling this function. In general |key| will match the | // JSProtoKey before calling this function. In general |key| will match the | ||||
// cached proto key, except in cases where multiple JSProtoKeys share a | // cached proto key, except in cases where multiple JSProtoKeys share a | ||||
// JSClass. | // JSClass. | ||||
inline JSProtoKey | inline JSProtoKey | ||||
ParentKeyForStandardClass(JSProtoKey key) | InheritanceProtoKeyForStandardClass(JSProtoKey key) | ||||
{ | { | ||||
// [Object] has nothing to inherit from. | // [Object] has nothing to inherit from. | ||||
if (key == JSProto_Object) | if (key == JSProto_Object) | ||||
return JSProto_Null; | return JSProto_Null; | ||||
// If we're dependent, return the key of the class we depend on. | // If we're ClassSpec defined return the proto key from that | ||||
if (StandardClassIsDependent(key)) | if (ProtoKeyToClass(key)->specDefined()) | ||||
return ProtoKeyToClass(key)->spec.parentKey(); | return ProtoKeyToClass(key)->specInheritanceProtoKey(); | ||||
// Otherwise, we inherit [Object]. | // Otherwise, we inherit [Object]. | ||||
return JSProto_Object; | return JSProto_Object; | ||||
} | } | ||||
JS_FRIEND_API(bool) | JS_FRIEND_API(bool) | ||||
IsFunctionObject(JSObject* obj); | IsFunctionObject(JSObject* obj); | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
SetFunctionNativeReserved(JSObject* fun, size_t which, const JS::Value& val); | SetFunctionNativeReserved(JSObject* fun, size_t which, const JS::Value& val); | ||||
JS_FRIEND_API(bool) | JS_FRIEND_API(bool) | ||||
FunctionHasNativeReserved(JSObject* fun); | FunctionHasNativeReserved(JSObject* fun); | ||||
JS_FRIEND_API(bool) | JS_FRIEND_API(bool) | ||||
GetObjectProto(JSContext* cx, JS::HandleObject obj, JS::MutableHandleObject proto); | GetObjectProto(JSContext* cx, JS::HandleObject obj, JS::MutableHandleObject proto); | ||||
extern JS_FRIEND_API(JSObject*) | |||||
GetStaticPrototype(JSObject* obj); | |||||
JS_FRIEND_API(bool) | JS_FRIEND_API(bool) | ||||
GetOriginalEval(JSContext* cx, JS::HandleObject scope, | GetOriginalEval(JSContext* cx, JS::HandleObject scope, | ||||
JS::MutableHandleObject eval); | JS::MutableHandleObject eval); | ||||
inline void* | inline void* | ||||
GetObjectPrivate(JSObject* obj) | GetObjectPrivate(JSObject* obj) | ||||
{ | { | ||||
MOZ_ASSERT(GetObjectClass(obj)->flags & JSCLASS_HAS_PRIVATE); | MOZ_ASSERT(GetObjectClass(obj)->flags & JSCLASS_HAS_PRIVATE); | ||||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
using shadow::String; | using shadow::String; | ||||
String* s = reinterpret_cast<String*>(str); | String* s = reinterpret_cast<String*>(str); | ||||
if (MOZ_UNLIKELY((s->flags & String::TYPE_FLAGS_MASK) == String::ROPE_FLAGS)) | if (MOZ_UNLIKELY((s->flags & String::TYPE_FLAGS_MASK) == String::ROPE_FLAGS)) | ||||
return StringToLinearStringSlow(cx, str); | return StringToLinearStringSlow(cx, str); | ||||
return reinterpret_cast<JSLinearString*>(str); | return reinterpret_cast<JSLinearString*>(str); | ||||
} | } | ||||
template<typename CharType> | |||||
MOZ_ALWAYS_INLINE void | |||||
CopyLinearStringChars(CharType* dest, JSLinearString* s, size_t len, size_t start = 0); | |||||
MOZ_ALWAYS_INLINE void | MOZ_ALWAYS_INLINE void | ||||
CopyLinearStringChars(char16_t* dest, JSLinearString* s, size_t len) | CopyLinearStringChars(char16_t* dest, JSLinearString* s, size_t len, size_t start = 0) | ||||
{ | { | ||||
MOZ_ASSERT(start + len <= GetLinearStringLength(s)); | |||||
JS::AutoCheckCannotGC nogc; | JS::AutoCheckCannotGC nogc; | ||||
if (LinearStringHasLatin1Chars(s)) { | if (LinearStringHasLatin1Chars(s)) { | ||||
const JS::Latin1Char* src = GetLatin1LinearStringChars(nogc, s); | const JS::Latin1Char* src = GetLatin1LinearStringChars(nogc, s); | ||||
for (size_t i = 0; i < len; i++) | for (size_t i = 0; i < len; i++) | ||||
dest[i] = src[i]; | dest[i] = src[start + i]; | ||||
} else { | } else { | ||||
const char16_t* src = GetTwoByteLinearStringChars(nogc, s); | const char16_t* src = GetTwoByteLinearStringChars(nogc, s); | ||||
mozilla::PodCopy(dest, src, len); | mozilla::PodCopy(dest, src + start, len); | ||||
} | } | ||||
} | } | ||||
MOZ_ALWAYS_INLINE void | |||||
CopyLinearStringChars(char* dest, JSLinearString* s, size_t len, size_t start = 0) | |||||
{ | |||||
MOZ_ASSERT(start + len <= GetLinearStringLength(s)); | |||||
JS::AutoCheckCannotGC nogc; | |||||
if (LinearStringHasLatin1Chars(s)) { | |||||
const JS::Latin1Char* src = GetLatin1LinearStringChars(nogc, s); | |||||
for (size_t i = 0; i < len; i++) | |||||
dest[i] = char(src[start + i]); | |||||
} else { | |||||
const char16_t* src = GetTwoByteLinearStringChars(nogc, s); | |||||
for (size_t i = 0; i < len; i++) | |||||
dest[i] = char(src[start + i]); | |||||
} | |||||
} | |||||
template<typename CharType> | |||||
inline bool | inline bool | ||||
CopyStringChars(JSContext* cx, char16_t* dest, JSString* s, size_t len) | CopyStringChars(JSContext* cx, CharType* dest, JSString* s, size_t len, size_t start = 0) | ||||
{ | { | ||||
JSLinearString* linear = StringToLinearString(cx, s); | JSLinearString* linear = StringToLinearString(cx, s); | ||||
if (!linear) | if (!linear) | ||||
return false; | return false; | ||||
CopyLinearStringChars(dest, linear, len); | CopyLinearStringChars(dest, linear, len, start); | ||||
return true; | return true; | ||||
} | } | ||||
inline void | inline void | ||||
CopyFlatStringChars(char16_t* dest, JSFlatString* s, size_t len) | CopyFlatStringChars(char16_t* dest, JSFlatString* s, size_t len) | ||||
{ | { | ||||
CopyLinearStringChars(dest, FlatStringToLinearString(s), len); | CopyLinearStringChars(dest, FlatStringToLinearString(s), len); | ||||
} | } | ||||
Show All 24 Lines | |||||
JS_FRIEND_API(bool) | JS_FRIEND_API(bool) | ||||
AppendUnique(JSContext* cx, JS::AutoIdVector& base, JS::AutoIdVector& others); | AppendUnique(JSContext* cx, JS::AutoIdVector& base, JS::AutoIdVector& others); | ||||
JS_FRIEND_API(bool) | JS_FRIEND_API(bool) | ||||
StringIsArrayIndex(JSLinearString* str, uint32_t* indexp); | StringIsArrayIndex(JSLinearString* str, uint32_t* indexp); | ||||
JS_FRIEND_API(void) | JS_FRIEND_API(void) | ||||
SetPreserveWrapperCallback(JSRuntime* rt, PreserveWrapperCallback callback); | SetPreserveWrapperCallback(JSContext* cx, PreserveWrapperCallback callback); | ||||
JS_FRIEND_API(bool) | JS_FRIEND_API(bool) | ||||
IsObjectInContextCompartment(JSObject* obj, const JSContext* cx); | IsObjectInContextCompartment(JSObject* obj, const JSContext* cx); | ||||
/* | /* | ||||
* NB: these flag bits are encoded into the bytecode stream in the immediate | |||||
* operand of JSOP_ITER, so don't change them without advancing vm/Xdr.h's | |||||
* XDR_BYTECODE_VERSION. | |||||
* NB: keep these in sync with the copy in builtin/SelfHostingDefines.h. | * NB: keep these in sync with the copy in builtin/SelfHostingDefines.h. | ||||
* The first three are omitted because they shouldn't be used in new code. | * The first three are omitted because they shouldn't be used in new code. | ||||
*/ | */ | ||||
#define JSITER_ENUMERATE 0x1 /* for-in compatible hidden default iterator */ | #define JSITER_ENUMERATE 0x1 /* for-in compatible hidden default iterator */ | ||||
#define JSITER_FOREACH 0x2 /* get obj[key] for each property */ | #define JSITER_FOREACH 0x2 /* get obj[key] for each property */ | ||||
#define JSITER_KEYVALUE 0x4 /* obsolete destructuring for-in wants [key, value] */ | #define JSITER_KEYVALUE 0x4 /* obsolete destructuring for-in wants [key, value] */ | ||||
#define JSITER_OWNONLY 0x8 /* iterate over obj's own properties only */ | #define JSITER_OWNONLY 0x8 /* iterate over obj's own properties only */ | ||||
#define JSITER_HIDDEN 0x10 /* also enumerate non-enumerable properties */ | #define JSITER_HIDDEN 0x10 /* also enumerate non-enumerable properties */ | ||||
#define JSITER_SYMBOLS 0x20 /* also include symbol property keys */ | #define JSITER_SYMBOLS 0x20 /* also include symbol property keys */ | ||||
#define JSITER_SYMBOLSONLY 0x40 /* exclude string property keys */ | #define JSITER_SYMBOLSONLY 0x40 /* exclude string property keys */ | ||||
JS_FRIEND_API(bool) | JS_FRIEND_API(bool) | ||||
RunningWithTrustedPrincipals(JSContext* cx); | RunningWithTrustedPrincipals(JSContext* cx); | ||||
inline uintptr_t | inline uintptr_t | ||||
GetNativeStackLimit(JSContext* cx, StackKind kind, int extraAllowance = 0) | GetNativeStackLimit(JSContext* cx, StackKind kind, int extraAllowance = 0) | ||||
{ | { | ||||
PerThreadDataFriendFields* mainThread = | uintptr_t limit = ContextFriendFields::get(cx)->nativeStackLimit[kind]; | ||||
PerThreadDataFriendFields::getMainThread(GetRuntime(cx)); | |||||
uintptr_t limit = mainThread->nativeStackLimit[kind]; | |||||
#if JS_STACK_GROWTH_DIRECTION > 0 | #if JS_STACK_GROWTH_DIRECTION > 0 | ||||
limit += extraAllowance; | limit += extraAllowance; | ||||
#else | #else | ||||
limit -= extraAllowance; | limit -= extraAllowance; | ||||
#endif | #endif | ||||
return limit; | return limit; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | |||||
* content within the buffer would be set to the length out-param. | * content within the buffer would be set to the length out-param. | ||||
* | * | ||||
* In case of out-of-memory, this function returns nullptr and does not set any | * In case of out-of-memory, this function returns nullptr and does not set any | ||||
* value to the length out-param. | * value to the length out-param. | ||||
*/ | */ | ||||
JS_FRIEND_API(char*) | JS_FRIEND_API(char*) | ||||
GetCodeCoverageSummary(JSContext* cx, size_t* length); | GetCodeCoverageSummary(JSContext* cx, size_t* length); | ||||
JS_FRIEND_API(bool) | |||||
ContextHasOutstandingRequests(const JSContext* cx); | |||||
typedef void | typedef void | ||||
(* ActivityCallback)(void* arg, bool active); | (* ActivityCallback)(void* arg, bool active); | ||||
/** | /** | ||||
* Sets a callback that is run whenever the runtime goes idle - the | * Sets a callback that is run whenever the runtime goes idle - the | ||||
* last active request ceases - and begins activity - when it was | * last active request ceases - and begins activity - when it was | ||||
* idle and a request begins. | * idle and a request begins. | ||||
*/ | */ | ||||
JS_FRIEND_API(void) | JS_FRIEND_API(void) | ||||
SetActivityCallback(JSRuntime* rt, ActivityCallback cb, void* arg); | SetActivityCallback(JSContext* cx, ActivityCallback cb, void* arg); | ||||
typedef bool | typedef bool | ||||
(* DOMInstanceClassHasProtoAtDepth)(const Class* instanceClass, | (* DOMInstanceClassHasProtoAtDepth)(const Class* instanceClass, | ||||
uint32_t protoID, uint32_t depth); | uint32_t protoID, uint32_t depth); | ||||
struct JSDOMCallbacks { | struct JSDOMCallbacks { | ||||
DOMInstanceClassHasProtoAtDepth instanceClassMatchesProto; | DOMInstanceClassHasProtoAtDepth instanceClassMatchesProto; | ||||
}; | }; | ||||
typedef struct JSDOMCallbacks DOMCallbacks; | typedef struct JSDOMCallbacks DOMCallbacks; | ||||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | ||||
SetDOMCallbacks(JSRuntime* rt, const DOMCallbacks* callbacks); | SetDOMCallbacks(JSContext* cx, const DOMCallbacks* callbacks); | ||||
extern JS_FRIEND_API(const DOMCallbacks*) | extern JS_FRIEND_API(const DOMCallbacks*) | ||||
GetDOMCallbacks(JSRuntime* rt); | GetDOMCallbacks(JSContext* cx); | ||||
extern JS_FRIEND_API(JSObject*) | extern JS_FRIEND_API(JSObject*) | ||||
GetTestingFunctions(JSContext* cx); | GetTestingFunctions(JSContext* cx); | ||||
/** | /** | ||||
* Helper to convert FreeOp to JSFreeOp when the definition of FreeOp is not | * Helper to convert FreeOp to JSFreeOp when the definition of FreeOp is not | ||||
* available and the compiler does not know that FreeOp inherits from | * available and the compiler does not know that FreeOp inherits from | ||||
* JSFreeOp. | * JSFreeOp. | ||||
*/ | */ | ||||
inline JSFreeOp* | inline JSFreeOp* | ||||
CastToJSFreeOp(FreeOp* fop) | CastToJSFreeOp(FreeOp* fop) | ||||
{ | { | ||||
return reinterpret_cast<JSFreeOp*>(fop); | return reinterpret_cast<JSFreeOp*>(fop); | ||||
} | } | ||||
/* Implemented in jsexn.cpp. */ | /* Implemented in jsexn.cpp. */ | ||||
/** | /** | ||||
* Get an error type name from a JSExnType constant. | * Get an error type name from a JSExnType constant. | ||||
* Returns nullptr for invalid arguments and JSEXN_INTERNALERR | * Returns nullptr for invalid arguments and JSEXN_INTERNALERR | ||||
*/ | */ | ||||
extern JS_FRIEND_API(JSFlatString*) | extern JS_FRIEND_API(JSFlatString*) | ||||
GetErrorTypeName(JSRuntime* rt, int16_t exnType); | GetErrorTypeName(JSContext* cx, int16_t exnType); | ||||
#ifdef JS_DEBUG | #ifdef JS_DEBUG | ||||
extern JS_FRIEND_API(unsigned) | extern JS_FRIEND_API(unsigned) | ||||
GetEnterCompartmentDepth(JSContext* cx); | GetEnterCompartmentDepth(JSContext* cx); | ||||
#endif | #endif | ||||
class RegExpGuard; | class RegExpGuard; | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
struct ExpandoAndGeneration { | struct ExpandoAndGeneration { | ||||
ExpandoAndGeneration() | ExpandoAndGeneration() | ||||
: expando(JS::UndefinedValue()), | : expando(JS::UndefinedValue()), | ||||
generation(0) | generation(0) | ||||
{} | {} | ||||
void Unlink() | void OwnerUnlinked() | ||||
{ | { | ||||
++generation; | ++generation; | ||||
expando.setUndefined(); | |||||
} | } | ||||
static size_t offsetOfExpando() | static size_t offsetOfExpando() | ||||
{ | { | ||||
return offsetof(ExpandoAndGeneration, expando); | return offsetof(ExpandoAndGeneration, expando); | ||||
} | } | ||||
static size_t offsetOfGeneration() | static size_t offsetOfGeneration() | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | |||||
* This class provides safe access to a string's chars across a GC. Once | * This class provides safe access to a string's chars across a GC. Once | ||||
* we allocate strings and chars in the nursery (bug 903519), this class | * we allocate strings and chars in the nursery (bug 903519), this class | ||||
* will have to make a copy of the string's chars if they are allocated | * will have to make a copy of the string's chars if they are allocated | ||||
* in the nursery, so it's best to avoid using this class unless you really | * in the nursery, so it's best to avoid using this class unless you really | ||||
* need it. It's usually more efficient to use the latin1Chars/twoByteChars | * need it. It's usually more efficient to use the latin1Chars/twoByteChars | ||||
* JSString methods and often the code can be rewritten so that only indexes | * JSString methods and often the code can be rewritten so that only indexes | ||||
* instead of char pointers are used in parts of the code that can GC. | * instead of char pointers are used in parts of the code that can GC. | ||||
*/ | */ | ||||
class MOZ_STACK_CLASS AutoStableStringChars | class MOZ_STACK_CLASS JS_FRIEND_API(AutoStableStringChars) | ||||
{ | { | ||||
/* | |||||
* When copying string char, use this many bytes of inline storage. This is | |||||
* chosen to allow the inline string types to be copied without allocating. | |||||
* This is asserted in AutoStableStringChars::allocOwnChars. | |||||
*/ | |||||
static const size_t InlineCapacity = 24; | |||||
/* Ensure the string is kept alive while we're using its chars. */ | /* Ensure the string is kept alive while we're using its chars. */ | ||||
JS::RootedString s_; | JS::RootedString s_; | ||||
union { | union { | ||||
const char16_t* twoByteChars_; | const char16_t* twoByteChars_; | ||||
const JS::Latin1Char* latin1Chars_; | const JS::Latin1Char* latin1Chars_; | ||||
}; | }; | ||||
mozilla::Maybe<Vector<uint8_t, InlineCapacity>> ownChars_; | |||||
enum State { Uninitialized, Latin1, TwoByte }; | enum State { Uninitialized, Latin1, TwoByte }; | ||||
State state_; | State state_; | ||||
bool ownsChars_; | |||||
public: | public: | ||||
explicit AutoStableStringChars(JSContext* cx) | explicit AutoStableStringChars(JSContext* cx) | ||||
: s_(cx), state_(Uninitialized), ownsChars_(false) | : s_(cx), state_(Uninitialized) | ||||
{} | {} | ||||
~AutoStableStringChars(); | |||||
MOZ_WARN_UNUSED_RESULT | MOZ_MUST_USE | ||||
bool init(JSContext* cx, JSString* s); | bool init(JSContext* cx, JSString* s); | ||||
/* Like init(), but Latin1 chars are inflated to TwoByte. */ | /* Like init(), but Latin1 chars are inflated to TwoByte. */ | ||||
MOZ_WARN_UNUSED_RESULT | MOZ_MUST_USE | ||||
bool initTwoByte(JSContext* cx, JSString* s); | bool initTwoByte(JSContext* cx, JSString* s); | ||||
bool isLatin1() const { return state_ == Latin1; } | bool isLatin1() const { return state_ == Latin1; } | ||||
bool isTwoByte() const { return state_ == TwoByte; } | bool isTwoByte() const { return state_ == TwoByte; } | ||||
const char16_t* twoByteChars() const { | const char16_t* twoByteChars() const { | ||||
MOZ_ASSERT(state_ == TwoByte); | MOZ_ASSERT(state_ == TwoByte); | ||||
return twoByteChars_; | return twoByteChars_; | ||||
} | } | ||||
mozilla::Range<const JS::Latin1Char> latin1Range() const { | mozilla::Range<const JS::Latin1Char> latin1Range() const { | ||||
MOZ_ASSERT(state_ == Latin1); | MOZ_ASSERT(state_ == Latin1); | ||||
return mozilla::Range<const JS::Latin1Char>(latin1Chars_, | return mozilla::Range<const JS::Latin1Char>(latin1Chars_, | ||||
GetStringLength(s_)); | GetStringLength(s_)); | ||||
} | } | ||||
mozilla::Range<const char16_t> twoByteRange() const { | mozilla::Range<const char16_t> twoByteRange() const { | ||||
MOZ_ASSERT(state_ == TwoByte); | MOZ_ASSERT(state_ == TwoByte); | ||||
return mozilla::Range<const char16_t>(twoByteChars_, | return mozilla::Range<const char16_t>(twoByteChars_, | ||||
GetStringLength(s_)); | GetStringLength(s_)); | ||||
} | } | ||||
/* If we own the chars, transfer ownership to the caller. */ | /* If we own the chars, transfer ownership to the caller. */ | ||||
bool maybeGiveOwnershipToCaller() { | bool maybeGiveOwnershipToCaller() { | ||||
MOZ_ASSERT(state_ != Uninitialized); | MOZ_ASSERT(state_ != Uninitialized); | ||||
if (!ownsChars_) | if (!ownChars_.isSome() || !ownChars_->extractRawBuffer()) | ||||
return false; | return false; | ||||
state_ = Uninitialized; | state_ = Uninitialized; | ||||
ownsChars_ = false; | ownChars_.reset(); | ||||
return true; | return true; | ||||
} | } | ||||
private: | private: | ||||
AutoStableStringChars(const AutoStableStringChars& other) = delete; | AutoStableStringChars(const AutoStableStringChars& other) = delete; | ||||
void operator=(const AutoStableStringChars& other) = delete; | void operator=(const AutoStableStringChars& other) = delete; | ||||
}; | |||||
/** | bool baseIsInline(JS::Handle<JSLinearString*> linearString); | ||||
* Creates a string of the form |ErrorType: ErrorMessage| for a JSErrorReport, | template <typename T> T* allocOwnChars(JSContext* cx, size_t count); | ||||
* which generally matches the toString() behavior of an ErrorObject. | bool copyLatin1Chars(JSContext* cx, JS::Handle<JSLinearString*> linearString); | ||||
*/ | bool copyTwoByteChars(JSContext* cx, JS::Handle<JSLinearString*> linearString); | ||||
extern JS_FRIEND_API(JSString*) | bool copyAndInflateLatin1Chars(JSContext*, JS::Handle<JSLinearString*> linearString); | ||||
ErrorReportToString(JSContext* cx, JSErrorReport* reportp); | }; | ||||
struct MOZ_STACK_CLASS JS_FRIEND_API(ErrorReport) | struct MOZ_STACK_CLASS JS_FRIEND_API(ErrorReport) | ||||
{ | { | ||||
explicit ErrorReport(JSContext* cx); | explicit ErrorReport(JSContext* cx); | ||||
~ErrorReport(); | ~ErrorReport(); | ||||
bool init(JSContext* cx, JS::HandleValue exn); | enum SniffingBehavior { | ||||
WithSideEffects, | |||||
NoSideEffects | |||||
}; | |||||
/** | |||||
* Generate a JSErrorReport from the provided thrown value. | |||||
* | |||||
* If the value is a (possibly wrapped) Error object, the JSErrorReport will | |||||
* be exactly initialized from the Error object's information, without | |||||
* observable side effects. (The Error object's JSErrorReport is reused, if | |||||
* it has one.) | |||||
* | |||||
* Otherwise various attempts are made to derive JSErrorReport information | |||||
* from |exn| and from the current execution state. This process is | |||||
* *definitely* inconsistent with any standard, and particulars of the | |||||
* behavior implemented here generally shouldn't be relied upon. | |||||
* | |||||
* If the value of |sniffingBehavior| is |WithSideEffects|, some of these | |||||
* attempts *may* invoke user-configurable behavior when |exn| is an object: | |||||
* converting |exn| to a string, detecting and getting properties on |exn|, | |||||
* accessing |exn|'s prototype chain, and others are possible. Users *must* | |||||
* tolerate |ErrorReport::init| potentially having arbitrary effects. Any | |||||
* exceptions thrown by these operations will be caught and silently | |||||
* ignored, and "default" values will be substituted into the JSErrorReport. | |||||
* | |||||
* But if the value of |sniffingBehavior| is |NoSideEffects|, these attempts | |||||
* *will not* invoke any observable side effects. The JSErrorReport will | |||||
* simply contain fewer, less precise details. | |||||
* | |||||
* Unlike some functions involved in error handling, this function adheres | |||||
* to the usual JSAPI return value error behavior. | |||||
*/ | |||||
bool init(JSContext* cx, JS::HandleValue exn, | |||||
SniffingBehavior sniffingBehavior); | |||||
JSErrorReport* report() | JSErrorReport* report() | ||||
{ | { | ||||
return reportp; | return reportp; | ||||
} | } | ||||
const char* message() | const JS::ConstUTF8CharsZ toStringResult() | ||||
{ | { | ||||
return message_; | return toStringResult_; | ||||
} | } | ||||
private: | private: | ||||
// More or less an equivalent of JS_ReportErrorNumber/js::ReportErrorNumberVA | // More or less an equivalent of JS_ReportErrorNumber/js::ReportErrorNumberVA | ||||
// but fills in an ErrorReport instead of reporting it. Uses varargs to | // but fills in an ErrorReport instead of reporting it. Uses varargs to | ||||
// make it simpler to call js::ExpandErrorArgumentsVA. | // make it simpler to call js::ExpandErrorArgumentsVA. | ||||
// | // | ||||
// Returns false if we fail to actually populate the ErrorReport | // Returns false if we fail to actually populate the ErrorReport | ||||
// for some reason (probably out of memory). | // for some reason (probably out of memory). | ||||
bool populateUncaughtExceptionReport(JSContext* cx, ...); | bool populateUncaughtExceptionReportUTF8(JSContext* cx, ...); | ||||
bool populateUncaughtExceptionReportVA(JSContext* cx, va_list ap); | bool populateUncaughtExceptionReportUTF8VA(JSContext* cx, va_list ap); | ||||
// Reports exceptions from add-on scopes to telementry. | // Reports exceptions from add-on scopes to telementry. | ||||
void ReportAddonExceptionToTelementry(JSContext* cx); | void ReportAddonExceptionToTelementry(JSContext* cx); | ||||
// We may have a provided JSErrorReport, so need a way to represent that. | // We may have a provided JSErrorReport, so need a way to represent that. | ||||
JSErrorReport* reportp; | JSErrorReport* reportp; | ||||
// And we may have a message. | |||||
const char* message_; | |||||
// Or we may need to synthesize a JSErrorReport one of our own. | // Or we may need to synthesize a JSErrorReport one of our own. | ||||
JSErrorReport ownedReport; | JSErrorReport ownedReport; | ||||
// Or a message of our own. If this is non-null, we need to clean up both | |||||
// it and ownedReport. | |||||
char* ownedMessage; | |||||
// And we have a string to maybe keep alive that has pointers into | // And we have a string to maybe keep alive that has pointers into | ||||
// it from ownedReport. | // it from ownedReport. | ||||
JS::RootedString str; | JS::RootedString str; | ||||
// And keep its chars alive too. | // And keep its chars alive too. | ||||
AutoStableStringChars strChars; | AutoStableStringChars strChars; | ||||
// And we need to root our exception value. | // And we need to root our exception value. | ||||
JS::RootedObject exnObject; | JS::RootedObject exnObject; | ||||
// And possibly some byte storage for our message_. | |||||
JSAutoByteString bytesStorage; | |||||
// And for our filename. | // And for our filename. | ||||
JSAutoByteString filename; | JSAutoByteString filename; | ||||
// True if we need to free message_ and the stuff in ownedReport | // We may have a result of error.toString(). | ||||
bool ownsMessageAndReport; | // FIXME: We should not call error.toString(), since it could have side | ||||
// effect (see bug 633623). | |||||
JS::ConstUTF8CharsZ toStringResult_; | |||||
JSAutoByteString toStringResultBytesStorage; | |||||
}; | }; | ||||
/* Implemented in vm/StructuredClone.cpp. */ | /* Implemented in vm/StructuredClone.cpp. */ | ||||
extern JS_FRIEND_API(uint64_t) | extern JS_FRIEND_API(uint64_t) | ||||
GetSCOffset(JSStructuredCloneWriter* writer); | GetSCOffset(JSStructuredCloneWriter* writer); | ||||
namespace Scalar { | namespace Scalar { | ||||
Show All 15 Lines | enum Type { | ||||
/** | /** | ||||
* Special type that is a uint8_t, but assignments are clamped to [0, 256). | * Special type that is a uint8_t, but assignments are clamped to [0, 256). | ||||
* Treat the raw data type as a uint8_t. | * Treat the raw data type as a uint8_t. | ||||
*/ | */ | ||||
Uint8Clamped, | Uint8Clamped, | ||||
/** | /** | ||||
* SIMD types don't have their own TypedArray equivalent, for now. | * Types that don't have their own TypedArray equivalent, for now. | ||||
*/ | */ | ||||
MaxTypedArrayViewType, | MaxTypedArrayViewType, | ||||
Int64, | |||||
Float32x4, | Float32x4, | ||||
Int8x16, | |||||
Int16x8, | |||||
Int32x4 | Int32x4 | ||||
}; | }; | ||||
static inline size_t | static inline size_t | ||||
byteSize(Type atype) | byteSize(Type atype) | ||||
{ | { | ||||
switch (atype) { | switch (atype) { | ||||
case Int8: | case Int8: | ||||
case Uint8: | case Uint8: | ||||
case Uint8Clamped: | case Uint8Clamped: | ||||
return 1; | return 1; | ||||
case Int16: | case Int16: | ||||
case Uint16: | case Uint16: | ||||
return 2; | return 2; | ||||
case Int32: | case Int32: | ||||
case Uint32: | case Uint32: | ||||
case Float32: | case Float32: | ||||
return 4; | return 4; | ||||
case Int64: | |||||
case Float64: | case Float64: | ||||
return 8; | return 8; | ||||
case Int8x16: | |||||
case Int16x8: | |||||
case Int32x4: | case Int32x4: | ||||
case Float32x4: | case Float32x4: | ||||
return 16; | return 16; | ||||
default: | default: | ||||
MOZ_CRASH("invalid scalar type"); | MOZ_CRASH("invalid scalar type"); | ||||
} | } | ||||
} | } | ||||
static inline bool | static inline bool | ||||
isSignedIntType(Type atype) { | isSignedIntType(Type atype) { | ||||
switch (atype) { | switch (atype) { | ||||
case Int8: | case Int8: | ||||
case Int16: | case Int16: | ||||
case Int32: | case Int32: | ||||
case Int64: | |||||
case Int8x16: | |||||
case Int16x8: | |||||
case Int32x4: | case Int32x4: | ||||
return true; | return true; | ||||
case Uint8: | case Uint8: | ||||
case Uint8Clamped: | case Uint8Clamped: | ||||
case Uint16: | case Uint16: | ||||
case Uint32: | case Uint32: | ||||
case Float32: | case Float32: | ||||
case Float64: | case Float64: | ||||
Show All 9 Lines | isSimdType(Type atype) { | ||||
switch (atype) { | switch (atype) { | ||||
case Int8: | case Int8: | ||||
case Uint8: | case Uint8: | ||||
case Uint8Clamped: | case Uint8Clamped: | ||||
case Int16: | case Int16: | ||||
case Uint16: | case Uint16: | ||||
case Int32: | case Int32: | ||||
case Uint32: | case Uint32: | ||||
case Int64: | |||||
case Float32: | case Float32: | ||||
case Float64: | case Float64: | ||||
return false; | return false; | ||||
case Int8x16: | |||||
case Int16x8: | |||||
case Int32x4: | case Int32x4: | ||||
case Float32x4: | case Float32x4: | ||||
return true; | return true; | ||||
case MaxTypedArrayViewType: | case MaxTypedArrayViewType: | ||||
break; | break; | ||||
} | } | ||||
MOZ_CRASH("invalid scalar type"); | MOZ_CRASH("invalid scalar type"); | ||||
} | } | ||||
static inline size_t | static inline size_t | ||||
scalarByteSize(Type atype) { | scalarByteSize(Type atype) { | ||||
switch (atype) { | switch (atype) { | ||||
case Int8x16: | |||||
return 1; | |||||
case Int16x8: | |||||
return 2; | |||||
case Int32x4: | case Int32x4: | ||||
case Float32x4: | case Float32x4: | ||||
return 4; | return 4; | ||||
case Int8: | case Int8: | ||||
case Uint8: | case Uint8: | ||||
case Uint8Clamped: | case Uint8Clamped: | ||||
case Int16: | case Int16: | ||||
case Uint16: | case Uint16: | ||||
case Int32: | case Int32: | ||||
case Uint32: | case Uint32: | ||||
case Int64: | |||||
case Float32: | case Float32: | ||||
case Float64: | case Float64: | ||||
case MaxTypedArrayViewType: | case MaxTypedArrayViewType: | ||||
break; | break; | ||||
} | } | ||||
MOZ_CRASH("invalid simd type"); | MOZ_CRASH("invalid simd type"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | |||||
extern JS_FRIEND_API(JSObject*) | extern JS_FRIEND_API(JSObject*) | ||||
JS_NewFloat32ArrayWithBuffer(JSContext* cx, JS::HandleObject arrayBuffer, | JS_NewFloat32ArrayWithBuffer(JSContext* cx, JS::HandleObject arrayBuffer, | ||||
uint32_t byteOffset, int32_t length); | uint32_t byteOffset, int32_t length); | ||||
extern JS_FRIEND_API(JSObject*) | extern JS_FRIEND_API(JSObject*) | ||||
JS_NewFloat64ArrayWithBuffer(JSContext* cx, JS::HandleObject arrayBuffer, | JS_NewFloat64ArrayWithBuffer(JSContext* cx, JS::HandleObject arrayBuffer, | ||||
uint32_t byteOffset, int32_t length); | uint32_t byteOffset, int32_t length); | ||||
/** | /** | ||||
* Create a new SharedArrayBuffer with the given byte length. | * Create a new SharedArrayBuffer with the given byte length. This | ||||
* may only be called if | |||||
* JS::CompartmentCreationOptionsRef(cx).getSharedMemoryAndAtomicsEnabled() is | |||||
* true. | |||||
*/ | */ | ||||
extern JS_FRIEND_API(JSObject*) | extern JS_FRIEND_API(JSObject*) | ||||
JS_NewSharedArrayBuffer(JSContext* cx, uint32_t nbytes); | JS_NewSharedArrayBuffer(JSContext* cx, uint32_t nbytes); | ||||
/** | /** | ||||
* Create a new ArrayBuffer with the given byte length. | * Create a new ArrayBuffer with the given byte length. | ||||
*/ | */ | ||||
extern JS_FRIEND_API(JSObject*) | extern JS_FRIEND_API(JSObject*) | ||||
▲ Show 20 Lines • Show All 219 Lines • ▼ Show 20 Lines | |||||
extern JS_FRIEND_API(uint32_t) | extern JS_FRIEND_API(uint32_t) | ||||
JS_GetArrayBufferByteLength(JSObject* obj); | JS_GetArrayBufferByteLength(JSObject* obj); | ||||
extern JS_FRIEND_API(uint32_t) | extern JS_FRIEND_API(uint32_t) | ||||
JS_GetSharedArrayBufferByteLength(JSObject* obj); | JS_GetSharedArrayBufferByteLength(JSObject* obj); | ||||
/** | /** | ||||
* Return true if the arrayBuffer contains any data. This will return false for | * Return true if the arrayBuffer contains any data. This will return false for | ||||
* ArrayBuffer.prototype and neutered ArrayBuffers. | * ArrayBuffer.prototype and detached ArrayBuffers. | ||||
* | * | ||||
* |obj| must have passed a JS_IsArrayBufferObject test, or somehow be known | * |obj| must have passed a JS_IsArrayBufferObject test, or somehow be known | ||||
* that it would pass such a test: it is an ArrayBuffer or a wrapper of an | * that it would pass such a test: it is an ArrayBuffer or a wrapper of an | ||||
* ArrayBuffer, and the unwrapping will succeed. | * ArrayBuffer, and the unwrapping will succeed. | ||||
*/ | */ | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
JS_ArrayBufferHasData(JSObject* obj); | JS_ArrayBufferHasData(JSObject* obj); | ||||
▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* Same as above, but for any kind of ArrayBufferView. Prefer the type-specific | * Same as above, but for any kind of ArrayBufferView. Prefer the type-specific | ||||
* versions when possible. | * versions when possible. | ||||
*/ | */ | ||||
extern JS_FRIEND_API(void*) | extern JS_FRIEND_API(void*) | ||||
JS_GetArrayBufferViewData(JSObject* obj, bool* isSharedMemory, const JS::AutoCheckCannotGC&); | JS_GetArrayBufferViewData(JSObject* obj, bool* isSharedMemory, const JS::AutoCheckCannotGC&); | ||||
/** | /** | ||||
* Return the ArrayBuffer or SharedArrayBuffer underlying an | * Return the ArrayBuffer or SharedArrayBuffer underlying an ArrayBufferView. | ||||
* ArrayBufferView. If the buffer has been neutered, this will still | * This may return a detached buffer. |obj| must be an object that would | ||||
* return the neutered buffer. |obj| must be an object that would | |||||
* return true for JS_IsArrayBufferViewObject(). | * return true for JS_IsArrayBufferViewObject(). | ||||
*/ | */ | ||||
extern JS_FRIEND_API(JSObject*) | extern JS_FRIEND_API(JSObject*) | ||||
JS_GetArrayBufferViewBuffer(JSContext* cx, JS::HandleObject obj, bool* isSharedMemory); | JS_GetArrayBufferViewBuffer(JSContext* cx, JS::HandleObject obj, bool* isSharedMemory); | ||||
typedef enum { | |||||
ChangeData, | |||||
KeepData | |||||
} NeuterDataDisposition; | |||||
/** | /** | ||||
* Set an ArrayBuffer's length to 0 and neuter all of its views. | * Detach an ArrayBuffer, causing all associated views to no longer refer to | ||||
* the ArrayBuffer's original attached memory. | |||||
* | * | ||||
* The |changeData| argument is a hint to inform internal behavior with respect | * The |changeData| argument is obsolete and ignored. | ||||
* to the internal pointer to the ArrayBuffer's data after being neutered. | |||||
* There is no guarantee it will be respected. But if it is respected, the | |||||
* ArrayBuffer's internal data pointer will, or will not, have changed | |||||
* accordingly. | |||||
*/ | */ | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
JS_NeuterArrayBuffer(JSContext* cx, JS::HandleObject obj, | JS_DetachArrayBuffer(JSContext* cx, JS::HandleObject obj); | ||||
NeuterDataDisposition changeData); | |||||
/** | /** | ||||
* Check whether the obj is ArrayBufferObject and neutered. Note that this | * Check whether the obj is a detached ArrayBufferObject. Note that this may | ||||
* may return false if a security wrapper is encountered that denies the | * return false if a security wrapper is encountered that denies the | ||||
* unwrapping. | * unwrapping. | ||||
*/ | */ | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
JS_IsNeuteredArrayBufferObject(JSObject* obj); | JS_IsDetachedArrayBufferObject(JSObject* obj); | ||||
/** | /** | ||||
* Check whether obj supports JS_GetDataView* APIs. | * Check whether obj supports JS_GetDataView* APIs. | ||||
*/ | */ | ||||
JS_FRIEND_API(bool) | JS_FRIEND_API(bool) | ||||
JS_IsDataViewObject(JSObject* obj); | JS_IsDataViewObject(JSObject* obj); | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 277 Lines • ▼ Show 20 Lines | union { | ||||
JSNative staticMethod; | JSNative staticMethod; | ||||
}; | }; | ||||
union { | union { | ||||
uint16_t protoID; | uint16_t protoID; | ||||
js::jit::InlinableNative inlinableNative; | js::jit::InlinableNative inlinableNative; | ||||
}; | }; | ||||
union { | |||||
uint16_t depth; | uint16_t depth; | ||||
// Additional opcode for some InlinableNative functions. | |||||
uint16_t nativeOp; | |||||
}; | |||||
// These fields are carefully packed to take up 4 bytes. If you need more | // These fields are carefully packed to take up 4 bytes. If you need more | ||||
// bits for whatever reason, please see if you can steal bits from existing | // bits for whatever reason, please see if you can steal bits from existing | ||||
// fields before adding more members to this structure. | // fields before adding more members to this structure. | ||||
#define JITINFO_OP_TYPE_BITS 4 | #define JITINFO_OP_TYPE_BITS 4 | ||||
#define JITINFO_ALIAS_SET_BITS 4 | #define JITINFO_ALIAS_SET_BITS 4 | ||||
#define JITINFO_RETURN_TYPE_BITS 8 | #define JITINFO_RETURN_TYPE_BITS 8 | ||||
#define JITINFO_SLOT_INDEX_BITS 10 | #define JITINFO_SLOT_INDEX_BITS 10 | ||||
▲ Show 20 Lines • Show All 248 Lines • ▼ Show 20 Lines | struct ScriptEnvironmentPreparer { | ||||
virtual void invoke(JS::HandleObject scope, Closure& closure) = 0; | virtual void invoke(JS::HandleObject scope, Closure& closure) = 0; | ||||
}; | }; | ||||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | ||||
PrepareScriptEnvironmentAndInvoke(JSContext* cx, JS::HandleObject scope, | PrepareScriptEnvironmentAndInvoke(JSContext* cx, JS::HandleObject scope, | ||||
ScriptEnvironmentPreparer::Closure& closure); | ScriptEnvironmentPreparer::Closure& closure); | ||||
JS_FRIEND_API(void) | JS_FRIEND_API(void) | ||||
SetScriptEnvironmentPreparer(JSRuntime* rt, ScriptEnvironmentPreparer* | SetScriptEnvironmentPreparer(JSContext* cx, ScriptEnvironmentPreparer* preparer); | ||||
preparer); | |||||
/** | |||||
* To help embedders enforce their invariants, we allow them to specify in | |||||
* advance which JSContext should be passed to JSAPI calls. If this is set | |||||
* to a non-null value, the assertSameCompartment machinery does double- | |||||
* duty (in debug builds) to verify that it matches the cx being used. | |||||
*/ | |||||
#ifdef DEBUG | |||||
JS_FRIEND_API(void) | |||||
Debug_SetActiveJSContext(JSRuntime* rt, JSContext* cx); | |||||
#else | |||||
inline void | |||||
Debug_SetActiveJSContext(JSRuntime* rt, JSContext* cx) {} | |||||
#endif | |||||
enum CTypesActivityType { | enum CTypesActivityType { | ||||
CTYPES_CALL_BEGIN, | CTYPES_CALL_BEGIN, | ||||
CTYPES_CALL_END, | CTYPES_CALL_END, | ||||
CTYPES_CALLBACK_BEGIN, | CTYPES_CALLBACK_BEGIN, | ||||
CTYPES_CALLBACK_END | CTYPES_CALLBACK_END | ||||
}; | }; | ||||
typedef void | typedef void | ||||
(* CTypesActivityCallback)(JSContext* cx, CTypesActivityType type); | (* CTypesActivityCallback)(JSContext* cx, CTypesActivityType type); | ||||
/** | /** | ||||
* Sets a callback that is run whenever js-ctypes is about to be used when | * Sets a callback that is run whenever js-ctypes is about to be used when | ||||
* calling into C. | * calling into C. | ||||
*/ | */ | ||||
JS_FRIEND_API(void) | JS_FRIEND_API(void) | ||||
SetCTypesActivityCallback(JSRuntime* rt, CTypesActivityCallback cb); | SetCTypesActivityCallback(JSContext* cx, CTypesActivityCallback cb); | ||||
class MOZ_RAII JS_FRIEND_API(AutoCTypesActivityCallback) { | class MOZ_RAII JS_FRIEND_API(AutoCTypesActivityCallback) { | ||||
private: | private: | ||||
JSContext* cx; | JSContext* cx; | ||||
CTypesActivityCallback callback; | CTypesActivityCallback callback; | ||||
CTypesActivityType endType; | CTypesActivityType endType; | ||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER | MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER | ||||
public: | public: | ||||
AutoCTypesActivityCallback(JSContext* cx, CTypesActivityType beginType, | AutoCTypesActivityCallback(JSContext* cx, CTypesActivityType beginType, | ||||
CTypesActivityType endType | CTypesActivityType endType | ||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM); | MOZ_GUARD_OBJECT_NOTIFIER_PARAM); | ||||
~AutoCTypesActivityCallback() { | ~AutoCTypesActivityCallback() { | ||||
DoEndCallback(); | DoEndCallback(); | ||||
} | } | ||||
void DoEndCallback() { | void DoEndCallback() { | ||||
if (callback) { | if (callback) { | ||||
callback(cx, endType); | callback(cx, endType); | ||||
callback = nullptr; | callback = nullptr; | ||||
} | } | ||||
} | } | ||||
}; | }; | ||||
typedef JSObject* | // Abstract base class for objects that build allocation metadata for JavaScript | ||||
(* ObjectMetadataCallback)(JSContext* cx, JSObject* obj); | // values. | ||||
struct AllocationMetadataBuilder { | |||||
AllocationMetadataBuilder() { } | |||||
// Return a metadata object for the newly constructed object |obj|, or | |||||
// nullptr if there's no metadata to attach. | |||||
// | |||||
// Implementations should treat all errors as fatal; there is no way to | |||||
// report errors from this callback. In particular, the caller provides an | |||||
// oomUnsafe for overriding implementations to use. | |||||
virtual JSObject* build(JSContext* cx, JS::HandleObject obj, | |||||
AutoEnterOOMUnsafeRegion& oomUnsafe) const | |||||
{ | |||||
return nullptr; | |||||
} | |||||
}; | |||||
/** | /** | ||||
* Specify a callback to invoke when creating each JS object in the current | * Specify a callback to invoke when creating each JS object in the current | ||||
* compartment, which may return a metadata object to associate with the | * compartment, which may return a metadata object to associate with the | ||||
* object. | * object. | ||||
*/ | */ | ||||
JS_FRIEND_API(void) | JS_FRIEND_API(void) | ||||
SetObjectMetadataCallback(JSContext* cx, ObjectMetadataCallback callback); | SetAllocationMetadataBuilder(JSContext* cx, const AllocationMetadataBuilder *callback); | ||||
/** Get the metadata associated with an object. */ | /** Get the metadata associated with an object. */ | ||||
JS_FRIEND_API(JSObject*) | JS_FRIEND_API(JSObject*) | ||||
GetObjectMetadata(JSObject* obj); | GetAllocationMetadata(JSObject* obj); | ||||
JS_FRIEND_API(bool) | JS_FRIEND_API(bool) | ||||
GetElementsWithAdder(JSContext* cx, JS::HandleObject obj, JS::HandleObject receiver, | GetElementsWithAdder(JSContext* cx, JS::HandleObject obj, JS::HandleObject receiver, | ||||
uint32_t begin, uint32_t end, js::ElementAdder* adder); | uint32_t begin, uint32_t end, js::ElementAdder* adder); | ||||
JS_FRIEND_API(bool) | JS_FRIEND_API(bool) | ||||
ForwardToNative(JSContext* cx, JSNative native, const JS::CallArgs& args); | ForwardToNative(JSContext* cx, JSNative native, const JS::CallArgs& args); | ||||
Show All 15 Lines | |||||
* except the initial getOwnPropertyDescriptor() call. The caller must supply | * except the initial getOwnPropertyDescriptor() call. The caller must supply | ||||
* that descriptor as the 'ownDesc' parameter. | * that descriptor as the 'ownDesc' parameter. | ||||
* | * | ||||
* Implemented in proxy/BaseProxyHandler.cpp. | * Implemented in proxy/BaseProxyHandler.cpp. | ||||
*/ | */ | ||||
JS_FRIEND_API(bool) | JS_FRIEND_API(bool) | ||||
SetPropertyIgnoringNamedGetter(JSContext* cx, JS::HandleObject obj, JS::HandleId id, | SetPropertyIgnoringNamedGetter(JSContext* cx, JS::HandleObject obj, JS::HandleId id, | ||||
JS::HandleValue v, JS::HandleValue receiver, | JS::HandleValue v, JS::HandleValue receiver, | ||||
JS::Handle<JSPropertyDescriptor> ownDesc, | JS::Handle<JS::PropertyDescriptor> ownDesc, | ||||
JS::ObjectOpResult& result); | JS::ObjectOpResult& result); | ||||
JS_FRIEND_API(void) | JS_FRIEND_API(void) | ||||
ReportErrorWithId(JSContext* cx, const char* msg, JS::HandleId id); | ReportASCIIErrorWithId(JSContext* cx, const char* msg, JS::HandleId id); | ||||
// This function is for one specific use case, please don't use this for anything else! | // This function is for one specific use case, please don't use this for anything else! | ||||
extern JS_FRIEND_API(bool) | extern JS_FRIEND_API(bool) | ||||
ExecuteInGlobalAndReturnScope(JSContext* cx, JS::HandleObject obj, JS::HandleScript script, | ExecuteInGlobalAndReturnScope(JSContext* cx, JS::HandleObject obj, JS::HandleScript script, | ||||
JS::MutableHandleObject scope); | JS::MutableHandleObject scope); | ||||
#if defined(XP_WIN) && defined(_WIN64) | #if defined(XP_WIN) && defined(_WIN64) | ||||
// Parameters use void* types to avoid #including windows.h. The return value of | // Parameters use void* types to avoid #including windows.h. The return value of | ||||
Show All 21 Lines | |||||
* Gecko must call SetJitExceptionFilter before any JIT code is compiled and | * Gecko must call SetJitExceptionFilter before any JIT code is compiled and | ||||
* only once per process. | * only once per process. | ||||
*/ | */ | ||||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | ||||
SetJitExceptionHandler(JitExceptionHandler handler); | SetJitExceptionHandler(JitExceptionHandler handler); | ||||
#endif | #endif | ||||
/** | /** | ||||
* Get the nearest enclosing with scope object for a given function. If the | * Get the nearest enclosing with environment object for a given function. If | ||||
* function is not scripted or is not enclosed by a with scope, returns the | * the function is not scripted or is not enclosed by a with scope, returns | ||||
* global. | * the global. | ||||
*/ | */ | ||||
extern JS_FRIEND_API(JSObject*) | extern JS_FRIEND_API(JSObject*) | ||||
GetNearestEnclosingWithScopeObjectForFunction(JSFunction* fun); | GetNearestEnclosingWithEnvironmentObjectForFunction(JSFunction* fun); | ||||
/** | /** | ||||
* Get the first SavedFrame object in this SavedFrame stack whose principals are | * Get the first SavedFrame object in this SavedFrame stack whose principals are | ||||
* subsumed by the cx's principals. If there is no such frame, return nullptr. | * subsumed by the cx's principals. If there is no such frame, return nullptr. | ||||
* | * | ||||
* Do NOT pass a non-SavedFrame object here. | * Do NOT pass a non-SavedFrame object here. | ||||
* | * | ||||
* The savedFrame and cx do not need to be in the same compartment. | * The savedFrame and cx do not need to be in the same compartment. | ||||
Show All 9 Lines | |||||
/** | /** | ||||
* Window and WindowProxy | * Window and WindowProxy | ||||
* | * | ||||
* The functions below have to do with Windows and WindowProxies. There's an | * The functions below have to do with Windows and WindowProxies. There's an | ||||
* invariant that actual Window objects (the global objects of web pages) are | * invariant that actual Window objects (the global objects of web pages) are | ||||
* never directly exposed to script. Instead we often substitute a WindowProxy. | * never directly exposed to script. Instead we often substitute a WindowProxy. | ||||
* | * | ||||
* The scope chain, on the other hand, contains the Window and never its | * The environment chain, on the other hand, contains the Window and never its | ||||
* WindowProxy. | * WindowProxy. | ||||
* | * | ||||
* As a result, we have calls to these "substitute-this-object-for-that-object" | * As a result, we have calls to these "substitute-this-object-for-that-object" | ||||
* functions sprinkled at apparently arbitrary (but actually *very* carefully | * functions sprinkled at apparently arbitrary (but actually *very* carefully | ||||
* and nervously selected) places throughout the engine and indeed the | * and nervously selected) places throughout the engine and indeed the | ||||
* universe. | * universe. | ||||
*/ | */ | ||||
/** | /** | ||||
* Tell the JS engine which Class is used for WindowProxy objects. Used by the | * Tell the JS engine which Class is used for WindowProxy objects. Used by the | ||||
* functions below. | * functions below. | ||||
*/ | */ | ||||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | ||||
SetWindowProxyClass(JSRuntime* rt, const Class* clasp); | SetWindowProxyClass(JSContext* cx, const Class* clasp); | ||||
/** | /** | ||||
* Associates a WindowProxy with a Window (global object). `windowProxy` must | * Associates a WindowProxy with a Window (global object). `windowProxy` must | ||||
* have the Class set by SetWindowProxyClass. | * have the Class set by SetWindowProxyClass. | ||||
*/ | */ | ||||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | ||||
SetWindowProxy(JSContext* cx, JS::HandleObject global, JS::HandleObject windowProxy); | SetWindowProxy(JSContext* cx, JS::HandleObject global, JS::HandleObject windowProxy); | ||||
Show All 35 Lines | |||||
* global), else return `obj`. This function is infallible and never returns | * global), else return `obj`. This function is infallible and never returns | ||||
* nullptr. | * nullptr. | ||||
*/ | */ | ||||
extern JS_FRIEND_API(JSObject*) | extern JS_FRIEND_API(JSObject*) | ||||
ToWindowIfWindowProxy(JSObject* obj); | ToWindowIfWindowProxy(JSObject* obj); | ||||
} /* namespace js */ | } /* namespace js */ | ||||
extern JS_FRIEND_API(void) | |||||
JS_StoreObjectPostBarrierCallback(JSContext* cx, | |||||
void (*callback)(JSTracer* trc, JSObject* key, void* data), | |||||
JSObject* key, void* data); | |||||
extern JS_FRIEND_API(void) | |||||
JS_StoreStringPostBarrierCallback(JSContext* cx, | |||||
void (*callback)(JSTracer* trc, JSString* key, void* data), | |||||
JSString* key, void* data); | |||||
/** | |||||
* Forcibly clear postbarrier callbacks queued by the previous two methods. | |||||
* This should be used when the object owning the postbarriered pointers is | |||||
* being destroyed outside of a garbage collection. | |||||
* | |||||
* This currently works by performing a minor GC. | |||||
*/ | |||||
extern JS_FRIEND_API(void) | |||||
JS_ClearAllPostBarrierCallbacks(JSRuntime *rt); | |||||
class NativeProfiler | class NativeProfiler | ||||
{ | { | ||||
public: | public: | ||||
virtual ~NativeProfiler() {}; | virtual ~NativeProfiler() {}; | ||||
virtual void sampleNative(void* addr, uint32_t size) = 0; | virtual void sampleNative(void* addr, uint32_t size) = 0; | ||||
virtual void removeNative(void* addr) = 0; | virtual void removeNative(void* addr) = 0; | ||||
virtual void reset() = 0; | virtual void reset() = 0; | ||||
}; | }; | ||||
Show All 10 Lines | public: | ||||
virtual void sweepNursery() = 0; | virtual void sweepNursery() = 0; | ||||
virtual void moveNurseryToTenured(void* addrOld, void* addrNew) = 0; | virtual void moveNurseryToTenured(void* addrOld, void* addrNew) = 0; | ||||
virtual void reset() = 0; | virtual void reset() = 0; | ||||
}; | }; | ||||
class MemProfiler | class MemProfiler | ||||
{ | { | ||||
static mozilla::Atomic<uint32_t, mozilla::Relaxed> sActiveProfilerCount; | static mozilla::Atomic<uint32_t, mozilla::Relaxed> sActiveProfilerCount; | ||||
static NativeProfiler* sNativeProfiler; | static JS_FRIEND_DATA(NativeProfiler*) sNativeProfiler; | ||||
static GCHeapProfiler* GetGCHeapProfiler(void* addr); | static GCHeapProfiler* GetGCHeapProfiler(void* addr); | ||||
static GCHeapProfiler* GetGCHeapProfiler(JSRuntime* runtime); | static GCHeapProfiler* GetGCHeapProfiler(JSRuntime* runtime); | ||||
static NativeProfiler* GetNativeProfiler() { | static NativeProfiler* GetNativeProfiler() { | ||||
return sNativeProfiler; | return sNativeProfiler; | ||||
} | } | ||||
GCHeapProfiler* mGCHeapProfiler; | GCHeapProfiler* mGCHeapProfiler; | ||||
JSRuntime* mRuntime; | JSRuntime* mRuntime; | ||||
public: | public: | ||||
explicit MemProfiler(JSRuntime* aRuntime) : mGCHeapProfiler(nullptr), mRuntime(aRuntime) {} | explicit MemProfiler(JSRuntime* aRuntime) : mGCHeapProfiler(nullptr), mRuntime(aRuntime) {} | ||||
void start(GCHeapProfiler* aGCHeapProfiler); | JS_FRIEND_API(void) start(GCHeapProfiler* aGCHeapProfiler); | ||||
void stop(); | JS_FRIEND_API(void) stop(); | ||||
GCHeapProfiler* getGCHeapProfiler() const { | GCHeapProfiler* getGCHeapProfiler() const { | ||||
return mGCHeapProfiler; | return mGCHeapProfiler; | ||||
} | } | ||||
static MOZ_ALWAYS_INLINE bool enabled() { | static MOZ_ALWAYS_INLINE bool enabled() { | ||||
return sActiveProfilerCount > 0; | return sActiveProfilerCount > 0; | ||||
} | } | ||||
static MemProfiler* GetMemProfiler(JSRuntime* runtime); | static JS_FRIEND_API(MemProfiler*) GetMemProfiler(JSContext* context); | ||||
static void SetNativeProfiler(NativeProfiler* aProfiler) { | static void SetNativeProfiler(NativeProfiler* aProfiler) { | ||||
sNativeProfiler = aProfiler; | sNativeProfiler = aProfiler; | ||||
} | } | ||||
static MOZ_ALWAYS_INLINE void SampleNative(void* addr, uint32_t size) { | static MOZ_ALWAYS_INLINE void SampleNative(void* addr, uint32_t size) { | ||||
JS::AutoSuppressGCAnalysis nogc; | JS::AutoSuppressGCAnalysis nogc; | ||||
▲ Show 20 Lines • Show All 98 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator