memory-tracing.h 1.53 KB
Newer Older
1 2 3 4
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6 7 8
#if !V8_ENABLE_WEBASSEMBLY
#error This header should only be included if WebAssembly is enabled.
#endif  // !V8_ENABLE_WEBASSEMBLY

9 10
#ifndef V8_WASM_MEMORY_TRACING_H_
#define V8_WASM_MEMORY_TRACING_H_
11 12 13

#include <cstdint>

14
#include "src/base/optional.h"
15
#include "src/codegen/machine-type.h"
16
#include "src/wasm/wasm-tier.h"
17 18 19

namespace v8 {
namespace internal {
20
namespace wasm {
21

22 23
// This struct is create in generated code, hence use low-level types.
struct MemoryTracingInfo {
24
  uintptr_t offset;
25 26 27 28 29 30 31
  uint8_t is_store;  // 0 or 1
  uint8_t mem_rep;
  static_assert(
      std::is_same<decltype(mem_rep),
                   std::underlying_type<MachineRepresentation>::type>::value,
      "MachineRepresentation uses uint8_t");

32 33 34 35
  MemoryTracingInfo(uintptr_t offset, bool is_store, MachineRepresentation rep)
      : offset(offset),
        is_store(is_store),
        mem_rep(static_cast<uint8_t>(rep)) {}
36
};
37 38 39

// Callback for tracing a memory operation for debugging.
// Triggered by --wasm-trace-memory.
40
V8_EXPORT_PRIVATE void TraceMemoryOperation(base::Optional<ExecutionTier>,
41 42 43
                                            const MemoryTracingInfo* info,
                                            int func_index, int position,
                                            uint8_t* mem_start);
44

45
}  // namespace wasm
46 47 48
}  // namespace internal
}  // namespace v8

49
#endif  // V8_WASM_MEMORY_TRACING_H_