Skip to content

Commit fe55db2

Browse files
committed
[GR-11643] Implement specializing storages for tuples
PullRequest: graalpython/784
2 parents 113fe19 + 1a83bb1 commit fe55db2

File tree

72 files changed

+1368
-1054
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1368
-1054
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
2+
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3+
#
4+
# The Universal Permissive License (UPL), Version 1.0
5+
#
6+
# Subject to the condition set forth below, permission is hereby granted to any
7+
# person obtaining a copy of this software, associated documentation and/or
8+
# data (collectively the "Software"), free of charge and under any and all
9+
# copyright rights in the Software, and any and all patent rights owned or
10+
# freely licensable by each licensor hereunder covering either (i) the
11+
# unmodified Software as contributed to or provided by such licensor, or (ii)
12+
# the Larger Works (as defined below), to deal in both
13+
#
14+
# (a) the Software, and
15+
#
16+
# (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
17+
# one is included with the Software each a "Larger Work" to which the Software
18+
# is contributed by such licensors),
19+
#
20+
# without restriction, including without limitation the rights to copy, create
21+
# derivative works of, display, perform, and distribute the Software and make,
22+
# use, sell, offer for sale, import, export, have made, and have sold the
23+
# Software and the Larger Work(s), and to sublicense the foregoing rights on
24+
# either these or other terms.
25+
#
26+
# This license is subject to the following condition:
27+
#
28+
# The above copyright notice and either this complete permission notice or at a
29+
# minimum a reference to the UPL must be included in all copies or substantial
30+
# portions of the Software.
31+
#
32+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38+
# SOFTWARE.
39+
40+
41+
def index(num):
42+
x = list(x * 2 for x in range(16))
43+
x_len = len(x)
44+
item = 0
45+
46+
for t in range(num):
47+
for i in range(x_len):
48+
item = item + x[i] + x[x[i] % x_len] + x[x[x[i] % x_len] % x_len]
49+
50+
return item
51+
52+
53+
def measure(num):
54+
print(index(num))
55+
56+
57+
def __benchmark__(num=100000):
58+
measure(num)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
2+
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3+
#
4+
# The Universal Permissive License (UPL), Version 1.0
5+
#
6+
# Subject to the condition set forth below, permission is hereby granted to any
7+
# person obtaining a copy of this software, associated documentation and/or
8+
# data (collectively the "Software"), free of charge and under any and all
9+
# copyright rights in the Software, and any and all patent rights owned or
10+
# freely licensable by each licensor hereunder covering either (i) the
11+
# unmodified Software as contributed to or provided by such licensor, or (ii)
12+
# the Larger Works (as defined below), to deal in both
13+
#
14+
# (a) the Software, and
15+
#
16+
# (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
17+
# one is included with the Software each a "Larger Work" to which the Software
18+
# is contributed by such licensors),
19+
#
20+
# without restriction, including without limitation the rights to copy, create
21+
# derivative works of, display, perform, and distribute the Software and make,
22+
# use, sell, offer for sale, import, export, have made, and have sold the
23+
# Software and the Larger Work(s), and to sublicense the foregoing rights on
24+
# either these or other terms.
25+
#
26+
# This license is subject to the following condition:
27+
#
28+
# The above copyright notice and either this complete permission notice or at a
29+
# minimum a reference to the UPL must be included in all copies or substantial
30+
# portions of the Software.
31+
#
32+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38+
# SOFTWARE.
39+
40+
41+
def index(num):
42+
x = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]
43+
x_len = len(x)
44+
item = 0
45+
46+
for t in range(num):
47+
for i in range(x_len):
48+
item = item + x[i] + x[x[i] % x_len] + x[x[x[i] % x_len] % x_len]
49+
50+
return item
51+
52+
53+
def measure(num):
54+
print(index(num))
55+
56+
57+
def __benchmark__(num=100000):
58+
measure(num)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
2+
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3+
#
4+
# The Universal Permissive License (UPL), Version 1.0
5+
#
6+
# Subject to the condition set forth below, permission is hereby granted to any
7+
# person obtaining a copy of this software, associated documentation and/or
8+
# data (collectively the "Software"), free of charge and under any and all
9+
# copyright rights in the Software, and any and all patent rights owned or
10+
# freely licensable by each licensor hereunder covering either (i) the
11+
# unmodified Software as contributed to or provided by such licensor, or (ii)
12+
# the Larger Works (as defined below), to deal in both
13+
#
14+
# (a) the Software, and
15+
#
16+
# (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
17+
# one is included with the Software each a "Larger Work" to which the Software
18+
# is contributed by such licensors),
19+
#
20+
# without restriction, including without limitation the rights to copy, create
21+
# derivative works of, display, perform, and distribute the Software and make,
22+
# use, sell, offer for sale, import, export, have made, and have sold the
23+
# Software and the Larger Work(s), and to sublicense the foregoing rights on
24+
# either these or other terms.
25+
#
26+
# This license is subject to the following condition:
27+
#
28+
# The above copyright notice and either this complete permission notice or at a
29+
# minimum a reference to the UPL must be included in all copies or substantial
30+
# portions of the Software.
31+
#
32+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38+
# SOFTWARE.
39+
40+
41+
def index(num):
42+
x = tuple(x * 2 for x in range(16))
43+
x_len = len(x)
44+
item = 0
45+
46+
for t in range(num):
47+
for i in range(x_len):
48+
item = item + x[i] + x[x[i] % x_len] + x[x[x[i] % x_len] % x_len]
49+
50+
return item
51+
52+
53+
def measure(num):
54+
print(index(num))
55+
56+
57+
def __benchmark__(num=100000):
58+
measure(num)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
2+
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3+
#
4+
# The Universal Permissive License (UPL), Version 1.0
5+
#
6+
# Subject to the condition set forth below, permission is hereby granted to any
7+
# person obtaining a copy of this software, associated documentation and/or
8+
# data (collectively the "Software"), free of charge and under any and all
9+
# copyright rights in the Software, and any and all patent rights owned or
10+
# freely licensable by each licensor hereunder covering either (i) the
11+
# unmodified Software as contributed to or provided by such licensor, or (ii)
12+
# the Larger Works (as defined below), to deal in both
13+
#
14+
# (a) the Software, and
15+
#
16+
# (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
17+
# one is included with the Software each a "Larger Work" to which the Software
18+
# is contributed by such licensors),
19+
#
20+
# without restriction, including without limitation the rights to copy, create
21+
# derivative works of, display, perform, and distribute the Software and make,
22+
# use, sell, offer for sale, import, export, have made, and have sold the
23+
# Software and the Larger Work(s), and to sublicense the foregoing rights on
24+
# either these or other terms.
25+
#
26+
# This license is subject to the following condition:
27+
#
28+
# The above copyright notice and either this complete permission notice or at a
29+
# minimum a reference to the UPL must be included in all copies or substantial
30+
# portions of the Software.
31+
#
32+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38+
# SOFTWARE.
39+
40+
41+
def index(num):
42+
x = (0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30)
43+
x_len = len(x)
44+
item = 0
45+
46+
for t in range(num):
47+
for i in range(x_len):
48+
item = item + x[i] + x[x[i] % x_len] + x[x[x[i] % x_len] % x_len]
49+
50+
return item
51+
52+
53+
def measure(num):
54+
print(index(num))
55+
56+
57+
def __benchmark__(num=100000):
58+
measure(num)

