LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - DOMErrorBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 22 148 14.9 %
Date: 2017-07-14 16:53:18 Functions: 3 13 23.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM DOMError.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "DOMErrorBinding.h"
       4             : #include "WrapperFactory.h"
       5             : #include "mozilla/OwningNonNull.h"
       6             : #include "mozilla/dom/BindingUtils.h"
       7             : #include "mozilla/dom/DOMError.h"
       8             : #include "mozilla/dom/DOMJSClass.h"
       9             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      10             : #include "mozilla/dom/XrayExpandoClass.h"
      11             : 
      12             : namespace mozilla {
      13             : namespace dom {
      14             : 
      15             : namespace DOMErrorBinding {
      16             : 
      17             : static bool
      18           0 : get_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMError* self, JSJitGetterCallArgs args)
      19             : {
      20           0 :   DOMString result;
      21           0 :   self->GetName(result);
      22           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      23           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
      24           0 :     return false;
      25             :   }
      26           0 :   return true;
      27             : }
      28             : 
      29             : static const JSJitInfo name_getterinfo = {
      30             :   { (JSJitGetterOp)get_name },
      31             :   { prototypes::id::DOMError },
      32             :   { PrototypeTraits<prototypes::id::DOMError>::Depth },
      33             :   JSJitInfo::Getter,
      34             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
      35             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
      36             :   false,  /* isInfallible. False in setters. */
      37             :   true,  /* isMovable.  Not relevant for setters. */
      38             :   true, /* isEliminatable.  Not relevant for setters. */
      39             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      40             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      41             :   false,  /* isTypedMethod.  Only relevant for methods. */
      42             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      43             : };
      44             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      45             : static_assert(0 < 1, "There is no slot for us");
      46             : 
      47             : static bool
      48           0 : get_message(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMError* self, JSJitGetterCallArgs args)
      49             : {
      50           0 :   DOMString result;
      51           0 :   self->GetMessage(result);
      52           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      53           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
      54           0 :     return false;
      55             :   }
      56           0 :   return true;
      57             : }
      58             : 
      59             : static const JSJitInfo message_getterinfo = {
      60             :   { (JSJitGetterOp)get_message },
      61             :   { prototypes::id::DOMError },
      62             :   { PrototypeTraits<prototypes::id::DOMError>::Depth },
      63             :   JSJitInfo::Getter,
      64             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
      65             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
      66             :   false,  /* isInfallible. False in setters. */
      67             :   true,  /* isMovable.  Not relevant for setters. */
      68             :   true, /* isEliminatable.  Not relevant for setters. */
      69             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      70             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      71             :   false,  /* isTypedMethod.  Only relevant for methods. */
      72             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      73             : };
      74             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      75             : static_assert(0 < 1, "There is no slot for us");
      76             : 
      77             : static bool
      78           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
      79             : {
      80           0 :   mozilla::dom::DOMError* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::DOMError>(obj);
      81             :   // We don't want to preserve if we don't have a wrapper, and we
      82             :   // obviously can't preserve if we're not initialized.
      83           0 :   if (self && self->GetWrapperPreserveColor()) {
      84           0 :     PreserveWrapper(self);
      85             :   }
      86           0 :   return true;
      87             : }
      88             : 
      89             : static void
      90           0 : _finalize(js::FreeOp* fop, JSObject* obj)
      91             : {
      92           0 :   mozilla::dom::DOMError* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::DOMError>(obj);
      93           0 :   if (self) {
      94           0 :     ClearWrapper(self, self, obj);
      95           0 :     AddForDeferredFinalization<mozilla::dom::DOMError>(self);
      96             :   }
      97           0 : }
      98             : 
      99             : static void
     100           0 : _objectMoved(JSObject* obj, const JSObject* old)
     101             : {
     102           0 :   mozilla::dom::DOMError* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::DOMError>(obj);
     103           0 :   if (self) {
     104           0 :     UpdateWrapper(self, self, obj, old);
     105             :   }
     106           0 : }
     107             : 
     108             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     109             : #if defined(__clang__)
     110             : #pragma clang diagnostic push
     111             : #pragma clang diagnostic ignored "-Wmissing-braces"
     112             : #endif
     113             : static const JSPropertySpec sAttributes_specs[] = {
     114             :   { "name", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &name_getterinfo, nullptr, nullptr },
     115             :   { "message", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &message_getterinfo, nullptr, nullptr },
     116             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     117             : };
     118             : #if defined(__clang__)
     119             : #pragma clang diagnostic pop
     120             : #endif
     121             : 
     122             : 
     123             : // Can't be const because the pref-enabled boolean needs to be writable
     124             : static Prefable<const JSPropertySpec> sAttributes[] = {
     125             :   { nullptr, &sAttributes_specs[0] },
     126             :   { nullptr, nullptr }
     127             : };
     128             : 
     129             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     130             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     131             : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     132             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     133             : 
     134             : 
     135             : static uint16_t sNativeProperties_sortedPropertyIndices[2];
     136             : static PropertyInfo sNativeProperties_propertyInfos[2];
     137             : 
     138             : static const NativePropertiesN<1> sNativeProperties = {
     139             :   false, 0,
     140             :   false, 0,
     141             :   false, 0,
     142             :   true,  0 /* sAttributes */,
     143             :   false, 0,
     144             :   false, 0,
     145             :   false, 0,
     146             :   -1,
     147             :   2,
     148             :   sNativeProperties_sortedPropertyIndices,
     149             :   {
     150             :     { sAttributes, &sNativeProperties_propertyInfos[0] }
     151             :   }
     152             : };
     153             : static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     154             :     "We have a property info count that is oversized");
     155             : 
     156             : static bool
     157           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
     158             : {
     159           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     160           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     161           0 :   if (!args.isConstructing()) {
     162             :     // XXXbz wish I could get the name from the callee instead of
     163             :     // Adding more relocations
     164           0 :     return ThrowConstructorWithoutNew(cx, "DOMError");
     165             :   }
     166             : 
     167           0 :   GlobalObject global(cx, obj);
     168           0 :   if (global.Failed()) {
     169           0 :     return false;
     170             :   }
     171             : 
     172           0 :   JS::Rooted<JSObject*> desiredProto(cx);
     173           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
     174           0 :     return false;
     175             :   }
     176             : 
     177           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     178           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "DOMError");
     179             :   }
     180           0 :   bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
     181           0 :   binding_detail::FakeString arg0;
     182           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     183           0 :     return false;
     184             :   }
     185           0 :   binding_detail::FakeString arg1;
     186           0 :   if (args.hasDefined(1)) {
     187           0 :     if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
     188           0 :       return false;
     189             :     }
     190             :   } else {
     191             :     static const char16_t data[] = { 0 };
     192           0 :     arg1.Rebind(data, ArrayLength(data) - 1);
     193             :   }
     194           0 :   Maybe<JSAutoCompartment> ac;
     195           0 :   if (objIsXray) {
     196           0 :     obj = js::CheckedUnwrap(obj);
     197           0 :     if (!obj) {
     198           0 :       return false;
     199             :     }
     200           0 :     ac.emplace(cx, obj);
     201           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
     202           0 :       return false;
     203             :     }
     204             :   }
     205           0 :   binding_detail::FastErrorResult rv;
     206           0 :   auto result(StrongOrRawPtr<mozilla::dom::DOMError>(mozilla::dom::DOMError::Constructor(global, NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), rv)));
     207           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     208           0 :     return false;
     209             :   }
     210           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     211             :   static_assert(!IsPointer<decltype(result)>::value,
     212             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     213           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
     214           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     215           0 :     return false;
     216             :   }
     217           0 :   return true;
     218             : }
     219             : 
     220             : static const js::ClassOps sInterfaceObjectClassOps = {
     221             :     nullptr,               /* addProperty */
     222             :     nullptr,               /* delProperty */
     223             :     nullptr,               /* getProperty */
     224             :     nullptr,               /* setProperty */
     225             :     nullptr,               /* enumerate */
     226             :     nullptr,               /* newEnumerate */
     227             :     nullptr,               /* resolve */
     228             :     nullptr,               /* mayResolve */
     229             :     nullptr,               /* finalize */
     230             :     _constructor, /* call */
     231             :     nullptr,               /* hasInstance */
     232             :     _constructor, /* construct */
     233             :     nullptr,               /* trace */
     234             : };
     235             : 
     236             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     237             :   {
     238             :     "Function",
     239             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     240             :     &sInterfaceObjectClassOps,
     241             :     JS_NULL_CLASS_SPEC,
     242             :     JS_NULL_CLASS_EXT,
     243             :     &sInterfaceObjectClassObjectOps
     244             :   },
     245             :   eInterface,
     246             :   true,
     247             :   prototypes::id::DOMError,
     248             :   PrototypeTraits<prototypes::id::DOMError>::Depth,
     249             :   sNativePropertyHooks,
     250             :   "function DOMError() {\n    [native code]\n}",
     251             :   JS::GetRealmFunctionPrototype
     252             : };
     253             : 
     254             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     255             :   {
     256             :     "DOMErrorPrototype",
     257             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     258             :     JS_NULL_CLASS_OPS,
     259             :     JS_NULL_CLASS_SPEC,
     260             :     JS_NULL_CLASS_EXT,
     261             :     JS_NULL_OBJECT_OPS
     262             :   },
     263             :   eInterfacePrototype,
     264             :   false,
     265             :   prototypes::id::DOMError,
     266             :   PrototypeTraits<prototypes::id::DOMError>::Depth,
     267             :   sNativePropertyHooks,
     268             :   "[object DOMErrorPrototype]",
     269             :   JS::GetRealmObjectPrototype
     270             : };
     271             : 
     272             : JSObject*
     273           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     274             : {
     275           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     276             : }
     277             : 
     278             : static const js::ClassOps sClassOps = {
     279             :   _addProperty, /* addProperty */
     280             :   nullptr,               /* delProperty */
     281             :   nullptr,               /* getProperty */
     282             :   nullptr,               /* setProperty */
     283             :   nullptr,               /* enumerate */
     284             :   nullptr, /* newEnumerate */
     285             :   nullptr, /* resolve */
     286             :   nullptr, /* mayResolve */
     287             :   _finalize, /* finalize */
     288             :   nullptr, /* call */
     289             :   nullptr,               /* hasInstance */
     290             :   nullptr,               /* construct */
     291             :   nullptr, /* trace */
     292             : };
     293             : 
     294             : static const js::ClassExtension sClassExtension = {
     295             :   nullptr, /* weakmapKeyDelegateOp */
     296             :   _objectMoved /* objectMovedOp */
     297             : };
     298             : 
     299             : static const DOMJSClass sClass = {
     300             :   { "DOMError",
     301             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     302             :     &sClassOps,
     303             :     JS_NULL_CLASS_SPEC,
     304             :     &sClassExtension,
     305             :     JS_NULL_OBJECT_OPS
     306             :   },
     307             :   { prototypes::id::DOMError, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     308             :   IsBaseOf<nsISupports, mozilla::dom::DOMError >::value,
     309             :   sNativePropertyHooks,
     310             :   FindAssociatedGlobalForNative<mozilla::dom::DOMError>::Get,
     311             :   GetProtoObjectHandle,
     312             :   GetCCParticipant<mozilla::dom::DOMError>::Get()
     313             : };
     314             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     315             :               "Must have the right minimal number of reserved slots.");
     316             : static_assert(1 >= 1,
     317             :               "Must have enough reserved slots.");
     318             : 
     319             : const JSClass*
     320           0 : GetJSClass()
     321             : {
     322           0 :   return sClass.ToJSClass();
     323             : }
     324             : 
     325             : bool
     326           0 : Wrap(JSContext* aCx, mozilla::dom::DOMError* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     327             : {
     328             :   MOZ_ASSERT(static_cast<mozilla::dom::DOMError*>(aObject) ==
     329             :              reinterpret_cast<mozilla::dom::DOMError*>(aObject),
     330             :              "Multiple inheritance for mozilla::dom::DOMError is broken.");
     331           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     332           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     333           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     334             :              "You should probably not be using Wrap() directly; use "
     335             :              "GetOrCreateDOMReflector instead");
     336             : 
     337           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     338             :              "nsISupports must be on our primary inheritance chain");
     339             : 
     340           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     341           0 :   if (!global) {
     342           0 :     return false;
     343             :   }
     344           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     345           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     346             : 
     347             :   // That might have ended up wrapping us already, due to the wonders
     348             :   // of XBL.  Check for that, and bail out as needed.
     349           0 :   aReflector.set(aCache->GetWrapper());
     350           0 :   if (aReflector) {
     351             : #ifdef DEBUG
     352           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     353             : #endif // DEBUG
     354           0 :     return true;
     355             :   }
     356             : 
     357           0 :   JSAutoCompartment ac(aCx, global);
     358           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     359           0 :   if (!canonicalProto) {
     360           0 :     return false;
     361             :   }
     362           0 :   JS::Rooted<JSObject*> proto(aCx);
     363           0 :   if (aGivenProto) {
     364           0 :     proto = aGivenProto;
     365             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     366             :     // coming in, we changed compartments to that of "parent" so may need
     367             :     // to wrap the proto here.
     368           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     369           0 :       if (!JS_WrapObject(aCx, &proto)) {
     370           0 :         return false;
     371             :       }
     372             :     }
     373             :   } else {
     374           0 :     proto = canonicalProto;
     375             :   }
     376             : 
     377           0 :   BindingJSObjectCreator<mozilla::dom::DOMError> creator(aCx);
     378           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     379           0 :   if (!aReflector) {
     380           0 :     return false;
     381             :   }
     382             : 
     383           0 :   aCache->SetWrapper(aReflector);
     384           0 :   creator.InitializationSucceeded();
     385             : 
     386           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     387             :              aCache->GetWrapperPreserveColor() == aReflector);
     388             :   // If proto != canonicalProto, we have to preserve our wrapper;
     389             :   // otherwise we won't be able to properly recreate it later, since
     390             :   // we won't know what proto to use.  Note that we don't check
     391             :   // aGivenProto here, since it's entirely possible (and even
     392             :   // somewhat common) to have a non-null aGivenProto which is the
     393             :   // same as canonicalProto.
     394           0 :   if (proto != canonicalProto) {
     395           0 :     PreserveWrapper(aObject);
     396             :   }
     397             : 
     398           0 :   return true;
     399             : }
     400             : 
     401             : const NativePropertyHooks sNativePropertyHooks[] = { {
     402             :   nullptr,
     403             :   nullptr,
     404             :   nullptr,
     405             :   { sNativeProperties.Upcast(), nullptr },
     406             :   prototypes::id::DOMError,
     407             :   constructors::id::DOMError,
     408             :   nullptr,
     409             :   &DefaultXrayExpandoObjectClass
     410             : } };
     411             : 
     412             : void
     413           1 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     414             : {
     415           2 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
     416           1 :   if (!parentProto) {
     417           0 :     return;
     418             :   }
     419             : 
     420           2 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
     421           1 :   if (!constructorProto) {
     422           0 :     return;
     423             :   }
     424             : 
     425             :   static bool sIdsInited = false;
     426           1 :   if (!sIdsInited && NS_IsMainThread()) {
     427           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     428           0 :       return;
     429             :     }
     430           0 :     sIdsInited = true;
     431             :   }
     432             : 
     433           1 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::DOMError);
     434           1 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::DOMError);
     435           2 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     436             :                               &sPrototypeClass.mBase, protoCache,
     437             :                               constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr,
     438             :                               interfaceCache,
     439             :                               sNativeProperties.Upcast(),
     440             :                               nullptr,
     441             :                               "DOMError", aDefineOnGlobal,
     442             :                               nullptr,
     443           1 :                               false);
     444             : }
     445             : 
     446             : JS::Handle<JSObject*>
     447           0 : GetProtoObjectHandle(JSContext* aCx)
     448             : {
     449             :   /* Get the interface prototype object for this class.  This will create the
     450             :      object as needed. */
     451           0 :   bool aDefineOnGlobal = true;
     452             : 
     453             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     454           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     455           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     456           0 :     return nullptr;
     457             :   }
     458             : 
     459             :   /* Check to see whether the interface objects are already installed */
     460           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     461           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::DOMError)) {
     462           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     463           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     464             :   }
     465             : 
     466             :   /*
     467             :    * The object might _still_ be null, but that's OK.
     468             :    *
     469             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     470             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     471             :    * changed after they have been set.
     472             :    *
     473             :    * Calling address() avoids the read read barrier that does gray
     474             :    * unmarking, but it's not possible for the object to be gray here.
     475             :    */
     476             : 
     477           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::DOMError);
     478           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     479           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     480             : }
     481             : 
     482             : JS::Handle<JSObject*>
     483           1 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     484             : {
     485             :   /* Get the interface object for this class.  This will create the object as
     486             :      needed. */
     487             : 
     488             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     489           1 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     490           1 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     491           0 :     return nullptr;
     492             :   }
     493             : 
     494             :   /* Check to see whether the interface objects are already installed */
     495           1 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     496           1 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::DOMError)) {
     497           2 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     498           1 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     499             :   }
     500             : 
     501             :   /*
     502             :    * The object might _still_ be null, but that's OK.
     503             :    *
     504             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     505             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     506             :    * changed after they have been set.
     507             :    *
     508             :    * Calling address() avoids the read read barrier that does gray
     509             :    * unmarking, but it's not possible for the object to be gray here.
     510             :    */
     511             : 
     512           1 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::DOMError);
     513           1 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     514           1 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     515             : }
     516             : 
     517             : JSObject*
     518           1 : GetConstructorObject(JSContext* aCx)
     519             : {
     520           1 :   return GetConstructorObjectHandle(aCx);
     521             : }
     522             : 
     523             : } // namespace DOMErrorBinding
     524             : 
     525             : 
     526             : 
     527             : } // namespace dom
     528             : } // namespace mozilla

Generated by: LCOV version 1.13