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
e07eda8f
Commit
e07eda8f
authored
May 05, 2016
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
generator: borrow passed_generator
this makes sure that we don't generate additional cycles to the generator
parent
e5146422
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
8 deletions
+22
-8
src/codegen/ast_interpreter.cpp
src/codegen/ast_interpreter.cpp
+4
-2
src/codegen/irgen.cpp
src/codegen/irgen.cpp
+18
-6
No files found.
src/codegen/ast_interpreter.cpp
View file @
e07eda8f
...
...
@@ -785,8 +785,10 @@ Box* ASTInterpreter::doOSR(AST_Jump* node) {
return
nullptr
;
}
if
(
generator
)
sorted_symbol_table
[
source_info
->
getInternedStrings
().
get
(
PASSED_GENERATOR_NAME
)]
=
incref
(
generator
);
if
(
generator
)
{
// generated is only borrowed in order to not introduce cycles
sorted_symbol_table
[
source_info
->
getInternedStrings
().
get
(
PASSED_GENERATOR_NAME
)]
=
generator
;
}
if
(
frame_info
.
passed_closure
)
sorted_symbol_table
[
source_info
->
getInternedStrings
().
get
(
PASSED_CLOSURE_NAME
)]
...
...
src/codegen/irgen.cpp
View file @
e07eda8f
...
...
@@ -299,6 +299,13 @@ static ConcreteCompilerType* getTypeAtBlockStart(TypeAnalysis* types, InternedSt
return
types
->
getTypeAtBlockStart
(
name
,
block
);
}
static
bool
shouldPhisOwnThisSym
(
llvm
::
StringRef
name
)
{
// generating unnecessary increfs to the passed generator would introduce cycles inside the generator
if
(
name
==
PASSED_GENERATOR_NAME
)
return
false
;
return
true
;
}
llvm
::
Value
*
handlePotentiallyUndefined
(
ConcreteCompilerVariable
*
is_defined_var
,
llvm
::
Type
*
rtn_type
,
llvm
::
BasicBlock
*&
cur_block
,
IREmitter
&
emitter
,
bool
speculate_undefined
,
std
::
function
<
llvm
::
Value
*
(
IREmitter
&
)
>
when_defined
,
...
...
@@ -624,7 +631,8 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
llvm
::
PHINode
*
phi
=
emitter
->
getBuilder
()
->
CreatePHI
(
analyzed_type
->
llvmType
(),
block
->
predecessors
.
size
()
+
1
,
p
.
first
.
s
());
if
(
analyzed_type
->
getBoxType
()
==
analyzed_type
)
{
irstate
->
getRefcounts
()
->
setType
(
phi
,
RefType
::
OWNED
);
RefType
type
=
shouldPhisOwnThisSym
(
p
.
first
.
s
())
?
RefType
::
OWNED
:
RefType
::
BORROWED
;
irstate
->
getRefcounts
()
->
setType
(
phi
,
type
);
}
ConcreteCompilerVariable
*
var
=
new
ConcreteCompilerVariable
(
analyzed_type
,
phi
);
generator
->
giveLocalSymbol
(
p
.
first
,
var
);
...
...
@@ -665,8 +673,10 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
ConcreteCompilerType
*
type
=
getTypeAtBlockStart
(
types
,
s
,
block
);
llvm
::
PHINode
*
phi
=
emitter
->
getBuilder
()
->
CreatePHI
(
type
->
llvmType
(),
block
->
predecessors
.
size
(),
s
.
s
());
if
(
type
->
getBoxType
()
==
type
)
irstate
->
getRefcounts
()
->
setType
(
phi
,
RefType
::
OWNED
);
if
(
type
->
getBoxType
()
==
type
)
{
RefType
type
=
shouldPhisOwnThisSym
(
s
.
s
())
?
RefType
::
OWNED
:
RefType
::
BORROWED
;
irstate
->
getRefcounts
()
->
setType
(
phi
,
type
);
}
ConcreteCompilerVariable
*
var
=
new
ConcreteCompilerVariable
(
type
,
phi
);
generator
->
giveLocalSymbol
(
s
,
var
);
...
...
@@ -766,8 +776,10 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
// printf("block %d: adding phi for %s from pred %d\n", block->idx, name.c_str(), pred->idx);
llvm
::
PHINode
*
phi
=
emitter
->
getBuilder
()
->
CreatePHI
(
cv
->
getType
()
->
llvmType
(),
block
->
predecessors
.
size
(),
name
.
s
());
if
(
cv
->
getType
()
->
getBoxType
()
==
cv
->
getType
())
irstate
->
getRefcounts
()
->
setType
(
phi
,
RefType
::
OWNED
);
if
(
cv
->
getType
()
->
getBoxType
()
==
cv
->
getType
())
{
RefType
type
=
shouldPhisOwnThisSym
(
name
.
s
())
?
RefType
::
OWNED
:
RefType
::
BORROWED
;
irstate
->
getRefcounts
()
->
setType
(
phi
,
type
);
}
// emitter->getBuilder()->CreateCall(g.funcs.dump, phi);
ConcreteCompilerVariable
*
var
=
new
ConcreteCompilerVariable
(
cv
->
getType
(),
phi
);
generator
->
giveLocalSymbol
(
name
,
var
);
...
...
@@ -875,7 +887,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
llvm
::
Value
*
val
=
v
->
getValue
();
llvm_phi
->
addIncoming
(
v
->
getValue
(),
llvm_exit_blocks
[
b
->
predecessors
[
j
]]);
if
(
v
->
getType
()
->
getBoxType
()
==
v
->
getType
())
{
if
(
v
->
getType
()
->
getBoxType
()
==
v
->
getType
()
&&
shouldPhisOwnThisSym
(
it
->
first
.
s
())
)
{
// llvm::outs() << *v->getValue() << " is getting consumed by phi " << *llvm_phi << '\n';
assert
(
llvm
::
isa
<
llvm
::
BranchInst
>
(
terminator
));
irstate
->
getRefcounts
()
->
refConsumed
(
v
->
getValue
(),
terminator
);
...
...
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