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
e041df0a
Commit
e041df0a
authored
Feb 10, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix irgen bug
Need to unbox-rebox bools like we do for ints and floats.
parent
528c0268
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
src/codegen/irgen.cpp
src/codegen/irgen.cpp
+15
-0
test/tests/bool_passing.py
test/tests/bool_passing.py
+9
-0
No files found.
src/codegen/irgen.cpp
View file @
e041df0a
...
...
@@ -445,6 +445,8 @@ static void emitBBs(IRGenState* irstate, const char* bb_type, GuardList& out_gua
speculated_class
=
int_cls
;
}
else
if
(
phi_type
==
FLOAT
)
{
speculated_class
=
float_cls
;
}
else
if
(
phi_type
==
BOOL
)
{
speculated_class
=
bool_cls
;
}
else
{
speculated_class
=
phi_type
->
guaranteedClass
();
}
...
...
@@ -501,6 +503,15 @@ static void emitBBs(IRGenState* irstate, const char* bb_type, GuardList& out_gua
return
v
;
},
[](
IREmitter
&
emitter
)
{
return
llvm
::
UndefValue
::
get
(
FLOAT
->
llvmType
());
});
}
else
if
(
speculated_class
==
bool_cls
)
{
v
=
handlePotentiallyUndefined
(
is_defined_var
,
BOOL
->
llvmType
(),
osr_unbox_block_end
,
*
unbox_emitter
,
true
,
[
from_arg
](
IREmitter
&
emitter
)
{
auto
v
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
unboxBool
,
from_arg
);
(
new
ConcreteCompilerVariable
(
BOXED_BOOL
,
from_arg
,
true
))
->
decvref
(
emitter
);
return
boolFromI1
(
emitter
,
v
)
->
getValue
();
},
[](
IREmitter
&
emitter
)
{
return
llvm
::
UndefValue
::
get
(
BOOL
->
llvmType
());
});
}
else
{
assert
(
phi_type
==
typeFromClass
(
speculated_class
));
v
=
from_arg
;
...
...
@@ -929,6 +940,10 @@ static void emitBBs(IRGenState* irstate, const char* bb_type, GuardList& out_gua
llvm
::
Value
*
unboxed
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
unboxInt
,
converted
->
getValue
());
v
=
new
ConcreteCompilerVariable
(
INT
,
unboxed
,
true
);
}
else
if
(
it
->
second
.
first
==
BOOL
)
{
llvm
::
Value
*
unboxed
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
unboxBool
,
converted
->
getValue
());
v
=
boolFromI1
(
emitter
,
unboxed
);
}
else
{
printf
(
"%s
\n
"
,
it
->
second
.
first
->
debugName
().
c_str
());
abort
();
...
...
test/tests/bool_passing.py
0 → 100644
View file @
e041df0a
# Test that we can pass known-bool values through OSRs and what not:
def
f
(
b
):
b2
=
b
.
__nonzero__
()
for
i
in
xrange
(
10000
):
pass
print
b
,
b2
f
(
True
)
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