Bug 1842773 - Part 32: Allow constructing growable SharedArrayBuffers. r=sfink
[gecko.git] / js / src / vm / ArrayBufferObject-inl.h
blob10fbdf4f37124588c114974305315d14e3232aa5
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/. */
7 #ifndef vm_ArrayBufferObject_inl_h
8 #define vm_ArrayBufferObject_inl_h
10 // Utilities and common inline code for ArrayBufferObject and
11 // SharedArrayBufferObject.
13 #include "vm/ArrayBufferObject.h"
15 #include "vm/SharedArrayObject.h"
16 #include "vm/SharedMem.h"
18 namespace js {
20 inline SharedMem<uint8_t*> ArrayBufferObjectMaybeShared::dataPointerEither() {
21 if (this->is<ArrayBufferObject>()) {
22 return this->as<ArrayBufferObject>().dataPointerShared();
24 return this->as<SharedArrayBufferObject>().dataPointerShared();
27 inline bool ArrayBufferObjectMaybeShared::isDetached() const {
28 if (this->is<ArrayBufferObject>()) {
29 return this->as<ArrayBufferObject>().isDetached();
31 return false;
34 inline bool ArrayBufferObjectMaybeShared::isResizable() const {
35 if (this->is<ArrayBufferObject>()) {
36 return this->as<ArrayBufferObject>().isResizable();
38 return this->as<SharedArrayBufferObject>().isGrowable();
41 inline size_t ArrayBufferObjectMaybeShared::byteLength() const {
42 if (this->is<ArrayBufferObject>()) {
43 return this->as<ArrayBufferObject>().byteLength();
45 return this->as<SharedArrayBufferObject>().byteLength();
48 inline bool ArrayBufferObjectMaybeShared::isPreparedForAsmJS() const {
49 if (this->is<ArrayBufferObject>()) {
50 return this->as<ArrayBufferObject>().isPreparedForAsmJS();
52 return false;
55 inline bool ArrayBufferObjectMaybeShared::isWasm() const {
56 if (this->is<ArrayBufferObject>()) {
57 return this->as<ArrayBufferObject>().isWasm();
59 return this->as<SharedArrayBufferObject>().isWasm();
62 inline bool ArrayBufferObjectMaybeShared::pinLength(bool pin) {
63 if (is<ArrayBufferObject>()) {
64 return as<ArrayBufferObject>().pinLength(pin);
66 return false; // Cannot pin or unpin shared array buffers.
69 } // namespace js
71 #endif // vm_ArrayBufferObject_inl_h