Skip to content

Commit 9af52a5

Browse files
authored
Merge pull request #25 from google/2017-updates
Moved the replace call from the bytecode to the sampler
2 parents a88fa25 + c4c77ae commit 9af52a5

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/main/java/com/google/monitoring/runtime/instrumentation/AllocationMethodAdapter.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,6 @@ private void pushClassNameOnStack() {
147147
super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Class",
148148
"getName", "()Ljava/lang/String;", false);
149149
// -> stack: ... class classNameDotted
150-
super.visitLdcInsn('.');
151-
// -> stack: ... class classNameDotted '.'
152-
super.visitLdcInsn('/');
153-
// -> stack: ... class classNameDotted '.' '/'
154-
super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/String",
155-
"replace", "(CC)Ljava/lang/String;", false);
156-
// -> stack: ... class className
157150
}
158151

159152
// Helper method to compute the product of an integer array and push it on

src/main/java/com/google/monitoring/runtime/instrumentation/AllocationRecorder.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ public static void recordAllocation(int count, String desc, Object newObj) {
231231
// optional samplers. However, you don't need the optional samplers in
232232
// the common case, so I thought I'd save some space.
233233

234+
if (count >= 0) {
235+
desc = desc.replace('.', '/');
236+
}
237+
234238
// Copy value into local variable to prevent NPE that occurs when
235239
// instrumentation field is set to null by this class's shutdown hook
236240
// after another thread passed the null check but has yet to call

0 commit comments

Comments
 (0)