Skip to content

Commit 21952af

Browse files
sstricklCommit Queue
authored andcommitted
[vm,dyn_modules] Handle bytecode in LookupHeapObjectCode.
TEST=pkg/vm_service/test/code pkg/vm_service/test/fetch_all_types Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try,vm-dyn-mac-debug-arm64-try Change-Id: I4e630911ec836ddcad2cadd338bc59be50827316 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/449801 Reviewed-by: Alexander Markov <[email protected]> Commit-Queue: Tess Strickland <[email protected]>
1 parent 0449e9e commit 21952af

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

runtime/vm/object.cc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19529,6 +19529,39 @@ const char* Bytecode::FullyQualifiedName() const {
1952919529
return zone->PrintToString("[Bytecode] %s", function_name);
1953019530
}
1953119531

19532+
BytecodePtr Bytecode::FindBytecode(uword pc) {
19533+
#if defined(DART_DYNAMIC_MODULES)
19534+
class SlowFindBytecodeVisitor : public ObjectVisitor {
19535+
public:
19536+
explicit SlowFindBytecodeVisitor(uword pc)
19537+
: pc_(pc), result_(Bytecode::null()) {}
19538+
19539+
void VisitObject(ObjectPtr obj) {
19540+
if (!obj->IsBytecode()) return;
19541+
BytecodePtr bytecode = static_cast<BytecodePtr>(obj);
19542+
if (PayloadStartOf(bytecode) != pc_) return;
19543+
ASSERT(result_ == Bytecode::null());
19544+
result_ = bytecode;
19545+
}
19546+
19547+
BytecodePtr result() const { return result_; }
19548+
19549+
private:
19550+
uword pc_;
19551+
BytecodePtr result_;
19552+
};
19553+
19554+
HeapIterationScope iteration(Thread::Current());
19555+
SlowFindBytecodeVisitor visitor(pc);
19556+
iteration.IterateVMIsolateObjects(&visitor);
19557+
iteration.IterateOldObjectsNoImagePages(&visitor);
19558+
return visitor.result();
19559+
#else
19560+
UNREACHABLE();
19561+
return Bytecode::null();
19562+
#endif
19563+
}
19564+
1953219565
void Bytecode::set_binary(const TypedDataBase& binary) const {
1953319566
ASSERT(binary.IsNull() || binary.IsExternalOrExternalView());
1953419567
untag()->set_binary(binary.ptr());

runtime/vm/object.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7522,7 +7522,10 @@ class Bytecode : public Object {
75227522
public:
75237523
uword instructions() const { return untag()->instructions_; }
75247524

7525-
uword PayloadStart() const { return instructions(); }
7525+
static uword PayloadStartOf(BytecodePtr ptr) {
7526+
return ptr->untag()->instructions_;
7527+
}
7528+
uword PayloadStart() const { return PayloadStartOf(ptr()); }
75267529
intptr_t Size() const { return untag()->instructions_size_; }
75277530

75287531
ObjectPoolPtr object_pool() const { return untag()->object_pool(); }
@@ -7628,6 +7631,8 @@ class Bytecode : public Object {
76287631
const char* QualifiedName() const;
76297632
const char* FullyQualifiedName() const;
76307633

7634+
static BytecodePtr FindBytecode(uword pc);
7635+
76317636
private:
76327637
void set_instructions(uword instructions) const {
76337638
StoreNonPointer(&untag()->instructions_, instructions);

runtime/vm/service.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2194,6 +2194,12 @@ static ObjectPtr LookupHeapObjectCode(char** parts, int num_parts) {
21942194
if (!code.IsNull()) {
21952195
return code.ptr();
21962196
}
2197+
#if defined(DART_DYNAMIC_MODULES)
2198+
const auto& bytecode = Bytecode::Handle(Bytecode::FindBytecode(pc));
2199+
if (!bytecode.IsNull()) {
2200+
return bytecode.ptr();
2201+
}
2202+
#endif
21972203

21982204
// Not found.
21992205
return Object::sentinel().ptr();

0 commit comments

Comments
 (0)