| 1 | // Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file |
| 2 | // for details. All rights reserved. Use of this source code is governed by a |
| 3 | // BSD-style license that can be found in the LICENSE file. |
| 4 | |
| 5 | #ifndef RUNTIME_VM_OBJECT_GRAPH_COPY_H_ |
| 6 | #define RUNTIME_VM_OBJECT_GRAPH_COPY_H_ |
| 7 | |
| 8 | namespace dart { |
| 9 | |
| 10 | class Isolate; |
| 11 | class Object; |
| 12 | class ObjectPtr; |
| 13 | class Zone; |
| 14 | |
| 15 | // Whether the object can safely be shared across isolates due to it being |
| 16 | // deeply immutable. |
| 17 | bool CanShareObjectAcrossIsolates(ObjectPtr obj); |
| 18 | |
| 19 | // Makes a transitive copy of the object graph referenced by [object]. Will not |
| 20 | // copy objects that can be safely shared - due to being immutable. |
| 21 | // |
| 22 | // The result will be an array of length 3 of the format |
| 23 | // |
| 24 | // [ |
| 25 | // <message>, |
| 26 | // <collection-lib-objects-to-rehash>, |
| 27 | // <core-lib-objects-to-rehash>, |
| 28 | // ] |
| 29 | // |
| 30 | // If the array of objects to rehash is not `null` the receiver should re-hash |
| 31 | // those objects. |
| 32 | ObjectPtr CopyMutableObjectGraph(const Object& root); |
| 33 | |
| 34 | typedef enum { |
| 35 | kInternalToIsolateGroup, |
| 36 | kExternalBetweenIsolateGroups, |
| 37 | } TraversalRules; |
| 38 | |
| 39 | // Returns a string representation of a retaining path from `from` to `to`, |
| 40 | // blank string if `to` is not reachable from `from`. |
| 41 | // Traversal doesn't follow all the object graph links, only those |
| 42 | // that makes sense isolate message passing. |
| 43 | const char* FindRetainingPath(Zone* zone, |
| 44 | Isolate* isolate, |
| 45 | const Object& from, |
| 46 | const Object& to, |
| 47 | TraversalRules traversal_rules); |
| 48 | |
| 49 | } // namespace dart |
| 50 | |
| 51 | #endif // RUNTIME_VM_OBJECT_GRAPH_COPY_H_ |
| 52 | |