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
cefce6a5
Commit
cefce6a5
authored
Feb 12, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rip out the vestiges of the old vref-counting system
parent
c9b0d8f9
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
97 additions
and
493 deletions
+97
-493
src/codegen/compvars.cpp
src/codegen/compvars.cpp
+48
-204
src/codegen/compvars.h
src/codegen/compvars.h
+2
-78
src/codegen/irgen.cpp
src/codegen/irgen.cpp
+5
-15
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+42
-196
No files found.
src/codegen/compvars.cpp
View file @
cefce6a5
This diff is collapsed.
Click to expand it.
src/codegen/compvars.h
View file @
cefce6a5
...
...
@@ -93,14 +93,6 @@ public:
printf
(
"getBoxType not defined for %s
\n
"
,
debugName
().
c_str
());
abort
();
}
virtual
void
drop
(
IREmitter
&
emmitter
,
VAR
*
var
)
{
printf
(
"drop not defined for %s
\n
"
,
debugName
().
c_str
());
abort
();
}
virtual
void
grab
(
IREmitter
&
emmitter
,
VAR
*
var
)
{
printf
(
"grab not defined for %s
\n
"
,
debugName
().
c_str
());
abort
();
}
bool
canConvertTo
(
CompilerType
*
other_type
)
override
{
printf
(
"canConvertTo not defined for %s
\n
"
,
debugName
().
c_str
());
abort
();
...
...
@@ -216,52 +208,10 @@ public:
};
class
CompilerVariable
{
private:
int
vrefs
;
bool
grabbed
;
protected:
virtual
void
drop
(
IREmitter
&
emitter
)
=
0
;
virtual
void
grab
(
IREmitter
&
emmitter
)
=
0
;
public:
CompilerVariable
(
bool
grabbed
)
:
vrefs
(
1
),
grabbed
(
grabbed
)
{}
CompilerVariable
()
{}
virtual
~
CompilerVariable
()
{}
bool
isGrabbed
()
{
return
grabbed
;
}
void
incvref
()
{
assert
(
vrefs
);
vrefs
++
;
}
void
decvrefNodrop
()
{
assert
(
vrefs
>
0
&&
vrefs
<
(
1
<<
20
));
// It'd be nice to print out the type of the variable, but this is all happening
// after the object got deleted so it's pretty precarious, and the getType()
// debugging call will probably segfault:
// ASSERT(vrefs, "%s", getType()->debugName().c_str());
vrefs
--
;
if
(
vrefs
==
0
)
{
delete
this
;
}
}
void
decvref
(
IREmitter
&
emitter
)
{
ASSERT
(
vrefs
>
0
&&
vrefs
<
(
1
<<
20
),
"%d"
,
vrefs
);
// ASSERT(vrefs, "%s", getType()->debugName().c_str());
vrefs
--
;
if
(
vrefs
==
0
)
{
if
(
grabbed
)
drop
(
emitter
);
delete
this
;
}
}
int
getVrefs
()
{
return
vrefs
;
}
void
ensureGrabbed
(
IREmitter
&
emitter
)
{
if
(
!
grabbed
)
{
grab
(
emitter
);
grabbed
=
true
;
}
}
virtual
CompilerVariable
*
split
(
IREmitter
&
emitter
)
=
0
;
virtual
CompilerVariable
*
dup
(
DupCache
&
cache
)
=
0
;
virtual
CompilerType
*
getType
()
=
0
;
...
...
@@ -302,12 +252,8 @@ private:
T
*
type
;
V
value
;
protected:
void
drop
(
IREmitter
&
emitter
)
override
{
type
->
drop
(
emitter
,
this
);
}
void
grab
(
IREmitter
&
emitter
)
override
{
type
->
grab
(
emitter
,
this
);
}
public:
ValuedCompilerVariable
(
T
*
type
,
V
value
,
bool
grabbed
)
:
CompilerVariable
(
grabbed
),
type
(
type
),
value
(
value
)
{
ValuedCompilerVariable
(
T
*
type
,
V
value
)
:
CompilerVariable
(
),
type
(
type
),
value
(
value
)
{
#ifndef NDEBUG
type
->
assertMatches
(
value
);
#endif
...
...
@@ -318,21 +264,9 @@ public:
ConcreteCompilerType
*
getConcreteType
()
override
{
return
type
->
getConcreteType
();
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
type
->
getBoxType
();
}
ValuedCompilerVariable
<
V
>*
split
(
IREmitter
&
emitter
)
override
{
ValuedCompilerVariable
<
V
>*
rtn
;
if
(
getVrefs
()
==
1
)
{
rtn
=
this
;
}
else
{
rtn
=
new
ValuedCompilerVariable
<
V
>
(
type
,
value
,
false
);
this
->
decvref
(
emitter
);
}
rtn
->
ensureGrabbed
(
emitter
);
return
rtn
;
}
CompilerVariable
*
dup
(
DupCache
&
cache
)
override
{
CompilerVariable
*
rtn
=
type
->
dup
(
this
,
cache
);
ASSERT
(
rtn
->
getVrefs
()
==
getVrefs
(),
"%d %s"
,
rtn
->
getVrefs
(),
type
->
debugName
().
c_str
());
return
rtn
;
}
...
...
@@ -402,12 +336,6 @@ public:
}
};
// template <>
// inline ConcreteCompilerVariable::ValuedCompilerVariable(ConcreteCompilerType *type, llvm::Value* value, bool grabbed)
// : CompilerVariable(grabbed), type(type), value(value) {
// assert(value->getType() == type->llvmType());
//}
// Emit the test for whether one variable 'is' another one.
ConcreteCompilerVariable
*
doIs
(
IREmitter
&
emitter
,
CompilerVariable
*
lhs
,
CompilerVariable
*
rhs
,
bool
negate
);
...
...
@@ -457,7 +385,6 @@ template <typename V>
CompilerVariable
*
_ValuedCompilerType
<
V
>::
getPystonIter
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
)
{
ConcreteCompilerVariable
*
converted
=
makeConverted
(
emitter
,
var
,
getBoxType
());
auto
r
=
UNKNOWN
->
getPystonIter
(
emitter
,
info
,
converted
);
converted
->
decvref
(
emitter
);
return
r
;
}
...
...
@@ -466,7 +393,6 @@ CompilerVariable* _ValuedCompilerType<V>::contains(IREmitter& emitter, const OpI
CompilerVariable
*
rhs
)
{
ConcreteCompilerVariable
*
converted
=
makeConverted
(
emitter
,
var
,
getBoxType
());
auto
r
=
UNKNOWN
->
contains
(
emitter
,
info
,
converted
,
rhs
);
converted
->
decvref
(
emitter
);
return
r
;
}
...
...
@@ -475,7 +401,6 @@ CompilerVariable* _ValuedCompilerType<V>::unaryop(IREmitter& emitter, const OpIn
AST_TYPE
::
AST_TYPE
op_type
)
{
ConcreteCompilerVariable
*
converted
=
makeConverted
(
emitter
,
var
,
getBoxType
());
auto
r
=
UNKNOWN
->
unaryop
(
emitter
,
info
,
converted
,
op_type
);
converted
->
decvref
(
emitter
);
return
r
;
}
...
...
@@ -486,7 +411,6 @@ std::vector<CompilerVariable*> _ValuedCompilerType<V>::unpack(IREmitter& emitter
ConcreteCompilerVariable
*
converted
=
makeConverted
(
emitter
,
var
,
UNKNOWN
);
auto
r
=
UNKNOWN
->
unpack
(
emitter
,
info
,
converted
,
num_into
);
converted
->
decvref
(
emitter
);
return
r
;
}
...
...
src/codegen/irgen.cpp
View file @
cefce6a5
...
...
@@ -452,7 +452,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
ConcreteCompilerType
*
phi_type
;
phi_type
=
getTypeAtBlockStart
(
types
,
p
.
first
,
target_block
);
ConcreteCompilerVariable
*
var
=
new
ConcreteCompilerVariable
(
p
.
second
,
from_arg
,
true
);
ConcreteCompilerVariable
*
var
=
new
ConcreteCompilerVariable
(
p
.
second
,
from_arg
);
(
*
initial_syms
)[
p
.
first
]
=
var
;
// It's possible to OSR into a version of the function with a higher speculation level;
...
...
@@ -477,7 +477,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
if
(
VERBOSITY
(
"irgen"
)
>=
2
)
v
->
setName
(
"prev_"
+
p
.
first
.
s
());
(
*
osr_syms
)[
p
.
first
]
=
new
ConcreteCompilerVariable
(
phi_type
,
v
,
true
);
(
*
osr_syms
)[
p
.
first
]
=
new
ConcreteCompilerVariable
(
phi_type
,
v
);
}
entry_emitter
->
getBuilder
()
->
CreateBr
(
osr_unbox_block
);
...
...
@@ -624,7 +624,7 @@ 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
());
ConcreteCompilerVariable
*
var
=
new
ConcreteCompilerVariable
(
analyzed_type
,
phi
,
true
);
ConcreteCompilerVariable
*
var
=
new
ConcreteCompilerVariable
(
analyzed_type
,
phi
);
generator
->
giveLocalSymbol
(
p
.
first
,
var
);
(
*
phis
)[
p
.
first
]
=
std
::
make_pair
(
analyzed_type
,
phi
);
}
...
...
@@ -661,7 +661,7 @@ 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
());
ConcreteCompilerVariable
*
var
=
new
ConcreteCompilerVariable
(
type
,
phi
,
true
);
ConcreteCompilerVariable
*
var
=
new
ConcreteCompilerVariable
(
type
,
phi
);
generator
->
giveLocalSymbol
(
s
,
var
);
(
*
phis
)[
s
]
=
std
::
make_pair
(
type
,
phi
);
...
...
@@ -761,7 +761,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
llvm
::
PHINode
*
phi
=
emitter
->
getBuilder
()
->
CreatePHI
(
cv
->
getType
()
->
llvmType
(),
block
->
predecessors
.
size
(),
name
.
s
());
// emitter->getBuilder()->CreateCall(g.funcs.dump, phi);
ConcreteCompilerVariable
*
var
=
new
ConcreteCompilerVariable
(
cv
->
getType
(),
phi
,
true
);
ConcreteCompilerVariable
*
var
=
new
ConcreteCompilerVariable
(
cv
->
getType
(),
phi
);
generator
->
giveLocalSymbol
(
name
,
var
);
(
*
phis
)[
name
]
=
std
::
make_pair
(
cv
->
getType
(),
phi
);
...
...
@@ -851,7 +851,6 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
ConcreteCompilerVariable
*
v
=
(
*
phi_ending_symbol_tables
[
bpred
])[
it
->
first
];
assert
(
v
);
assert
(
v
->
isGrabbed
());
// Make sure they all prepared for the same type:
ASSERT
(
it
->
second
.
first
==
v
->
getType
(),
"%d %d: %s %s %s"
,
b
->
idx
,
bpred
->
idx
,
it
->
first
.
c_str
(),
...
...
@@ -864,7 +863,6 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
if
(
this_is_osr_entry
)
{
ConcreteCompilerVariable
*
v
=
(
*
osr_syms
)[
it
->
first
];
assert
(
v
);
assert
(
v
->
isGrabbed
());
ASSERT
(
it
->
second
.
first
==
v
->
getType
(),
""
);
llvm_phi
->
addIncoming
(
v
->
getValue
(),
osr_unbox_block_end
);
...
...
@@ -880,14 +878,6 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
if
(
ending_symbol_tables
[
b
]
==
NULL
)
continue
;
for
(
SymbolTable
::
iterator
it
=
ending_symbol_tables
[
b
]
->
begin
();
it
!=
ending_symbol_tables
[
b
]
->
end
();
++
it
)
{
it
->
second
->
decvrefNodrop
();
}
for
(
ConcreteSymbolTable
::
iterator
it
=
phi_ending_symbol_tables
[
b
]
->
begin
();
it
!=
phi_ending_symbol_tables
[
b
]
->
end
();
++
it
)
{
it
->
second
->
decvrefNodrop
();
}
delete
phi_ending_symbol_tables
[
b
];
delete
ending_symbol_tables
[
b
];
delete
created_phis
[
b
];
}
...
...
src/codegen/irgen/irgenerator.cpp
View file @
cefce6a5
This diff is collapsed.
Click to expand it.
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