v8  10.1.124 (node 18.2.0)
V8 is Google's open source JavaScript engine
v8-embedder-state-scope.h
Go to the documentation of this file.
1 // Copyright 2021 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 INCLUDE_V8_EMBEDDER_STATE_SCOPE_H_
6 #define INCLUDE_V8_EMBEDDER_STATE_SCOPE_H_
7 
8 #include <memory>
9 
10 #include "v8-context.h" // NOLINT(build/include_directory)
11 #include "v8-internal.h" // NOLINT(build/include_directory)
12 #include "v8-local-handle.h" // NOLINT(build/include_directory)
13 
14 namespace v8 {
15 
16 namespace internal {
17 class EmbedderState;
18 } // namespace internal
19 
20 // A StateTag represents a possible state of the embedder.
21 enum class EmbedderStateTag : uint8_t {
22  // reserved
23  EMPTY = 0,
24  OTHER = 1,
25  // embedder can define any state after
26 };
27 
28 // A stack-allocated class that manages an embedder state on the isolate.
29 // After an EmbedderState scope has been created, a new embedder state will be
30 // pushed on the isolate stack.
32  public:
33  EmbedderStateScope(Isolate* isolate, Local<v8::Context> context,
34  EmbedderStateTag tag);
35 
37 
38  private:
39  // Declaring operator new and delete as deleted is not spec compliant.
40  // Therefore declare them private instead to disable dynamic alloc
41  void* operator new(size_t size);
42  void* operator new[](size_t size);
43  void operator delete(void*, size_t);
44  void operator delete[](void*, size_t);
45 
46  std::unique_ptr<internal::EmbedderState> embedder_state_;
47 };
48 
49 } // namespace v8
50 
51 #endif // INCLUDE_V8_EMBEDDER_STATE_SCOPE_H_