Skip to content

Commit 45b26f4

Browse files
committed
Add quickened loads for longs and double constants
1 parent bf1537c commit 45b26f4

File tree

7 files changed

+30
-14
lines changed

7 files changed

+30
-14
lines changed

graalpython/com.oracle.graal.python.test/testData/goldenFiles/CompilerTests/testAugAssignment.co

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Disassembly of <module>:
22
000000 0 LOAD_NAME 0 (a)
3-
000005 2 LOAD_DOUBLE 0 (12.0)
3+
000005 2 LOAD_DOUBLE_O 0 (12.0)
44
000000 4 BINARY_OP 1 (INPLACE_ADD)
55
000000 6 STORE_NAME 0 (a)
66
000000 8 LOAD_NONE

graalpython/com.oracle.graal.python.test/testData/goldenFiles/CompilerTests/testBenchmark.co

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ Disassembly of docompute:
1717
000024 6 GET_ITER
1818
000024 >> 7 FOR_ITER 74 (to 81) can quicken
1919
000028 9 STORE_FAST 1 (i) generalizes: 7
20-
000060 11 LOAD_DOUBLE 0 (0.0)
21-
000053 13 STORE_FAST 2 (sum_)
20+
000060 11 LOAD_DOUBLE_D 0 (0.0) can quicken
21+
000053 13 STORE_FAST 2 (sum_) generalizes: 11
2222
000076 15 LOAD_BYTE_I 0 can quicken
2323
000072 17 STORE_FAST 3 (j) generalizes: 15
2424
000092 >> 19 LOAD_FAST 3 (j) can quicken
2525
000096 21 LOAD_FAST 0 (num) can quicken
2626
000092 23 BINARY_OP 14 (LT) can quicken, generalizes: 21, 19
2727
000086 25 POP_AND_JUMP_IF_FALSE 54 (to 79) generalizes: 23
2828
000113 29 LOAD_FAST 2 (sum_) can quicken
29-
000121 31 LOAD_DOUBLE 1 (1.0)
29+
000121 31 LOAD_DOUBLE_D 1 (1.0) can quicken
3030
000130 33 LOAD_FAST 1 (i) can quicken
3131
000134 35 LOAD_FAST 3 (j) can quicken
3232
000130 37 BINARY_OP 0 (ADD) can quicken, generalizes: 35, 33
@@ -41,8 +41,8 @@ Disassembly of docompute:
4141
000159 55 LOAD_FAST 1 (i) can quicken
4242
000128 57 BINARY_OP 0 (ADD) can quicken, generalizes: 55, 53
4343
000163 59 LOAD_BYTE_I 1 can quicken
44-
000128 61 BINARY_OP 0 (ADD) generalizes: 59, 57
45-
000121 63 BINARY_OP 8 (TRUEDIV) can quicken
44+
000128 61 BINARY_OP 0 (ADD) can quicken, generalizes: 59, 57
45+
000121 63 BINARY_OP 8 (TRUEDIV) can quicken, generalizes: 61, 31
4646
000113 65 BINARY_OP 1 (INPLACE_ADD) can quicken, generalizes: 63, 29
4747
000113 67 STORE_FAST 2 (sum_) generalizes: 65
4848
000178 69 LOAD_FAST 3 (j) can quicken
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Disassembly of <module>:
2-
000001 0 LOAD_BYTE_O -1
3-
000006 2 LOAD_DOUBLE 0 (-7.0)
4-
000000 4 BINARY_OP 4 (MUL)
2+
000001 0 LOAD_BYTE_O -1 can quicken
3+
000006 2 LOAD_DOUBLE_O 0 (-7.0) can quicken
4+
000000 4 BINARY_OP 4 (MUL) generalizes: 2, 0
55
000000 6 RETURN_VALUE

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/CompilationUnit.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,10 @@ private void emitBytecode(Instruction instr, ByteArrayOutputStream buf) throws I
447447
opcode = (instr.quickenOutput & QuickeningTypes.INT) != 0 ? OpCodes.LOAD_BYTE_I : OpCodes.LOAD_BYTE_O;
448448
} else if (opcode == OpCodes.LOAD_INT) {
449449
opcode = (instr.quickenOutput & QuickeningTypes.INT) != 0 ? OpCodes.LOAD_INT_I : OpCodes.LOAD_INT_O;
450+
} else if (opcode == OpCodes.LOAD_LONG) {
451+
opcode = (instr.quickenOutput & QuickeningTypes.LONG) != 0 ? OpCodes.LOAD_LONG_L : OpCodes.LOAD_LONG_O;
452+
} else if (opcode == OpCodes.LOAD_DOUBLE) {
453+
opcode = (instr.quickenOutput & QuickeningTypes.DOUBLE) != 0 ? OpCodes.LOAD_DOUBLE_D : OpCodes.LOAD_DOUBLE_O;
450454
} else if (opcode == OpCodes.LOAD_TRUE) {
451455
opcode = (instr.quickenOutput & QuickeningTypes.BOOLEAN) != 0 ? OpCodes.LOAD_TRUE_B : OpCodes.LOAD_TRUE_O;
452456
} else if (opcode == OpCodes.LOAD_FALSE) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/Compiler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@
180180
* Compiler for bytecode interpreter.
181181
*/
182182
public class Compiler implements SSTreeVisitor<Void> {
183-
public static final int BYTECODE_VERSION = 24;
183+
public static final int BYTECODE_VERSION = 25;
184184

185185
private final ErrorCallback errorCallback;
186186

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/OpCodes.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,10 @@ public enum OpCodes {
674674
LOAD_BYTE_I(LOAD_BYTE, 0, QuickeningTypes.INT, LOAD_BYTE_O),
675675
LOAD_INT_O(LOAD_INT, 0, QuickeningTypes.OBJECT),
676676
LOAD_INT_I(LOAD_INT, 0, QuickeningTypes.INT, LOAD_INT_O),
677+
LOAD_LONG_O(LOAD_LONG, 0, QuickeningTypes.OBJECT),
678+
LOAD_LONG_L(LOAD_LONG, 0, QuickeningTypes.LONG, LOAD_LONG_O),
679+
LOAD_DOUBLE_O(LOAD_DOUBLE, 0, QuickeningTypes.OBJECT),
680+
LOAD_DOUBLE_D(LOAD_DOUBLE, 0, QuickeningTypes.DOUBLE, LOAD_DOUBLE_O),
677681
LOAD_FAST_O(LOAD_FAST, 0, QuickeningTypes.OBJECT),
678682
LOAD_FAST_I_BOX(LOAD_FAST, 0, QuickeningTypes.OBJECT),
679683
LOAD_FAST_I(LOAD_FAST, 0, QuickeningTypes.INT, LOAD_FAST_I_BOX),

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,12 +1130,22 @@ private Object bytecodeLoop(VirtualFrame virtualFrame, Frame localFrame, Bytecod
11301130
virtualFrame.setObject(++stackTop, (int) localLongConsts[oparg]);
11311131
break;
11321132
}
1133-
case OpCodesConstants.LOAD_LONG: {
1133+
case OpCodesConstants.LOAD_LONG_L: {
1134+
oparg |= Byte.toUnsignedInt(localBC[++bci]);
1135+
virtualFrame.setLong(++stackTop, localLongConsts[oparg]);
1136+
break;
1137+
}
1138+
case OpCodesConstants.LOAD_LONG_O: {
11341139
oparg |= Byte.toUnsignedInt(localBC[++bci]);
11351140
virtualFrame.setObject(++stackTop, localLongConsts[oparg]);
11361141
break;
11371142
}
1138-
case OpCodesConstants.LOAD_DOUBLE: {
1143+
case OpCodesConstants.LOAD_DOUBLE_D: {
1144+
oparg |= Byte.toUnsignedInt(localBC[++bci]);
1145+
virtualFrame.setDouble(++stackTop, Double.longBitsToDouble(localLongConsts[oparg]));
1146+
break;
1147+
}
1148+
case OpCodesConstants.LOAD_DOUBLE_O: {
11391149
oparg |= Byte.toUnsignedInt(localBC[++bci]);
11401150
virtualFrame.setObject(++stackTop, Double.longBitsToDouble(localLongConsts[oparg]));
11411151
break;
@@ -2220,7 +2230,6 @@ private void bytecodeBinaryOpAdaptive(VirtualFrame virtualFrame, int stackTop, b
22202230
case BinaryOpsConstants.GE:
22212231
case BinaryOpsConstants.LE:
22222232
case BinaryOpsConstants.LT:
2223-
case BinaryOpsConstants.IS:
22242233
if ((outputCanQuicken[bci] & QuickeningTypes.BOOLEAN) != 0) {
22252234
localBC[bci] = OpCodesConstants.BINARY_OP_DD_B;
22262235
bytecodeBinaryOpDDB(virtualFrame, stackTop, bci, op);
@@ -2518,7 +2527,6 @@ private void bytecodeBinaryOpDDB(VirtualFrame virtualFrame, int stackTop, int bc
25182527
boolean result;
25192528
switch (op) {
25202529
case BinaryOpsConstants.EQ:
2521-
case BinaryOpsConstants.IS:
25222530
result = left == right;
25232531
break;
25242532
case BinaryOpsConstants.NE:

0 commit comments

Comments
 (0)