Commit e448740e authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Use PRIxPTR for printing addresses

Avoid casting to {void*} just for printing with "%p". Instead, use the
standard "PRIxPTR", prefixed with "0x". This allows to directly print
addresses.

Drive-by: Remove other unneeded pointer casts; "%p" accepts any pointer
          type.

R=mstarzinger@chromium.org

Bug: v8:9183
Change-Id: I38c9575babaf04689fbd4568c90d593c5a591540
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1627339
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61800}
parent 9a2e4693
......@@ -1686,9 +1686,8 @@ class WasmFullDecoder : public WasmDecoder<validate> {
// Decodes the body of a function.
void DecodeFunctionBody() {
TRACE("wasm-decode %p...%p (module+%u, %d bytes)\n",
reinterpret_cast<const void*>(this->start()),
reinterpret_cast<const void*>(this->end()), this->pc_offset(),
TRACE("wasm-decode %p...%p (module+%u, %d bytes)\n", this->start(),
this->end(), this->pc_offset(),
static_cast<int>(this->end() - this->start()));
// Set up initial function block.
......
......@@ -628,7 +628,7 @@ class WasmGraphBuildingInterface {
break;
}
}
PrintF("{set_env = %p, state = %c", static_cast<void*>(env), state);
PrintF("{set_env = %p, state = %c", env, state);
if (env && env->control) {
PrintF(", control = ");
compiler::WasmGraphBuilder::PrintDebugName(env->control);
......
......@@ -367,8 +367,7 @@ class ModuleDecoderImpl : public Decoder {
if (failed()) return;
Reset(bytes, offset);
TRACE("Section: %s\n", SectionName(section_code));
TRACE("Decode Section %p - %p\n", static_cast<const void*>(bytes.begin()),
static_cast<const void*>(bytes.end()));
TRACE("Decode Section %p - %p\n", bytes.begin(), bytes.end());
// Check if the section is out-of-order.
if (section_code < next_ordered_section_ &&
......
......@@ -628,8 +628,8 @@ void InstanceBuilder::LoadDataSegments(Handle<WasmInstanceObject> instance) {
void InstanceBuilder::WriteGlobalValue(const WasmGlobal& global, double num) {
TRACE("init [globals_start=%p + %u] = %lf, type = %s\n",
reinterpret_cast<void*>(raw_buffer_ptr(untagged_globals_, 0)),
global.offset, num, ValueTypes::TypeName(global.type));
raw_buffer_ptr(untagged_globals_, 0), global.offset, num,
ValueTypes::TypeName(global.type));
switch (global.type) {
case kWasmI32:
WriteLittleEndianValue<int32_t>(GetRawGlobalPtr<int32_t>(global),
......@@ -654,16 +654,15 @@ void InstanceBuilder::WriteGlobalValue(const WasmGlobal& global, double num) {
void InstanceBuilder::WriteGlobalValue(const WasmGlobal& global, int64_t num) {
TRACE("init [globals_start=%p + %u] = %" PRId64 ", type = %s\n",
reinterpret_cast<void*>(raw_buffer_ptr(untagged_globals_, 0)),
global.offset, num, ValueTypes::TypeName(global.type));
raw_buffer_ptr(untagged_globals_, 0), global.offset, num,
ValueTypes::TypeName(global.type));
DCHECK_EQ(kWasmI64, global.type);
WriteLittleEndianValue<int64_t>(GetRawGlobalPtr<int64_t>(global), num);
}
void InstanceBuilder::WriteGlobalValue(const WasmGlobal& global,
Handle<WasmGlobalObject> value) {
TRACE("init [globals_start=%p + %u] = ",
reinterpret_cast<void*>(raw_buffer_ptr(untagged_globals_, 0)),
TRACE("init [globals_start=%p + %u] = ", raw_buffer_ptr(untagged_globals_, 0),
global.offset);
switch (global.type) {
case kWasmI32: {
......
......@@ -515,8 +515,8 @@ Vector<byte> WasmCodeAllocator::AllocateForCode(NativeModule* native_module,
allocated_code_space_.Merge(code_space);
generated_code_size_.fetch_add(code_space.size(), std::memory_order_relaxed);
TRACE_HEAP("Code alloc for %p: %" PRIxPTR ",+%zu\n", this, code_space.begin(),
size);
TRACE_HEAP("Code alloc for %p: 0x%" PRIxPTR ",+%zu\n", this,
code_space.begin(), size);
return {reinterpret_cast<byte*>(code_space.begin()), code_space.size()};
}
......@@ -561,9 +561,8 @@ bool WasmCodeAllocator::SetExecutable(bool executable) {
permission)) {
return false;
}
TRACE_HEAP("Set %p:%p to executable:%d\n",
reinterpret_cast<void*>(region.begin()),
reinterpret_cast<void*>(region.end()), executable);
TRACE_HEAP("Set 0x%" PRIxPTR ":0x%" PRIxPTR " to executable:%d\n",
region.begin(), region.end(), executable);
}
}
is_executable_ = executable;
......@@ -1198,9 +1197,8 @@ bool WasmCodeManager::Commit(base::AddressRegion region) {
bool ret = SetPermissions(GetPlatformPageAllocator(), region.begin(),
region.size(), permission);
TRACE_HEAP("Setting rw permissions for %p:%p\n",
reinterpret_cast<void*>(region.begin()),
reinterpret_cast<void*>(region.end()));
TRACE_HEAP("Setting rw permissions for 0x%" PRIxPTR ":0x%" PRIxPTR "\n",
region.begin(), region.end());
if (!ret) {
// Highly unlikely.
......@@ -1219,9 +1217,8 @@ void WasmCodeManager::Decommit(base::AddressRegion region) {
size_t old_committed = total_committed_code_space_.fetch_sub(region.size());
DCHECK_LE(region.size(), old_committed);
USE(old_committed);
TRACE_HEAP("Discarding system pages %p:%p\n",
reinterpret_cast<void*>(region.begin()),
reinterpret_cast<void*>(region.end()));
TRACE_HEAP("Discarding system pages 0x%" PRIxPTR ":0x%" PRIxPTR "\n",
region.begin(), region.end());
CHECK(allocator->DiscardSystemPages(reinterpret_cast<void*>(region.begin()),
region.size()));
}
......@@ -1246,9 +1243,8 @@ VirtualMemory WasmCodeManager::TryAllocate(size_t size, void* hint) {
memory_tracker_->ReleaseReservation(size);
return {};
}
TRACE_HEAP("VMem alloc: %p:%p (%zu)\n",
reinterpret_cast<void*>(mem.address()),
reinterpret_cast<void*>(mem.end()), mem.size());
TRACE_HEAP("VMem alloc: 0x%" PRIxPTR ":0x%" PRIxPTR " (%zu)\n", mem.address(),
mem.end(), mem.size());
// TODO(v8:8462): Remove eager commit once perf supports remapping.
if (FLAG_perf_prof) {
......@@ -1461,7 +1457,7 @@ void WasmCodeManager::FreeNativeModule(Vector<VirtualMemory> owned_code_space,
base::MutexGuard lock(&native_modules_mutex_);
for (auto& code_space : owned_code_space) {
DCHECK(code_space.IsReserved());
TRACE_HEAP("VMem Release: %" PRIxPTR ":%" PRIxPTR " (%zu)\n",
TRACE_HEAP("VMem Release: 0x%" PRIxPTR ":0x%" PRIxPTR " (%zu)\n",
code_space.address(), code_space.end(), code_space.size());
#if defined(V8_OS_WIN_X64)
......
......@@ -1430,11 +1430,11 @@ void IndirectFunctionTableEntry::clear() {
void IndirectFunctionTableEntry::Set(int sig_id,
Handle<WasmInstanceObject> target_instance,
int target_func_index) {
TRACE_IFT(
"IFT entry %p[%d] = {sig_id=%d, target_instance=%p, "
"target_func_index=%d}\n",
reinterpret_cast<void*>(instance_->ptr()), index_, sig_id,
reinterpret_cast<void*>(target_instance->ptr()), target_func_index);
TRACE_IFT("IFT entry 0x%" PRIxPTR
"[%d] = {sig_id=%d, target_instance=0x%" PRIxPTR
", target_func_index=%d}\n",
instance_->ptr(), index_, sig_id, target_instance->ptr(),
target_func_index);
Object ref;
Address call_target = 0;
......@@ -1485,9 +1485,9 @@ void IndirectFunctionTableEntry::CopyFrom(
void ImportedFunctionEntry::SetWasmToJs(
Isolate* isolate, Handle<JSReceiver> callable,
const wasm::WasmCode* wasm_to_js_wrapper) {
TRACE_IFT("Import callable %p[%d] = {callable=%p, target=%p}\n",
reinterpret_cast<void*>(instance_->ptr()), index_,
reinterpret_cast<void*>(callable->ptr()),
TRACE_IFT("Import callable 0x%" PRIxPTR "[%d] = {callable=0x%" PRIxPTR
", target=%p}\n",
instance_->ptr(), index_, callable->ptr(),
wasm_to_js_wrapper->instructions().begin());
DCHECK(wasm_to_js_wrapper->kind() == wasm::WasmCode::kWasmToJsWrapper ||
wasm_to_js_wrapper->kind() == wasm::WasmCode::kWasmToCapiWrapper);
......@@ -1500,9 +1500,9 @@ void ImportedFunctionEntry::SetWasmToJs(
void ImportedFunctionEntry::SetWasmToWasm(WasmInstanceObject instance,
Address call_target) {
TRACE_IFT("Import WASM %p[%d] = {instance=%p, target=%" PRIuPTR "}\n",
reinterpret_cast<void*>(instance_->ptr()), index_,
reinterpret_cast<void*>(instance.ptr()), call_target);
TRACE_IFT("Import WASM 0x%" PRIxPTR "[%d] = {instance=0x%" PRIxPTR
", target=0x%" PRIxPTR "}\n",
instance_->ptr(), index_, instance.ptr(), call_target);
instance_->imported_function_refs().set(index_, instance);
instance_->imported_function_targets()[index_] = call_target;
}
......
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