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