Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  ArrayObject.h

  Sprache: C
 

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


#ifndef vm_ArrayObject_h
#define vm_ArrayObject_h

#include "vm/JSContext.h"
#include "vm/NativeObject.h"

namespace js {

class AutoSetNewObjectMetadata;

class ArrayObject : public NativeObject {
 public:
  // Array(x) eagerly allocates dense elements if x <= this value.
  // This number was chosen so that the elements, the elements header,
  // and the MediumBuffer header all fit within MaxMediumAllocSize.
  static const uint32_t EagerAllocationMaxLength =
      (1 << 16) - ObjectElements::VALUES_PER_HEADER - 1;

  static const JSClass class_;

  bool lengthIsWritable() const {
    return !getElementsHeader()->hasNonwritableArrayLength();
  }

  uint32_t length() const { return getElementsHeader()->length; }

  void setNonWritableLength(JSContext* cx) {
    shrinkCapacityToInitializedLength(cx);
    assertInt32LengthFuse(cx);
    getElementsHeader()->setNonwritableArrayLength();
  }

  void setLengthToInitializedLength() {
    MOZ_ASSERT(lengthIsWritable());
    MOZ_ASSERT_IF(length() != getElementsHeader()->length,
                  !denseElementsAreFrozen());
    getElementsHeader()->length = getDenseInitializedLength();
    static_assert(MAX_DENSE_ELEMENTS_COUNT <= INT32_MAX,
                  "No need to check HasSeenArrayExceedsInt32LengthFuse");
  }

  void setLength(JSContext* cx, uint32_t length) {
    MOZ_ASSERT(lengthIsWritable());
    MOZ_ASSERT_IF(length != getElementsHeader()->length,
                  !denseElementsAreFrozen());
    assertInt32LengthFuse(cx);
    NativeObject::elementsSizeMustNotOverflow();
    if (MOZ_UNLIKELY(length > INT32_MAX)) {
      cx->runtime()
          ->runtimeFuses.ref()
          .hasSeenArrayExceedsInt32LengthFuse.popFuse(cx);
    }
    getElementsHeader()->length = length;
  }

  void assertInt32LengthFuse(JSContext* cx) {
    MOZ_ASSERT_IF(length() > INT32_MAX,
                  !cx->runtime()
                       ->runtimeFuses.ref()
                       .hasSeenArrayExceedsInt32LengthFuse.intact());
  }

  // Try to add a new dense element to this array. The array must be extensible.
  //
  // Returns DenseElementResult::Incomplete if `index >= length`, if the array
  // has sparse elements, if we're adding a sparse element, or if the array
  // already contains a dense element at this index.
  inline DenseElementResult addDenseElementNoLengthChange(JSContext* cx,
                                                          uint32_t index,
                                                          const Value& val);

  // Make an array object with the specified initial state.
  static MOZ_ALWAYS_INLINE ArrayObject* create(
      JSContext* cx, gc::AllocKind kind, gc::Heap heap,
      Handle<SharedShape*> shape, uint32_t length, uint32_t slotSpan,
      AutoSetNewObjectMetadata& metadata, gc::AllocSite* site = nullptr);
};

}  // namespace js

#endif  // vm_ArrayObject_h

Messung V0.5 in Prozent
C=91 H=94 G=92

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

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.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=141584
#Domains=752002