Source code

Revision control

Other Tools

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
// Specialized .h file to be used by both JS and C++ code.
8
9
#ifndef builtin_TypedObjectConstants_h
10
#define builtin_TypedObjectConstants_h
11
12
///////////////////////////////////////////////////////////////////////////
13
// Slots for objects using the typed array layout
14
15
#define JS_TYPEDARRAYLAYOUT_BUFFER_SLOT 0
16
#define JS_TYPEDARRAYLAYOUT_LENGTH_SLOT 1
17
#define JS_TYPEDARRAYLAYOUT_BYTEOFFSET_SLOT 2
18
19
///////////////////////////////////////////////////////////////////////////
20
// Slots and flags for ArrayBuffer objects
21
22
#define JS_ARRAYBUFFER_FLAGS_SLOT 3
23
24
#define JS_ARRAYBUFFER_DETACHED_FLAG 0x8
25
26
///////////////////////////////////////////////////////////////////////////
27
// Slots for typed prototypes
28
29
#define JS_TYPROTO_SLOTS 0
30
31
///////////////////////////////////////////////////////////////////////////
32
// Slots for type objects
33
//
34
// Some slots apply to all type objects and some are specific to
35
// particular kinds of type objects. For simplicity we use the same
36
// number of slots no matter what kind of type descriptor we are
37
// working with, even though this is mildly wasteful.
38
39
// Slots on all type objects
40
#define JS_DESCR_SLOT_KIND 0 // Atomized string representation
41
#define JS_DESCR_SLOT_STRING_REPR 1 // Atomized string representation
42
#define JS_DESCR_SLOT_ALIGNMENT 2 // Alignment in bytes
43
#define JS_DESCR_SLOT_SIZE 3 // Size in bytes, else 0
44
#define JS_DESCR_SLOT_OPAQUE 4 // Atomized string representation
45
#define JS_DESCR_SLOT_TYPROTO 5 // Prototype for instances, if any
46
#define JS_DESCR_SLOT_ARRAYPROTO 6 // Lazily created prototype for arrays
47
#define JS_DESCR_SLOT_TRACE_LIST 7 // List of references for use in tracing
48
#define JS_DESCR_SLOT_FLAGS 8 // int32 bitvector of JS_DESCR_FLAG_*
49
50
// Slots on scalars, references
51
#define JS_DESCR_SLOT_TYPE 9 // Type code
52
53
// Slots on array descriptors
54
#define JS_DESCR_SLOT_ARRAY_ELEM_TYPE 9
55
#define JS_DESCR_SLOT_ARRAY_LENGTH 10
56
57
// Slots on struct type objects
58
#define JS_DESCR_SLOT_STRUCT_FIELD_NAMES 9
59
#define JS_DESCR_SLOT_STRUCT_FIELD_TYPES 10
60
#define JS_DESCR_SLOT_STRUCT_FIELD_OFFSETS 11
61
#define JS_DESCR_SLOT_STRUCT_FIELD_MUTS 12
62
63
// Maximum number of slots for any descriptor
64
#define JS_DESCR_SLOTS 13
65
66
#define JS_DESCR_FLAG_ALLOW_CONSTRUCT 1 // Allow structure to be constructed
67
68
// These constants are for use exclusively in JS code. In C++ code,
69
// prefer TypeRepresentation::Scalar etc, which allows you to
70
// write a switch which will receive a warning if you omit a case.
71
#define JS_TYPEREPR_SCALAR_KIND 1
72
#define JS_TYPEREPR_REFERENCE_KIND 2
73
#define JS_TYPEREPR_STRUCT_KIND 3
74
#define JS_TYPEREPR_ARRAY_KIND 4
75
76
// These constants are for use exclusively in JS code. In C++ code,
77
// prefer Scalar::Int8 etc, which allows you to write a switch which will
78
// receive a warning if you omit a case.
79
#define JS_SCALARTYPEREPR_INT8 0
80
#define JS_SCALARTYPEREPR_UINT8 1
81
#define JS_SCALARTYPEREPR_INT16 2
82
#define JS_SCALARTYPEREPR_UINT16 3
83
#define JS_SCALARTYPEREPR_INT32 4
84
#define JS_SCALARTYPEREPR_UINT32 5
85
#define JS_SCALARTYPEREPR_FLOAT32 6
86
#define JS_SCALARTYPEREPR_FLOAT64 7
87
#define JS_SCALARTYPEREPR_UINT8_CLAMPED 8
88
#define JS_SCALARTYPEREPR_BIGINT64 9
89
#define JS_SCALARTYPEREPR_BIGUINT64 10
90
91
// These constants are for use exclusively in JS code. In C++ code,
92
// prefer ReferenceTypeRepresentation::TYPE_ANY etc, which allows
93
// you to write a switch which will receive a warning if you omit a
94
// case.
95
#define JS_REFERENCETYPEREPR_ANY 0
96
#define JS_REFERENCETYPEREPR_OBJECT 1
97
#define JS_REFERENCETYPEREPR_WASM_ANYREF 2
98
#define JS_REFERENCETYPEREPR_STRING 3
99
100
#endif