v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
protectors.h
Go to the documentation of this file.
1// Copyright 2019 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_EXECUTION_PROTECTORS_H_
6#define V8_EXECUTION_PROTECTORS_H_
7
9
10namespace v8 {
11namespace internal {
12
13class Protectors : public AllStatic {
14 public:
15 static const int kProtectorValid = 1;
16 static const int kProtectorInvalid = 0;
17
18#define DECLARED_PROTECTORS_ON_ISOLATE(V) \
19 V(ArrayBufferDetaching, ArrayBufferDetachingProtector, \
20 array_buffer_detaching_protector) \
21 V(ArrayConstructor, ArrayConstructorProtector, array_constructor_protector) \
22 V(ArrayIteratorLookupChain, ArrayIteratorProtector, \
23 array_iterator_protector) \
24 V(ArraySpeciesLookupChain, ArraySpeciesProtector, array_species_protector) \
25 V(IsConcatSpreadableLookupChain, IsConcatSpreadableProtector, \
26 is_concat_spreadable_protector) \
27 V(NoElements, NoElementsProtector, no_elements_protector) \
28 \
29 V(MegaDOM, MegaDOMProtector, mega_dom_protector) \
30 V(NoProfiling, NoProfilingProtector, no_profiling_protector) \
31 V(NoUndetectableObjects, NoUndetectableObjectsProtector, \
32 no_undetectable_objects_protector) \
33 \
34 /* The MapIterator protector protects the original iteration behaviors */ \
35 /* of Map.prototype.keys(), Map.prototype.values(), and */ \
36 /* Set.prototype.entries(). It does not protect the original iteration */ \
37 /* behavior of Map.prototype[Symbol.iterator](). */ \
38 /* The protector is invalidated when: */ \
39 /* * The 'next' property is set on an object where the property holder */ \
40 /* is the %MapIteratorPrototype% (e.g. because the object is that very */ \
41 /* prototype). */ \
42 /* * The 'Symbol.iterator' property is set on an object where the */ \
43 /* property holder is the %IteratorPrototype%. Note that this also */ \
44 /* invalidates the SetIterator protector (see below). */ \
45 V(MapIteratorLookupChain, MapIteratorProtector, map_iterator_protector) \
46 /* String.prototype.{matchAll|replace|split} looks up */ \
47 /* Symbol.{matchAll|replace|split} (aka @@matchAll, @@replace @split) on */ \
48 /* the search term to check if it is regexp-like. */ \
49 /* This protector ensures the prototype chain of String.prototype and */ \
50 /* Number.prototype does not contain Symbol.{matchAll|replace|split}. */ \
51 /* It enables a fast-path for String.prototype.{matchAll|replace|split} */ \
52 /* by ensuring that */ \
53 /* the implicit wrapper object for strings and numbers do not contain */ \
54 /* the property Symbol.{matchAll|replace|split}. */ \
55 V(NumberStringNotRegexpLike, NumberStringNotRegexpLikeProtector, \
56 number_string_not_regexp_like_protector) \
57 V(RegExpSpeciesLookupChain, RegExpSpeciesProtector, \
58 regexp_species_protector) \
59 V(PromiseHook, PromiseHookProtector, promise_hook_protector) \
60 V(PromiseThenLookupChain, PromiseThenProtector, promise_then_protector) \
61 V(PromiseResolveLookupChain, PromiseResolveProtector, \
62 promise_resolve_protector) \
63 V(PromiseSpeciesLookupChain, PromiseSpeciesProtector, \
64 promise_species_protector) \
65 \
66 /* The SetIterator protector protects the original iteration behavior of */ \
67 /* Set.prototype.keys(), Set.prototype.values(), */ \
68 /* Set.prototype.entries(), and Set.prototype[Symbol.iterator](). The */ \
69 /* protector is invalidated when: */ \
70 /* * The 'next' property is set on an object where the property holder */ \
71 /* is the %SetIteratorPrototype% (e.g. because the object is that very */ \
72 /* prototype). */ \
73 /* * The 'Symbol.iterator' property is set on an object where the */ \
74 /* property holder is the %SetPrototype% OR %IteratorPrototype%. This */ \
75 /* means that setting Symbol.iterator on a MapIterator object can also */ \
76 /* invalidate the SetIterator protector, and vice versa, setting */ \
77 /* Symbol.iterator on a SetIterator object can also invalidate the */ \
78 /* MapIterator. This is an over-approximation for the sake of */ \
79 /* simplicity. */ \
80 V(SetIteratorLookupChain, SetIteratorProtector, set_iterator_protector) \
81 \
82 /* The StringIteratorProtector protects the original string iteration */ \
83 /* behavior for primitive strings. As long as the */ \
84 /* StringIteratorProtector is valid, iterating over a primitive string */ \
85 /* is guaranteed to be unobservable from user code and can thus be cut */ \
86 /* short. More specifically, the protector gets invalidated as soon as */ \
87 /* either String.prototype[Symbol.iterator] or */ \
88 /* String.prototype[Symbol.iterator]().next is modified. This guarantee */ \
89 /* does not apply to string objects (as opposed to primitives), since */ \
90 /* they could define their own Symbol.iterator. */ \
91 /* String.prototype itself does not need to be protected, since it is */ \
92 /* non-configurable and non-writable. */ \
93 V(StringIteratorLookupChain, StringIteratorProtector, \
94 string_iterator_protector) \
95 V(StringLengthOverflowLookupChain, StringLengthProtector, \
96 string_length_protector) \
97 /* This protects the ToPrimitive conversion of string wrappers (with the */ \
98 /* default type hint NUMBER). */ \
99 V(StringWrapperToPrimitive, StringWrapperToPrimitiveProtector, \
100 string_wrapper_to_primitive_protector) \
101 V(TypedArrayLengthLookupChain, TypedArrayLengthProtector, \
102 typed_array_length_protector) \
103 V(TypedArraySpeciesLookupChain, TypedArraySpeciesProtector, \
104 typed_array_species_protector)
105
106#define DECLARE_PROTECTOR_ON_ISOLATE(name, unused_root_index, unused_cell) \
107 V8_EXPORT_PRIVATE static inline bool Is##name##Intact(Isolate* isolate); \
108 V8_EXPORT_PRIVATE static void Invalidate##name(Isolate* isolate);
110#undef DECLARE_PROTECTOR_ON_ISOLATE
111};
112
113} // namespace internal
114} // namespace v8
115
116#endif // V8_EXECUTION_PROTECTORS_H_
static const int kProtectorValid
Definition protectors.h:15
static const int kProtectorInvalid
Definition protectors.h:16
#define DECLARE_PROTECTOR_ON_ISOLATE(name, unused_root_index, unused_cell)
Definition protectors.h:106
#define DECLARED_PROTECTORS_ON_ISOLATE(V)
Definition protectors.h:18