This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0x00007fd71508b1ec: mov 0x1b0(%r15),%r10 ;*invokestatic currentThread | |
; - java.lang.ThreadLocal::get@0 (line 143) | |
; - Opt::handleRequest@3 (line 70) | |
0x00007fd71508b1f3: mov 0x50(%r10),%r11d ;*getfield threadLocals | |
; - java.lang.ThreadLocal::getMap@1 (line 213) | |
; - java.lang.ThreadLocal::get@6 (line 144) | |
; - Opt::handleRequest@3 (line 70) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static final ThreadLocal<Integer> counter = new ThreadLocal<Integer>(); | |
private static void handleRequest() { | |
if (counter.get() == null) { | |
counter.set(0); | |
} | |
counter.set(counter.get() + 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void calcLine(int a, int b, int from, int to) { | |
Line l = new Line(a, b); | |
for (int x = from; x <= to; x++) { | |
int y = (l.a * x + l.b); | |
System.err.println("(" + x + ", " + y + ")"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void calcLine(int a, int b, int from, int to) { | |
Line l = new Line(a, b); | |
for (int x = from; x <= to; x++) { | |
int y = l.getY(x); | |
System.err.println("(" + x + ", " + y + ")"); | |
} | |
} | |
static class Line { | |
public final int a; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static double[] loopUnrolling(double[][] matrix1, double[] vector1) { | |
double[] result = new double[vector1.length]; | |
for (int i = 0; i < matrix1.length; i++) { | |
for (int j = 0; j < vector1.length; j++) { | |
result[i] += matrix1[i][j] * vector1[j]; | |
} | |
} | |
return result; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static double[] loopUnrolling2(double[][] matrix1, double[] vector1) { | |
double[] result = new double[vector1.length]; | |
for (int i = 0; i < matrix1.length; i++) { | |
result[i] += matrix1[i][0] * vector1[0]; | |
result[i] += matrix1[i][1] * vector1[1]; | |
result[i] += matrix1[i][2] * vector1[2]; | |
// and maybe it will expand even further - e.g. 4 iterations, thus | |
// adding code to fix the indexing | |
// which we would waste more time doing correctly and efficiently |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.... | |
0x00007fd715060743: vmovsd 0x10(%r8,%rcx,8),%xmm0 ;*daload | |
; - Opt::loopUnrolling@26 (line 179) | |
0x00007fd71506074a: vmovsd 0x10(%rbp),%xmm1 ;*daload | |
; - Opt::loopUnrolling@36 (line 179) | |
0x00007fd71506074f: vmulsd 0x10(%r12,%r9,8),%xmm1,%xmm1 | |
0x00007fd715060756: vaddsd %xmm0,%xmm1,%xmm0 ;*dadd | |
; - Opt::loopUnrolling@38 (line 179) | |
0x00007fd71506075a: vmovsd %xmm0,0x10(%r8,%rcx,8) ;*dastore | |
; - Opt::loopUnrolling@39 (line 179) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0x00007fd715062d0c: cmp %edx,%esi | |
0x00007fd715062d0e: jge 0x00007fd715062d24 ;*if_icmplt | |
; - Opt::isOpt@4 (line 117) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static int isOpt(int x, int y) { | |
int veryHardCalculation = 0; | |
if (x < y) { | |
// this would not require a jump | |
veryHardCalculation = y * 1000 + x; | |
return veryHardCalculation; | |
} else { | |
veryHardCalculation = x * 1000 + y; | |
return veryHardCalculation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static int isOpt(int x, int y) { | |
int veryHardCalculation = 0; | |
if (x >= y) { | |
veryHardCalculation = x * 1000 + y; | |
} else { | |
veryHardCalculation = y * 1000 + x; | |
} | |
return veryHardCalculation; | |
} |