}
}
-ValueProfData *serializeValueProfDataFrom(ValueProfRecordClosure *Closure) {
+ValueProfData *serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
+ ValueProfData *DstData) {
uint32_t TotalSize = getValueProfDataSize(Closure);
- ValueProfData *VPD = Closure->AllocValueProfData(TotalSize);
+ ValueProfData *VPD =
+ DstData ? DstData : Closure->AllocValueProfData(TotalSize);
VPD->TotalSize = TotalSize;
VPD->NumValueKinds = Closure->GetNumValueKinds(Closure->Record);
InstrProfRecordClosure.Record = &Record;
std::unique_ptr<ValueProfData> VPD(
- serializeValueProfDataFrom(&InstrProfRecordClosure));
+ serializeValueProfDataFrom(&InstrProfRecordClosure, 0));
return VPD;
}
}
/* Return a ValueProfData instance that stores the data collected
- from runtime. */
+ * from runtime. If \c DstData is provided by the caller, the value
+ * profile data will be store in *DstData and DstData is returned,
+ * otherwise the method will allocate space for the value data and
+ * return pointer to the newly allocated space.
+ */
ValueProfData *
-serializeValueProfDataFromRT(const ValueProfRuntimeRecord *Record) {
+serializeValueProfDataFromRT(const ValueProfRuntimeRecord *Record,
+ ValueProfData *DstData) {
RTRecordClosure.Record = Record;
- return serializeValueProfDataFrom(&RTRecordClosure);
+ return serializeValueProfDataFrom(&RTRecordClosure, DstData);
}
-
-
-
void ValueProfRecord::deserializeTo(InstrProfRecord &Record,
InstrProfRecord::ValueMapType *VMap) {
Record.reserveSites(Kind, NumValueSites);