Skip to content

Commit 99c6832

Browse files
committed
[GR-31126] Add fast paths for common unary operations.
PullRequest: graalpython/1789
2 parents 79a6daa + d847196 commit 99c6832

File tree

16 files changed

+163
-138
lines changed

16 files changed

+163
-138
lines changed

graalpython/com.oracle.graal.python.test/testData/goldenFiles/BasicTests/unary01.tast

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ ModuleRootNode Name: <module 'unary01'> SourceSection: [0,2]`+u`
55
FrameDescriptor: Empty
66
Documentation: None
77
InnerRootNode SourceSection: [0,2]`+u`
8-
UnaryArithmeticExpression SourceSection: [0,2]`+u`
9-
LookupAndCallUnaryNodeGen SourceSection: None
10-
Op: __pos__
8+
PosNodeGen SourceSection: [0,2]`+u`
119
ReadNameNodeGen SourceSection: [1,2]`u`
1210
Identifier: u
1311
IsBuiltinClassProfile SourceSection: None

graalpython/com.oracle.graal.python.test/testData/goldenFiles/BasicTests/unary02.tast

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ ModuleRootNode Name: <module 'unary02'> SourceSection: [0,2]`-u`
55
FrameDescriptor: Empty
66
Documentation: None
77
InnerRootNode SourceSection: [0,2]`-u`
8-
UnaryArithmeticExpression SourceSection: [0,2]`-u`
9-
LookupAndCallUnaryNodeGen SourceSection: None
10-
Op: __neg__
8+
NegNodeGen SourceSection: [0,2]`-u`
119
ReadNameNodeGen SourceSection: [1,2]`u`
1210
Identifier: u
1311
IsBuiltinClassProfile SourceSection: None

graalpython/com.oracle.graal.python.test/testData/goldenFiles/BasicTests/unary03.tast

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ ModuleRootNode Name: <module 'unary03'> SourceSection: [0,2]`~u`
55
FrameDescriptor: Empty
66
Documentation: None
77
InnerRootNode SourceSection: [0,2]`~u`
8-
UnaryArithmeticExpression SourceSection: [0,2]`~u`
9-
LookupAndCallUnaryNodeGen SourceSection: None
10-
Op: __invert__
8+
InvertNodeGen SourceSection: [0,2]`~u`
119
ReadNameNodeGen SourceSection: [1,2]`u`
1210
Identifier: u
1311
IsBuiltinClassProfile SourceSection: None

graalpython/com.oracle.graal.python.test/testData/goldenFiles/NumberTests/Float04.tast

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@ ModuleRootNode Name: <module 'Float04'> SourceSection: [0,5]`--0.0`
55
FrameDescriptor: Empty
66
Documentation: None
77
InnerRootNode SourceSection: [0,5]`--0.0`
8-
UnaryArithmeticExpression SourceSection: [0,5]`--0.0`
9-
LookupAndCallUnaryNodeGen SourceSection: None
10-
Op: __neg__
8+
NegNodeGen SourceSection: [0,5]`--0.0`
119
DoubleLiteralNode SourceSection: [1,5]`-0.0`

graalpython/com.oracle.graal.python.test/testData/goldenFiles/NumberTests/int05.tast

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ ModuleRootNode Name: <module 'int05'> SourceSection: [0,3]`--2`
55
FrameDescriptor: Empty
66
Documentation: None
77
InnerRootNode SourceSection: [0,3]`--2`
8-
UnaryArithmeticExpression SourceSection: [0,3]`--2`
9-
LookupAndCallUnaryNodeGen SourceSection: None
10-
Op: __neg__
8+
NegNodeGen SourceSection: [0,3]`--2`
119
IntegerLiteralNode SourceSection: [1,3]`-2`
1210
Value: -2

graalpython/com.oracle.graal.python.test/testData/goldenFiles/NumberTests/int06.tast

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ ModuleRootNode Name: <module 'int06'> SourceSection: [0,4]`---2`
55
FrameDescriptor: Empty
66
Documentation: None
77
InnerRootNode SourceSection: [0,4]`---2`
8-
UnaryArithmeticExpression SourceSection: [0,4]`---2`
9-
LookupAndCallUnaryNodeGen SourceSection: None
10-
Op: __neg__
11-
UnaryArithmeticExpression SourceSection: [1,4]`--2`
12-
LookupAndCallUnaryNodeGen SourceSection: None
13-
Op: __neg__
8+
NegNodeGen SourceSection: [0,4]`---2`
9+
NegNodeGen SourceSection: [1,4]`--2`
1410
IntegerLiteralNode SourceSection: [2,4]`-2`
1511
Value: -2

