v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
vm-state-inl.h
Go to the documentation of this file.
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_EXECUTION_VM_STATE_INL_H_
6#define V8_EXECUTION_VM_STATE_INL_H_
7
9// Include the non-inl header before the rest of the headers.
10
13#include "src/logging/log.h"
15
16namespace v8 {
17namespace internal {
18
19// VMState class implementation. A simple stack of VM states held by the logger
20// and partially threaded through the call stack. States are pushed by VMState
21// construction and popped by destruction.
22inline const char* StateToString(StateTag state) {
23 switch (state) {
24 case JS:
25 return "JS";
26 case GC:
27 return "GC";
28 case PARSER:
29 return "PARSER";
31 return "BYTECODE_COMPILER";
32 case COMPILER:
33 return "COMPILER";
34 case OTHER:
35 return "OTHER";
36 case EXTERNAL:
37 return "EXTERNAL";
38 case ATOMICS_WAIT:
39 return "ATOMICS_WAIT";
40 case IDLE:
41 return "IDLE";
42 case LOGGING:
43 return "LOGGING";
44 }
45}
46
47template <StateTag Tag>
49 : isolate_(isolate), previous_tag_(isolate->current_vm_state()) {
50 isolate_->set_current_vm_state(Tag);
51}
52
53template <StateTag Tag>
55 isolate_->set_current_vm_state(previous_tag_);
56}
57
59 Isolate* isolate, Address callback, v8::ExceptionContext exception_context,
60 const void* callback_info)
62 callback_info_(callback_info),
63 previous_scope_(isolate->external_callback_scope()),
64 vm_state_(isolate),
65 exception_context_(exception_context),
66 pause_timed_histogram_scope_(isolate->counters()->execute()) {
67#if USE_SIMULATOR || V8_USE_ADDRESS_SANITIZER || V8_USE_SAFE_STACK
68 js_stack_comparable_address_ =
69 i::SimulatorStack::RegisterJSStackComparableAddress(isolate);
70#endif
71 vm_state_.isolate_->set_external_callback_scope(this);
72#ifdef V8_RUNTIME_CALL_STATS
74 "V8.ExternalCallback");
75#endif
76 // The external callback might be called via different code paths and on some
77 // of them it's not guaranteed that the topmost_script_having_context value
78 // is still valid (in particular, when the callback call is initiated by
79 // embedder via V8 Api). So, clear it to ensure correctness of
80 // Isolate::GetIncumbentContext().
82}
83
85 vm_state_.isolate_->set_external_callback_scope(previous_scope_);
86 // JS code might have been executed by the callback and it could have changed
87 // {topmost_script_having_context}, clear it to ensure correctness of
88 // Isolate::GetIncumbentContext() in case it'll be called after returning
89 // from the callback.
91#ifdef V8_RUNTIME_CALL_STATS
93 "V8.ExternalCallback");
94#endif
95#if USE_SIMULATOR || V8_USE_ADDRESS_SANITIZER || V8_USE_SAFE_STACK
96 i::SimulatorStack::UnregisterJSStackComparableAddress(vm_state_.isolate_);
97#endif
98}
99
101#if USE_SIMULATOR || V8_USE_ADDRESS_SANITIZER || V8_USE_SAFE_STACK
102 return js_stack_comparable_address_;
103#else
104 return reinterpret_cast<Address>(this);
105#endif
106}
107
108} // namespace internal
109} // namespace v8
110
111#endif // V8_EXECUTION_VM_STATE_INL_H_
Isolate * isolate_
ExternalCallbackScope(Isolate *isolate, Address callback, v8::ExceptionContext exception_context=v8::ExceptionContext::kUnknown, const void *callback_info=nullptr)
ExternalCallbackScope *const previous_scope_
Definition vm-state.h:61
VMState< EXTERNAL > const vm_state_
Definition vm-state.h:62
void clear_topmost_script_having_context()
Definition isolate-inl.h:63
Isolate *const isolate_
Definition vm-state.h:29
VMState(Isolate *isolate)
TNode< Object > callback
const char * StateToString(StateTag state)
ExceptionContext
StateTag
Definition v8-unwinder.h:36
@ COMPILER
Definition v8-unwinder.h:41
@ BYTECODE_COMPILER
Definition v8-unwinder.h:40
@ EXTERNAL
Definition v8-unwinder.h:43
@ GC
Definition v8-unwinder.h:38
@ ATOMICS_WAIT
Definition v8-unwinder.h:44
@ PARSER
Definition v8-unwinder.h:39
@ LOGGING
Definition v8-unwinder.h:46
@ IDLE
Definition v8-unwinder.h:45
@ JS
Definition v8-unwinder.h:37
@ OTHER
Definition v8-unwinder.h:42
const AsyncStreamingDecoder::MoreFunctionsCanBeSerializedCallback callback_
#define TRACE_EVENT_END0(category_group, name)
#define TRACE_DISABLED_BY_DEFAULT(name)
#define TRACE_EVENT_BEGIN0(category_group, name)