• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2010 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_VM_STATE_H_
6 #define V8_EXECUTION_VM_STATE_H_
7 
8 #include "include/v8-unwinder.h"
9 #include "src/common/globals.h"
10 #include "src/logging/counters-scopes.h"
11 
12 namespace v8 {
13 namespace internal {
14 
15 // Logging and profiling. A StateTag represents a possible state of the VM. The
16 // logger maintains a stack of these. Creating a VMState object enters a state
17 // by pushing on the stack, and destroying a VMState object leaves a state by
18 // popping the current state from the stack.
19 template <StateTag Tag>
20 class VMState {
21  public:
22   explicit inline VMState(Isolate* isolate);
23   inline ~VMState();
24 
25  private:
26   Isolate* isolate_;
27   StateTag previous_tag_;
28 };
29 
30 class V8_NODISCARD ExternalCallbackScope {
31  public:
32   inline ExternalCallbackScope(Isolate* isolate, Address callback);
33   inline ~ExternalCallbackScope();
callback()34   Address callback() { return callback_; }
callback_entrypoint_address()35   Address* callback_entrypoint_address() {
36     if (callback_ == kNullAddress) return nullptr;
37 #if USES_FUNCTION_DESCRIPTORS
38     return FUNCTION_ENTRYPOINT_ADDRESS(callback_);
39 #else
40     return &callback_;
41 #endif
42   }
previous()43   ExternalCallbackScope* previous() { return previous_scope_; }
44   inline Address scope_address();
45 
46  private:
47   Isolate* isolate_;
48   Address callback_;
49   ExternalCallbackScope* previous_scope_;
50   VMState<EXTERNAL> vm_state_;
51   PauseNestedTimedHistogramScope pause_timed_histogram_scope_;
52 #ifdef USE_SIMULATOR
53   Address scope_address_;
54 #endif
55 };
56 
57 }  // namespace internal
58 }  // namespace v8
59 
60 #endif  // V8_EXECUTION_VM_STATE_H_
61