graalpython/com.oracle.graal.python.test/testData/goldenFiles/NumberTests/int07.tast

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,8 @@ ModuleRootNode Name: <module 'int07'> SourceSection: [0,5]`----2`
55
FrameDescriptor: Empty
66
Documentation: None
77
InnerRootNode SourceSection: [0,5]`----2`
8-
UnaryArithmeticExpression SourceSection: [0,5]`----2`
9-
LookupAndCallUnaryNodeGen SourceSection: None
10-
Op: __neg__
11-
UnaryArithmeticExpression SourceSection: [1,5]`---2`
12-
LookupAndCallUnaryNodeGen SourceSection: None
13-
Op: __neg__
14-
UnaryArithmeticExpression SourceSection: [2,5]`--2`
15-
LookupAndCallUnaryNodeGen SourceSection: None
16-
Op: __neg__
8+
NegNodeGen SourceSection: [0,5]`----2`
9+
NegNodeGen SourceSection: [1,5]`---2`
10+
NegNodeGen SourceSection: [2,5]`--2`
1711
IntegerLiteralNode SourceSection: [3,5]`-2`
1812
Value: -2

graalpython/com.oracle.graal.python.test/testData/testFiles/RuntimeFileTests/enumt.tast

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6151,9 +6151,7 @@ ModuleRootNode Name: <module 'enumt'> SourceSection: [0,34561]`import sys↵from
61516151
WriteLocalVariableNodeGen SourceSection: [26734,26748]`value = ~value`
61526152
Identifier: value
61536153
Frame: [1,value,Illegal]
6154-
UnaryArithmeticExpression SourceSection: [26742,26748]`~value`
6155-
LookupAndCallUnaryNodeGen SourceSection: None
6156-
Op: __invert__
6154+
InvertNodeGen SourceSection: [26742,26748]`~value`
61576155
ReadLocalVariableNodeGen SourceSection: [26743,26748]`value`
61586156
Frame: [1,value,Illegal]
61596157
BlockNode SourceSection: None
@@ -6177,9 +6175,7 @@ ModuleRootNode Name: <module 'enumt'> SourceSection: [0,34561]`import sys↵from
61776175
WriteLocalVariableNodeGen SourceSection: [26852,26886]`possible_member = ~p...`
61786176
Identifier: possible_member
61796177
Frame: [3,possible_member,Illegal]
6180-
UnaryArithmeticExpression SourceSection: [26870,26886]`~possible_member`
6181-
LookupAndCallUnaryNodeGen SourceSection: None
6182-
Op: __invert__
6178+
InvertNodeGen SourceSection: [26870,26886]`~possible_member`
61836179
ReadLocalVariableNodeGen SourceSection: [26871,26886]`possible_member`
61846180
Frame: [3,possible_member,Illegal]
61856181
BlockNode SourceSection: None
@@ -7840,9 +7836,7 @@ ModuleRootNode Name: <module 'enumt'> SourceSection: [0,34561]`import sys↵from
78407836
EqNodeGen SourceSection: [30984,31010]`extra_flags == -flag...`
78417837
ReadLocalVariableNodeGen SourceSection: [30984,30995]`extra_flags`
78427838
Frame: [5,extra_flags,Illegal]
7843-
UnaryArithmeticExpression SourceSection: [30999,31010]`-flag_value`
7844-
LookupAndCallUnaryNodeGen SourceSection: None
7845-
Op: __neg__
7839+
NegNodeGen SourceSection: [30999,31010]`-flag_value`
78467840
ReadLocalVariableNodeGen SourceSection: [31000,31010]`flag_value`
78477841
Frame: [7,flag_value,Illegal]
78487842
WriteLocalVariableNodeGen SourceSection: [31032,31047]`extra_flags = 0`
@@ -8339,9 +8333,7 @@ ModuleRootNode Name: <module 'enumt'> SourceSection: [0,34561]`import sys↵from
83398333
GetCallAttributeNodeGen SourceSection: None
83408334
ReadLocalVariableNodeGen SourceSection: [32330,32334]`self`
83418335
Frame: [0,self,Illegal]
8342-
UnaryArithmeticExpression SourceSection: [32345,32358]`~self._value_`
8343-
LookupAndCallUnaryNodeGen SourceSection: None
8344-
Op: __invert__
8336+
InvertNodeGen SourceSection: [32345,32358]`~self._value_`
83458337
GetAttributeNode SourceSection: [32346,32358]`self._value_`
83468338
GetFixedAttributeNodeGen SourceSection: None
83478339
Key: _value_
@@ -8963,9 +8955,7 @@ ModuleRootNode Name: <module 'enumt'> SourceSection: [0,34561]`import sys↵from
89638955
LookupAndCallInplaceNodeGen SourceSection: None
89648956
ReadLocalVariableNodeGen SourceSection: [34078,34089]`not_covered`
89658957
Frame: [2,not_covered,Illegal]
8966-
UnaryArithmeticExpression SourceSection: [34093,34106]`~member_value`
8967-
LookupAndCallUnaryNodeGen SourceSection: None
8968-
Op: __invert__
8958+
InvertNodeGen SourceSection: [34093,34106]`~member_value`
89698959
ReadLocalVariableNodeGen SourceSection: [34094,34106]`member_value`
89708960
Frame: [7,member_value,Illegal]
89718961
ObjectLiteralNode SourceSection: None

graalpython/com.oracle.graal.python.test/testData/testFiles/RuntimeFileTests/heapq.tast

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3024,9 +3024,7 @@ ModuleRootNode Name: <module 'heapq'> SourceSection: [0,23017]`"""Heap queue alg
30243024
ReadAttributeFromObjectNotTypeNodeGen SourceSection: None
30253025
IntegerLiteralNode SourceSection: [21677,21678]`0`
30263026
Value: 0
3027-
UnaryArithmeticExpression SourceSection: [21680,21682]`-n`
3028-
LookupAndCallUnaryNodeGen SourceSection: None
3029-
Op: __neg__
3027+
NegNodeGen SourceSection: [21680,21682]`-n`
30303028
ReadLocalVariableNodeGen SourceSection: [21681,21682]`n`
30313029
Frame: [0,n,Illegal]
30323030
IntegerLiteralNode SourceSection: [21684,21686]`-1`
@@ -3067,9 +3065,7 @@ ModuleRootNode Name: <module 'heapq'> SourceSection: [0,23017]`"""Heap queue alg
30673065
WriteLocalVariableNodeGen SourceSection: [21802,21812]`order = -n`
30683066
Identifier: order
30693067
Frame: [8,order,Illegal]
3070-
UnaryArithmeticExpression SourceSection: [21810,21812]`-n`
3071-
LookupAndCallUnaryNodeGen SourceSection: None
3072-
Op: __neg__
3068+
NegNodeGen SourceSection: [21810,21812]`-n`
30733069
ReadLocalVariableNodeGen SourceSection: [21811,21812]`n`
30743070
Frame: [0,n,Illegal]
30753071
WriteLocalVariableNodeGen SourceSection: [21821,21847]`_heapreplace = heapr...`
@@ -3330,9 +3326,7 @@ ModuleRootNode Name: <module 'heapq'> SourceSection: [0,23017]`"""Heap queue alg
33303326
ReadAttributeFromObjectNotTypeNodeGen SourceSection: None
33313327
IntegerLiteralNode SourceSection: [22222,22223]`0`
33323328
Value: 0
3333-
UnaryArithmeticExpression SourceSection: [22225,22227]`-n`
3334-
LookupAndCallUnaryNodeGen SourceSection: None
3335-
Op: __neg__
3329+
NegNodeGen SourceSection: [22225,22227]`-n`
33363330
ReadLocalVariableNodeGen SourceSection: [22226,22227]`n`
33373331
Frame: [0,n,Illegal]
33383332
IntegerLiteralNode SourceSection: [22229,22231]`-1`
@@ -3373,9 +3367,7 @@ ModuleRootNode Name: <module 'heapq'> SourceSection: [0,23017]`"""Heap queue alg
33733367
WriteLocalVariableNodeGen SourceSection: [22327,22337]`order = -n`
33743368
Identifier: order
33753369
Frame: [8,order,Illegal]
3376-
UnaryArithmeticExpression SourceSection: [22335,22337]`-n`
3377-
LookupAndCallUnaryNodeGen SourceSection: None
3378-
Op: __neg__
3370+
NegNodeGen SourceSection: [22335,22337]`-n`
33793371
ReadLocalVariableNodeGen SourceSection: [22336,22337]`n`
33803372
Frame: [0,n,Illegal]
33813373
WriteLocalVariableNodeGen SourceSection: [22342,22368]`_heapreplace = heapr...`

graalpython/com.oracle.graal.python.test/testData/testFiles/RuntimeFileTests/locale.tast

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -781,9 +781,7 @@ ModuleRootNode Name: <module 'locale'> SourceSection: [0,78027]`"""Locale suppor
781781
Frame: [0,s,Illegal]
782782
SliceLiteralNodeGen SourceSection: [4626,4636]`-interval:`
783783
PythonObjectFactoryNodeGen SourceSection: None
784-
UnaryArithmeticExpression SourceSection: [4626,4635]`-interval`
785-
LookupAndCallUnaryNodeGen SourceSection: None
786-
Op: __neg__
784+
NegNodeGen SourceSection: [4626,4635]`-interval`
787785
ReadLocalVariableNodeGen SourceSection: [4627,4635]`interval`
788786
Frame: [9,interval,Illegal]
789787
EmptyNode SourceSection: None
@@ -797,9 +795,7 @@ ModuleRootNode Name: <module 'locale'> SourceSection: [0,78027]`"""Locale suppor
797795
SliceLiteralNodeGen SourceSection: [4653,4663]`:-interval`
798796
PythonObjectFactoryNodeGen SourceSection: None
799797
EmptyNode SourceSection: None
800-
UnaryArithmeticExpression SourceSection: [4654,4663]`-interval`
801-
LookupAndCallUnaryNodeGen SourceSection: None
802-
Op: __neg__
798+
NegNodeGen SourceSection: [4654,4663]`-interval`
803799
ReadLocalVariableNodeGen SourceSection: [4655,4663]`interval`
804800
Frame: [9,interval,Illegal]
805801
EmptyNode SourceSection: None

0 commit comments

Comments
 (0)