Commits

Jonathan Gilbert committed 37b5018

fixed int bytecode replacement

  • Participants
  • Parent commits 2b27960

Comments (0)

Files changed (5)

File mangler/src/main/scala/org/trillica/mangley/adapter/ContextCallSwitcher.scala

                     }
                 else
                     {
-                      super.visitIntInsn(Opcodes.BIPUSH, ManglingContext.current().methodId)
-                      //super.visitLdcInsn(ManglingContext.current().methodId)
+                      val methodId = ManglingContext.current().methodId
+
+                      Math.abs(methodId) match {
+                          case x if x < 128 => super.visitIntInsn(Opcodes.BIPUSH, methodId)
+                          case x if x < 32768 => super.visitIntInsn(Opcodes.SIPUSH, methodId)
+                          case _ => super.visitLdcInsn(methodId)
+                      }
                     }
 
             }

File profiler/pom.xml

                                     <shadedPattern>shaded.org.apache</shadedPattern>
                                 </relocation>
                                 <relocation>
+                                    <pattern>org.objectweb</pattern>
+                                    <shadedPattern>shaded.org.objectweb</shadedPattern>
+                                </relocation>
+                                <relocation>
                                     <pattern>org.json</pattern>
                                     <shadedPattern>shaded.org.json</shadedPattern>
                                 </relocation>

File profiler/src/main/scala/org/trillica/mangley/profiler/Profiler.scala

     //private records = new scala.collection.mutable.Map[Int, AtomicInteger]
 
     //todo fixme
-    private val vars = new Array[Int](999999)
+    private val vars = new Array[Int](4*1000*1000)
 
     def recordInvocation(methodId: Int) {
         vars(methodId) = vars(methodId) + 1

File profiler/src/main/scala/org/trillica/mangley/profiler/server/context/MostInvocationsHandler.scala

+package org.trillica.mangley.profiler.server.context
+
+import org.json.JSONWriter
+import org.trillica.mangley.MangleState
+import java.io.Writer
+
+class MostInvocationsHandler extends SimpleGetHttpHandler {
+
+    def handle(arg: String) = {
+
+    out: Writer => {
+
+      val json = new JSONWriter(out)
+
+      json.`object`()
+
+      MangleState.foreach((idx: Int, name: String) => {
+        json.key(name)
+        json.value(Profiler.invocationCount(idx))
+      })
+
+      json.endObject
+
+    }
+  }
+}

File profiler/src/test/java/org/trillica/mangley/profiler/simple/SimpleProfileTest.java

     }
 
     class Code {
-        public void before(){
-            Profiler.recordInvocation(MangleContext.methodLocation());
+        public void bipush(){
+            Profiler.recordInvocation(127);
         }
         
-        public void after(){
-            Profiler.recordInvocation(17);
+        public void sipush(){
+            Profiler.recordInvocation(32000);
+        }
+
+        public void more(){
+            Profiler.recordInvocation(62000);
         }
     }
 }