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
5e4f44b0
Commit
5e4f44b0
authored
Jul 24, 2014
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Generator: implement basic review comments
parent
4c9e23d2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
36 deletions
+19
-36
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+1
-2
src/codegen/runtime_hooks.h
src/codegen/runtime_hooks.h
+1
-1
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+6
-15
src/runtime/types.cpp
src/runtime/types.cpp
+11
-18
No files found.
src/codegen/irgen/irgenerator.cpp
View file @
5e4f44b0
...
...
@@ -1817,8 +1817,7 @@ private:
llvm
::
BasicBlock
*
target
=
entry_blocks
[
node
->
target
];
if
(
ENABLE_OSR
&&
node
->
target
->
idx
<
myblock
->
idx
&&
irstate
->
getEffortLevel
()
<
EffortLevel
::
MAXIMAL
&&
!
irstate
->
getScopeInfo
()
->
takesGenerator
())
{
if
(
ENABLE_OSR
&&
node
->
target
->
idx
<
myblock
->
idx
&&
irstate
->
getEffortLevel
()
<
EffortLevel
::
MAXIMAL
)
{
assert
(
node
->
target
->
predecessors
.
size
()
>
1
);
doOSRExit
(
target
,
node
);
}
else
{
...
...
src/codegen/runtime_hooks.h
View file @
5e4f44b0
...
...
@@ -32,7 +32,7 @@ struct GlobalFuncs {
llvm
::
Value
*
boxInt
,
*
unboxInt
,
*
boxFloat
,
*
unboxFloat
,
*
boxStringPtr
,
*
boxCLFunction
,
*
unboxCLFunction
,
*
boxInstanceMethod
,
*
boxBool
,
*
unboxBool
,
*
createTuple
,
*
createDict
,
*
createList
,
*
createSlice
,
*
createUserClass
,
*
createClosure
,
*
createGenerator
,
*
insideGenerator
;
*
createUserClass
,
*
createClosure
,
*
createGenerator
;
llvm
::
Value
*
getattr
,
*
setattr
,
*
delattr
,
*
delitem
,
*
delGlobal
,
*
print
,
*
nonzero
,
*
binop
,
*
compare
,
*
augbinop
,
*
unboxedLen
,
*
getitem
,
*
getclsattr
,
*
getGlobal
,
*
setitem
,
*
unaryop
,
*
import
,
*
importFrom
,
*
importStar
,
*
repr
,
*
isinstance
,
*
yield
;
...
...
src/runtime/objmodel.cpp
View file @
5e4f44b0
...
...
@@ -858,8 +858,6 @@ Box* getattr_internal(Box* obj, const std::string& attr, bool check_cls, bool al
raiseExcHelper
(
NameError
,
"free variable '%s' referenced before assignment in enclosing scope"
,
attr
.
c_str
());
}
if
(
obj
->
cls
==
generator_cls
)
{
}
if
(
allow_custom
)
{
// Don't need to pass icentry args, since we special-case __getattribtue__ and __getattr__ to use
...
...
@@ -1758,7 +1756,7 @@ Box* callFunc(BoxedFunction* func, CallRewriteArgs* rewrite_args, ArgPassSpec ar
BoxedClosure
*
closure
=
func
->
closure
;
if
(
argspec
.
has_starargs
||
argspec
.
has_kwargs
||
f
->
takes_kwargs
)
if
(
argspec
.
has_starargs
||
argspec
.
has_kwargs
||
f
->
takes_kwargs
||
func
->
isGenerator
)
rewrite_args
=
NULL
;
// These could be handled:
...
...
@@ -1793,26 +1791,21 @@ Box* callFunc(BoxedFunction* func, CallRewriteArgs* rewrite_args, ArgPassSpec ar
if
(
rewrite_args
)
{
int
closure_indicator
=
closure
?
1
:
0
;
int
generator_indicator
=
func
->
isGenerator
?
1
:
0
;
int
arg_offset
=
closure_indicator
+
generator_indicator
;
if
(
num_passed_args
>=
1
)
rewrite_args
->
arg1
=
rewrite_args
->
arg1
.
move
(
0
+
arg_offset
);
rewrite_args
->
arg1
=
rewrite_args
->
arg1
.
move
(
0
+
closure_indicator
);
if
(
num_passed_args
>=
2
)
rewrite_args
->
arg2
=
rewrite_args
->
arg2
.
move
(
1
+
arg_offset
);
rewrite_args
->
arg2
=
rewrite_args
->
arg2
.
move
(
1
+
closure_indicator
);
if
(
num_passed_args
>=
3
)
rewrite_args
->
arg3
=
rewrite_args
->
arg3
.
move
(
2
+
arg_offset
);
rewrite_args
->
arg3
=
rewrite_args
->
arg3
.
move
(
2
+
closure_indicator
);
if
(
num_passed_args
>=
4
)
rewrite_args
->
args
=
rewrite_args
->
args
.
move
(
3
+
arg_offset
);
rewrite_args
->
args
=
rewrite_args
->
args
.
move
(
3
+
closure_indicator
);
// TODO this kind of embedded reference needs to be tracked by the GC somehow?
// Or maybe it's ok, since we've guarded on the function object?
if
(
closure
)
rewrite_args
->
rewriter
->
loadConst
(
0
,
(
intptr_t
)
closure
);
if
(
func
->
isGenerator
)
rewrite_args
->
rewriter
->
loadConst
(
0
,
(
intptr_t
)
func
->
isGenerator
);
// We might have trouble if we have more output args than input args,
// such as if we need more space to pass defaults.
if
(
num_output_args
>
3
&&
num_output_args
>
argspec
.
totalPassed
())
{
...
...
@@ -2002,8 +1995,7 @@ Box* callFunc(BoxedFunction* func, CallRewriteArgs* rewrite_args, ArgPassSpec ar
return
createGenerator
(
func
,
oarg1
,
oarg2
,
oarg3
,
oargs
);
}
return
callCLFunc
(
f
,
rewrite_args
,
num_output_args
,
closure
,
(
BoxedGenerator
*
)
func
->
isGenerator
,
oarg1
,
oarg2
,
oarg3
,
oargs
);
return
callCLFunc
(
f
,
rewrite_args
,
num_output_args
,
closure
,
NULL
,
oarg1
,
oarg2
,
oarg3
,
oargs
);
}
Box
*
callCLFunc
(
CLFunction
*
f
,
CallRewriteArgs
*
rewrite_args
,
int
num_output_args
,
BoxedClosure
*
closure
,
...
...
@@ -2035,7 +2027,6 @@ Box* callCLFunc(CLFunction* f, CallRewriteArgs* rewrite_args, int num_output_arg
}
Box
*
runtimeCallInternal
(
Box
*
obj
,
CallRewriteArgs
*
rewrite_args
,
ArgPassSpec
argspec
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
{
int
npassed_args
=
argspec
.
totalPassed
();
...
...
src/runtime/types.cpp
View file @
5e4f44b0
...
...
@@ -285,29 +285,22 @@ extern "C" void generatorGCHandler(GCVisitor* v, void* p) {
BoxedGenerator
*
g
=
(
BoxedGenerator
*
)
p
;
if
(
g
->
function
)
{
v
->
visit
(
g
->
function
);
if
(
g
->
function
->
f
)
{
int
num_args
=
g
->
function
->
f
->
num_args
;
if
(
num_args
>=
1
)
v
->
visit
(
g
->
arg1
);
if
(
num_args
>=
2
)
v
->
visit
(
g
->
arg2
);
if
(
num_args
>=
3
)
v
->
visit
(
g
->
arg3
);
if
(
num_args
>
3
)
v
->
visitPotentialRange
(
reinterpret_cast
<
void
*
const
*>
(
&
g
->
args
->
elts
[
0
]),
reinterpret_cast
<
void
*
const
*>
(
&
g
->
args
->
elts
[
num_args
-
3
]));
}
}
v
->
visit
(
g
->
function
);
int
num_args
=
g
->
function
->
f
->
num_args
;
if
(
num_args
>=
1
)
v
->
visit
(
g
->
arg1
);
if
(
num_args
>=
2
)
v
->
visit
(
g
->
arg2
);
if
(
num_args
>=
3
)
v
->
visit
(
g
->
arg3
);
if
(
num_args
>
3
)
v
->
visitPotentialRange
(
reinterpret_cast
<
void
*
const
*>
(
&
g
->
args
->
elts
[
0
]),
reinterpret_cast
<
void
*
const
*>
(
&
g
->
args
->
elts
[
num_args
-
3
]));
if
(
g
->
returnValue
)
v
->
visit
(
g
->
returnValue
);
if
(
g
->
exception
)
v
->
visit
(
g
->
exception
);
v
->
visitPotentialRange
((
void
**
)
&
g
->
context
,
((
void
**
)
&
g
->
context
)
+
sizeof
(
g
->
context
)
/
sizeof
(
void
*
));
v
->
visitPotentialRange
((
void
**
)
&
g
->
returnContext
,
((
void
**
)
&
g
->
returnContext
)
+
sizeof
(
g
->
returnContext
)
/
sizeof
(
void
*
));
...
...
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