Commit 1bbed026 authored by Ng Zhi An's avatar Ng Zhi An Committed by Commit Bot

Introduce WasmValue for debugging

WasmValue holds a Wasm value with its type. This will be exposed to the
inspector (via a to-be-created class in debug_interface.h) for debugging
in DevTools.

Design at http://doc/1XQlX6DWsv6BPYnRtw-JZSASPEjsRlyXLnke7TTQ9Wrg.

Bug: v8:10347
Change-Id: Ib523e617d46fdf1adb13d13bf49749c4ce23a126
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2132720Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarKim-Anh Tran <kimanh@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67029}
parent 8e4a5e97
......@@ -351,6 +351,7 @@ Type::bitset BitsetType::Lub(const MapRefLike& map) {
case TUPLE2_TYPE:
case BREAK_POINT_TYPE:
case BREAK_POINT_INFO_TYPE:
case WASM_VALUE_TYPE:
case CACHED_TEMPLATE_OBJECT_TYPE:
case ENUM_CACHE_TYPE:
case WASM_CAPI_FUNCTION_DATA_TYPE:
......
......@@ -2199,6 +2199,12 @@ void DebugInfo::DebugInfoPrint(std::ostream& os) { // NOLINT
os << "\n - coverage_info: " << Brief(coverage_info());
}
void WasmValue::WasmValuePrint(std::ostream& os) { // NOLINT
PrintHeader(os, "WasmValue");
os << "\n - value_type: " << value_type();
os << "\n - bytes: " << Brief(bytes());
}
void StackTraceFrame::StackTraceFramePrint(std::ostream& os) { // NOLINT
PrintHeader(os, "StackTraceFrame");
os << "\n - frame_index: " << frame_index();
......
......@@ -3019,6 +3019,15 @@ Handle<DebugInfo> Factory::NewDebugInfo(Handle<SharedFunctionInfo> shared) {
return debug_info;
}
Handle<WasmValue> Factory::NewWasmValue(int value_type,
Handle<ByteArray> bytes) {
Handle<WasmValue> wasm_value =
Handle<WasmValue>::cast(NewStruct(WASM_VALUE_TYPE, AllocationType::kOld));
wasm_value->set_value_type(value_type);
wasm_value->set_bytes(*bytes);
return wasm_value;
}
Handle<BreakPointInfo> Factory::NewBreakPointInfo(int source_position) {
Handle<BreakPointInfo> new_break_point_info = Handle<BreakPointInfo>::cast(
NewStruct(BREAK_POINT_INFO_TYPE, AllocationType::kOld));
......
......@@ -734,6 +734,8 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
Handle<DebugInfo> NewDebugInfo(Handle<SharedFunctionInfo> shared);
Handle<WasmValue> NewWasmValue(int32_t value_type, Handle<ByteArray> bytes);
// Return a map for given number of properties using the map cache in the
// native context.
Handle<Map> ObjectLiteralMapFromCache(Handle<NativeContext> native_context,
......
......@@ -23,6 +23,8 @@ TQ_OBJECT_CONSTRUCTORS_IMPL(BreakPointInfo)
TQ_OBJECT_CONSTRUCTORS_IMPL(CoverageInfo)
TQ_OBJECT_CONSTRUCTORS_IMPL(DebugInfo)
TQ_OBJECT_CONSTRUCTORS_IMPL(WasmValue)
NEVER_READ_ONLY_SPACE_IMPL(DebugInfo)
BIT_FIELD_ACCESSORS(DebugInfo, debugger_hints, side_effect_state,
......
......@@ -202,6 +202,14 @@ class BreakPoint : public TorqueGeneratedBreakPoint<BreakPoint, Struct> {
TQ_OBJECT_CONSTRUCTORS(BreakPoint)
};
// Holds Wasm values. This is used by the inspector.
class WasmValue : public TorqueGeneratedWasmValue<WasmValue, Struct> {
public:
DECL_PRINTER(WasmValue)
TQ_OBJECT_CONSTRUCTORS(WasmValue)
};
} // namespace internal
} // namespace v8
......
......@@ -69,3 +69,13 @@ extern class CoverageInfo extends HeapObject {
const slot_count: int32;
slots[slot_count]: CoverageInfoSlot;
}
@generateCppClass
extern class WasmValue extends Struct {
// The type, should map to ValueType::Kind values in value-type.h.
value_type: Smi;
// Holds the actual value. For example, if this holds a Wasm i32, this will
// be of length 4, for s128, it will have length 16. These values are
// represented by the respective C++ types, and memcpy-ed in.
bytes: ByteArray;
}
......@@ -157,7 +157,8 @@ namespace internal {
wasm_exported_function_data) \
V(_, WASM_INDIRECT_FUNCTION_TABLE_TYPE, WasmIndirectFunctionTable, \
wasm_indirect_function_table) \
V(_, WASM_JS_FUNCTION_DATA_TYPE, WasmJSFunctionData, wasm_js_function_data)
V(_, WASM_JS_FUNCTION_DATA_TYPE, WasmJSFunctionData, wasm_js_function_data) \
V(_, WASM_VALUE_TYPE, WasmValue, wasm_value)
#define STRUCT_LIST_GENERATOR(V, _) STRUCT_LIST_GENERATOR_BASE(V, _)
......
......@@ -181,6 +181,7 @@
// - SourceTextModule
// - SyntheticModule
// - SourceTextModuleInfoEntry
// - WasmValue
// - FeedbackCell
// - FeedbackVector
// - PreparseData
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment