Commit d7a9ca5d authored by jgruber's avatar jgruber Committed by Commit Bot

[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/934242Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51561}
parent 330ad4f2
......@@ -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);
}
......
......@@ -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++) {
......
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