blob: 9838b8732b5c220f1d5ef0d51cc942c6399bbc03 [file] [log] [blame]
Andrei Popescu402d9372010-02-26 13:31:12 +00001// Copyright 2010 the V8 project authors. All rights reserved.
Ben Murdochb8a8cc12014-11-26 15:28:44 +00002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Andrei Popescu402d9372010-02-26 13:31:12 +00004
Steve Block6ded16b2010-05-10 14:33:55 +01005#ifndef V8_VM_STATE_H_
6#define V8_VM_STATE_H_
Andrei Popescu402d9372010-02-26 13:31:12 +00007
Ben Murdochb8a8cc12014-11-26 15:28:44 +00008#include "src/allocation.h"
9#include "src/isolate.h"
Ben Murdochf87a2032010-10-22 12:50:53 +010010
Andrei Popescu402d9372010-02-26 13:31:12 +000011namespace v8 {
12namespace internal {
13
Emily Bernierd0a1eb72015-03-24 16:35:39 -040014// 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.
Ben Murdochb8a8cc12014-11-26 15:28:44 +000019template <StateTag Tag>
Steve Block6ded16b2010-05-10 14:33:55 +010020class VMState BASE_EMBEDDED {
Andrei Popescu402d9372010-02-26 13:31:12 +000021 public:
Ben Murdochb8a8cc12014-11-26 15:28:44 +000022 explicit inline VMState(Isolate* isolate);
Steve Block6ded16b2010-05-10 14:33:55 +010023 inline ~VMState();
Andrei Popescu402d9372010-02-26 13:31:12 +000024
Steve Block6ded16b2010-05-10 14:33:55 +010025 private:
Steve Block44f0eee2011-05-26 01:26:41 +010026 Isolate* isolate_;
Ben Murdochb0fe1622011-05-05 13:52:32 +010027 StateTag previous_tag_;
Andrei Popescu402d9372010-02-26 13:31:12 +000028};
29
Ben Murdochb0fe1622011-05-05 13:52:32 +010030
31class ExternalCallbackScope BASE_EMBEDDED {
Ben Murdochb0fe1622011-05-05 13:52:32 +010032 public:
Steve Block44f0eee2011-05-26 01:26:41 +010033 inline ExternalCallbackScope(Isolate* isolate, Address callback);
Ben Murdochb0fe1622011-05-05 13:52:32 +010034 inline ~ExternalCallbackScope();
Ben Murdochb8a8cc12014-11-26 15:28:44 +000035 Address callback() { return callback_; }
36 Address* callback_address() { return &callback_; }
37 ExternalCallbackScope* previous() { return previous_scope_; }
38 inline Address scope_address();
39
Ben Murdochb0fe1622011-05-05 13:52:32 +010040 private:
Steve Block44f0eee2011-05-26 01:26:41 +010041 Isolate* isolate_;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000042 Address callback_;
43 ExternalCallbackScope* previous_scope_;
44#ifdef USE_SIMULATOR
45 Address scope_address_;
46#endif
Ben Murdochb0fe1622011-05-05 13:52:32 +010047};
48
Andrei Popescu402d9372010-02-26 13:31:12 +000049} } // namespace v8::internal
50
Steve Block6ded16b2010-05-10 14:33:55 +010051
52#endif // V8_VM_STATE_H_