| 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 |
#ifndef vm_ObjectFlags_h |
| 8 |
#define vm_ObjectFlags_h |
| 9 |
|
| 10 |
#include <stdint.h> |
| 11 |
|
| 12 |
#include "util/EnumFlags.h" // js::EnumFlags |
| 13 |
|
| 14 |
namespace js { |
| 15 |
|
| 16 |
// Flags set on the Shape which describe the referring object. Once set these |
| 17 |
// cannot be unset (except during object densification of sparse indexes), and |
| 18 |
// are transferred from shape to shape as the object's last property changes. |
| 19 |
// |
| 20 |
// If you add a new flag here, please add appropriate code to JSObject::dump to |
| 21 |
// dump it as part of the object representation. |
| 22 |
enum class ObjectFlag : uint16_t { |
| 23 |
IsUsedAsPrototype = 1 << 0, |
| 24 |
NotExtensible = 1 << 1, |
| 25 |
Indexed = 1 << 2, |
| 26 |
HasInterestingSymbol = 1 << 3, |
| 27 |
|
| 28 |
// If set, the shape's property map may contain an enumerable property. This |
| 29 |
// only accounts for (own) shape properties: if the flag is not set, the |
| 30 |
// object may still have (enumerable) dense elements, typed array elements, or |
| 31 |
// a JSClass enumeration hook. |
| 32 |
HasEnumerable = 1 << 4, |
| 33 |
|
| 34 |
FrozenElements = 1 << 5, // See ObjectElements::FROZEN comment. |
| 35 |
|
| 36 |
// If set, the shape teleporting optimization can no longer be used for |
| 37 |
// accessing properties on this object. |
| 38 |
// See: JSObject::hasInvalidatedTeleporting, ProtoChainSupportsTeleporting. |
| 39 |
InvalidatedTeleporting = 1 << 6, |
| 40 |
|
| 41 |
ImmutablePrototype = 1 << 7, |
| 42 |
|
| 43 |
// See JSObject::isQualifiedVarObj(). |
| 44 |
QualifiedVarObj = 1 << 8, |
| 45 |
|
| 46 |
// If set, the object may have a non-writable property or an accessor |
| 47 |
// property. |
| 48 |
// |
| 49 |
// * This is only set for PlainObjects because we only need it for these |
| 50 |
// objects and setting it for other objects confuses insertInitialShape. |
| 51 |
// |
| 52 |
// * This flag does not account for properties named "__proto__". This is |
| 53 |
// because |Object.prototype| has a "__proto__" accessor property and we |
| 54 |
// don't want to include it because it would result in the flag being set on |
| 55 |
// most proto chains. Code using this flag must check for "__proto__" |
| 56 |
// property names separately. |
| 57 |
HasNonWritableOrAccessorPropExclProto = 1 << 9, |
| 58 |
|
| 59 |
// If set, the object either mutated or deleted an accessor property. This is |
| 60 |
// used to invalidate IC/Warp code specializing on specific getter/setter |
| 61 |
// objects. See also the SMDOC comment in vm/GetterSetter.h. |
| 62 |
HadGetterSetterChange = 1 << 10, |
| 63 |
|
| 64 |
// If set, use the watchtower testing mechanism to log changes to this object. |
| 65 |
UseWatchtowerTestingLog = 1 << 11, |
| 66 |
|
| 67 |
// If set, access to existing properties of this global object can be guarded |
| 68 |
// based on a per-global counter that is incremented when the global object |
| 69 |
// has its properties reordered/shadowed, instead of a shape guard. |
| 70 |
GenerationCountedGlobal = 1 << 12, |
| 71 |
|
| 72 |
// If set, we need to verify the result of a proxy get/set trap. |
| 73 |
// |
| 74 |
// The [[Get]] and [[Set]] traps for proxy objects enforce certain invariants |
| 75 |
// for non-configurable, non-writable data properties and non-configurable |
| 76 |
// accessors. If the invariants are not maintained, we must throw a type |
| 77 |
// error. If this flag is not set, and this is a NativeObject, *and* the |
| 78 |
// class does not have a resolve hook, then this object does not have any |
| 79 |
// such properties, and we can skip the slow check. |
| 80 |
// |
| 81 |
// See |
| 82 |
// https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots |
| 83 |
NeedsProxyGetSetResultValidation = 1 << 13, |
| 84 |
|
| 85 |
// There exists a property on this object which has fuse semantics associated |
| 86 |
// with it, and thus we must trap on changes to said property. |
| 87 |
HasFuseProperty = 1 << 14, |
| 88 |
|
| 89 |
}; |
| 90 |
|
| 91 |
using ObjectFlags = EnumFlags<ObjectFlag>; |
| 92 |
|
| 93 |
} // namespace js |
| 94 |
|
| 95 |
#endif /* vm_ObjectFlags_h */ |