tor-browser

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

JSAtomState.h (2139B)


      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
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef vm_JSAtomState_h
      8 #define vm_JSAtomState_h
      9 
     10 #include "gc/Barrier.h"
     11 #include "js/ProtoKey.h"
     12 #include "js/Symbol.h"
     13 #include "vm/CommonPropertyNames.h"
     14 
     15 namespace js {
     16 class PropertyName;
     17 }  // namespace js
     18 
     19 /* Various built-in or commonly-used names pinned on first context. */
     20 struct JSAtomState {
     21 #define PROPERTYNAME_FIELD(id, text) \
     22  js::ImmutableTenuredPtr<js::PropertyName*> id;
     23  FOR_EACH_COMMON_PROPERTYNAME(PROPERTYNAME_FIELD)
     24 #undef PROPERTYNAME_FIELD
     25 #define PROPERTYNAME_FIELD(name, clasp) \
     26  js::ImmutableTenuredPtr<js::PropertyName*> name;
     27  JS_FOR_EACH_PROTOTYPE(PROPERTYNAME_FIELD)
     28 #undef PROPERTYNAME_FIELD
     29 #define PROPERTYNAME_FIELD(name) \
     30  js::ImmutableTenuredPtr<js::PropertyName*> name;
     31  JS_FOR_EACH_WELL_KNOWN_SYMBOL(PROPERTYNAME_FIELD)
     32 #undef PROPERTYNAME_FIELD
     33 #define PROPERTYNAME_FIELD(name) \
     34  js::ImmutableTenuredPtr<js::PropertyName*> Symbol_##name;
     35  JS_FOR_EACH_WELL_KNOWN_SYMBOL(PROPERTYNAME_FIELD)
     36 #undef PROPERTYNAME_FIELD
     37 
     38  js::ImmutableTenuredPtr<js::PropertyName*>* wellKnownSymbolNames(){
     39 #define FIRST_PROPERTYNAME_FIELD(name) return &name;
     40      JS_FOR_EACH_WELL_KNOWN_SYMBOL(FIRST_PROPERTYNAME_FIELD)
     41 #undef FIRST_PROPERTYNAME_FIELD
     42  }
     43 
     44  js::ImmutableTenuredPtr<js::PropertyName*>* wellKnownSymbolDescriptions() {
     45 #define FIRST_PROPERTYNAME_FIELD(name) return &Symbol_##name;
     46    JS_FOR_EACH_WELL_KNOWN_SYMBOL(FIRST_PROPERTYNAME_FIELD)
     47 #undef FIRST_PROPERTYNAME_FIELD
     48  }
     49 };
     50 
     51 namespace js {
     52 
     53 #define NAME_OFFSET(name) offsetof(JSAtomState, name)
     54 
     55 inline Handle<PropertyName*> AtomStateOffsetToName(const JSAtomState& atomState,
     56                                                   size_t offset) {
     57  return *reinterpret_cast<js::ImmutableTenuredPtr<js::PropertyName*>*>(
     58      (char*)&atomState + offset);
     59 }
     60 
     61 } /* namespace js */
     62 
     63 #endif /* vm_JSAtomState_h */