[wasm] Fix printing of reloc info on the native heap
Tag RelocInfo which belongs to native wasm code, and fix printing to not try to access the Code object for CODE_TARGET, but rather just print "(wasm trampoline)". Bug: chromium:801785 R=mstarzinger@chromium.org Change-Id: I84a37f0c48ed7397cccf677b4d0f0352e5aceb9d Reviewed-on: https://chromium-review.googlesource.com/875271 Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Commit-Queue: Clemens Hammacher <clemensh@chromium.org> Cr-Commit-Position: refs/heads/master@{#50758}
This commit is contained in:
parent
41b80eeffd
commit
d414d80d25
@ -560,7 +560,8 @@ void RelocIterator::next() {
|
||||
done_ = true;
|
||||
}
|
||||
|
||||
RelocIterator::RelocIterator(Code* code, int mode_mask) {
|
||||
RelocIterator::RelocIterator(Code* code, int mode_mask)
|
||||
: mode_mask_(mode_mask) {
|
||||
rinfo_.host_ = code;
|
||||
rinfo_.pc_ = code->instruction_start();
|
||||
rinfo_.data_ = 0;
|
||||
@ -568,35 +569,30 @@ RelocIterator::RelocIterator(Code* code, int mode_mask) {
|
||||
// Relocation info is read backwards.
|
||||
pos_ = code->relocation_start() + code->relocation_size();
|
||||
end_ = code->relocation_start();
|
||||
done_ = false;
|
||||
mode_mask_ = mode_mask;
|
||||
if (mode_mask_ == 0) pos_ = end_;
|
||||
next();
|
||||
}
|
||||
|
||||
RelocIterator::RelocIterator(const CodeDesc& desc, int mode_mask) {
|
||||
RelocIterator::RelocIterator(const CodeDesc& desc, int mode_mask)
|
||||
: mode_mask_(mode_mask) {
|
||||
rinfo_.pc_ = desc.buffer;
|
||||
rinfo_.data_ = 0;
|
||||
// Relocation info is read backwards.
|
||||
pos_ = desc.buffer + desc.buffer_size;
|
||||
end_ = pos_ - desc.reloc_size;
|
||||
done_ = false;
|
||||
mode_mask_ = mode_mask;
|
||||
if (mode_mask_ == 0) pos_ = end_;
|
||||
next();
|
||||
}
|
||||
|
||||
RelocIterator::RelocIterator(Vector<byte> instructions,
|
||||
Vector<const byte> reloc_info, Address const_pool,
|
||||
int mode_mask) {
|
||||
int mode_mask)
|
||||
: mode_mask_(mode_mask) {
|
||||
rinfo_.pc_ = instructions.start();
|
||||
rinfo_.data_ = 0;
|
||||
rinfo_.constant_pool_ = const_pool;
|
||||
rinfo_.flags_ = RelocInfo::kInNativeWasmCode;
|
||||
// Relocation info is read backwards.
|
||||
pos_ = reloc_info.start() + reloc_info.size();
|
||||
end_ = reloc_info.start();
|
||||
done_ = false;
|
||||
mode_mask_ = mode_mask;
|
||||
if (mode_mask_ == 0) pos_ = end_;
|
||||
next();
|
||||
}
|
||||
@ -685,9 +681,15 @@ void RelocInfo::Print(Isolate* isolate, std::ostream& os) { // NOLINT
|
||||
<< ") (" << static_cast<const void*>(target_external_reference())
|
||||
<< ")";
|
||||
} else if (IsCodeTarget(rmode_)) {
|
||||
Code* code = Code::GetCodeFromTargetAddress(target_address());
|
||||
os << " (" << Code::Kind2String(code->kind()) << ") ("
|
||||
<< static_cast<const void*>(target_address()) << ")";
|
||||
const Address code_target = target_address();
|
||||
if (flags_ & kInNativeWasmCode) {
|
||||
os << " (wasm trampoline) ";
|
||||
} else {
|
||||
Code* code = Code::GetCodeFromTargetAddress(code_target);
|
||||
DCHECK(code->IsCode());
|
||||
os << " (" << Code::Kind2String(code->kind()) << ") ";
|
||||
}
|
||||
os << " (" << static_cast<const void*>(target_address()) << ")";
|
||||
} else if (IsRuntimeEntry(rmode_) && isolate->deoptimizer_data() != nullptr) {
|
||||
// Depotimization bailouts are stored as runtime entries.
|
||||
int id = Deoptimizer::GetDeoptimizationId(
|
||||
|
@ -341,6 +341,12 @@ enum ICacheFlushMode { FLUSH_ICACHE_IF_NEEDED, SKIP_ICACHE_FLUSH };
|
||||
|
||||
class RelocInfo {
|
||||
public:
|
||||
enum Flag : uint8_t {
|
||||
kNoFlags = 0,
|
||||
kInNativeWasmCode = 1u << 0, // Reloc info belongs to native wasm code.
|
||||
};
|
||||
typedef base::Flags<Flag> Flags;
|
||||
|
||||
// This string is used to add padding comments to the reloc info in cases
|
||||
// where we are not sure to have enough space for patching in during
|
||||
// lazy deoptimization. This is the case if we have indirect calls for which
|
||||
@ -623,9 +629,10 @@ class RelocInfo {
|
||||
// comment).
|
||||
byte* pc_;
|
||||
Mode rmode_;
|
||||
intptr_t data_;
|
||||
intptr_t data_ = 0;
|
||||
Code* host_;
|
||||
Address constant_pool_ = nullptr;
|
||||
Flags flags_;
|
||||
friend class RelocIterator;
|
||||
};
|
||||
|
||||
@ -728,8 +735,9 @@ class RelocIterator: public Malloced {
|
||||
const byte* pos_;
|
||||
const byte* end_;
|
||||
RelocInfo rinfo_;
|
||||
bool done_;
|
||||
int mode_mask_;
|
||||
bool done_ = false;
|
||||
const int mode_mask_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(RelocIterator);
|
||||
};
|
||||
|
||||
|
22
test/mjsunit/regress/wasm/regress-801785.js
Normal file
22
test/mjsunit/regress/wasm/regress-801785.js
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright 2018 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.
|
||||
|
||||
load('test/mjsunit/wasm/wasm-constants.js');
|
||||
load('test/mjsunit/wasm/wasm-module-builder.js');
|
||||
|
||||
// Flags: --print-wasm-code
|
||||
|
||||
const builder = new WasmModuleBuilder();
|
||||
builder.addMemory(8, 16);
|
||||
builder.addFunction(undefined, kSig_i_i).addBody([
|
||||
// wasm to wasm call.
|
||||
kExprGetLocal, 0, kExprCallFunction, 0x1
|
||||
]);
|
||||
builder.addFunction(undefined, kSig_i_i).addBody([
|
||||
// load from <get_local 0> to create trap code.
|
||||
kExprGetLocal, 0, kExprI32LoadMem, 0,
|
||||
// unreachable to create a runtime call.
|
||||
kExprUnreachable
|
||||
]);
|
||||
builder.instantiate();
|
Loading…
Reference in New Issue
Block a user