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.
5 #ifndef V8_VM_STATE_INL_H_
6 #define V8_VM_STATE_INL_H_
10 #include "simulator.h"
16 // VMState class implementation. A simple stack of VM states held by the
17 // logger and partially threaded through the call stack. States are pushed by
18 // VMState construction and popped by destruction.
20 inline const char* StateToString(StateTag state) {
39 template <StateTag Tag>
40 VMState<Tag>::VMState(Isolate* isolate)
41 : isolate_(isolate), previous_tag_(isolate->current_vm_state()) {
42 if (FLAG_log_timer_events && previous_tag_ != EXTERNAL && Tag == EXTERNAL) {
44 TimerEvent(Logger::START, Logger::TimerEventScope::v8_external));
46 isolate_->set_current_vm_state(Tag);
50 template <StateTag Tag>
51 VMState<Tag>::~VMState() {
52 if (FLAG_log_timer_events && previous_tag_ != EXTERNAL && Tag == EXTERNAL) {
54 TimerEvent(Logger::END, Logger::TimerEventScope::v8_external));
56 isolate_->set_current_vm_state(previous_tag_);
60 ExternalCallbackScope::ExternalCallbackScope(Isolate* isolate, Address callback)
63 previous_scope_(isolate->external_callback_scope()) {
65 scope_address_ = Simulator::current(isolate)->get_sp();
67 isolate_->set_external_callback_scope(this);
70 ExternalCallbackScope::~ExternalCallbackScope() {
71 isolate_->set_external_callback_scope(previous_scope_);
74 Address ExternalCallbackScope::scope_address() {
76 return scope_address_;
78 return reinterpret_cast<Address>(this);
83 } } // namespace v8::internal
85 #endif // V8_VM_STATE_INL_H_