9838b8732b5c220f1d5ef0d51cc942c6399bbc03
[platform/upstream/v8.git] / src / vm-state.h
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_VM_STATE_H_
6 #define V8_VM_STATE_H_
7
8 #include "src/allocation.h"
9 #include "src/isolate.h"
10
11 namespace v8 {
12 namespace internal {
13
14 // Logging and profiling.  A StateTag represents a possible state of
15 // the VM. The logger maintains a stack of these. Creating a VMState
16 // object enters a state by pushing on the stack, and destroying a
17 // VMState object leaves a state by popping the current state from the
18 // stack.
19 template <StateTag Tag>
20 class VMState BASE_EMBEDDED {
21  public:
22   explicit inline VMState(Isolate* isolate);
23   inline ~VMState();
24
25  private:
26   Isolate* isolate_;
27   StateTag previous_tag_;
28 };
29
30
31 class ExternalCallbackScope BASE_EMBEDDED {
32  public:
33   inline ExternalCallbackScope(Isolate* isolate, Address callback);
34   inline ~ExternalCallbackScope();
35   Address callback() { return callback_; }
36   Address* callback_address() { return &callback_; }
37   ExternalCallbackScope* previous() { return previous_scope_; }
38   inline Address scope_address();
39
40  private:
41   Isolate* isolate_;
42   Address callback_;
43   ExternalCallbackScope* previous_scope_;
44 #ifdef USE_SIMULATOR
45   Address scope_address_;
46 #endif
47 };
48
49 } }  // namespace v8::internal
50
51
52 #endif  // V8_VM_STATE_H_