Overview
Shallow Copy Optimization is a technique for improving copy performance when a shallow copy is sufficient. In the RISCV-DV context described by the evidence, the generator uses a native shallow-copy construct rather than copying individual elements of a class object through a UVM utilities copy construct.
Implementation pattern
The eUVM implementation follows a low-level clone-and-copy pattern:
- Return
nullif the source object isnull. - Obtain the object's
ClassInfothrough object introspection. - Allocate a new object instance using the discovered class information.
- Compute the start and end offsets of the object memory region to be copied.
- Copy the source object's memory slice into the destination object's corresponding memory slice.
- Return the cloned object cast to the requested type.
The evidence describes this as using object introspection to determine the underlying memory footprint of the object and then copying the corresponding memory slice from source to destination.
Performance rationale
The optimization relies on the fact that, in the D language implementation used by eUVM, the slice-copy operation results in a single memcopy call. This is described as much more efficient than copying individual class-object elements, which would result from using the UVM utilities copy construct.
Applicability
This technique is applicable when a shallow copy is semantically sufficient: the copied object may duplicate the object's immediate stored state, but it does not imply recursive duplication of objects referenced from that state. The evidence specifically states that, for the discussed RISCV-DV use case, a shallow copy suffices and RISCV-DV uses the native shallow-copy construct.