Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/js/src/vm/ArrayBufferObject-inl.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2
 * vim: set ts=8 sts=4 et sw=4 tw=99:
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_ArrayBufferObject_inl_h
8
#define vm_ArrayBufferObject_inl_h
9
10
/* Utilities and common inline code for ArrayBufferObject and SharedArrayBufferObject */
11
12
#include "vm/ArrayBufferObject.h"
13
14
#include "js/Value.h"
15
16
#include "vm/SharedArrayObject.h"
17
#include "vm/SharedMem.h"
18
19
namespace js {
20
21
inline SharedMem<uint8_t*>
22
ArrayBufferObjectMaybeShared::dataPointerEither()
23
0
{
24
0
    ArrayBufferObjectMaybeShared* buf = this;
25
0
    if (buf->is<ArrayBufferObject>()) {
26
0
        return buf->as<ArrayBufferObject>().dataPointerShared();
27
0
    }
28
0
    return buf->as<SharedArrayBufferObject>().dataPointerShared();
29
0
}
30
31
inline bool
32
ArrayBufferObjectMaybeShared::isDetached() const
33
0
{
34
0
    if (this->is<ArrayBufferObject>()) {
35
0
        return this->as<ArrayBufferObject>().isDetached();
36
0
    }
37
0
    return false;
38
0
}
39
40
inline uint32_t
41
AnyArrayBufferByteLength(const ArrayBufferObjectMaybeShared* buf)
42
0
{
43
0
    if (buf->is<ArrayBufferObject>()) {
44
0
        return buf->as<ArrayBufferObject>().byteLength();
45
0
    }
46
0
    return buf->as<SharedArrayBufferObject>().byteLength();
47
0
}
48
49
inline uint32_t
50
ArrayBufferObjectMaybeShared::byteLength()
51
0
{
52
0
    return AnyArrayBufferByteLength(this);
53
0
}
54
55
inline bool
56
AnyArrayBufferIsPreparedForAsmJS(const ArrayBufferObjectMaybeShared* buf)
57
0
{
58
0
    if (buf->is<ArrayBufferObject>()) {
59
0
        return buf->as<ArrayBufferObject>().isPreparedForAsmJS();
60
0
    }
61
0
    return buf->as<SharedArrayBufferObject>().isPreparedForAsmJS();
62
0
}
63
64
inline bool
65
ArrayBufferObjectMaybeShared::isPreparedForAsmJS() const
66
0
{
67
0
    return AnyArrayBufferIsPreparedForAsmJS(this);
68
0
}
69
70
inline bool
71
AnyArrayBufferIsWasm(const ArrayBufferObjectMaybeShared* buf)
72
0
{
73
0
    if (buf->is<ArrayBufferObject>()) {
74
0
        return buf->as<ArrayBufferObject>().isWasm();
75
0
    }
76
0
    return buf->as<SharedArrayBufferObject>().isWasm();
77
0
}
78
79
inline bool
80
ArrayBufferObjectMaybeShared::isWasm() const
81
0
{
82
0
    return AnyArrayBufferIsWasm(this);
83
0
}
84
85
inline ArrayBufferObjectMaybeShared&
86
AsAnyArrayBuffer(HandleValue val)
87
0
{
88
0
    if (val.toObject().is<ArrayBufferObject>()) {
89
0
        return val.toObject().as<ArrayBufferObject>();
90
0
    }
91
0
    return val.toObject().as<SharedArrayBufferObject>();
92
0
}
93
94
} // namespace js
95
96
#endif // vm_ArrayBufferObject_inl_h