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
a47832d6
Commit
a47832d6
authored
Mar 24, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'public/refcounting' into refcounting
parents
a38d319c
97842832
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
23 deletions
+16
-23
src/codegen/ast_interpreter.cpp
src/codegen/ast_interpreter.cpp
+12
-16
src/codegen/baseline_jit.cpp
src/codegen/baseline_jit.cpp
+1
-1
src/codegen/irgen.cpp
src/codegen/irgen.cpp
+2
-4
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+1
-2
No files found.
src/codegen/ast_interpreter.cpp
View file @
a47832d6
...
...
@@ -66,7 +66,7 @@ extern "C" Box* executeInnerAndSetupFrame(ASTInterpreter& interpreter, CFGBlock*
*/
class
ASTInterpreter
{
public:
ASTInterpreter
(
FunctionMetadata
*
md
,
Box
**
vregs
);
ASTInterpreter
(
FunctionMetadata
*
md
,
Box
**
vregs
,
int
num_vregs
);
void
initArguments
(
BoxedClosure
*
closure
,
BoxedGenerator
*
generator
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
);
...
...
@@ -154,14 +154,6 @@ private:
public:
~
ASTInterpreter
()
{
Py_XDECREF
(
frame_info
.
boxedLocals
);
int
nvregs
=
getMD
()
->
calculateNumVRegs
();
int
nvregs_user_visible
=
getMD
()
->
calculateNumUserVisibleVRegs
();
// skip the user visible ones because they will get decrefed in deinitFrame
for
(
int
i
=
nvregs_user_visible
;
i
<
nvregs
;
i
++
)
{
Py_XDECREF
(
vregs
[
i
]);
}
Py_DECREF
(
frame_info
.
globals
);
Py_XDECREF
(
this
->
created_closure
);
}
...
...
@@ -241,7 +233,7 @@ void ASTInterpreter::setGlobals(Box* globals) {
this
->
frame_info
.
globals
=
incref
(
globals
);
}
ASTInterpreter
::
ASTInterpreter
(
FunctionMetadata
*
md
,
Box
**
vregs
)
ASTInterpreter
::
ASTInterpreter
(
FunctionMetadata
*
md
,
Box
**
vregs
,
int
num_vregs
)
:
current_block
(
0
),
frame_info
(
ExcInfo
(
NULL
,
NULL
,
NULL
)),
edgecount
(
0
),
...
...
@@ -258,6 +250,7 @@ ASTInterpreter::ASTInterpreter(FunctionMetadata* md, Box** vregs)
scope_info
=
source_info
->
getScopeInfo
();
frame_info
.
vregs
=
vregs
;
frame_info
.
md
=
md
;
frame_info
.
num_vregs
=
num_vregs
;
assert
(
scope_info
);
}
...
...
@@ -571,6 +564,7 @@ Value ASTInterpreter::getNone() {
Value
ASTInterpreter
::
visit_unaryop
(
AST_UnaryOp
*
node
)
{
Value
operand
=
visit_expr
(
node
->
operand
);
AUTO_DECREF
(
operand
.
o
);
if
(
node
->
op_type
==
AST_TYPE
::
Not
)
return
Value
(
boxBool
(
!
nonzero
(
operand
.
o
)),
jit
?
jit
->
emitNotNonzero
(
operand
)
:
NULL
);
else
...
...
@@ -733,7 +727,8 @@ Box* ASTInterpreter::doOSR(AST_Jump* node) {
}
for
(
auto
&&
dead
:
dead_symbols
)
{
assert
(
getSymVRegMap
().
count
(
dead
));
vregs
[
getSymVRegMap
()[
dead
]]
=
NULL
;
int
vreg_num
=
getSymVRegMap
()[
dead
];
Py_CLEAR
(
vregs
[
vreg_num
]);
}
const
OSREntryDescriptor
*
found_entry
=
nullptr
;
...
...
@@ -757,12 +752,13 @@ Box* ASTInterpreter::doOSR(AST_Jump* node) {
if
(
phis
->
isPotentiallyUndefinedAfter
(
name
,
current_block
))
{
bool
is_defined
=
val
!=
NULL
;
assert
(
is_defined
&&
"check refcounting"
);
// TODO only mangle once
sorted_symbol_table
[
getIsDefinedName
(
name
,
source_info
->
getInternedStrings
())]
=
(
Box
*
)
is_defined
;
sorted_symbol_table
[
name
]
=
is_defined
?
val
:
VAL_UNDEFINED
;
sorted_symbol_table
[
name
]
=
is_defined
?
incref
(
val
)
:
VAL_UNDEFINED
;
}
else
{
ASSERT
(
val
!=
NULL
,
"%s"
,
name
.
c_str
());
Box
*
v
=
sorted_symbol_table
[
name
]
=
val
;
sorted_symbol_table
[
name
]
=
incref
(
val
)
;
}
}
...
...
@@ -1912,7 +1908,7 @@ Box* astInterpretFunction(FunctionMetadata* md, Box* closure, Box* generator, Bo
}
++
md
->
times_interpreted
;
ASTInterpreter
interpreter
(
md
,
vregs
);
ASTInterpreter
interpreter
(
md
,
vregs
,
num_vregs
);
ScopeInfo
*
scope_info
=
md
->
source
->
getScopeInfo
();
...
...
@@ -1953,7 +1949,7 @@ Box* astInterpretFunctionEval(FunctionMetadata* md, Box* globals, Box* boxedLoca
memset
(
vregs
,
0
,
sizeof
(
Box
*
)
*
num_vregs
);
}
ASTInterpreter
interpreter
(
md
,
vregs
);
ASTInterpreter
interpreter
(
md
,
vregs
,
num_vregs
);
interpreter
.
initArguments
(
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
interpreter
.
setBoxedLocals
(
boxedLocals
);
...
...
@@ -1988,7 +1984,7 @@ extern "C" Box* astInterpretDeoptFromASM(FunctionMetadata* md, AST_expr* after_e
memset
(
vregs
,
0
,
sizeof
(
Box
*
)
*
num_vregs
);
}
ASTInterpreter
interpreter
(
md
,
vregs
);
ASTInterpreter
interpreter
(
md
,
vregs
,
num_vregs
);
if
(
source_info
->
scoping
->
areGlobalsFromModule
())
interpreter
.
setGlobals
(
source_info
->
parent_module
);
...
...
src/codegen/baseline_jit.cpp
View file @
a47832d6
...
...
@@ -585,7 +585,7 @@ void JitFragmentWriter::emitSetLocal(InternedString s, int vreg, bool set_closur
v
);
v
->
refConsumed
();
}
else
{
RewriterVar
*
prev
=
vregs_array
->
getAttr
(
8
*
vreg
);
RewriterVar
*
prev
=
vregs_array
->
getAttr
(
8
*
vreg
)
->
setNullable
(
true
)
;
vregs_array
->
setAttr
(
8
*
vreg
,
v
);
v
->
refConsumed
();
...
...
src/codegen/irgen.cpp
View file @
a47832d6
...
...
@@ -459,7 +459,9 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
if
(
p
.
second
==
phi_type
)
{
// good to go
v
=
from_arg
;
irstate
->
getRefcounts
()
->
setType
(
v
,
RefType
::
BORROWED
);
}
else
if
(
p
.
second
->
canConvertTo
(
phi_type
))
{
assert
(
0
&&
"check refcounting"
);
// not sure if/when this happens, but if there's a type mismatch but one we know
// can be handled (such as casting from a subclass to a superclass), handle it:
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
*
unbox_emitter
,
phi_type
);
...
...
@@ -601,7 +603,6 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
// TODO might be more efficient to do post-call safepoints?
generator
->
doSafePoint
(
block
->
body
[
0
]);
}
else
if
(
entry_descriptor
&&
block
==
entry_descriptor
->
backedge
->
target
)
{
assert
(
0
&&
"check refcounting"
);
assert
(
block
->
predecessors
.
size
()
>
1
);
assert
(
osr_entry_block
);
assert
(
phis
);
...
...
@@ -619,11 +620,9 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
// printf("For %s, given %s, analyzed for %s\n", p.first.c_str(), p.second->debugName().c_str(),
// analyzed_type->debugName().c_str());
assert
(
0
&&
"check refcounting"
);
llvm
::
PHINode
*
phi
=
emitter
->
getBuilder
()
->
CreatePHI
(
analyzed_type
->
llvmType
(),
block
->
predecessors
.
size
()
+
1
,
p
.
first
.
s
());
if
(
analyzed_type
->
getBoxType
()
==
analyzed_type
)
{
assert
(
0
&&
"check refcounting"
);
irstate
->
getRefcounts
()
->
setType
(
phi
,
RefType
::
OWNED
);
}
ConcreteCompilerVariable
*
var
=
new
ConcreteCompilerVariable
(
analyzed_type
,
phi
);
...
...
@@ -877,7 +876,6 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
}
if
(
this_is_osr_entry
)
{
assert
(
0
&&
"check refcounting"
);
ConcreteCompilerVariable
*
v
=
(
*
osr_syms
)[
it
->
first
];
assert
(
v
);
...
...
src/codegen/irgen/irgenerator.cpp
View file @
a47832d6
...
...
@@ -225,13 +225,12 @@ void IRGenState::setupFrameInfoVar(llvm::Value* passed_closure, llvm::Value* pas
assert
(
!
passed_globals
);
// The OSR case
assert
(
0
&&
"check refcounting"
);
this
->
frame_info
=
frame_info_arg
;
// use vrags array from the interpreter
vregs
=
builder
.
CreateLoad
(
getVRegsGep
(
builder
,
frame_info_arg
));
this
->
globals
=
builder
.
CreateLoad
(
getGlobalsGep
(
builder
,
frame_info_arg
));
getRefcounts
()
->
setType
(
this
->
globals
,
RefType
::
BORROWED
);
if
(
getScopeInfo
()
->
usesNameLookup
())
{
// load frame_info.boxedLocals
...
...
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