Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lttng: updated flags for gc tracing #3388

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/node_lttng_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,17 @@ void NODE_GC_START(v8::GCType type,
}
if (flags == v8::GCCallbackFlags::kNoGCCallbackFlags) {
flagsStr = "kNoGCCallbackFlags";
} else if (flags == v8::GCCallbackFlags::kGCCallbackFlagCompacted) {
flagsStr = "kGCCallbackFlagCompacted";
} else if (flags == v8::GCCallbackFlags::kGCCallbackFlagConstructRetainedObjectInfos) {
flagsStr = "kGCCallbackFlagConstructRetainedObjectInfos";
} else if (flags == v8::GCCallbackFlags::kGCCallbackFlagForced) {
flagsStr = "kGCCallbackFlagForced";
} else if (flags == v8::GCCallbackFlags::kGCCallbackFlagSynchronousPhantomCallbackProcessing) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Long lines, please keep them <= 80 columns.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be okay if I used a switch here instead?
Heres what I'm thinking:

switch (flags) {
    case 
      v8::GCCallbackFlags::kNoGCCallbackFlags:
        flagsStr = "kNoGCCallbackFlags";
    break;
    case 
      v8::GCCallbackFlags::kGCCallbackFlagConstructRetainedObjectInfos;
        flagsStr = "kGCCallbackFlagConstructRetainedObjectInfos";
    break;
    case 
      v8::GCCallbackFlags::kGCCallbackFlagForced:
        flagsStr = "kGCCallbackFlagForced";
    break;
    case 
      v8::GCCallbackFlags::kGCCallbackFlagSynchronousPhantomCallbackProcessing:
        flagsStr = "kGCCallbackFlagSynchronousPhantomCallbackProcessing";
    break;
    default:
        flagsStr = "Unrecognised GCCallbackFlag";
    break;
  }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks a little awkward. You could add a using F = v8::GCCallbackFlags a few lines up so you can shorten the names but I'd probably use an x-macro to generate the clauses. That lets you drop the duplication of the enum and the string as well. You can find an example of an x-macro in src/node_v8.cc, grep for HEAP_STATISTICS_PROPERTIES.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! I also shortened the GCType if statement with an x-macro too.

flagsStr = "kGCCallbackFlagSynchronousPhantomCallbackProcessing";
}

tracepoint(node, gc_start, typeStr, flagsStr);
}


void NODE_GC_DONE(v8::GCType type,
v8::GCCallbackFlags flags,
v8::Isolate* isolate) {
Expand All @@ -81,8 +84,12 @@ void NODE_GC_DONE(v8::GCType type,
}
if (flags == v8::GCCallbackFlags::kNoGCCallbackFlags) {
flagsStr = "kNoGCCallbackFlags";
} else if (flags == v8::GCCallbackFlags::kGCCallbackFlagCompacted) {
flagsStr = "kGCCallbackFlagCompacted";
} else if (flags == v8::GCCallbackFlags::kGCCallbackFlagConstructRetainedObjectInfos) {
flagsStr = "kGCCallbackFlagConstructRetainedObjectInfos";
} else if (flags == v8::GCCallbackFlags::kGCCallbackFlagForced) {
flagsStr = "kGCCallbackFlagForced";
} else if (flags == v8::GCCallbackFlags::kGCCallbackFlagSynchronousPhantomCallbackProcessing) {
flagsStr = "kGCCallbackFlagSynchronousPhantomCallbackProcessing";
}

tracepoint(node, gc_done, typeStr, flagsStr);
Expand Down