Commit 8641d260 authored by Victor Gomes's avatar Victor Gomes Committed by V8 LUCI CQ

Allow BytecodeArray::Disassemble to be called by a background thread

BytecodeArray::Disassemble fails a SLOW_DCHECK when invoking from
a background thread, due to the little hack to recover the handle
inside the function.

This CL changes the method to static with a handle as input.
The old method calls the static one, since it is allowed to be
called by the main thread.

Change-Id: I3546f0d2b160d15386da0980efc539693672c230
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3879498
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83063}
parent 2acd2f9d
......@@ -547,7 +547,7 @@ void MaglevCompiler::Compile(LocalIsolate* local_isolate,
compilation_info->toplevel_compilation_unit();
std::cout << "Compiling " << Brief(*top_level_unit->function().object())
<< " with Maglev\n";
top_level_unit->bytecode().object()->Disassemble(std::cout);
BytecodeArray::Disassemble(top_level_unit->bytecode().object(), std::cout);
top_level_unit->feedback().object()->Print(std::cout);
}
......
......@@ -752,19 +752,26 @@ void BytecodeArray::PrintJson(std::ostream& os) {
void BytecodeArray::Disassemble(std::ostream& os) {
DisallowGarbageCollection no_gc;
os << "Parameter count " << parameter_count() << "\n";
os << "Register count " << register_count() << "\n";
os << "Frame size " << frame_size() << "\n";
os << "Bytecode age: " << bytecode_age() << "\n";
Address base_address = GetFirstBytecodeAddress();
SourcePositionTableIterator source_positions(SourcePositionTable());
// Storage for backing the handle passed to the iterator. This handle won't be
// updated by the gc, but that's ok because we've disallowed GCs anyway.
BytecodeArray handle_storage = *this;
Handle<BytecodeArray> handle(reinterpret_cast<Address*>(&handle_storage));
Disassemble(handle, os);
}
// static
void BytecodeArray::Disassemble(Handle<BytecodeArray> handle,
std::ostream& os) {
DisallowGarbageCollection no_gc;
os << "Parameter count " << handle->parameter_count() << "\n";
os << "Register count " << handle->register_count() << "\n";
os << "Frame size " << handle->frame_size() << "\n";
os << "Bytecode age: " << handle->bytecode_age() << "\n";
Address base_address = handle->GetFirstBytecodeAddress();
SourcePositionTableIterator source_positions(handle->SourcePositionTable());
interpreter::BytecodeArrayIterator iterator(handle);
while (!iterator.done()) {
if (!source_positions.done() &&
......@@ -803,22 +810,22 @@ void BytecodeArray::Disassemble(std::ostream& os) {
iterator.Advance();
}
os << "Constant pool (size = " << constant_pool().length() << ")\n";
os << "Constant pool (size = " << handle->constant_pool().length() << ")\n";
#ifdef OBJECT_PRINT
if (constant_pool().length() > 0) {
constant_pool().Print(os);
if (handle->constant_pool().length() > 0) {
handle->constant_pool().Print(os);
}
#endif
os << "Handler Table (size = " << handler_table().length() << ")\n";
os << "Handler Table (size = " << handle->handler_table().length() << ")\n";
#ifdef ENABLE_DISASSEMBLER
if (handler_table().length() > 0) {
HandlerTable table(*this);
if (handle->handler_table().length() > 0) {
HandlerTable table(*handle);
table.HandlerTableRangePrint(os);
}
#endif
ByteArray source_position_table = SourcePositionTable();
ByteArray source_position_table = handle->SourcePositionTable();
os << "Source Position Table (size = " << source_position_table.length()
<< ")\n";
#ifdef OBJECT_PRINT
......
......@@ -1281,6 +1281,9 @@ class BytecodeArray
V8_EXPORT_PRIVATE void PrintJson(std::ostream& os);
V8_EXPORT_PRIVATE void Disassemble(std::ostream& os);
V8_EXPORT_PRIVATE static void Disassemble(Handle<BytecodeArray> handle,
std::ostream& os);
void CopyBytecodesTo(BytecodeArray to);
// Bytecode aging
......
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