static EncodedJSValue JSC_HOST_CALL performProxyRevoke(ExecState* exec) { ProxyRevoke* proxyRevoke = jsCast<ProxyRevoke*>(exec->jsCallee()); JSValue proxyValue = proxyRevoke->proxy(); if (proxyValue.isNull()) return JSValue::encode(jsUndefined()); ProxyObject* proxy = jsCast<ProxyObject*>(proxyValue); VM& vm = exec->vm(); proxy->revoke(vm); proxyRevoke->setProxyToNull(vm); return JSValue::encode(jsUndefined()); }
void CustomStatusesManager::Add (const CustomState& state, int after) { ProxyObject proxy; QList<QStandardItem*> row; row << new QStandardItem (state.Name_); row << new QStandardItem (Core::Instance ().GetIconForState (state.State_), proxy.StateToString (state.State_)); row << new QStandardItem (state.Text_); row.at (1)->setData (static_cast<int> (state.State_)); if (after == -1) Model_->appendRow (row); else Model_->insertRow (after, row); }
/* * This method marks pointers that cross compartment boundaries. It is called in * per-zone GCs (since full GCs naturally follow pointers across compartments) * and when compacting to update cross-compartment pointers. */ void JSCompartment::markCrossCompartmentWrappers(JSTracer *trc) { MOZ_ASSERT(!zone()->isCollecting() || trc->runtime()->isHeapCompacting()); for (WrapperMap::Enum e(crossCompartmentWrappers); !e.empty(); e.popFront()) { Value v = e.front().value(); if (e.front().key().kind == CrossCompartmentKey::ObjectWrapper) { ProxyObject *wrapper = &v.toObject().as<ProxyObject>(); /* * We have a cross-compartment wrapper. Its private pointer may * point into the compartment being collected, so we should mark it. */ MarkValue(trc, wrapper->slotOfPrivate(), "cross-compartment wrapper"); } } }
void JSCompartment::traceOutgoingCrossCompartmentWrappers(JSTracer* trc) { MOZ_ASSERT(trc->runtime()->isHeapMajorCollecting()); MOZ_ASSERT(!zone()->isCollecting() || trc->runtime()->gc.isHeapCompacting()); for (WrapperMap::Enum e(crossCompartmentWrappers); !e.empty(); e.popFront()) { Value v = e.front().value().unbarrieredGet(); if (e.front().key().is<JSObject*>()) { ProxyObject* wrapper = &v.toObject().as<ProxyObject>(); /* * We have a cross-compartment wrapper. Its private pointer may * point into the compartment being collected, so we should mark it. */ TraceEdge(trc, wrapper->slotOfPrivate(), "cross-compartment wrapper"); } } }
/* * This method marks pointers that cross compartment boundaries. It should be * called only for per-compartment GCs, since full GCs naturally follow pointers * across compartments. */ void JSCompartment::markCrossCompartmentWrappers(JSTracer *trc) { JS_ASSERT(!zone()->isCollecting()); for (WrapperMap::Enum e(crossCompartmentWrappers); !e.empty(); e.popFront()) { Value v = e.front().value(); if (e.front().key().kind == CrossCompartmentKey::ObjectWrapper) { ProxyObject *wrapper = &v.toObject().as<ProxyObject>(); /* * We have a cross-compartment wrapper. Its private pointer may * point into the compartment being collected, so we should mark it. */ Value referent = wrapper->private_(); MarkValueRoot(trc, &referent, "cross-compartment wrapper"); JS_ASSERT(referent == wrapper->private_()); } } }
/* static */ void ProxyObject::trace(JSTracer* trc, JSObject* obj) { ProxyObject* proxy = &obj->as<ProxyObject>(); TraceEdge(trc, proxy->shapePtr(), "ProxyObject_shape"); #ifdef DEBUG if (TlsContext.get()->isStrictProxyCheckingEnabled() && proxy->is<WrapperObject>()) { JSObject* referent = MaybeForwarded(proxy->target()); if (referent->compartment() != proxy->compartment()) { /* * Assert that this proxy is tracked in the wrapper map. We maintain * the invariant that the wrapped object is the key in the wrapper map. */ Value key = ObjectValue(*referent); WrapperMap::Ptr p = proxy->compartment()->lookupWrapper(key); MOZ_ASSERT(p); MOZ_ASSERT(*p->value().unsafeGet() == ObjectValue(*proxy)); } } #endif // Note: If you add new slots here, make sure to change // nuke() to cope. traceEdgeToTarget(trc, proxy); size_t nreserved = proxy->numReservedSlots(); for (size_t i = 0; i < nreserved; i++) { /* * The GC can use the second reserved slot to link the cross compartment * wrappers into a linked list, in which case we don't want to trace it. */ if (proxy->is<CrossCompartmentWrapperObject>() && i == CrossCompartmentWrapperObject::GrayLinkReservedSlot) { continue; } TraceEdge(trc, proxy->reservedSlotPtr(i), "proxy_reserved"); } Proxy::trace(trc, obj); }