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
f1d4b01f
Commit
f1d4b01f
authored
Feb 17, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ok some basic cases working, but exceptions are hard
parent
e320ebee
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
38 deletions
+51
-38
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+3
-2
src/codegen/irgen/refcounts.cpp
src/codegen/irgen/refcounts.cpp
+42
-36
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+6
-0
No files found.
src/codegen/irgen/irgenerator.cpp
View file @
f1d4b01f
...
...
@@ -2843,8 +2843,9 @@ public:
irstate
->
getRefcounts
()
->
refConsumed
(
exc_traceback
,
call_inst
);
builder
->
CreateRet
(
getNullPtr
(
g
.
llvm_value_type_ptr
));
}
else
{
auto
call_inst
=
emitter
.
createCall3
(
UnwindInfo
(
unw_info
.
current_stmt
,
NO_CXX_INTERCEPTION
),
g
.
funcs
.
rawThrow
,
exc_type
,
exc_value
,
exc_traceback
);
//auto call_inst = emitter.createCall3(UnwindInfo(unw_info.current_stmt, NO_CXX_INTERCEPTION),
//g.funcs.rawThrow, exc_type, exc_value, exc_traceback);
auto
call_inst
=
emitter
.
getBuilder
()
->
CreateCall3
(
g
.
funcs
.
rawThrow
,
exc_type
,
exc_value
,
exc_traceback
);
irstate
->
getRefcounts
()
->
refConsumed
(
exc_type
,
call_inst
);
irstate
->
getRefcounts
()
->
refConsumed
(
exc_value
,
call_inst
);
irstate
->
getRefcounts
()
->
refConsumed
(
exc_traceback
,
call_inst
);
...
...
src/codegen/irgen/refcounts.cpp
View file @
f1d4b01f
...
...
@@ -111,8 +111,9 @@ void addDecrefs(llvm::Value* v, int num_refs, llvm::Instruction* decref_pt) {
new
llvm
::
StoreInst
(
new_refcount
,
refcount_ptr
,
decref_pt
);
llvm
::
BasicBlock
*
cur_block
=
decref_pt
->
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
*
dealloc_block
=
llvm
::
BasicBlock
::
Create
(
g
.
context
,
"dealloc"
,
decref_pt
->
getParent
()
->
getParent
(),
continue_block
);
assert
(
llvm
::
isa
<
llvm
::
BranchInst
>
(
cur_block
->
getTerminator
()));
cur_block
->
getTerminator
()
->
eraseFromParent
();
...
...
@@ -273,46 +274,51 @@ void RefcountTracker::addRefcounts(IRGenState* irstate) {
assert
(
rt
->
vars
.
count
(
v
));
auto
refstate
=
rt
->
vars
[
v
];
if
(
refstate
.
reftype
==
RefType
::
BORROWED
)
{
int
min_refs
=
1000000000
;
for
(
auto
SBB
:
successors
)
{
auto
it
=
states
[
SBB
].
refs
.
find
(
v
);
if
(
it
!=
states
[
SBB
].
refs
.
end
())
{
min_refs
=
std
::
min
(
it
->
second
,
min_refs
);
}
else
min_refs
=
0
;
}
int
min_refs
=
1000000000
;
for
(
auto
SBB
:
successors
)
{
auto
it
=
states
[
SBB
].
refs
.
find
(
v
);
if
(
it
!=
states
[
SBB
].
refs
.
end
())
{
min_refs
=
std
::
min
(
it
->
second
,
min_refs
);
}
else
min_refs
=
0
;
}
for
(
auto
SBB
:
successors
)
{
auto
it
=
states
[
SBB
].
refs
.
find
(
v
);
int
this_refs
=
0
;
if
(
it
!=
states
[
SBB
].
refs
.
end
())
{
this_refs
=
it
->
second
;
}
if
(
this_refs
>
min_refs
)
{
addIncrefs
(
v
,
this_refs
-
min_refs
,
findIncrefPt
(
SBB
));
//llvm::outs() << *incref_pt << '\n';
//llvm::outs() << "Need to incref " << *v << " at beginning of " << SBB->getName() << "\n";
}
}
if
(
refstate
.
reftype
==
RefType
::
OWNED
)
min_refs
=
std
::
max
(
1
,
min_refs
);
if
(
min_refs
)
state
.
refs
[
v
]
=
min_refs
;
else
assert
(
state
.
refs
.
count
(
v
)
==
0
);
}
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'
;
for
(
auto
SBB
:
successors
)
{
auto
it
=
states
[
SBB
].
refs
.
find
(
v
)
;
int
this_refs
=
0
;
if
(
it
!=
states
[
SBB
].
refs
.
end
())
{
this_refs
=
it
->
second
;
}
if
(
this_refs
>
min_refs
)
{
addIncrefs
(
v
,
this_refs
-
min_refs
,
findIncrefPt
(
SBB
));
//llvm::outs() << *incref_pt << '\n'
;
//llvm::outs() << "Need to incref " << *v << " at beginning of " << SBB->getName() << "\n";
}
else
if
(
this_refs
<
min_refs
)
{
assert
(
refstate
.
reftype
==
RefType
::
OWNED
);
addDecrefs
(
v
,
min_refs
-
this_refs
,
findIncrefPt
(
SBB
))
;
}
}
if
(
min_refs
)
state
.
refs
[
v
]
=
min_refs
;
else
assert
(
state
.
refs
.
count
(
v
)
==
0
);
assert
(
0
&&
"finish implementing"
);
#if 0
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';
}
#endif
}
}
...
...
src/runtime/objmodel.cpp
View file @
f1d4b01f
...
...
@@ -4281,6 +4281,12 @@ Box* callFunc(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args, ArgPassSpe
throw
e
;
}
if
(
num_output_args
<
1
)
arg1
=
NULL
;
if
(
num_output_args
<
2
)
arg2
=
NULL
;
if
(
num_output_args
<
3
)
arg3
=
NULL
;
AUTO_XDECREF
(
arg1
);
AUTO_XDECREF
(
arg2
);
AUTO_XDECREF
(
arg3
);
...
...
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