1 // Copyright 2016 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_INTERFACE_H_
6 #define V8_DEBUG_DEBUG_INTERFACE_H_
7
8 #include <memory>
9
10 #include "include/v8-inspector.h"
11 #include "include/v8-util.h"
12 #include "include/v8.h"
13 #include "src/base/platform/time.h"
14 #include "src/common/globals.h"
15 #include "src/debug/interface-types.h"
16 #include "src/utils/vector.h"
17
18 namespace v8 {
19
20 namespace internal {
21 struct CoverageBlock;
22 struct CoverageFunction;
23 struct CoverageScript;
24 struct TypeProfileEntry;
25 struct TypeProfileScript;
26 class Coverage;
27 class DisableBreak;
28 class PostponeInterruptsScope;
29 class Script;
30 class TypeProfile;
31 } // namespace internal
32
33 namespace debug {
34
35 void SetContextId(Local<Context> context, int id);
36 int GetContextId(Local<Context> context);
37
38 void SetInspector(Isolate* isolate, v8_inspector::V8Inspector*);
39 v8_inspector::V8Inspector* GetInspector(Isolate* isolate);
40
41 // Schedule a debugger break to happen when function is called inside given
42 // isolate.
43 V8_EXPORT_PRIVATE void SetBreakOnNextFunctionCall(Isolate* isolate);
44
45 // Remove scheduled debugger break in given isolate if it has not
46 // happened yet.
47 V8_EXPORT_PRIVATE void ClearBreakOnNextFunctionCall(Isolate* isolate);
48
49 /**
50 * Returns array of internal properties specific to the value type. Result has
51 * the following format: [<name>, <value>,...,<name>, <value>]. Result array
52 * will be allocated in the current context.
53 */
54 MaybeLocal<Array> GetInternalProperties(Isolate* isolate, Local<Value> value);
55
56 /**
57 * Returns through the out parameters names_out a vector of names
58 * in v8::String for private members, including fields, methods,
59 * accessors specific to the value type.
60 * The values are returned through the out parameter values_out in the
61 * corresponding indices. Private fields and methods are returned directly
62 * while accessors are returned as v8::debug::AccessorPair. Missing components
63 * in the accessor pairs are null.
64 * If an exception occurs, false is returned. Otherwise true is returned.
65 * Results will be allocated in the current context and handle scope.
66 */
67 V8_EXPORT_PRIVATE bool GetPrivateMembers(Local<Context> context,
68 Local<Object> value,
69 std::vector<Local<Value>>* names_out,
70 std::vector<Local<Value>>* values_out);
71
72 /**
73 * Forwards to v8::Object::CreationContext, but with special handling for
74 * JSGlobalProxy objects.
75 */
76 Local<Context> GetCreationContext(Local<Object> value);
77
78 enum ExceptionBreakState {
79 NoBreakOnException = 0,
80 BreakOnUncaughtException = 1,
81 BreakOnAnyException = 2
82 };
83
84 /**
85 * Defines if VM will pause on exceptions or not.
86 * If BreakOnAnyExceptions is set then VM will pause on caught and uncaught
87 * exception, if BreakOnUncaughtException is set then VM will pause only on
88 * uncaught exception, otherwise VM won't stop on any exception.
89 */
90 void ChangeBreakOnException(Isolate* isolate, ExceptionBreakState state);
91
92 void RemoveBreakpoint(Isolate* isolate, BreakpointId id);
93 void SetBreakPointsActive(Isolate* isolate, bool is_active);
94
95 enum StepAction {
96 StepOut = 0, // Step out of the current function.
97 StepNext = 1, // Step to the next statement in the current function.
98 StepIn = 2 // Step into new functions invoked or the next statement
99 // in the current function.
100 };
101
102 void PrepareStep(Isolate* isolate, StepAction action);
103 void ClearStepping(Isolate* isolate);
104 V8_EXPORT_PRIVATE void BreakRightNow(Isolate* isolate);
105
106 // Use `SetTerminateOnResume` to indicate that an TerminateExecution interrupt
107 // should be set shortly before resuming, i.e. shortly before returning into
108 // the JavaScript stack frames on the stack. In contrast to setting the
109 // interrupt with `RequestTerminateExecution` directly, this flag allows
110 // the isolate to be entered for further JavaScript execution.
111 V8_EXPORT_PRIVATE void SetTerminateOnResume(Isolate* isolate);
112
113 bool AllFramesOnStackAreBlackboxed(Isolate* isolate);
114
115 class Script;
116
117 struct LiveEditResult {
118 enum Status {
119 OK,
120 COMPILE_ERROR,
121 BLOCKED_BY_RUNNING_GENERATOR,
122 BLOCKED_BY_FUNCTION_ABOVE_BREAK_FRAME,
123 BLOCKED_BY_FUNCTION_BELOW_NON_DROPPABLE_FRAME,
124 BLOCKED_BY_ACTIVE_FUNCTION,
125 BLOCKED_BY_NEW_TARGET_IN_RESTART_FRAME,
126 FRAME_RESTART_IS_NOT_SUPPORTED
127 };
128 Status status = OK;
129 bool stack_changed = false;
130 // Available only for OK.
131 v8::Local<v8::debug::Script> script;
132 // Fields below are available only for COMPILE_ERROR.
133 v8::Local<v8::String> message;
134 int line_number = -1;
135 int column_number = -1;
136 };
137
138 /**
139 * Native wrapper around v8::internal::Script object.
140 */
141 class V8_EXPORT_PRIVATE Script {
142 public:
143 v8::Isolate* GetIsolate() const;
144
145 ScriptOriginOptions OriginOptions() const;
146 bool WasCompiled() const;
147 bool IsEmbedded() const;
148 int Id() const;
149 int LineOffset() const;
150 int ColumnOffset() const;
151 std::vector<int> LineEnds() const;
152 MaybeLocal<String> Name() const;
153 MaybeLocal<String> SourceURL() const;
154 MaybeLocal<String> SourceMappingURL() const;
155 Maybe<int> ContextId() const;
156 MaybeLocal<String> Source() const;
157 bool IsWasm() const;
158 bool IsModule() const;
159 bool GetPossibleBreakpoints(
160 const debug::Location& start, const debug::Location& end,
161 bool restrict_to_function,
162 std::vector<debug::BreakLocation>* locations) const;
163 int GetSourceOffset(const debug::Location& location) const;
164 v8::debug::Location GetSourceLocation(int offset) const;
165 bool SetScriptSource(v8::Local<v8::String> newSource, bool preview,
166 LiveEditResult* result) const;
167 bool SetBreakpoint(v8::Local<v8::String> condition, debug::Location* location,
168 BreakpointId* id) const;
169 void RemoveWasmBreakpoint(BreakpointId id);
170 bool SetBreakpointOnScriptEntry(BreakpointId* id) const;
171 };
172
173 // Specialization for wasm Scripts.
174 class WasmScript : public Script {
175 public:
176 static WasmScript* Cast(Script* script);
177
178 enum class DebugSymbolsType { None, SourceMap, EmbeddedDWARF, ExternalDWARF };
179 DebugSymbolsType GetDebugSymbolType() const;
180 MemorySpan<const char> ExternalSymbolsURL() const;
181 int NumFunctions() const;
182 int NumImportedFunctions() const;
183 MemorySpan<const uint8_t> Bytecode() const;
184
185 std::pair<int, int> GetFunctionRange(int function_index) const;
186 int GetContainingFunction(int byte_offset) const;
187
188 uint32_t GetFunctionHash(int function_index);
189
190 int CodeOffset() const;
191 int CodeLength() const;
192 };
193
194 V8_EXPORT_PRIVATE void GetLoadedScripts(
195 Isolate* isolate,
196 PersistentValueVector<Script>& scripts); // NOLINT(runtime/references)
197
198 MaybeLocal<UnboundScript> CompileInspectorScript(Isolate* isolate,
199 Local<String> source);
200
201 enum ExceptionType { kException, kPromiseRejection };
202
203 class DebugDelegate {
204 public:
205 virtual ~DebugDelegate() = default;
ScriptCompiled(v8::Local<Script> script,bool is_live_edited,bool has_compile_error)206 virtual void ScriptCompiled(v8::Local<Script> script, bool is_live_edited,
207 bool has_compile_error) {}
208 // |inspector_break_points_hit| contains id of breakpoints installed with
209 // debug::Script::SetBreakpoint API.
BreakProgramRequested(v8::Local<v8::Context> paused_context,const std::vector<debug::BreakpointId> & inspector_break_points_hit)210 virtual void BreakProgramRequested(
211 v8::Local<v8::Context> paused_context,
212 const std::vector<debug::BreakpointId>& inspector_break_points_hit) {}
ExceptionThrown(v8::Local<v8::Context> paused_context,v8::Local<v8::Value> exception,v8::Local<v8::Value> promise,bool is_uncaught,ExceptionType exception_type)213 virtual void ExceptionThrown(v8::Local<v8::Context> paused_context,
214 v8::Local<v8::Value> exception,
215 v8::Local<v8::Value> promise, bool is_uncaught,
216 ExceptionType exception_type) {}
IsFunctionBlackboxed(v8::Local<debug::Script> script,const debug::Location & start,const debug::Location & end)217 virtual bool IsFunctionBlackboxed(v8::Local<debug::Script> script,
218 const debug::Location& start,
219 const debug::Location& end) {
220 return false;
221 }
ShouldBeSkipped(v8::Local<v8::debug::Script> script,int line,int column)222 virtual bool ShouldBeSkipped(v8::Local<v8::debug::Script> script, int line,
223 int column) {
224 return false;
225 }
226 };
227
228 V8_EXPORT_PRIVATE void SetDebugDelegate(Isolate* isolate,
229 DebugDelegate* listener);
230
231 V8_EXPORT_PRIVATE void TierDownAllModulesPerIsolate(Isolate* isolate);
232 V8_EXPORT_PRIVATE void TierUpAllModulesPerIsolate(Isolate* isolate);
233
234 class AsyncEventDelegate {
235 public:
236 virtual ~AsyncEventDelegate() = default;
237 virtual void AsyncEventOccurred(debug::DebugAsyncActionType type, int id,
238 bool is_blackboxed) = 0;
239 };
240
241 void SetAsyncEventDelegate(Isolate* isolate, AsyncEventDelegate* delegate);
242
243 void ResetBlackboxedStateCache(Isolate* isolate,
244 v8::Local<debug::Script> script);
245
246 int EstimatedValueSize(Isolate* isolate, v8::Local<v8::Value> value);
247
248 enum Builtin { kStringToLowerCase };
249
250 Local<Function> GetBuiltin(Isolate* isolate, Builtin builtin);
251
252 V8_EXPORT_PRIVATE void SetConsoleDelegate(Isolate* isolate,
253 ConsoleDelegate* delegate);
254
255 V8_DEPRECATED("See http://crbug.com/v8/10566.")
256 int GetStackFrameId(v8::Local<v8::StackFrame> frame);
257
258 v8::Local<v8::StackTrace> GetDetailedStackTrace(Isolate* isolate,
259 v8::Local<v8::Object> error);
260
261 /**
262 * Native wrapper around v8::internal::JSGeneratorObject object.
263 */
264 class GeneratorObject {
265 public:
266 v8::MaybeLocal<debug::Script> Script();
267 v8::Local<v8::Function> Function();
268 debug::Location SuspendedLocation();
269 bool IsSuspended();
270
271 static v8::Local<debug::GeneratorObject> Cast(v8::Local<v8::Value> value);
272 };
273
274 /*
275 * Provide API layer between inspector and code coverage.
276 */
277 class V8_EXPORT_PRIVATE Coverage {
278 public:
279 MOVE_ONLY_NO_DEFAULT_CONSTRUCTOR(Coverage);
280
281 // Forward declarations.
282 class ScriptData;
283 class FunctionData;
284
285 class V8_EXPORT_PRIVATE BlockData {
286 public:
287 MOVE_ONLY_NO_DEFAULT_CONSTRUCTOR(BlockData);
288
289 int StartOffset() const;
290 int EndOffset() const;
291 uint32_t Count() const;
292
293 private:
BlockData(i::CoverageBlock * block,std::shared_ptr<i::Coverage> coverage)294 explicit BlockData(i::CoverageBlock* block,
295 std::shared_ptr<i::Coverage> coverage)
296 : block_(block), coverage_(std::move(coverage)) {}
297
298 i::CoverageBlock* block_;
299 std::shared_ptr<i::Coverage> coverage_;
300
301 friend class v8::debug::Coverage::FunctionData;
302 };
303
304 class V8_EXPORT_PRIVATE FunctionData {
305 public:
306 MOVE_ONLY_NO_DEFAULT_CONSTRUCTOR(FunctionData);
307
308 int StartOffset() const;
309 int EndOffset() const;
310 uint32_t Count() const;
311 MaybeLocal<String> Name() const;
312 size_t BlockCount() const;
313 bool HasBlockCoverage() const;
314 BlockData GetBlockData(size_t i) const;
315
316 private:
FunctionData(i::CoverageFunction * function,std::shared_ptr<i::Coverage> coverage)317 explicit FunctionData(i::CoverageFunction* function,
318 std::shared_ptr<i::Coverage> coverage)
319 : function_(function), coverage_(std::move(coverage)) {}
320
321 i::CoverageFunction* function_;
322 std::shared_ptr<i::Coverage> coverage_;
323
324 friend class v8::debug::Coverage::ScriptData;
325 };
326
327 class V8_EXPORT_PRIVATE ScriptData {
328 public:
329 MOVE_ONLY_NO_DEFAULT_CONSTRUCTOR(ScriptData);
330
331 Local<debug::Script> GetScript() const;
332 size_t FunctionCount() const;
333 FunctionData GetFunctionData(size_t i) const;
334
335 private:
336 explicit ScriptData(size_t index, std::shared_ptr<i::Coverage> c);
337
338 i::CoverageScript* script_;
339 std::shared_ptr<i::Coverage> coverage_;
340
341 friend class v8::debug::Coverage;
342 };
343
344 static Coverage CollectPrecise(Isolate* isolate);
345 static Coverage CollectBestEffort(Isolate* isolate);
346
347 static void SelectMode(Isolate* isolate, CoverageMode mode);
348
349 size_t ScriptCount() const;
350 ScriptData GetScriptData(size_t i) const;
IsEmpty()351 bool IsEmpty() const { return coverage_ == nullptr; }
352
353 private:
Coverage(std::shared_ptr<i::Coverage> coverage)354 explicit Coverage(std::shared_ptr<i::Coverage> coverage)
355 : coverage_(std::move(coverage)) {}
356 std::shared_ptr<i::Coverage> coverage_;
357 };
358
359 /*
360 * Provide API layer between inspector and type profile.
361 */
362 class V8_EXPORT_PRIVATE TypeProfile {
363 public:
364 MOVE_ONLY_NO_DEFAULT_CONSTRUCTOR(TypeProfile);
365
366 class ScriptData; // Forward declaration.
367
368 class V8_EXPORT_PRIVATE Entry {
369 public:
370 MOVE_ONLY_NO_DEFAULT_CONSTRUCTOR(Entry);
371
372 int SourcePosition() const;
373 std::vector<MaybeLocal<String>> Types() const;
374
375 private:
Entry(const i::TypeProfileEntry * entry,std::shared_ptr<i::TypeProfile> type_profile)376 explicit Entry(const i::TypeProfileEntry* entry,
377 std::shared_ptr<i::TypeProfile> type_profile)
378 : entry_(entry), type_profile_(std::move(type_profile)) {}
379
380 const i::TypeProfileEntry* entry_;
381 std::shared_ptr<i::TypeProfile> type_profile_;
382
383 friend class v8::debug::TypeProfile::ScriptData;
384 };
385
386 class V8_EXPORT_PRIVATE ScriptData {
387 public:
388 MOVE_ONLY_NO_DEFAULT_CONSTRUCTOR(ScriptData);
389
390 Local<debug::Script> GetScript() const;
391 std::vector<Entry> Entries() const;
392
393 private:
394 explicit ScriptData(size_t index,
395 std::shared_ptr<i::TypeProfile> type_profile);
396
397 i::TypeProfileScript* script_;
398 std::shared_ptr<i::TypeProfile> type_profile_;
399
400 friend class v8::debug::TypeProfile;
401 };
402
403 static TypeProfile Collect(Isolate* isolate);
404
405 static void SelectMode(Isolate* isolate, TypeProfileMode mode);
406
407 size_t ScriptCount() const;
408 ScriptData GetScriptData(size_t i) const;
409
410 private:
TypeProfile(std::shared_ptr<i::TypeProfile> type_profile)411 explicit TypeProfile(std::shared_ptr<i::TypeProfile> type_profile)
412 : type_profile_(std::move(type_profile)) {}
413
414 std::shared_ptr<i::TypeProfile> type_profile_;
415 };
416
417 class V8_EXPORT_PRIVATE ScopeIterator {
418 public:
419 static std::unique_ptr<ScopeIterator> CreateForFunction(
420 v8::Isolate* isolate, v8::Local<v8::Function> func);
421 static std::unique_ptr<ScopeIterator> CreateForGeneratorObject(
422 v8::Isolate* isolate, v8::Local<v8::Object> generator);
423
424 ScopeIterator() = default;
425 virtual ~ScopeIterator() = default;
426
427 enum ScopeType {
428 ScopeTypeGlobal = 0,
429 ScopeTypeLocal,
430 ScopeTypeWith,
431 ScopeTypeClosure,
432 ScopeTypeCatch,
433 ScopeTypeBlock,
434 ScopeTypeScript,
435 ScopeTypeEval,
436 ScopeTypeModule,
437 ScopeTypeWasmExpressionStack
438 };
439
440 virtual bool Done() = 0;
441 virtual void Advance() = 0;
442 virtual ScopeType GetType() = 0;
443 virtual v8::Local<v8::Object> GetObject() = 0;
444 virtual v8::Local<v8::Value> GetFunctionDebugName() = 0;
445 virtual int GetScriptId() = 0;
446 virtual bool HasLocationInfo() = 0;
447 virtual debug::Location GetStartLocation() = 0;
448 virtual debug::Location GetEndLocation() = 0;
449
450 virtual bool SetVariableValue(v8::Local<v8::String> name,
451 v8::Local<v8::Value> value) = 0;
452
453 private:
454 DISALLOW_COPY_AND_ASSIGN(ScopeIterator);
455 };
456
457 class V8_EXPORT_PRIVATE StackTraceIterator {
458 public:
459 static bool SupportsWasmDebugEvaluate();
460 static std::unique_ptr<StackTraceIterator> Create(Isolate* isolate,
461 int index = 0);
462 StackTraceIterator() = default;
463 virtual ~StackTraceIterator() = default;
464
465 virtual bool Done() const = 0;
466 virtual void Advance() = 0;
467
468 virtual int GetContextId() const = 0;
469 virtual v8::MaybeLocal<v8::Value> GetReceiver() const = 0;
470 virtual v8::Local<v8::Value> GetReturnValue() const = 0;
471 virtual v8::Local<v8::String> GetFunctionDebugName() const = 0;
472 virtual v8::Local<v8::debug::Script> GetScript() const = 0;
473 virtual debug::Location GetSourceLocation() const = 0;
474 virtual v8::Local<v8::Function> GetFunction() const = 0;
475 virtual std::unique_ptr<ScopeIterator> GetScopeIterator() const = 0;
476
477 virtual bool Restart() = 0;
478 virtual v8::MaybeLocal<v8::Value> Evaluate(v8::Local<v8::String> source,
479 bool throw_on_side_effect) = 0;
480 virtual v8::MaybeLocal<v8::String> EvaluateWasm(
481 internal::Vector<const internal::byte> source, int frame_index) = 0;
482
483 private:
484 DISALLOW_COPY_AND_ASSIGN(StackTraceIterator);
485 };
486
487 class QueryObjectPredicate {
488 public:
489 virtual ~QueryObjectPredicate() = default;
490 virtual bool Filter(v8::Local<v8::Object> object) = 0;
491 };
492
493 void QueryObjects(v8::Local<v8::Context> context,
494 QueryObjectPredicate* predicate,
495 v8::PersistentValueVector<v8::Object>* objects);
496
497 void GlobalLexicalScopeNames(v8::Local<v8::Context> context,
498 v8::PersistentValueVector<v8::String>* names);
499
500 void SetReturnValue(v8::Isolate* isolate, v8::Local<v8::Value> value);
501
502 enum class NativeAccessorType {
503 None = 0,
504 HasGetter = 1 << 0,
505 HasSetter = 1 << 1
506 };
507
508 int64_t GetNextRandomInt64(v8::Isolate* isolate);
509
510 using RuntimeCallCounterCallback =
511 std::function<void(const char* name, int64_t count, base::TimeDelta time)>;
512 void EnumerateRuntimeCallCounters(v8::Isolate* isolate,
513 RuntimeCallCounterCallback callback);
514
515 enum class EvaluateGlobalMode {
516 kDefault,
517 kDisableBreaks,
518 kDisableBreaksAndThrowOnSideEffect
519 };
520
521 V8_EXPORT_PRIVATE v8::MaybeLocal<v8::Value> EvaluateGlobal(
522 v8::Isolate* isolate, v8::Local<v8::String> source, EvaluateGlobalMode mode,
523 bool repl_mode = false);
524
525 int GetDebuggingId(v8::Local<v8::Function> function);
526
527 bool SetFunctionBreakpoint(v8::Local<v8::Function> function,
528 v8::Local<v8::String> condition, BreakpointId* id);
529
530 v8::Platform* GetCurrentPlatform();
531
532 void ForceGarbageCollection(
533 v8::Isolate* isolate,
534 v8::EmbedderHeapTracer::EmbedderStackState embedder_stack_state);
535
536 class PostponeInterruptsScope {
537 public:
538 explicit PostponeInterruptsScope(v8::Isolate* isolate);
539 ~PostponeInterruptsScope();
540
541 private:
542 std::unique_ptr<i::PostponeInterruptsScope> scope_;
543 };
544
545 class DisableBreakScope {
546 public:
547 explicit DisableBreakScope(v8::Isolate* isolate);
548 ~DisableBreakScope();
549
550 private:
551 std::unique_ptr<i::DisableBreak> scope_;
552 };
553
554 class WeakMap : public v8::Object {
555 public:
556 WeakMap() = delete;
557 V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT v8::MaybeLocal<v8::Value> Get(
558 v8::Local<v8::Context> context, v8::Local<v8::Value> key);
559 V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT v8::MaybeLocal<WeakMap> Set(
560 v8::Local<v8::Context> context, v8::Local<v8::Value> key,
561 v8::Local<v8::Value> value);
562
563 V8_EXPORT_PRIVATE static Local<WeakMap> New(v8::Isolate* isolate);
564 V8_INLINE static WeakMap* Cast(Value* obj);
565 };
566
567 /**
568 * Pairs of accessors.
569 *
570 * In the case of private accessors, getters and setters are either null or
571 * Functions.
572 */
573 class V8_EXPORT_PRIVATE AccessorPair : public v8::Value {
574 public:
575 AccessorPair() = delete;
576 v8::Local<v8::Value> getter();
577 v8::Local<v8::Value> setter();
578
579 static bool IsAccessorPair(v8::Local<v8::Value> obj);
580 V8_INLINE static AccessorPair* Cast(v8::Value* obj);
581
582 private:
583 static void CheckCast(v8::Value* obj);
584 };
585
586 struct PropertyDescriptor {
587 bool enumerable : 1;
588 bool has_enumerable : 1;
589 bool configurable : 1;
590 bool has_configurable : 1;
591 bool writable : 1;
592 bool has_writable : 1;
593 v8::Local<v8::Value> value;
594 v8::Local<v8::Value> get;
595 v8::Local<v8::Value> set;
596 };
597
598 class PropertyIterator {
599 public:
600 static std::unique_ptr<PropertyIterator> Create(v8::Local<v8::Object> object);
601
602 virtual ~PropertyIterator() = default;
603
604 virtual bool Done() const = 0;
605 virtual void Advance() = 0;
606
607 virtual v8::Local<v8::Name> name() const = 0;
608
609 virtual bool is_native_accessor() = 0;
610 virtual bool has_native_getter() = 0;
611 virtual bool has_native_setter() = 0;
612 virtual Maybe<PropertyAttribute> attributes() = 0;
613 virtual Maybe<PropertyDescriptor> descriptor() = 0;
614
615 virtual bool is_own() = 0;
616 virtual bool is_array_index() = 0;
617 };
618
619 // Wrapper around v8::internal::WasmValue.
620 class V8_EXPORT_PRIVATE WasmValue : public v8::Value {
621 public:
622 WasmValue() = delete;
623 static bool IsWasmValue(v8::Local<v8::Value> obj);
624 V8_INLINE static WasmValue* Cast(v8::Value* obj);
625 int value_type();
626 // Get the underlying values as a byte array, this is only valid if value_type
627 // is i32, i64, f32, f64, or s128.
628 v8::Local<v8::Array> bytes();
629 // Get the underlying externref, only valid if value_type is externref.
630 v8::Local<v8::Value> ref();
631
632 private:
633 static void CheckCast(v8::Value* obj);
634 };
635
Cast(v8::Value * value)636 AccessorPair* AccessorPair::Cast(v8::Value* value) {
637 #ifdef V8_ENABLE_CHECKS
638 CheckCast(value);
639 #endif
640 return static_cast<AccessorPair*>(value);
641 }
642
Cast(v8::Value * value)643 WasmValue* WasmValue::Cast(v8::Value* value) {
644 #ifdef V8_ENABLE_CHECKS
645 CheckCast(value);
646 #endif
647 return static_cast<WasmValue*>(value);
648 }
649
650 MaybeLocal<Message> GetMessageFromPromise(Local<Promise> promise);
651
652 } // namespace debug
653 } // namespace v8
654
655 #endif // V8_DEBUG_DEBUG_INTERFACE_H_
656