Line data Source code
1 : // Copyright 2017 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 : #include "src/wasm/memory-tracing.h"
6 :
7 : #include "src/utils.h"
8 :
9 : namespace v8 {
10 : namespace internal {
11 : namespace tracing {
12 :
13 108 : void TraceMemoryOperation(ExecutionEngine engine, bool is_store,
14 : MachineRepresentation rep, uint32_t addr,
15 : int func_index, int position, uint8_t* mem_start) {
16 : EmbeddedVector<char, 64> value;
17 108 : switch (rep) {
18 : #define TRACE_TYPE(rep, str, format, ctype1, ctype2) \
19 : case MachineRepresentation::rep: \
20 : SNPrintF(value, str ":" format, \
21 : ReadLittleEndianValue<ctype1>(mem_start + addr), \
22 : ReadLittleEndianValue<ctype2>(mem_start + addr)); \
23 : break;
24 72 : TRACE_TYPE(kWord8, " i8", "%d / %02x", uint8_t, uint8_t)
25 0 : TRACE_TYPE(kWord16, "i16", "%d / %04x", uint16_t, uint16_t)
26 96 : TRACE_TYPE(kWord32, "i32", "%d / %08x", uint32_t, uint32_t)
27 0 : TRACE_TYPE(kWord64, "i64", "%" PRId64 " / %016" PRIx64, uint64_t, uint64_t)
28 48 : TRACE_TYPE(kFloat32, "f32", "%f / %08x", float, uint32_t)
29 0 : TRACE_TYPE(kFloat64, "f64", "%f / %016" PRIx64, double, uint64_t)
30 : #undef TRACE_TYPE
31 : default:
32 0 : SNPrintF(value, "???");
33 : }
34 : char eng_c = '?';
35 108 : switch (engine) {
36 : case kWasmCompiled:
37 : eng_c = 'C';
38 54 : break;
39 : case kWasmInterpreted:
40 : eng_c = 'I';
41 54 : break;
42 : }
43 : printf("%c %8d+0x%-6x %s @%08x %s\n", eng_c, func_index, position,
44 108 : is_store ? "store" : "read ", addr, value.start());
45 108 : }
46 :
47 : } // namespace tracing
48 : } // namespace internal
49 : } // namespace v8
|