File tree Expand file tree Collapse file tree 3 files changed +45
-1
lines changed Expand file tree Collapse file tree 3 files changed +45
-1
lines changed Original file line number Diff line number Diff 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+ 
1953219565void Bytecode::set_binary(const TypedDataBase& binary) const {
1953319566  ASSERT(binary.IsNull() || binary.IsExternalOrExternalView());
1953419567  untag()->set_binary(binary.ptr());
Original file line number Diff line number Diff 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);
Original file line number Diff line number Diff 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 ();
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments