Closed Bug 1210217 Opened 10 years ago Closed 10 years ago

Create some kind of abstraction to avoid adding null elements to the output json by hand

Categories

(Core :: Gecko Profiler, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla44
Tracking Status
firefox44 --- fixed

People

(Reporter: fitzgen, Assigned: fitzgen)

References

Details

Attachments

(1 file, 2 obsolete files)

We have all this code like: if (aFrame.mCategory.isSome()) { if (aFrame.mLine.isNothing()) { mFrameTableWriter.NullElement(); // implementation mFrameTableWriter.NullElement(); // optimizations mFrameTableWriter.NullElement(); // line } mFrameTableWriter.IntElement(*aFrame.mCategory); } and it is fairly easy to forget to add null elements but we simultaneuosly have to add them all over the place everywhere. I think we should have some kind of API like abstraction.writeIntElement(CATEGORY, *aFrame.mCategory); where CATEGORY is a constant int specifying which element in the array it is supposed to be, and the abstraction takes care of adding null elements for us.
See bug 1209779 for one example of how easy it is to forget to add the nulls.
Depends on: 1209779
Comment on attachment 8668217 [details] [diff] [review] Stop manually adding null entries to the profiler's JSON output Review of attachment 8668217 [details] [diff] [review]: ----------------------------------------------------------------- Please fix/double check the hasTrackedOptimizations case. The rest is a nice improvement in readability. ::: tools/profiler/core/ProfileEntry.cpp @@ +201,5 @@ > +// } > +// ... etc ... > +class MOZ_RAII AutoArraySchemaWriter > +{ > + SpliceableJSONWriter& mJsonWriter; nit: all-caps JSON @@ +271,3 @@ > > + AutoArraySchemaWriter writer(mWriter, mUniqueStrings); > + writer.StringElement(Schema::STRATEGY, JS::TrackedStrategyString(strategy)); Huh, I thought |EnumName::VAL| syntax was only valid for enum classes, not bare enums. @@ +561,5 @@ > ? "ion" > : "baseline"); > > if (jitFrame.hasTrackedOptimizations()) { > + writer.FillUpTo(Schema::OPTIMIZATIONS); I don't think this is right. This is the case of streaming a JIT frame. The schema is [location, impl, opts, line, category], and mUniqueStrings.WriteElement is used directly to write the location and the implementation above, so writer's mNextFreeIndex == 0, right? This seems like it would fill in 2 nulls.
Attachment #8668217 - Flags: review?(shu)
Attachment #8668217 - Attachment is obsolete: true
Attachment #8669943 - Attachment is obsolete: true
Attachment #8669943 - Flags: review?(shu)
Comment on attachment 8669945 [details] [diff] [review] Stop manually adding null entries to the profiler's JSON output Review of attachment 8669945 [details] [diff] [review]: ----------------------------------------------------------------- LGTM
Attachment #8669945 - Flags: review?(shu) → review+
The patch landed yesterday with the wrong number - https://hg.mozilla.org/mozilla-central/rev/133773490619
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: