[safepoints] Support off-heap safepoint tables

There's two considerations involving off-heap code and safepoint
tables.

1. Since the safepoint table is embedded within the instructions area
of code objects, we need to ensure that the actual instruction size
(i.e.  safepoint_table_offset if a code object has safepoints) is
large enough for the off-heap trampoline.

2. The pc-relative calculation in SafepointTable::FindEntry must be
able to handle off-heap pcs.

Bug: v8:6666
Change-Id: I92a5ecc49d0a78755b89c3c5774523afb21cd724
Reviewed-on: https://chromium-review.googlesource.com/934242
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51561}
This commit is contained in:
jgruber 2018-02-26 11:12:28 +01:00 committed by Commit Bot
parent 330ad4f2fd
commit d7a9ca5de9
2 changed files with 20 additions and 2 deletions

View File

@ -2902,7 +2902,13 @@ void ChangeToOffHeapTrampoline(Isolate* isolate, Handle<Code> code,
DCHECK_LE(desc.instr_size, code->instruction_size());
byte* trailing_instruction_start =
code->instruction_start() + desc.instr_size;
size_t trailing_instruction_size = code->instruction_size() - desc.instr_size;
int instruction_size = code->instruction_size();
if (code->has_safepoint_info()) {
CHECK_LE(code->safepoint_table_offset(), code->instruction_size());
instruction_size = code->safepoint_table_offset();
CHECK_LE(desc.instr_size, instruction_size);
}
size_t trailing_instruction_size = instruction_size - desc.instr_size;
std::memset(trailing_instruction_start, 0, trailing_instruction_size);
}

View File

@ -8,6 +8,7 @@
#include "src/deoptimizer.h"
#include "src/disasm.h"
#include "src/frames-inl.h"
#include "src/instruction-stream.h"
#include "src/macro-assembler.h"
#include "src/ostreams.h"
@ -52,7 +53,18 @@ SafepointTable::SafepointTable(Address instruction_start,
SafepointTable::SafepointTable(Code* code)
: SafepointTable(code->instruction_start(), code->safepoint_table_offset(),
code->stack_slots(), true) {}
code->stack_slots(), true) {
#ifdef V8_EMBEDDED_BUILTINS
if (FLAG_stress_off_heap_code &&
Builtins::IsBuiltinId(code->builtin_index()) &&
Builtins::IsOffHeapSafe(code->builtin_index())) {
InstructionStream* stream =
InstructionStream::TryLookupInstructionStream(code->GetIsolate(), code);
DCHECK_NOT_NULL(stream);
instruction_start_ = static_cast<Address>(stream->bytes());
}
#endif
}
unsigned SafepointTable::find_return_pc(unsigned pc_offset) {
for (unsigned i = 0; i < length(); i++) {