5 #ifndef V8_VM_STATE_INL_H_ 6 #define V8_VM_STATE_INL_H_ 8 #include "src/vm-state.h" 10 #include "src/simulator.h" 11 #include "src/tracing/trace-event.h" 21 inline const char* StateToString(StateTag state) {
29 case BYTECODE_COMPILER:
30 return "BYTECODE_COMPILER";
43 template <StateTag Tag>
44 VMState<Tag>::VMState(Isolate* isolate)
45 : isolate_(isolate), previous_tag_(isolate->current_vm_state()) {
46 if (FLAG_log_timer_events && previous_tag_ != EXTERNAL && Tag == EXTERNAL) {
47 LOG(isolate_, TimerEvent(Logger::START, TimerEventExternal::name()));
49 isolate_->set_current_vm_state(Tag);
53 template <StateTag Tag>
54 VMState<Tag>::~VMState() {
55 if (FLAG_log_timer_events && previous_tag_ != EXTERNAL && Tag == EXTERNAL) {
56 LOG(isolate_, TimerEvent(Logger::END, TimerEventExternal::name()));
58 isolate_->set_current_vm_state(previous_tag_);
61 ExternalCallbackScope::ExternalCallbackScope(Isolate* isolate, Address callback)
64 previous_scope_(isolate->external_callback_scope()) {
66 scope_address_ = Simulator::current(isolate)->get_sp();
68 isolate_->set_external_callback_scope(
this);
69 TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT(
"v8.runtime"),
70 "V8.ExternalCallback");
73 ExternalCallbackScope::~ExternalCallbackScope() {
74 isolate_->set_external_callback_scope(previous_scope_);
75 TRACE_EVENT_END0(TRACE_DISABLED_BY_DEFAULT(
"v8.runtime"),
76 "V8.ExternalCallback");
79 Address ExternalCallbackScope::scope_address() {
81 return scope_address_;
83 return reinterpret_cast<Address
>(
this);
91 #endif // V8_VM_STATE_INL_H_