Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:42:30

0001 // Copyright 2021 the V8 project authors. All rights reserved.
0002 // Use of this source code is governed by a BSD-style license that can be
0003 // found in the LICENSE file.
0004 
0005 #ifndef INCLUDE_V8_EMBEDDER_STATE_SCOPE_H_
0006 #define INCLUDE_V8_EMBEDDER_STATE_SCOPE_H_
0007 
0008 #include <memory>
0009 
0010 #include "v8-internal.h"      // NOLINT(build/include_directory)
0011 #include "v8-local-handle.h"  // NOLINT(build/include_directory)
0012 
0013 namespace v8 {
0014 
0015 class Context;
0016 
0017 namespace internal {
0018 class EmbedderState;
0019 }  // namespace internal
0020 
0021 // A StateTag represents a possible state of the embedder.
0022 enum class EmbedderStateTag : uint8_t {
0023   // reserved
0024   EMPTY = 0,
0025   OTHER = 1,
0026   // embedder can define any state after
0027 };
0028 
0029 // A stack-allocated class that manages an embedder state on the isolate.
0030 // After an EmbedderState scope has been created, a new embedder state will be
0031 // pushed on the isolate stack.
0032 class V8_EXPORT EmbedderStateScope {
0033  public:
0034   EmbedderStateScope(Isolate* isolate, Local<v8::Context> context,
0035                      EmbedderStateTag tag);
0036 
0037   ~EmbedderStateScope();
0038 
0039  private:
0040   // Declaring operator new and delete as deleted is not spec compliant.
0041   // Therefore declare them private instead to disable dynamic alloc
0042   void* operator new(size_t size);
0043   void* operator new[](size_t size);
0044   void operator delete(void*, size_t);
0045   void operator delete[](void*, size_t);
0046 
0047   std::unique_ptr<internal::EmbedderState> embedder_state_;
0048 };
0049 
0050 }  // namespace v8
0051 
0052 #endif  // INCLUDE_V8_EMBEDDER_STATE_SCOPE_H_