本文整理汇总了C++中js::Value::toGCThing方法的典型用法代码示例。如果您正苦于以下问题:C++ Value::toGCThing方法的具体用法?C++ Value::toGCThing怎么用?C++ Value::toGCThing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类js::Value
的用法示例。
在下文中一共展示了Value::toGCThing方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool
JSCompartment::putWrapper(const CrossCompartmentKey &wrapped, const js::Value &wrapper)
{
JS_ASSERT(wrapped.wrapped);
JS_ASSERT(!IsPoisonedPtr(wrapped.wrapped));
JS_ASSERT(!IsPoisonedPtr(wrapped.debugger));
JS_ASSERT(!IsPoisonedPtr(wrapper.toGCThing()));
JS_ASSERT_IF(wrapped.kind == CrossCompartmentKey::StringWrapper, wrapper.isString());
JS_ASSERT_IF(wrapped.kind != CrossCompartmentKey::StringWrapper, wrapper.isObject());
return crossCompartmentWrappers.put(wrapped, wrapper);
}
示例2: ref
bool
JSCompartment::putWrapper(JSContext *cx, const CrossCompartmentKey &wrapped, const js::Value &wrapper)
{
MOZ_ASSERT(wrapped.wrapped);
MOZ_ASSERT(!IsPoisonedPtr(wrapped.wrapped));
MOZ_ASSERT(!IsPoisonedPtr(wrapped.debugger));
MOZ_ASSERT(!IsPoisonedPtr(wrapper.toGCThing()));
MOZ_ASSERT_IF(wrapped.kind == CrossCompartmentKey::StringWrapper, wrapper.isString());
MOZ_ASSERT_IF(wrapped.kind != CrossCompartmentKey::StringWrapper, wrapper.isObject());
bool success = crossCompartmentWrappers.put(wrapped, ReadBarriered<Value>(wrapper));
/* There's no point allocating wrappers in the nursery since we will tenure them anyway. */
MOZ_ASSERT(!IsInsideNursery(static_cast<gc::Cell *>(wrapper.toGCThing())));
if (success && (IsInsideNursery(wrapped.wrapped) || IsInsideNursery(wrapped.debugger))) {
WrapperMapRef ref(&crossCompartmentWrappers, wrapped);
cx->runtime()->gc.storeBuffer.putGeneric(ref);
}
return success;
}
示例3: ref
bool
JSCompartment::putWrapper(JSContext *cx, const CrossCompartmentKey &wrapped, const js::Value &wrapper)
{
JS_ASSERT(wrapped.wrapped);
JS_ASSERT(!IsPoisonedPtr(wrapped.wrapped));
JS_ASSERT(!IsPoisonedPtr(wrapped.debugger));
JS_ASSERT(!IsPoisonedPtr(wrapper.toGCThing()));
JS_ASSERT_IF(wrapped.kind == CrossCompartmentKey::StringWrapper, wrapper.isString());
JS_ASSERT_IF(wrapped.kind != CrossCompartmentKey::StringWrapper, wrapper.isObject());
bool success = crossCompartmentWrappers.put(wrapped, wrapper);
#ifdef JSGC_GENERATIONAL
/* There's no point allocating wrappers in the nursery since we will tenure them anyway. */
Nursery &nursery = cx->nursery();
JS_ASSERT(!nursery.isInside(wrapper.toGCThing()));
if (success && (nursery.isInside(wrapped.wrapped) || nursery.isInside(wrapped.debugger))) {
WrapperMapRef ref(&crossCompartmentWrappers, wrapped);
cx->runtime()->gcStoreBuffer.putGeneric(ref);
}
#endif
return success;
}
示例4: ref
bool
JSCompartment::putWrapper(JSContext* cx, const CrossCompartmentKey& wrapped,
const js::Value& wrapper)
{
MOZ_ASSERT(wrapped.is<JSString*>() == wrapper.isString());
MOZ_ASSERT_IF(!wrapped.is<JSString*>(), wrapper.isObject());
/* There's no point allocating wrappers in the nursery since we will tenure them anyway. */
MOZ_ASSERT(!IsInsideNursery(static_cast<gc::Cell*>(wrapper.toGCThing())));
if (!crossCompartmentWrappers.put(wrapped, ReadBarriered<Value>(wrapper))) {
ReportOutOfMemory(cx);
return false;
}
if (const_cast<CrossCompartmentKey&>(wrapped).applyToWrapped(IsInsideNurseryFunctor()) ||
const_cast<CrossCompartmentKey&>(wrapped).applyToDebugger(IsInsideNurseryFunctor()))
{
WrapperMapRef ref(&crossCompartmentWrappers, wrapped);
cx->runtime()->gc.storeBuffer.putGeneric(ref);
}
return true;
}