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 #if !V8_ENABLE_WEBASSEMBLY 6 #error This header should only be included if WebAssembly is enabled. 7 #endif // !V8_ENABLE_WEBASSEMBLY 8 9 #ifndef V8_WASM_MEMORY_TRACING_H_ 10 #define V8_WASM_MEMORY_TRACING_H_ 11 12 #include <cstdint> 13 14 #include "src/base/optional.h" 15 #include "src/codegen/machine-type.h" 16 #include "src/wasm/wasm-tier.h" 17 18 namespace v8 { 19 namespace internal { 20 namespace wasm { 21 22 // This struct is create in generated code, hence use low-level types. 23 struct MemoryTracingInfo { 24 uintptr_t offset; 25 uint8_t is_store; // 0 or 1 26 uint8_t mem_rep; 27 static_assert( 28 std::is_same<decltype(mem_rep), 29 std::underlying_type<MachineRepresentation>::type>::value, 30 "MachineRepresentation uses uint8_t"); 31 MemoryTracingInfoMemoryTracingInfo32 MemoryTracingInfo(uintptr_t offset, bool is_store, MachineRepresentation rep) 33 : offset(offset), 34 is_store(is_store), 35 mem_rep(static_cast<uint8_t>(rep)) {} 36 }; 37 38 // Callback for tracing a memory operation for debugging. 39 // Triggered by --wasm-trace-memory. 40 V8_EXPORT_PRIVATE void TraceMemoryOperation(base::Optional<ExecutionTier>, 41 const MemoryTracingInfo* info, 42 int func_index, int position, 43 uint8_t* mem_start); 44 45 } // namespace wasm 46 } // namespace internal 47 } // namespace v8 48 49 #endif // V8_WASM_MEMORY_TRACING_H_ 50