Commit 47764c76 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[heap] Skip offheap bytecode handlers for GC iteration

If builtins are embedded and we're not generating the snapshot, then
completely skip iterating over the dispatch table, since off-heap
bytecode handlers can never move or be collected.

Additionally the dispatch table is initialized elsewhere so skip
iterating over the table completely when serializing/deserializing.

Bug: chromium:902230
Change-Id: I2cfe5b4b325d100145d5759ff97e0c8dde7ed7a3
Reviewed-on: https://chromium-review.googlesource.com/c/1319750
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57312}
parent f7b0853d
......@@ -3806,12 +3806,17 @@ void Heap::IterateStrongRoots(RootVisitor* v, VisitMode mode) {
if (!isMinorGC) {
IterateBuiltins(v);
v->Synchronize(VisitorSynchronization::kBuiltins);
// Currently we iterate the dispatch table to update pointers to possibly
// moved Code objects for bytecode handlers.
// TODO(v8:6666): Remove iteration once builtins are embedded (and thus
// immovable) in every build configuration.
isolate_->interpreter()->IterateDispatchTable(v);
v->Synchronize(VisitorSynchronization::kDispatchTable);
// The dispatch table is set up directly from the builtins using
// IntitializeDispatchTable so there is no need to iterate to create it.
if (mode != VISIT_FOR_SERIALIZATION) {
// Currently we iterate the dispatch table to update pointers to possibly
// moved Code objects for bytecode handlers.
// TODO(v8:6666): Remove iteration once builtins are embedded (and thus
// immovable) in every build configuration.
isolate_->interpreter()->IterateDispatchTable(v);
v->Synchronize(VisitorSynchronization::kDispatchTable);
}
}
// Iterate over global handles.
......
......@@ -99,13 +99,30 @@ size_t Interpreter::GetDispatchTableIndex(Bytecode bytecode,
}
void Interpreter::IterateDispatchTable(RootVisitor* v) {
Heap* heap = isolate_->heap();
if (FLAG_embedded_builtins && !isolate_->serializer_enabled() &&
isolate_->embedded_blob() != nullptr) {
// If builtins are embedded (and we're not generating a snapshot), then
// every bytecode handler will be off-heap, so there's no point iterating
// over them.
#ifdef DEBUG
for (int i = 0; i < kDispatchTableSize; i++) {
Address code_entry = dispatch_table_[i];
CHECK(code_entry == kNullAddress ||
InstructionStream::PcIsOffHeap(isolate_, code_entry));
}
#endif // ENABLE_SLOW_DCHECKS
return;
}
for (int i = 0; i < kDispatchTableSize; i++) {
Address code_entry = dispatch_table_[i];
// Skip over off-heap bytecode handlers since they will never move.
if (InstructionStream::PcIsOffHeap(isolate_, code_entry)) continue;
Object* code = code_entry == kNullAddress
? nullptr
: heap->GcSafeFindCodeForInnerPointer(code_entry);
: Code::GetCodeFromTargetAddress(code_entry);
Object* old_code = code;
v->VisitRootPointer(Root::kDispatchTable, nullptr, ObjectSlot(&code));
if (code != old_code) {
......
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