Commit c9e83ebc authored by eholk's avatar eholk Committed by Commit bot

[wasm] Use PC after EnsureSpace in RecordProtectedInstruction

Previously we captured the PC before calling EnsureSpace in
RecordProtectedInstruction. Sometimes EnsureSpace would resize and move
the buffer, which would invalidate the previously captured PC and trip an
assert when writing RelocInfo. With this change, we do not capture the PC
until after we've ensured there's enough space, which ensures the PC will
be valid.

BUG=

Review-Url: https://codereview.chromium.org/2690523003
Cr-Commit-Position: refs/heads/master@{#43202}
parent c7eabee4
......@@ -280,9 +280,7 @@ class WasmOutOfLineTrap final : public OutOfLineCode {
// TODO(eholk): Refactor this method to take the code generator as a
// parameter.
void Generate() final {
Address current_pc = __ pc();
__ RecordProtectedInstruction(pc_, current_pc);
__ RecordProtectedInstructionLanding(pc_);
if (frame_elided_) {
__ EnterFrame(StackFrame::WASM_COMPILED);
......
......@@ -4669,9 +4669,9 @@ void Assembler::emit_sse_operand(XMMRegister dst) {
emit(0xD8 | dst.low_bits());
}
void Assembler::RecordProtectedInstruction(int pc_offset, byte* landing) {
void Assembler::RecordProtectedInstructionLanding(int pc_offset) {
EnsureSpace ensure_space(this);
RelocInfo rinfo(isolate(), landing,
RelocInfo rinfo(isolate(), pc(),
RelocInfo::WASM_PROTECTED_INSTRUCTION_LANDING, pc_offset,
nullptr);
reloc_info_writer.Write(&rinfo);
......
......@@ -1993,7 +1993,7 @@ class Assembler : public AssemblerBase {
UNREACHABLE();
}
void RecordProtectedInstruction(int pc_offset, byte* landing_offset);
void RecordProtectedInstructionLanding(int pc_offset);
// Writes a single word of data in the code stream.
// Used for inline tables, e.g., jump-tables.
......
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