v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
debug-evaluate.h
Go to the documentation of this file.
1// Copyright 2015 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_DEBUG_DEBUG_EVALUATE_H_
6#define V8_DEBUG_DEBUG_EVALUATE_H_
7
8#include <vector>
9
10#include "src/base/macros.h"
11#include "src/common/globals.h"
16#include "src/objects/objects.h"
19
20namespace v8 {
21namespace internal {
22
23class FrameInspector;
24
25class DebugEvaluate : public AllStatic {
26 public:
29 REPLMode repl_mode = REPLMode::kNo);
30
31 // Evaluate a piece of JavaScript in the context of a stack frame for
32 // debugging. Things that need special attention are:
33 // - Parameters and stack-allocated locals need to be materialized. Altered
34 // values need to be written back to the stack afterwards.
35 // - The arguments object needs to materialized.
36 // The stack frame can be either a JavaScript stack frame or a Wasm
37 // stack frame. In the latter case, a special Debug Proxy API is
38 // provided to peek into the Wasm state.
40 Isolate* isolate, StackFrameId frame_id, int inlined_jsframe_index,
41 DirectHandle<String> source, bool throw_on_side_effect);
42
43 // This is used for break-at-entry for builtins and API functions.
44 // Evaluate a piece of JavaScript in the native context, but with the
45 // materialized arguments object and receiver of the current call.
47 Isolate* isolate, DirectHandle<String> source);
48
51 static void ApplySideEffectChecks(Handle<BytecodeArray> bytecode_array);
53
54#ifdef DEBUG
55 static void VerifyTransitiveBuiltins(Isolate* isolate);
56#endif // DEBUG
57
58 private:
59 // This class builds a context chain for evaluation of expressions
60 // in debugger.
61 // The scope chain leading up to a breakpoint where evaluation occurs
62 // looks like:
63 // - [a mix of with, catch and block scopes]
64 // - [function stack + context]
65 // - [outer context]
66 // The builder materializes all stack variables into properties of objects;
67 // the expression is then evaluated as if it is inside a series of 'with'
68 // statements using those objects. To this end, the builder builds a new
69 // context chain, based on a scope chain:
70 // - every With and Catch scope begets a cloned context
71 // - Block scope begets one or two contexts:
72 // - if a block has context-allocated variables, its context is cloned
73 // - stack locals are materialized as a With context
74 // - Local scope begets a With context for materialized locals, chained to
75 // original function context. Original function context is the end of
76 // the chain.
102
104 Isolate* isolate, DirectHandle<SharedFunctionInfo> outer_info,
106 DirectHandle<String> source, bool throw_on_side_effect);
107};
108
109} // namespace internal
110} // namespace v8
111
112#endif // V8_DEBUG_DEBUG_EVALUATE_H_
DirectHandle< Context > evaluation_context() const
std::vector< ContextChainElement > context_chain_
ContextBuilder(Isolate *isolate, JavaScriptFrame *frame, int inlined_jsframe_index)
DirectHandle< SharedFunctionInfo > outer_info() const
static V8_EXPORT_PRIVATE MaybeDirectHandle< Object > Global(Isolate *isolate, Handle< String > source, debug::EvaluateGlobalMode mode, REPLMode repl_mode=REPLMode::kNo)
static void ApplySideEffectChecks(Handle< BytecodeArray > bytecode_array)
static MaybeDirectHandle< Object > WithTopmostArguments(Isolate *isolate, DirectHandle< String > source)
static bool IsSideEffectFreeIntrinsic(Runtime::FunctionId id)
static V8_EXPORT_PRIVATE MaybeDirectHandle< Object > Local(Isolate *isolate, StackFrameId frame_id, int inlined_jsframe_index, DirectHandle< String > source, bool throw_on_side_effect)
static DebugInfo::SideEffectState FunctionGetSideEffectState(Isolate *isolate, DirectHandle< SharedFunctionInfo > info)
static MaybeDirectHandle< Object > Evaluate(Isolate *isolate, DirectHandle< SharedFunctionInfo > outer_info, DirectHandle< Context > context, DirectHandle< Object > receiver, DirectHandle< String > source, bool throw_on_side_effect)
TNode< Object > receiver
#define V8_EXPORT_PRIVATE
Definition macros.h:460