Skip to content

Commit

Permalink
Use SynthTrace::decode over trace.decode
Browse files Browse the repository at this point in the history
Summary:
Original Author: [email protected]
Original Git: a8560fb
Original Reviewed By: dannysu
Original Revision: D67362181

It was pointed out in a previous diff comment that we're inconsistent
with using `SynthTrace::decode` and `trace.decode`. This diff just
replaces all usages with `SynthTrace::decode` for style.

Reviewed By: neildhar

Differential Revision: D68599525

fbshipit-source-id: 9c09bddc6cd74279ff812d37a86721d0d1ff61c5
  • Loading branch information
tsaichien authored and facebook-github-bot committed Jan 24, 2025
1 parent a08b71b commit 576fbea
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions API/hermes/SynthTraceParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,18 +226,17 @@ SynthTrace getTrace(
SynthTrace trace(
::hermes::vm::RuntimeConfig(), /* traceStream */ nullptr, globalObjID);
auto getListOfTraceValues =
[](JSONArray *array,
SynthTrace &trace) -> std::vector<SynthTrace::TraceValue> {
[](JSONArray *array) -> std::vector<SynthTrace::TraceValue> {
std::vector<SynthTrace::TraceValue> values;
std::transform(
array->begin(),
array->end(),
std::back_inserter(values),
[&trace](const JSONValue *value) -> SynthTrace::TraceValue {
[](const JSONValue *value) -> SynthTrace::TraceValue {
if (value->getKind() != JSONKind::String) {
::hermes::hermes_fatal("Array should contain only strings");
}
return trace.decode(llvh::cast<JSONString>(value)->c_str());
return SynthTrace::decode(llvh::cast<JSONString>(value)->c_str());
});
return values;
};
Expand Down Expand Up @@ -299,7 +298,7 @@ SynthTrace getTrace(
}
case RecordType::EndExecJS:
trace.emplace_back<SynthTrace::EndExecJSRecord>(
timeFromStart, trace.decode(retval->c_str()));
timeFromStart, SynthTrace::decode(retval->c_str()));
break;
case RecordType::Marker:
trace.emplace_back<SynthTrace::MarkerRecord>(
Expand Down Expand Up @@ -428,7 +427,9 @@ SynthTrace getTrace(
}
case RecordType::CreatePropNameIDWithValue: {
trace.emplace_back<SynthTrace::CreatePropNameIDWithValueRecord>(
timeFromStart, objID->getValue(), trace.decode(propValue->c_str()));
timeFromStart,
objID->getValue(),
SynthTrace::decode(propValue->c_str()));
break;
}
case RecordType::CreateHostObject:
Expand Down Expand Up @@ -476,7 +477,7 @@ SynthTrace getTrace(
#ifdef HERMESVM_API_TRACE_DEBUG
std::string(propName->c_str()),
#endif
trace.decode(propValue->c_str()));
SynthTrace::decode(propValue->c_str()));
break;
case RecordType::HasProperty:
trace.emplace_back<SynthTrace::HasPropertyRecord>(
Expand Down Expand Up @@ -510,36 +511,36 @@ SynthTrace getTrace(
timeFromStart,
objID->getValue(),
arrayIndex->getValue(),
trace.decode(propValue->c_str()));
SynthTrace::decode(propValue->c_str()));
break;
case RecordType::CallFromNative:
trace.emplace_back<SynthTrace::CallFromNativeRecord>(
timeFromStart,
funcID->getValue(),
trace.decode(thisArg->c_str()),
getListOfTraceValues(callArgs, trace));
SynthTrace::decode(thisArg->c_str()),
getListOfTraceValues(callArgs));
break;
case RecordType::ConstructFromNative:
trace.emplace_back<SynthTrace::ConstructFromNativeRecord>(
timeFromStart,
funcID->getValue(),
trace.decode(thisArg->c_str()),
getListOfTraceValues(callArgs, trace));
SynthTrace::decode(thisArg->c_str()),
getListOfTraceValues(callArgs));
break;
case RecordType::ReturnFromNative:
trace.emplace_back<SynthTrace::ReturnFromNativeRecord>(
timeFromStart, trace.decode(retval->c_str()));
timeFromStart, SynthTrace::decode(retval->c_str()));
break;
case RecordType::ReturnToNative:
trace.emplace_back<SynthTrace::ReturnToNativeRecord>(
timeFromStart, trace.decode(retval->c_str()));
timeFromStart, SynthTrace::decode(retval->c_str()));
break;
case RecordType::CallToNative:
trace.emplace_back<SynthTrace::CallToNativeRecord>(
timeFromStart,
funcID->getValue(),
trace.decode(thisArg->c_str()),
getListOfTraceValues(callArgs, trace));
SynthTrace::decode(thisArg->c_str()),
getListOfTraceValues(callArgs));
break;
case RecordType::GetPropertyNative:
trace.emplace_back<SynthTrace::GetPropertyNativeRecord>(
Expand All @@ -550,15 +551,15 @@ SynthTrace getTrace(
break;
case RecordType::GetPropertyNativeReturn:
trace.emplace_back<SynthTrace::GetPropertyNativeReturnRecord>(
timeFromStart, trace.decode(retval->c_str()));
timeFromStart, SynthTrace::decode(retval->c_str()));
break;
case RecordType::SetPropertyNative:
trace.emplace_back<SynthTrace::SetPropertyNativeRecord>(
timeFromStart,
hostObjID->getValue(),
propNameID->getValue(),
propName->c_str(),
trace.decode(propValue->c_str()));
SynthTrace::decode(propValue->c_str()));
break;
case RecordType::SetPropertyNativeReturn:
trace.emplace_back<SynthTrace::SetPropertyNativeReturnRecord>(
Expand All @@ -572,7 +573,7 @@ SynthTrace getTrace(
auto *pnids =
llvh::dyn_cast_or_null<JSONArray>(obj->get("propNameIDs"));
trace.emplace_back<SynthTrace::GetNativePropertyNamesReturnRecord>(
timeFromStart, getListOfTraceValues(pnids, trace));
timeFromStart, getListOfTraceValues(pnids));
break;
}
case RecordType::SetExternalMemoryPressure: {
Expand Down

0 comments on commit 576fbea

Please sign in to comment.