vm-state.h 1.48 KB
Newer Older
1
// Copyright 2010 the V8 project authors. All rights reserved.
2 3
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
4 5 6 7

#ifndef V8_VM_STATE_H_
#define V8_VM_STATE_H_

8
#include "src/allocation.h"
9
#include "src/counters.h"
10

11 12 13
namespace v8 {
namespace internal {

14 15 16 17 18
// Logging and profiling.  A StateTag represents a possible state of
// the VM. The logger maintains a stack of these. Creating a VMState
// object enters a state by pushing on the stack, and destroying a
// VMState object leaves a state by popping the current state from the
// stack.
19
template <StateTag Tag>
20 21
class VMState BASE_EMBEDDED {
 public:
22
  explicit inline VMState(Isolate* isolate);
23 24
  inline ~VMState();

25
 private:
26
  Isolate* isolate_;
27 28
  StateTag previous_tag_;
};
29

30

31 32
class ExternalCallbackScope BASE_EMBEDDED {
 public:
33
  inline ExternalCallbackScope(Isolate* isolate, Address callback);
34
  inline ~ExternalCallbackScope();
35
  Address callback() { return callback_; }
36 37 38 39 40 41 42 43
  Address* callback_entrypoint_address() {
    if (callback_ == nullptr) return nullptr;
#if USES_FUNCTION_DESCRIPTORS
    return FUNCTION_ENTRYPOINT_ADDRESS(callback_);
#else
    return &callback_;
#endif
  }
44 45 46
  ExternalCallbackScope* previous() { return previous_scope_; }
  inline Address scope_address();

47
 private:
48
  Isolate* isolate_;
49 50 51 52 53
  Address callback_;
  ExternalCallbackScope* previous_scope_;
#ifdef USE_SIMULATOR
  Address scope_address_;
#endif
54 55
};

56 57
}  // namespace internal
}  // namespace v8
58 59 60


#endif  // V8_VM_STATE_H_