tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

JSSlots.h (2546B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 /**
      8 * This file defines various reserved slot indices used by JavaScript
      9 * reflections of DOM objects.
     10 */
     11 #ifndef mozilla_dom_DOMSlots_h
     12 #define mozilla_dom_DOMSlots_h
     13 
     14 // We use slot 0 for holding the raw object.  This is safe for both
     15 // globals and non-globals.
     16 // NOTE: This is baked into the Ion JIT as 0 in codegen for LGetDOMProperty and
     17 // LSetDOMProperty. Those constants need to be changed accordingly if this value
     18 // changes.
     19 #define DOM_OBJECT_SLOT 0
     20 
     21 // The total number of slots non-proxy DOM objects use by default.
     22 // Specific objects may have more for storing cached values.
     23 #define DOM_INSTANCE_RESERVED_SLOTS 1
     24 
     25 // Interface objects store a number of reserved slots equal to
     26 // INTERFACE_OBJECT_INFO_RESERVED_SLOT + number of legacy factory functions,
     27 // with a maximum of js::FunctionExtended::NUM_EXTENDED_SLOTS.
     28 // INTERFACE_OBJECT_INFO_RESERVED_SLOT contains the DOMInterfaceInfo.
     29 // INTERFACE_OBJECT_FIRST_LEGACY_FACTORY_FUNCTION and higher contain the
     30 // JSObjects for the legacy factory functions.
     31 enum {
     32  INTERFACE_OBJECT_INFO_RESERVED_SLOT = 0,
     33  INTERFACE_OBJECT_FIRST_LEGACY_FACTORY_FUNCTION,
     34 };
     35 // See js::FunctionExtended::NUM_EXTENDED_SLOTS.
     36 #define INTERFACE_OBJECT_MAX_SLOTS 3
     37 
     38 // Legacy factory functions store a LegacyFactoryFunction in the
     39 // LEGACY_FACTORY_FUNCTION_RESERVED_SLOT slot.
     40 enum { LEGACY_FACTORY_FUNCTION_RESERVED_SLOT = 0 };
     41 
     42 // Interface prototype objects store a number of reserved slots equal to
     43 // DOM_INTERFACE_PROTO_SLOTS_BASE or DOM_INTERFACE_PROTO_SLOTS_BASE + 1 if a
     44 // slot for the unforgeable holder is needed.
     45 #define DOM_INTERFACE_PROTO_SLOTS_BASE 0
     46 
     47 // The slot index of raw pointer of dom object stored in observable array exotic
     48 // object. We need this in order to call the OnSet* and OnDelete* callbacks.
     49 #define OBSERVABLE_ARRAY_DOM_INTERFACE_SLOT 0
     50 
     51 // The slot index of backing list stored in observable array exotic object.
     52 #define OBSERVABLE_ARRAY_BACKING_LIST_OBJECT_SLOT 1
     53 
     54 namespace mozilla::dom {
     55 
     56 // This mimics xpc::JSSLOT_EXPANDO_COUNT (and we static assert that), but avoids
     57 // pulling in XPConnect headers.
     58 enum ExpandoSlots {
     59  DOM_EXPANDO_RESERVED_SLOTS = 4,
     60 };
     61 
     62 }  // namespace mozilla::dom
     63 
     64 #endif /* mozilla_dom_DOMSlots_h */