static inline void AssertObjectPropertyFrozen(JSContext* cx, HandleNativeObject obj, uint32_t slot) { #ifdef DEBUG bool frozen = false; RootedObject property(cx, &obj->getSlot(slot).toObject()); MOZ_ALWAYS_TRUE(TestIntegrityLevel(cx, property, IntegrityLevel::Frozen, &frozen)); MOZ_ASSERT(frozen); #endif }
static bool GetUnclonedValue(JSContext *cx, HandleNativeObject selfHostedObject, HandleId id, MutableHandleValue vp) { vp.setUndefined(); if (JSID_IS_INT(id)) { size_t index = JSID_TO_INT(id); if (index < selfHostedObject->getDenseInitializedLength() && !selfHostedObject->getDenseElement(index).isMagic(JS_ELEMENTS_HOLE)) { vp.set(selfHostedObject->getDenseElement(JSID_TO_INT(id))); return true; } } // Since all atoms used by self hosting are marked as permanent, any // attempt to look up a non-permanent atom will fail. We should only // see such atoms when code is looking for properties on the self // hosted global which aren't present. if (JSID_IS_STRING(id) && !JSID_TO_STRING(id)->isPermanentAtom()) { MOZ_ASSERT(selfHostedObject->is<GlobalObject>()); RootedValue value(cx, IdToValue(id)); return js_ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_NO_SUCH_SELF_HOSTED_PROP, JSDVG_IGNORE_STACK, value, NullPtr(), nullptr, nullptr); } RootedShape shape(cx, selfHostedObject->lookupPure(id)); if (!shape) { RootedValue value(cx, IdToValue(id)); return js_ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_NO_SUCH_SELF_HOSTED_PROP, JSDVG_IGNORE_STACK, value, NullPtr(), nullptr, nullptr); } MOZ_ASSERT(shape->hasSlot() && shape->hasDefaultGetter()); vp.set(selfHostedObject->getSlot(shape->slot())); return true; }
static bool FreezeObjectProperty(JSContext* cx, HandleNativeObject obj, uint32_t slot) { RootedObject property(cx, &obj->getSlot(slot).toObject()); return FreezeObject(cx, property); }
static inline bool IsObjectPropertyFrozen(JSContext* cx, HandleNativeObject obj, uint32_t slot) { RootedObject property(cx, &obj->getSlot(slot).toObject()); return IsObjectFrozen(cx, property); }