/* *Thesestandardinternalmethodsareimplemented,asaconvenience,so *thatProxyHandlersubclassesdon'thavetoprovideeverysinglemethod. * -implementationsworkcalling *andgoing *followswhatisdefinedforOrdinaryObjectsinjava.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 52 dofollowstandard.Whendoubt,themjava.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
*/ virtualJS ,* proxy const
:( java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 43
getJSContext,JS:java.lang.StringIndexOutOfBoundsException: Range [56, 50) out of bounds for length 57
JS::HandleValue
java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52 virtualbool // Number of reserved slots required for proxies that may be swapped by
JS::HandleValue v, JS::HandleValue receiver,
JS::ObjectOpResult& result) const;
// Use the ProxyExpando object for private fields, rather than taking the // normal get/set/defineField paths. virtualbool useProxyExpandoObjectForPrivateFields() const { returntrue; }
// For some exotic objects (WindowProxy, Location), we want to be able to // throw rather than allow private fields on these objects. // // As a simplfying assumption, if throwOnPrivateFields returns true, // we should also return true to useProxyExpandoObjectForPrivateFields. virtualbool throwOnPrivateField() const { returnfalse; }
// Allow proxies, wrappers in particular, to specify callability at runtime. // Note: These do not take const JSObject*, but they do in spirit. // We are not prepared to do this, as there's little const correctness // in the external APIs that handle proxies. virtualbool isCallable(JSObject* obj) const; virtualbool isConstructor(JSObject* obj) const;
// Whether proxies with this handler may be transplanted/swapped via // JS_TransplantObject or ProxyObject::swap. virtualbool mayBeSwapped() const { returnfalse; }
};
class JS_PUBLIC_API NurseryAllocableProxyHandler : public BaseProxyHandler { using BaseProxyHandler::BaseProxyHandler;
// Don't allow overriding the default finalize method. void finalize(JS::GCContext* gcx, JSObject* proxy) const final {
BaseProxyHandler::finalize(gcx, proxy);
} // Can allocate in the nursery as long as we use the default finalize method. bool canNurseryAllocate() const override { returntrue; }
};
extern JS_PUBLIC_DATA const JSClass ProxyClass;
// Number of reserved slots required for proxies that may be swapped by // JS_TransplantObject.
constexpr size_t SwappableProxyReservedSlots = 2;
// Proxy slot layout // ----------------- // // Every proxy has a ProxyValueArray that contains the following Values: // // - The private slot. // - The reserved slots. The number of slots is determined by the proxy's Class. // // The ProxyValueArray is allocated inline immediately after the ProxyObject // header (containing the object's shape and ProxyDataLayout). struct ProxyValueArray {
JS::Value privateSlot;
JS::Value reservedSlots[1];
void init(size_t nreserved) {
privateSlot = JS::UndefinedValue(); for (size_t i = 0; i < nreserved; i++) {
reservedSlots[i] = JS::UndefinedValue();
}
}
// All proxies share the same data layout. Following the object's shape, the // proxy has a ProxyDataLayout structure with the proxy's handler and expando // object pointer. The ProxyValueArray is stored inline immediately after the // ProxyDataLayout. struct ProxyDataLayout { const BaseProxyHandler* handler;
// The expando object holds private fields should they be stamped into a // non-forwarding proxy. This is nullptr when the proxy has no expando.
JSObject* expando;
class JS_PUBLIC_API AutoEnterPolicy { public: typedef BaseProxyHandler::Action Action;
AutoEnterPolicySetProxyReservedSlotUnchecked(obj, n, extra);
JS::HandleObject wrapper, JS::HandleId id, Action act, bool mayThrow) #ifdef JS_DEBUG
: context(nullptr) #endif
{
allow = handler->hasSecurityPolicy()
? handler->enter(cx, wrapper, id, act, mayThrow, &rv)
: true;
recordEnter(cx, wrapper, id, act); // We want to throw an exception if all of the following are true: // * The policy disallowed access. // * The policy set rv to false, indicating that we should throw. // * The caller did not instruct us to ignore exceptions. // * The policy did not throw itself. if (!allow && !rv && mayThrow) {
reportErrorIfExceptionIsNotPending(cx, id);
}
}
// NB: We explicitly don't track the entered action here, because sometimes // set() methods do an implicit get() during their implementation, leading // to spurious assertions.
AutoEnterPolicy* prev; void recordEnter(JSContext* cx, JS::HandleObject proxy, JS::HandleId id,
Action act); void recordLeave();
private: // This operator needs to be deleted explicitly, otherwise Visual C++ will // create it automatically when it is part of the export JS API. In that // case, compile would fail because HandleId is not allowed to be assigned // and consequently instantiation of assign operator of mozilla::Maybe // would fail. See bug 1325351 comment 16. Copy constructor is removed at // the same time for consistency.
AutoEnterPolicy(const AutoEnterPolicy&) = delete;
AutoEnterPolicy& operator=(const AutoEnterPolicy&) = delete;
};
// For now assert each Proxy Class has at least 1 reserved slot. This is // not a hard requirement, but helps catch Classes that need an explicit // JSCLASS_HAS_RESERVED_SLOTS since bug 1360523.
static_assert(reservedSlots > 0, "Proxy Classes must have at least 1 reserved slot");
// ProxyValueArray must fit inline in the object, so assert the number of // slots does not exceed MAX_FIXED_SLOTS.
static_assert(numSlots + reservedSlots <= JS::shadow::Object::MAX_FIXED_SLOTS, "ProxyValueArray size must not exceed max JSObject size");
// Proxies must not have the JSCLASS_SKIP_NURSERY_FINALIZE flag set: they // always have finalizers, and whether they can be nursery allocated is // controlled by the canNurseryAllocate() method on the proxy handler.
static_assert(!(Flags & JSCLASS_SKIP_NURSERY_FINALIZE), "Proxies must not use JSCLASS_SKIP_NURSERY_FINALIZE; use " "the canNurseryAllocate() proxy handler method instead."); return Flags;
}
// Converts a proxy into a DeadObjectProxy that will throw exceptions on all // access. This will run the proxy's finalizer to perform clean-up before the // conversion happens.
JS_PUBLIC_API void NukeNonCCWProxy(JSContext* cx, JS::HandleObject proxy);
} /* namespace js */
#endif/* js_Proxy_h */
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.33 Sekunden
(vorverarbeitet am 2026-10-12)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.