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
e320ebee
Commit
e320ebee
authored
Feb 17, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
45349e60
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
15 deletions
+25
-15
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+1
-1
src/codegen/irgen/refcounts.cpp
src/codegen/irgen/refcounts.cpp
+24
-14
No files found.
src/codegen/irgen/irgenerator.cpp
View file @
e320ebee
...
@@ -2794,7 +2794,7 @@ public:
...
@@ -2794,7 +2794,7 @@ public:
llvm
::
BasicBlock
*
orig_block
=
curblock
;
llvm
::
BasicBlock
*
orig_block
=
curblock
;
llvm
::
BasicBlock
*
cxx_exc_dest
=
llvm
::
BasicBlock
::
Create
(
g
.
context
,
""
,
irstate
->
getLLVMFunction
());
llvm
::
BasicBlock
*
cxx_exc_dest
=
llvm
::
BasicBlock
::
Create
(
g
.
context
,
"
cxxwrapper
"
,
irstate
->
getLLVMFunction
());
emitter
.
getBuilder
()
->
SetInsertPoint
(
cxx_exc_dest
);
emitter
.
getBuilder
()
->
SetInsertPoint
(
cxx_exc_dest
);
...
...
src/codegen/irgen/refcounts.cpp
View file @
e320ebee
...
@@ -79,18 +79,16 @@ void addIncrefs(llvm::Value* v, int num_refs, llvm::Instruction* incref_pt) {
...
@@ -79,18 +79,16 @@ void addIncrefs(llvm::Value* v, int num_refs, llvm::Instruction* incref_pt) {
#ifdef Py_REF_DEBUG
#ifdef Py_REF_DEBUG
auto
reftotal_gv
=
g
.
cur_module
->
getOrInsertGlobal
(
"_Py_RefTotal"
,
g
.
i64
);
auto
reftotal_gv
=
g
.
cur_module
->
getOrInsertGlobal
(
"_Py_RefTotal"
,
g
.
i64
);
auto
reftotal
=
new
llvm
::
LoadInst
(
reftotal_gv
,
""
,
incref_pt
);
auto
reftotal
=
new
llvm
::
LoadInst
(
reftotal_gv
,
""
,
incref_pt
);
auto
new_reftotal
=
llvm
::
BinaryOperator
::
Create
(
auto
new_reftotal
=
llvm
::
BinaryOperator
::
Create
(
llvm
::
BinaryOperator
::
BinaryOps
::
Add
,
reftotal
,
llvm
::
BinaryOperator
::
BinaryOps
::
Add
,
reftotal
,
getConstantInt
(
num_refs
,
g
.
i64
),
""
,
incref_pt
);
getConstantInt
(
num_refs
,
g
.
i64
),
""
,
incref_pt
);
new
llvm
::
StoreInst
(
new_reftotal
,
reftotal_gv
,
incref_pt
);
new
llvm
::
StoreInst
(
new_reftotal
,
reftotal_gv
,
incref_pt
);
#endif
#endif
llvm
::
ArrayRef
<
llvm
::
Value
*>
idxs
({
getConstantInt
(
0
,
g
.
i32
),
getConstantInt
(
0
,
g
.
i32
)
});
llvm
::
ArrayRef
<
llvm
::
Value
*>
idxs
({
getConstantInt
(
0
,
g
.
i32
),
getConstantInt
(
0
,
g
.
i32
)
});
auto
refcount_ptr
=
llvm
::
GetElementPtrInst
::
CreateInBounds
(
v
,
idxs
,
""
,
incref_pt
);
auto
refcount_ptr
=
llvm
::
GetElementPtrInst
::
CreateInBounds
(
v
,
idxs
,
""
,
incref_pt
);
auto
refcount
=
new
llvm
::
LoadInst
(
refcount_ptr
,
""
,
incref_pt
);
auto
refcount
=
new
llvm
::
LoadInst
(
refcount_ptr
,
""
,
incref_pt
);
auto
new_refcount
=
llvm
::
BinaryOperator
::
Create
(
auto
new_refcount
=
llvm
::
BinaryOperator
::
Create
(
llvm
::
BinaryOperator
::
BinaryOps
::
Add
,
refcount
,
llvm
::
BinaryOperator
::
BinaryOps
::
Add
,
refcount
,
getConstantInt
(
num_refs
,
g
.
i64
),
""
,
incref_pt
);
getConstantInt
(
num_refs
,
g
.
i64
),
""
,
incref_pt
);
new
llvm
::
StoreInst
(
new_refcount
,
refcount_ptr
,
incref_pt
);
new
llvm
::
StoreInst
(
new_refcount
,
refcount_ptr
,
incref_pt
);
}
}
...
@@ -100,22 +98,20 @@ void addDecrefs(llvm::Value* v, int num_refs, llvm::Instruction* decref_pt) {
...
@@ -100,22 +98,20 @@ void addDecrefs(llvm::Value* v, int num_refs, llvm::Instruction* decref_pt) {
#ifdef Py_REF_DEBUG
#ifdef Py_REF_DEBUG
auto
reftotal_gv
=
g
.
cur_module
->
getOrInsertGlobal
(
"_Py_RefTotal"
,
g
.
i64
);
auto
reftotal_gv
=
g
.
cur_module
->
getOrInsertGlobal
(
"_Py_RefTotal"
,
g
.
i64
);
auto
reftotal
=
new
llvm
::
LoadInst
(
reftotal_gv
,
""
,
decref_pt
);
auto
reftotal
=
new
llvm
::
LoadInst
(
reftotal_gv
,
""
,
decref_pt
);
auto
new_reftotal
=
llvm
::
BinaryOperator
::
Create
(
auto
new_reftotal
=
llvm
::
BinaryOperator
::
Create
(
llvm
::
BinaryOperator
::
BinaryOps
::
Sub
,
reftotal
,
llvm
::
BinaryOperator
::
BinaryOps
::
Sub
,
reftotal
,
getConstantInt
(
num_refs
,
g
.
i64
),
""
,
decref_pt
);
getConstantInt
(
num_refs
,
g
.
i64
),
""
,
decref_pt
);
new
llvm
::
StoreInst
(
new_reftotal
,
reftotal_gv
,
decref_pt
);
new
llvm
::
StoreInst
(
new_reftotal
,
reftotal_gv
,
decref_pt
);
#endif
#endif
llvm
::
ArrayRef
<
llvm
::
Value
*>
idxs
({
getConstantInt
(
0
,
g
.
i32
),
getConstantInt
(
0
,
g
.
i32
)
});
llvm
::
ArrayRef
<
llvm
::
Value
*>
idxs
({
getConstantInt
(
0
,
g
.
i32
),
getConstantInt
(
0
,
g
.
i32
)
});
auto
refcount_ptr
=
llvm
::
GetElementPtrInst
::
CreateInBounds
(
v
,
idxs
,
""
,
decref_pt
);
auto
refcount_ptr
=
llvm
::
GetElementPtrInst
::
CreateInBounds
(
v
,
idxs
,
""
,
decref_pt
);
auto
refcount
=
new
llvm
::
LoadInst
(
refcount_ptr
,
""
,
decref_pt
);
auto
refcount
=
new
llvm
::
LoadInst
(
refcount_ptr
,
""
,
decref_pt
);
auto
new_refcount
=
llvm
::
BinaryOperator
::
Create
(
auto
new_refcount
=
llvm
::
BinaryOperator
::
Create
(
llvm
::
BinaryOperator
::
BinaryOps
::
Sub
,
refcount
,
llvm
::
BinaryOperator
::
BinaryOps
::
Sub
,
refcount
,
getConstantInt
(
num_refs
,
g
.
i64
),
""
,
decref_pt
);
getConstantInt
(
num_refs
,
g
.
i64
),
""
,
decref_pt
);
new
llvm
::
StoreInst
(
new_refcount
,
refcount_ptr
,
decref_pt
);
new
llvm
::
StoreInst
(
new_refcount
,
refcount_ptr
,
decref_pt
);
llvm
::
BasicBlock
*
cur_block
=
decref_pt
->
getParent
();
llvm
::
BasicBlock
*
cur_block
=
decref_pt
->
getParent
();
llvm
::
BasicBlock
*
dealloc_block
=
llvm
::
BasicBlock
::
Create
(
g
.
context
,
""
,
decref_pt
->
getParent
()
->
getParent
());
llvm
::
BasicBlock
*
dealloc_block
=
llvm
::
BasicBlock
::
Create
(
g
.
context
,
"
dealloc
"
,
decref_pt
->
getParent
()
->
getParent
());
llvm
::
BasicBlock
*
continue_block
=
cur_block
->
splitBasicBlock
(
decref_pt
);
llvm
::
BasicBlock
*
continue_block
=
cur_block
->
splitBasicBlock
(
decref_pt
);
assert
(
llvm
::
isa
<
llvm
::
BranchInst
>
(
cur_block
->
getTerminator
()));
assert
(
llvm
::
isa
<
llvm
::
BranchInst
>
(
cur_block
->
getTerminator
()));
...
@@ -268,6 +264,7 @@ void RefcountTracker::addRefcounts(IRGenState* irstate) {
...
@@ -268,6 +264,7 @@ void RefcountTracker::addRefcounts(IRGenState* irstate) {
for
(
auto
SBB
:
successors
)
{
for
(
auto
SBB
:
successors
)
{
assert
(
states
.
count
(
SBB
));
assert
(
states
.
count
(
SBB
));
for
(
auto
&&
p
:
states
[
SBB
].
refs
)
{
for
(
auto
&&
p
:
states
[
SBB
].
refs
)
{
assert
(
p
.
second
>
0
);
tracked_values
.
insert
(
p
.
first
);
tracked_values
.
insert
(
p
.
first
);
}
}
}
}
...
@@ -304,6 +301,16 @@ void RefcountTracker::addRefcounts(IRGenState* irstate) {
...
@@ -304,6 +301,16 @@ void RefcountTracker::addRefcounts(IRGenState* irstate) {
else
else
assert
(
state
.
refs
.
count
(
v
)
==
0
);
assert
(
state
.
refs
.
count
(
v
)
==
0
);
}
else
{
}
else
{
llvm
::
outs
()
<<
*
v
<<
" goes to multiple successors
\n
"
;
for
(
auto
SBB
:
successors
)
{
auto
it
=
states
[
SBB
].
refs
.
find
(
v
);
if
(
it
!=
states
[
SBB
].
refs
.
end
())
{
llvm
::
outs
()
<<
SBB
->
getName
()
<<
": "
<<
it
->
second
<<
'\n'
;
}
else
llvm
::
outs
()
<<
SBB
->
getName
()
<<
": "
<<
0
<<
'\n'
;
}
assert
(
0
&&
"finish implementing"
);
assert
(
0
&&
"finish implementing"
);
}
}
}
}
...
@@ -346,6 +353,7 @@ void RefcountTracker::addRefcounts(IRGenState* irstate) {
...
@@ -346,6 +353,7 @@ void RefcountTracker::addRefcounts(IRGenState* irstate) {
if
(
rt
->
vars
[
op
].
reftype
==
RefType
::
OWNED
)
{
if
(
rt
->
vars
[
op
].
reftype
==
RefType
::
OWNED
)
{
if
(
state
.
refs
[
op
]
==
0
)
{
if
(
state
.
refs
[
op
]
==
0
)
{
// Don't do any updates now since we are iterating over the bb
// Don't do any updates now since we are iterating over the bb
llvm
::
outs
()
<<
"Last use of "
<<
*
op
<<
" is at "
<<
I
<<
"; adding a decref after
\n
"
;
last_uses
.
push_back
(
std
::
make_pair
(
op
,
&
I
));
last_uses
.
push_back
(
std
::
make_pair
(
op
,
&
I
));
state
.
refs
[
op
]
=
1
;
state
.
refs
[
op
]
=
1
;
}
}
...
@@ -382,7 +390,9 @@ void RefcountTracker::addRefcounts(IRGenState* irstate) {
...
@@ -382,7 +390,9 @@ void RefcountTracker::addRefcounts(IRGenState* irstate) {
addDecrefs
(
p
.
first
,
1
,
findIncrefPt
(
invoke
->
getUnwindDest
()));
addDecrefs
(
p
.
first
,
1
,
findIncrefPt
(
invoke
->
getUnwindDest
()));
}
else
{
}
else
{
assert
(
p
.
second
!=
p
.
second
->
getParent
()
->
getTerminator
());
assert
(
p
.
second
!=
p
.
second
->
getParent
()
->
getTerminator
());
addDecrefs
(
p
.
first
,
1
,
p
.
second
->
getNextNode
());
auto
next
=
p
.
second
->
getNextNode
();
ASSERT
(
!
llvm
::
isa
<
llvm
::
UnreachableInst
>
(
next
),
"Can't add decrefs after this function..."
);
addDecrefs
(
p
.
first
,
1
,
next
);
}
}
}
}
...
...
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