LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - PrecompiledScriptBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 128 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 14 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13