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

[wasm] Reduce size of ProtectedInstructionData

Since code objects cannot grow larger than 2GB anyway, it's enough to
store the instruction offset and landing pad offset as 32-bit values.
This reduces the size of the ProtectedInstructionData struct by 50%.

R=eholk@chromium.org

Bug: v8:5277
Change-Id: I4d2e0dc76b8a853fb50d51d70d5ec4038ee594ac
Reviewed-on: https://chromium-review.googlesource.com/686757
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarEric Holk <eholk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48192}
parent 46f6e24a
......@@ -30,12 +30,13 @@ namespace trap_handler {
struct ProtectedInstructionData {
// The offset of this instruction from the start of its code object.
intptr_t instr_offset;
// Wasm code never grows larger than 2GB, so uint32_t is sufficient.
uint32_t instr_offset;
// The offset of the landing pad from the start of its code object.
//
// TODO(eholk): Using a single landing pad and store parameters here.
intptr_t landing_offset;
uint32_t landing_offset;
};
const int kInvalidIndex = -1;
......
......@@ -330,14 +330,17 @@ void UnpackAndRegisterProtectedInstructions(Isolate* isolate,
continue;
}
const intptr_t base = reinterpret_cast<intptr_t>(code->entry());
byte* base = code->entry();
const int mode_mask =
RelocInfo::ModeMask(RelocInfo::WASM_PROTECTED_INSTRUCTION_LANDING);
for (RelocIterator it(code, mode_mask); !it.done(); it.next()) {
trap_handler::ProtectedInstructionData data;
data.instr_offset = it.rinfo()->data();
data.landing_offset = reinterpret_cast<intptr_t>(it.rinfo()->pc()) - base;
data.instr_offset = static_cast<uint32_t>(it.rinfo()->data());
data.landing_offset = static_cast<uint32_t>(it.rinfo()->pc() - base);
// Check that now over-/underflow happened.
DCHECK_EQ(it.rinfo()->data(), data.instr_offset);
DCHECK_EQ(it.rinfo()->pc() - base, data.landing_offset);
unpacked.emplace_back(data);
}
if (unpacked.empty()) continue;
......
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