diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /js/src/jit/TemplateObject.h | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | js/src/jit/TemplateObject.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/js/src/jit/TemplateObject.h b/js/src/jit/TemplateObject.h new file mode 100644 index 0000000000..3620b94738 --- /dev/null +++ b/js/src/jit/TemplateObject.h @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * vim: set ts=8 sts=2 et sw=2 tw=80: + * 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 jit_TemplateObject_h +#define jit_TemplateObject_h + +#include "vm/NativeObject.h" +#include "vm/Shape.h" + +namespace js { +namespace jit { + +class TemplateNativeObject; + +// Wrapper for template objects. This should only expose methods that can be +// safely called off-thread without racing with the main thread. +class TemplateObject { + protected: + JSObject* obj_; + + public: + explicit TemplateObject(JSObject* obj) : obj_(obj) {} + + inline gc::AllocKind getAllocKind() const; + + // The following methods rely on the object's group->clasp. This is safe + // to read off-thread for template objects. + inline bool isNativeObject() const; + inline const TemplateNativeObject& asTemplateNativeObject() const; + inline bool isArrayObject() const; + inline bool isArgumentsObject() const; + inline bool isTypedArrayObject() const; + inline bool isRegExpObject() const; + inline bool isCallObject() const; + inline bool isBlockLexicalEnvironmentObject() const; + inline bool isPlainObject() const; + + // The shape should not change. This is true for template objects because + // they're never exposed to arbitrary script. + inline gc::Cell* shape() const; +}; + +class TemplateNativeObject : public TemplateObject { + protected: + NativeObject& asNativeObject() const { return obj_->as<NativeObject>(); } + + public: + // Reading slot counts and object slots is safe, as long as we don't touch + // the BaseShape (it can change when we create a ShapeTable for the shape). + inline bool hasDynamicSlots() const; + inline uint32_t numDynamicSlots() const; + inline uint32_t numUsedFixedSlots() const; + inline uint32_t numFixedSlots() const; + inline uint32_t slotSpan() const; + inline Value getSlot(uint32_t i) const; + + // Reading ObjectElements fields is safe, except for the flags. + // isSharedMemory is an exception: it's debug-only and not called on arrays. +#ifdef DEBUG + inline bool isSharedMemory() const; +#endif + inline uint32_t getDenseCapacity() const; + inline uint32_t getDenseInitializedLength() const; + inline uint32_t getArrayLength() const; + inline bool hasDynamicElements() const; + inline const Value* getDenseElements() const; + + inline gc::Cell* regExpShared() const; +}; + +} // namespace jit +} // namespace js + +#endif /* jit_TemplateObject_h */ |