graalpython/com.oracle.graal.python.test/testData/goldenFiles/AssignmentTests/assignment05.tast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ ModuleRootNode Name: <module 'assignment05'> SourceSection: [0,17]`a, b, c = 1,
1111
SideEffect:
1212
DestructuringAssignmentNodeGen SourceSection: [0,17]`a, b, c = 1, 2, 3`
1313
TupleLiteralNode SourceSection: [10,17]`1, 2, 3`
14-
PythonObjectFactoryNodeGen SourceSection: None
1514
IntegerLiteralNode SourceSection: [10,11]`1`
1615
Value: 1
1716
IntegerLiteralNode SourceSection: [13,14]`2`
1817
Value: 2
1918
IntegerLiteralNode SourceSection: [16,17]`3`
2019
Value: 3
20+
PythonObjectFactoryNodeGen SourceSection: None
2121
WriteLocalVariableNodeGen SourceSection: None
2222
Identifier: <>temp0
2323
WriteLocalFrameSlotNodeGen SourceSection: None

graalpython/com.oracle.graal.python.test/testData/goldenFiles/AssignmentTests/assignment07.tast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ ModuleRootNode Name: <module 'assignment07'> SourceSection: [0,29]`def fn():↵
3636
FunctionBodyNode SourceSection: [12,29]`a, b, c = 1, 2, 3`
3737
DestructuringAssignmentNodeGen SourceSection: [12,29]`a, b, c = 1, 2, 3`
3838
TupleLiteralNode SourceSection: [22,29]`1, 2, 3`
39-
PythonObjectFactoryNodeGen SourceSection: None
4039
IntegerLiteralNode SourceSection: [22,23]`1`
4140
Value: 1
4241
IntegerLiteralNode SourceSection: [25,26]`2`
4342
Value: 2
4443
IntegerLiteralNode SourceSection: [28,29]`3`
4544
Value: 3
45+
PythonObjectFactoryNodeGen SourceSection: None
4646
WriteLocalVariableNodeGen SourceSection: None
4747
Identifier: <>temp3
4848
WriteLocalFrameSlotNodeGen SourceSection: None

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ ModuleRootNode Name: <module 'call18'> SourceSection: [0,35]`def fn(arg = [1,2])
1414
FunctionDefinitionNode Name: fn SourceSection: None
1515
Arguments:
1616
ListLiteralNode SourceSection: [13,18]`[1,2]`
17-
PythonObjectFactoryNodeGen SourceSection: None
1817
IntegerLiteralNode SourceSection: [14,15]`1`
1918
Value: 1
2019
IntegerLiteralNode SourceSection: [16,17]`2`
2120
Value: 2
21+
PythonObjectFactoryNodeGen SourceSection: None
2222
KwArguments: None
2323
Documentation: StringLiteralNode: Empty
2424
FreeVarSlots: None
@@ -53,9 +53,9 @@ ModuleRootNode Name: <module 'call18'> SourceSection: [0,35]`def fn(arg = [1,2])
5353
KeywordArgumentsNodeGen SourceSection: None
5454
KeywordLiteralNode SourceSection: None
5555
ListLiteralNode SourceSection: [31,34]`[1]`
56-
PythonObjectFactoryNodeGen SourceSection: None
5756
IntegerLiteralNode SourceSection: [32,33]`1`
5857
Value: 1
58+
PythonObjectFactoryNodeGen SourceSection: None
5959
CompactKeywordsNodeGen SourceSection: None
6060
ExecuteKeywordStarargsNodeGen SourceSection: None
6161
EmptyNode SourceSection: None

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,19 @@ ModuleRootNode Name: <module 'for12'> SourceSection: [0,52]`def fn():↵ for a,
7373
GetIteratorExpressionNodeGen SourceSection: [24,38]`((1,2), (3,4))`
7474
GetIteratorNodeGen SourceSection: None
7575
TupleLiteralNode SourceSection: [24,38]`((1,2), (3,4))`
76-
PythonObjectFactoryNodeGen SourceSection: None
7776
TupleLiteralNode SourceSection: [25,30]`(1,2)`
78-
PythonObjectFactoryNodeGen SourceSection: None
7977
IntegerLiteralNode SourceSection: [26,27]`1`
8078
Value: 1
8179
IntegerLiteralNode SourceSection: [28,29]`2`
8280
Value: 2
83-
TupleLiteralNode SourceSection: [32,37]`(3,4)`
8481
PythonObjectFactoryNodeGen SourceSection: None
82+
TupleLiteralNode SourceSection: [32,37]`(3,4)`
8583
IntegerLiteralNode SourceSection: [33,34]`3`
8684
Value: 3
8785
IntegerLiteralNode SourceSection: [35,36]`4`
8886
Value: 4
87+
PythonObjectFactoryNodeGen SourceSection: None
88+
PythonObjectFactoryNodeGen SourceSection: None
8989
BlockNode SourceSection: None
9090
Return Expresssion: ReadLocalVariableNode SourceSection: None
9191
Frame: [4,<return_val>,Illegal]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ ModuleRootNode Name: <module 'try04'> SourceSection: [0,63]`try:↵ pass↵exce
1717
ExpressionStatementNode SourceSection: [59,63]`pass`
1818
EmptyNode SourceSection: [59,63]`pass`
1919
TupleLiteralNode SourceSection: [19,55]`(RuntimeError, TypeE...`
20-
PythonObjectFactoryNodeGen SourceSection: None
2120
ReadNameNodeGen SourceSection: [20,32]`RuntimeError`
2221
Identifier: RuntimeError
2322
ReadNameNodeGen SourceSection: [34,43]`TypeError`
2423
Identifier: TypeError
2524
ReadNameNodeGen SourceSection: [45,54]`NameError`
2625
Identifier: NameError
26+
PythonObjectFactoryNodeGen SourceSection: None
2727
BlockNode SourceSection: None
2828
SaveExceptionStateNodeGen SourceSection: None

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ ModuleRootNode Name: <module 'try06'> SourceSection: [0,124]`for cls in (B, C, D
3939
GetIteratorExpressionNodeGen SourceSection: [11,20]`(B, C, D)`
4040
GetIteratorNodeGen SourceSection: None
4141
TupleLiteralNode SourceSection: [11,20]`(B, C, D)`
42-
PythonObjectFactoryNodeGen SourceSection: None
4342
ReadNameNodeGen SourceSection: [12,13]`B`
4443
Identifier: B
4544
ReadNameNodeGen SourceSection: [15,16]`C`
4645
Identifier: C
4746
ReadNameNodeGen SourceSection: [18,19]`D`
4847
Identifier: D
48+
PythonObjectFactoryNodeGen SourceSection: None
4949
BlockNode SourceSection: None

0 commit comments

Comments
 (0)