Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
1782dd56
Commit
1782dd56
authored
Sep 07, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #901 from kmod/speculation_fix
Type system fix: need to add unpacking to the type system
parents
9a3a43c3
80f4bc34
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
2 deletions
+49
-2
src/analysis/type_analysis.cpp
src/analysis/type_analysis.cpp
+3
-1
src/codegen/compvars.cpp
src/codegen/compvars.cpp
+18
-0
src/codegen/compvars.h
src/codegen/compvars.h
+1
-0
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+1
-1
test/tests/callattr_exceptions.py
test/tests/callattr_exceptions.py
+14
-0
test/tests/unpacking_types.py
test/tests/unpacking_types.py
+12
-0
No files found.
src/analysis/type_analysis.cpp
View file @
1782dd56
...
...
@@ -177,8 +177,10 @@ private:
break
;
case
AST_TYPE
:
:
Tuple
:
{
AST_Tuple
*
tt
=
ast_cast
<
AST_Tuple
>
(
target
);
auto
val_types
=
t
->
unpackTypes
(
tt
->
elts
.
size
());
assert
(
val_types
.
size
()
==
tt
->
elts
.
size
());
for
(
int
i
=
0
;
i
<
tt
->
elts
.
size
();
i
++
)
{
_doSet
(
tt
->
elts
[
i
],
UNKNOWN
);
_doSet
(
tt
->
elts
[
i
],
val_types
[
i
]
);
}
break
;
}
...
...
src/codegen/compvars.cpp
View file @
1782dd56
...
...
@@ -57,6 +57,12 @@ CompilerType::Result CompilerType::hasattr(BoxedString* attr) {
return
Result
::
Yes
;
}
std
::
vector
<
CompilerType
*>
CompilerType
::
unpackTypes
(
int
num_into
)
{
assert
((
CompilerType
*
)
this
!=
UNKNOWN
);
return
UNKNOWN
->
unpackTypes
(
num_into
);
}
void
ConcreteCompilerType
::
serializeToFrame
(
VAR
*
var
,
std
::
vector
<
llvm
::
Value
*>&
stackmap_args
)
{
#ifndef NDEBUG
if
(
llvmType
()
==
g
.
i1
)
{
...
...
@@ -490,6 +496,10 @@ public:
}
return
rtn
;
}
std
::
vector
<
CompilerType
*>
unpackTypes
(
int
num_into
)
override
{
return
std
::
vector
<
CompilerType
*>
(
num_into
,
UNKNOWN
);
}
};
ConcreteCompilerType
*
UNKNOWN
=
new
UnknownType
();
...
...
@@ -2506,6 +2516,14 @@ public:
return
*
var
->
getValue
();
}
std
::
vector
<
CompilerType
*>
unpackTypes
(
int
num_into
)
override
{
if
(
num_into
!=
elt_types
.
size
())
{
return
ValuedCompilerType
::
unpackTypes
(
num_into
);
}
return
elt_types
;
}
};
CompilerType
*
makeTupleType
(
const
std
::
vector
<
CompilerType
*>&
elt_types
)
{
...
...
src/codegen/compvars.h
View file @
1782dd56
...
...
@@ -57,6 +57,7 @@ public:
virtual
BoxedClass
*
guaranteedClass
()
=
0
;
virtual
Box
*
deserializeFromFrame
(
const
FrameVals
&
vals
)
=
0
;
virtual
int
numFrameArgs
()
=
0
;
virtual
std
::
vector
<
CompilerType
*>
unpackTypes
(
int
num_into
);
};
typedef
std
::
unordered_map
<
CompilerVariable
*
,
CompilerVariable
*>
DupCache
;
...
...
src/runtime/objmodel.cpp
View file @
1782dd56
...
...
@@ -2823,7 +2823,7 @@ Box* callattrInternal(Box* obj, BoxedString* attr, LookupScope scope, CallRewrit
r_val
=
grewrite_args
.
out_rtn
;
}
}
else
{
val
=
getattrInternalEx
<
CXX
>
(
obj
,
attr
,
NULL
,
scope
==
CLASS_ONLY
,
true
,
&
bind_obj
,
&
r_bind_obj
);
val
=
getattrInternalEx
<
S
>
(
obj
,
attr
,
NULL
,
scope
==
CLASS_ONLY
,
true
,
&
bind_obj
,
&
r_bind_obj
);
}
if
(
val
==
NULL
)
{
...
...
test/tests/callattr_exceptions.py
0 → 100644
View file @
1782dd56
# Make sure that callattrs handle exceptions (including
# different exception styles) correctly.
class
C
(
object
):
def
__getattr__
(
self
,
attr
):
raise
ValueError
()
def
f
():
c
=
C
()
for
i
in
xrange
(
10000
):
try
:
c
.
foo
()
except
ValueError
:
pass
f
()
test/tests/unpacking_types.py
0 → 100644
View file @
1782dd56
# Regression test: make sure that irgen and type analysis
# both handle tuple -packing and -unpcaking.
def
get_str
():
return
"Hello world"
def
f
():
_
,
a
=
1
,
get_str
()
a
.
lower
()
for
i
in
xrange
(
100000
):
f
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment