2010-04-08 13:37:39 +00:00
|
|
|
// Copyright 2010 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2010-04-08 13:37:39 +00:00
|
|
|
|
|
|
|
#ifndef V8_VM_STATE_H_
|
|
|
|
#define V8_VM_STATE_H_
|
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/allocation.h"
|
2016-02-23 08:45:52 +00:00
|
|
|
#include "src/counters.h"
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/isolate.h"
|
2010-10-20 05:54:23 +00:00
|
|
|
|
2010-04-08 13:37:39 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
2014-09-29 12:59:54 +00:00
|
|
|
// 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.
|
2013-04-24 14:44:08 +00:00
|
|
|
template <StateTag Tag>
|
2010-04-08 13:37:39 +00:00
|
|
|
class VMState BASE_EMBEDDED {
|
|
|
|
public:
|
2013-04-24 14:44:08 +00:00
|
|
|
explicit inline VMState(Isolate* isolate);
|
2010-04-08 13:37:39 +00:00
|
|
|
inline ~VMState();
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
private:
|
2011-03-18 20:35:07 +00:00
|
|
|
Isolate* isolate_;
|
2010-12-07 11:31:57 +00:00
|
|
|
StateTag previous_tag_;
|
|
|
|
};
|
2010-12-07 11:01:02 +00:00
|
|
|
|
2010-04-08 13:37:39 +00:00
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
class ExternalCallbackScope BASE_EMBEDDED {
|
|
|
|
public:
|
2011-03-18 20:35:07 +00:00
|
|
|
inline ExternalCallbackScope(Isolate* isolate, Address callback);
|
2010-12-07 11:31:57 +00:00
|
|
|
inline ~ExternalCallbackScope();
|
2013-07-23 15:01:38 +00:00
|
|
|
Address callback() { return callback_; }
|
2015-10-28 13:42:23 +00:00
|
|
|
Address* callback_entrypoint_address() {
|
|
|
|
if (callback_ == nullptr) return nullptr;
|
|
|
|
#if USES_FUNCTION_DESCRIPTORS
|
|
|
|
return FUNCTION_ENTRYPOINT_ADDRESS(callback_);
|
|
|
|
#else
|
|
|
|
return &callback_;
|
|
|
|
#endif
|
|
|
|
}
|
2013-07-23 15:01:38 +00:00
|
|
|
ExternalCallbackScope* previous() { return previous_scope_; }
|
|
|
|
inline Address scope_address();
|
|
|
|
|
2010-04-08 13:37:39 +00:00
|
|
|
private:
|
2011-03-18 20:35:07 +00:00
|
|
|
Isolate* isolate_;
|
2013-07-23 15:01:38 +00:00
|
|
|
Address callback_;
|
|
|
|
ExternalCallbackScope* previous_scope_;
|
|
|
|
#ifdef USE_SIMULATOR
|
|
|
|
Address scope_address_;
|
|
|
|
#endif
|
2010-04-08 13:37:39 +00:00
|
|
|
};
|
|
|
|
|
2015-09-30 13:46:56 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
2010-04-08 13:37:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif // V8_VM_STATE_H_
|