2017-10-02 07:39:30 +00:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
#include "src/wasm/memory-tracing.h"
|
|
|
|
|
2019-05-15 12:51:26 +00:00
|
|
|
#include <cinttypes>
|
|
|
|
|
2019-06-17 09:26:18 +00:00
|
|
|
#include "src/base/memory.h"
|
2019-05-23 13:27:57 +00:00
|
|
|
#include "src/utils/utils.h"
|
|
|
|
#include "src/utils/vector.h"
|
2017-10-02 07:39:30 +00:00
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
2018-01-12 17:46:03 +00:00
|
|
|
namespace wasm {
|
2017-10-02 07:39:30 +00:00
|
|
|
|
2018-08-21 15:01:31 +00:00
|
|
|
void TraceMemoryOperation(ExecutionTier tier, const MemoryTracingInfo* info,
|
2017-10-02 07:39:30 +00:00
|
|
|
int func_index, int position, uint8_t* mem_start) {
|
2019-10-10 23:56:09 +00:00
|
|
|
EmbeddedVector<char, 91> value;
|
2018-01-12 17:46:03 +00:00
|
|
|
auto mem_rep = static_cast<MachineRepresentation>(info->mem_rep);
|
|
|
|
switch (mem_rep) {
|
2018-04-13 22:28:05 +00:00
|
|
|
#define TRACE_TYPE(rep, str, format, ctype1, ctype2) \
|
|
|
|
case MachineRepresentation::rep: \
|
|
|
|
SNPrintF(value, str ":" format, \
|
2019-06-17 09:26:18 +00:00
|
|
|
base::ReadLittleEndianValue<ctype1>( \
|
2018-04-13 22:28:05 +00:00
|
|
|
reinterpret_cast<Address>(mem_start) + info->address), \
|
2019-06-17 09:26:18 +00:00
|
|
|
base::ReadLittleEndianValue<ctype2>( \
|
2018-04-13 22:28:05 +00:00
|
|
|
reinterpret_cast<Address>(mem_start) + info->address)); \
|
2017-10-02 07:39:30 +00:00
|
|
|
break;
|
|
|
|
TRACE_TYPE(kWord8, " i8", "%d / %02x", uint8_t, uint8_t)
|
|
|
|
TRACE_TYPE(kWord16, "i16", "%d / %04x", uint16_t, uint16_t)
|
|
|
|
TRACE_TYPE(kWord32, "i32", "%d / %08x", uint32_t, uint32_t)
|
|
|
|
TRACE_TYPE(kWord64, "i64", "%" PRId64 " / %016" PRIx64, uint64_t, uint64_t)
|
|
|
|
TRACE_TYPE(kFloat32, "f32", "%f / %08x", float, uint32_t)
|
|
|
|
TRACE_TYPE(kFloat64, "f64", "%f / %016" PRIx64, double, uint64_t)
|
|
|
|
#undef TRACE_TYPE
|
2019-10-10 23:56:09 +00:00
|
|
|
case MachineRepresentation::kSimd128:
|
|
|
|
SNPrintF(value, "s128:%d %d %d %d / %08x %08x %08x %08x",
|
|
|
|
base::ReadLittleEndianValue<uint32_t>(
|
|
|
|
reinterpret_cast<Address>(mem_start) + info->address),
|
|
|
|
base::ReadLittleEndianValue<uint32_t>(
|
|
|
|
reinterpret_cast<Address>(mem_start) + info->address + 4),
|
|
|
|
base::ReadLittleEndianValue<uint32_t>(
|
|
|
|
reinterpret_cast<Address>(mem_start) + info->address + 8),
|
|
|
|
base::ReadLittleEndianValue<uint32_t>(
|
|
|
|
reinterpret_cast<Address>(mem_start) + info->address + 12),
|
|
|
|
base::ReadLittleEndianValue<uint32_t>(
|
|
|
|
reinterpret_cast<Address>(mem_start) + info->address),
|
|
|
|
base::ReadLittleEndianValue<uint32_t>(
|
|
|
|
reinterpret_cast<Address>(mem_start) + info->address + 4),
|
|
|
|
base::ReadLittleEndianValue<uint32_t>(
|
|
|
|
reinterpret_cast<Address>(mem_start) + info->address + 8),
|
|
|
|
base::ReadLittleEndianValue<uint32_t>(
|
|
|
|
reinterpret_cast<Address>(mem_start) + info->address + 12));
|
|
|
|
break;
|
2017-10-02 07:39:30 +00:00
|
|
|
default:
|
|
|
|
SNPrintF(value, "???");
|
|
|
|
}
|
2019-04-29 11:32:39 +00:00
|
|
|
const char* eng = ExecutionTierToString(tier);
|
2018-07-19 09:03:20 +00:00
|
|
|
printf("%-11s func:%6d+0x%-6x%s %08x val: %s\n", eng, func_index, position,
|
|
|
|
info->is_store ? " store to" : "load from", info->address,
|
2019-04-29 11:06:49 +00:00
|
|
|
value.begin());
|
2017-10-02 07:39:30 +00:00
|
|
|
}
|
|
|
|
|
2018-01-12 17:46:03 +00:00
|
|
|
} // namespace wasm
|
2017-10-02 07:39:30 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|