diff options
author | mikaelpeltier <mikaelpeltier@google.com> | 2014-09-26 17:13:44 +0200 |
---|---|---|
committer | mikaelpeltier <mikaelpeltier@google.com> | 2014-09-26 17:13:44 +0200 |
commit | b07070a1e0b10ffd24eee9b6a597e94840fa9604 (patch) | |
tree | b1d551d599b1abc8bb8156ca48e9c86a0c45e0bf /jack | |
parent | e85b5bb5b2b31bde7b8cb9ea90ca76dd9f8136aa (diff) | |
download | toolchain_jack-b07070a1e0b10ffd24eee9b6a597e94840fa9604.zip toolchain_jack-b07070a1e0b10ffd24eee9b6a597e94840fa9604.tar.gz toolchain_jack-b07070a1e0b10ffd24eee9b6a597e94840fa9604.tar.bz2 |
Call getTracer only one time into BinaryOperationWithCst
- It will avoid several calls to ThreadConfig.
Change-Id: I4387c65fceacfc2b7d96f04fec03f2619628ad42
Diffstat (limited to 'jack')
-rw-r--r-- | jack/src/com/android/jack/statistics/BinaryOperationWithCst.java | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/jack/src/com/android/jack/statistics/BinaryOperationWithCst.java b/jack/src/com/android/jack/statistics/BinaryOperationWithCst.java index aeaad8f..143afad 100644 --- a/jack/src/com/android/jack/statistics/BinaryOperationWithCst.java +++ b/jack/src/com/android/jack/statistics/BinaryOperationWithCst.java @@ -50,14 +50,12 @@ import javax.annotation.Nonnull; @Description("Compute number of binary operations using constant value.") @Constraint(no = {JConcatOperation.class, ImplicitCast.class, ImplicitBoxingAndUnboxing.class, ThreeAddressCodeForm.class, CompoundAssignment.class}) - public class BinaryOperationWithCst implements RunnableSchedulable<JMethod> { @Nonnull private final Filter<JMethod> filter = ThreadConfig.get(Options.METHOD_FILTER); @Nonnull - private static final CounterVisitor visitor = new CounterVisitor(); - + private static final CounterVisitor visitor = new CounterVisitor(TracerFactory.getTracer()); private static class StatBinOp { public static final StatisticId<Percent> SHIFT_WITH_LIT8 = new StatisticId<Percent>( @@ -78,10 +76,15 @@ public class BinaryOperationWithCst implements RunnableSchedulable<JMethod> { } private static class CounterVisitor extends JVisitor { + @Nonnull + private final Tracer tracer; + + public CounterVisitor(@Nonnull Tracer tracer) { + this.tracer = tracer; + } + @Override public boolean visit(@Nonnull JBinaryOperation binOp) { - Tracer tracer = TracerFactory.getTracer(); - if (binOp instanceof JShiftOperation) { computeStat( binOp, tracer.getStatistic(StatBinOp.SHIFT_WITH_LIT8), Byte.MIN_VALUE, Byte.MAX_VALUE); @@ -118,8 +121,7 @@ public class BinaryOperationWithCst implements RunnableSchedulable<JMethod> { } } - Percent twoCstPercent = - TracerFactory.getTracer().getStatistic(StatBinOp.BINARY_WITH_TWO_LITERALS); + Percent twoCstPercent = tracer.getStatistic(StatBinOp.BINARY_WITH_TWO_LITERALS); twoCstPercent.add( binOp.getRhs() instanceof JValueLiteral && binOp.getLhs() instanceof JValueLiteral); |