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
0e60f0d3
Commit
0e60f0d3
authored
Feb 13, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Can kill all notion of partial-block-compilation
We only needed that for supporting the old deopt system
parent
8feae20e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
133 additions
and
237 deletions
+133
-237
src/codegen/irgen.cpp
src/codegen/irgen.cpp
+35
-63
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+97
-173
src/codegen/irgen/irgenerator.h
src/codegen/irgen/irgenerator.h
+1
-1
No files found.
src/codegen/irgen.cpp
View file @
0e60f0d3
...
...
@@ -202,29 +202,24 @@ static bool compareBlockPairs(const std::pair<CFGBlock*, CFGBlock*>& p1, const s
return
p1
.
first
->
idx
<
p2
.
first
->
idx
;
}
static
std
::
vector
<
std
::
pair
<
CFGBlock
*
,
CFGBlock
*>>
computeBlockTraversalOrder
(
const
BlockSet
&
full_blocks
,
const
BlockSet
&
partial_blocks
,
CFGBlock
*
start
)
{
static
std
::
vector
<
std
::
pair
<
CFGBlock
*
,
CFGBlock
*>>
computeBlockTraversalOrder
(
const
BlockSet
&
blocks
,
CFGBlock
*
start
)
{
std
::
vector
<
std
::
pair
<
CFGBlock
*
,
CFGBlock
*>>
rtn
;
std
::
unordered_set
<
CFGBlock
*>
in_queue
;
if
(
start
)
{
assert
(
full_
blocks
.
count
(
start
));
assert
(
blocks
.
count
(
start
));
in_queue
.
insert
(
start
);
rtn
.
push_back
(
std
::
make_pair
(
start
,
(
CFGBlock
*
)
NULL
));
}
for
(
CFGBlock
*
b
:
partial_blocks
)
{
in_queue
.
insert
(
b
);
rtn
.
push_back
(
std
::
make_pair
(
b
,
(
CFGBlock
*
)
NULL
));
}
// It's important for debugging purposes that the order is deterministic, but the iteration
// over the BlockSet is not:
std
::
sort
(
rtn
.
begin
(),
rtn
.
end
(),
compareBlockPairs
);
int
idx
=
0
;
while
(
rtn
.
size
()
<
full_blocks
.
size
()
+
partial_
blocks
.
size
())
{
while
(
rtn
.
size
()
<
blocks
.
size
())
{
// TODO: come up with an alternative algorithm that outputs
// the blocks in "as close to in-order as possible".
// Do this by iterating over all blocks and picking the smallest one
...
...
@@ -234,7 +229,7 @@ computeBlockTraversalOrder(const BlockSet& full_blocks, const BlockSet& partial_
for
(
int
i
=
0
;
i
<
cur
->
successors
.
size
();
i
++
)
{
CFGBlock
*
b
=
cur
->
successors
[
i
];
assert
(
full_blocks
.
count
(
b
)
||
partial_
blocks
.
count
(
b
));
assert
(
blocks
.
count
(
b
));
if
(
in_queue
.
count
(
b
))
continue
;
...
...
@@ -245,11 +240,11 @@ computeBlockTraversalOrder(const BlockSet& full_blocks, const BlockSet& partial_
idx
++
;
}
if
(
rtn
.
size
()
==
full_blocks
.
size
()
+
partial_
blocks
.
size
())
if
(
rtn
.
size
()
==
blocks
.
size
())
break
;
CFGBlock
*
best
=
NULL
;
for
(
CFGBlock
*
b
:
full_
blocks
)
{
for
(
CFGBlock
*
b
:
blocks
)
{
if
(
in_queue
.
count
(
b
))
continue
;
...
...
@@ -268,7 +263,7 @@ computeBlockTraversalOrder(const BlockSet& full_blocks, const BlockSet& partial_
rtn
.
push_back
(
std
::
make_pair
(
best
,
(
CFGBlock
*
)
NULL
));
}
ASSERT
(
rtn
.
size
()
==
full_blocks
.
size
()
+
partial_
blocks
.
size
(),
"%ld
\n
"
,
rtn
.
size
());
ASSERT
(
rtn
.
size
()
==
blocks
.
size
(),
"%ld
\n
"
,
rtn
.
size
());
return
rtn
;
}
...
...
@@ -331,7 +326,7 @@ llvm::Value* handlePotentiallyUndefined(ConcreteCompilerVariable* is_defined_var
}
static
void
emitBBs
(
IRGenState
*
irstate
,
TypeAnalysis
*
types
,
const
OSREntryDescriptor
*
entry_descriptor
,
const
BlockSet
&
full_blocks
,
const
BlockSet
&
partial_
blocks
)
{
const
BlockSet
&
blocks
)
{
SourceInfo
*
source
=
irstate
->
getSourceInfo
();
EffortLevel
effort
=
irstate
->
getEffortLevel
();
CompiledFunction
*
cf
=
irstate
->
getCurFunction
();
...
...
@@ -339,12 +334,12 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
// llvm::MDNode* func_info = irstate->getFuncDbgInfo();
if
(
entry_descriptor
!=
NULL
)
assert
(
full_
blocks
.
count
(
source
->
cfg
->
getStartingBlock
())
==
0
);
assert
(
blocks
.
count
(
source
->
cfg
->
getStartingBlock
())
==
0
);
// We need the entry blocks pre-allocated so that we can jump forward to them.
std
::
unordered_map
<
CFGBlock
*
,
llvm
::
BasicBlock
*>
llvm_entry_blocks
;
for
(
CFGBlock
*
block
:
source
->
cfg
->
blocks
)
{
if
(
partial_blocks
.
count
(
block
)
==
0
&&
full_
blocks
.
count
(
block
)
==
0
)
{
if
(
blocks
.
count
(
block
)
==
0
)
{
llvm_entry_blocks
[
block
]
=
NULL
;
continue
;
}
...
...
@@ -435,8 +430,8 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
v
=
converted
->
getValue
();
delete
converted
;
}
else
{
RELEASE_ASSERT
(
0
,
"OSR'd with a %s into a
partial compile that expects a %s?
\n
"
,
p
.
second
->
debugName
().
c_str
(),
p
hi_type
->
debugName
().
c_str
());
RELEASE_ASSERT
(
0
,
"OSR'd with a %s into a
type inference of a %s?
\n
"
,
p
.
second
->
debugName
().
c_str
()
,
phi_type
->
debugName
().
c_str
());
}
if
(
VERBOSITY
(
"irgen"
))
...
...
@@ -471,7 +466,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
CFGBlock
*
initial_block
=
NULL
;
if
(
entry_descriptor
)
{
initial_block
=
entry_descriptor
->
backedge
->
target
;
}
else
if
(
full_
blocks
.
count
(
source
->
cfg
->
getStartingBlock
()))
{
}
else
if
(
blocks
.
count
(
source
->
cfg
->
getStartingBlock
()))
{
initial_block
=
source
->
cfg
->
getStartingBlock
();
}
...
...
@@ -482,8 +477,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
// with a lower index value, so if the entry block is 0 then we can iterate in index
// order.
// The entry block doesn't have to be zero, so we have to calculate an allowable order here:
std
::
vector
<
std
::
pair
<
CFGBlock
*
,
CFGBlock
*>>
traversal_order
=
computeBlockTraversalOrder
(
full_blocks
,
partial_blocks
,
initial_block
);
std
::
vector
<
std
::
pair
<
CFGBlock
*
,
CFGBlock
*>>
traversal_order
=
computeBlockTraversalOrder
(
blocks
,
initial_block
);
std
::
unordered_set
<
CFGBlock
*>
into_hax
;
for
(
int
_i
=
0
;
_i
<
traversal_order
.
size
();
_i
++
)
{
...
...
@@ -493,12 +487,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
if
(
VERBOSITY
(
"irgen"
)
>=
1
)
printf
(
"processing block %d
\n
"
,
block
->
idx
);
bool
is_partial
=
false
;
if
(
partial_blocks
.
count
(
block
))
{
if
(
VERBOSITY
(
"irgen"
)
>=
1
)
printf
(
"is partial block
\n
"
);
is_partial
=
true
;
}
else
if
(
!
full_blocks
.
count
(
block
))
{
if
(
!
blocks
.
count
(
block
))
{
if
(
VERBOSITY
(
"irgen"
)
>=
1
)
printf
(
"Skipping this block
\n
"
);
// created_phis[block] = NULL;
...
...
@@ -508,20 +497,15 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
continue
;
}
std
::
unique_ptr
<
IRGenerator
>
generator
(
createIRGenerator
(
irstate
,
llvm_entry_blocks
,
block
,
types
,
is_partial
));
std
::
unique_ptr
<
IRGenerator
>
generator
(
createIRGenerator
(
irstate
,
llvm_entry_blocks
,
block
,
types
));
llvm
::
BasicBlock
*
entry_block_end
=
llvm_entry_blocks
[
block
];
std
::
unique_ptr
<
IREmitter
>
emitter
(
createIREmitter
(
irstate
,
entry_block_end
));
PHITable
*
phis
=
NULL
;
if
(
!
is_partial
)
{
phis
=
new
PHITable
();
PHITable
*
phis
=
new
PHITable
();
created_phis
[
block
]
=
phis
;
}
// Set initial symbol table:
if
(
is_partial
)
{
// pass
}
else
if
(
block
==
source
->
cfg
->
getStartingBlock
())
{
if
(
block
==
source
->
cfg
->
getStartingBlock
())
{
assert
(
entry_descriptor
==
NULL
);
if
(
ENABLE_REOPT
&&
effort
<
EffortLevel
::
MAXIMAL
&&
source
->
ast
!=
NULL
...
...
@@ -641,7 +625,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
}
}
else
{
assert
(
pred
);
assert
(
full_blocks
.
count
(
pred
)
||
partial_
blocks
.
count
(
pred
));
assert
(
blocks
.
count
(
pred
));
if
(
block
->
predecessors
.
size
()
==
1
)
{
// If this block has only one predecessor, it by definition doesn't need any phi nodes.
...
...
@@ -738,7 +722,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
for
(
int
j
=
0
;
j
<
b
->
predecessors
.
size
();
j
++
)
{
CFGBlock
*
b2
=
b
->
predecessors
[
j
];
if
(
full_blocks
.
count
(
b2
)
==
0
&&
partial_
blocks
.
count
(
b2
)
==
0
)
if
(
blocks
.
count
(
b2
)
==
0
)
continue
;
// printf("(%d %ld) -> (%d %ld)\n", b2->idx, phi_ending_symbol_tables[b2]->size(), b->idx, phis->size());
...
...
@@ -760,7 +744,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
llvm
::
PHINode
*
llvm_phi
=
it
->
second
.
second
;
for
(
int
j
=
0
;
j
<
b
->
predecessors
.
size
();
j
++
)
{
CFGBlock
*
b2
=
b
->
predecessors
[
j
];
if
(
full_blocks
.
count
(
b2
)
==
0
&&
partial_
blocks
.
count
(
b2
)
==
0
)
if
(
blocks
.
count
(
b2
)
==
0
)
continue
;
ConcreteCompilerVariable
*
v
=
(
*
phi_ending_symbol_tables
[
b2
])[
it
->
first
];
...
...
@@ -814,23 +798,17 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
}
}
static
void
computeBlockSetClosure
(
BlockSet
&
full_blocks
,
BlockSet
&
partial_
blocks
)
{
static
void
computeBlockSetClosure
(
BlockSet
&
blocks
)
{
if
(
VERBOSITY
(
"irgen"
)
>=
1
)
{
printf
(
"Initial full:"
);
for
(
CFGBlock
*
b
:
full_blocks
)
{
printf
(
" %d"
,
b
->
idx
);
}
printf
(
"
\n
"
);
printf
(
"Initial partial:"
);
for
(
CFGBlock
*
b
:
partial_blocks
)
{
printf
(
"Initial:"
);
for
(
CFGBlock
*
b
:
blocks
)
{
printf
(
" %d"
,
b
->
idx
);
}
printf
(
"
\n
"
);
}
std
::
vector
<
CFGBlock
*>
q
;
BlockSet
expanded
;
q
.
insert
(
q
.
end
(),
full_blocks
.
begin
(),
full_blocks
.
end
());
q
.
insert
(
q
.
end
(),
partial_blocks
.
begin
(),
partial_blocks
.
end
());
q
.
insert
(
q
.
end
(),
blocks
.
begin
(),
blocks
.
end
());
while
(
q
.
size
())
{
CFGBlock
*
b
=
q
.
back
();
...
...
@@ -842,20 +820,14 @@ static void computeBlockSetClosure(BlockSet& full_blocks, BlockSet& partial_bloc
for
(
int
i
=
0
;
i
<
b
->
successors
.
size
();
i
++
)
{
CFGBlock
*
b2
=
b
->
successors
[
i
];
partial_blocks
.
erase
(
b2
);
full_blocks
.
insert
(
b2
);
blocks
.
insert
(
b2
);
q
.
push_back
(
b2
);
}
}
if
(
VERBOSITY
(
"irgen"
)
>=
1
)
{
printf
(
"Ending full:"
);
for
(
CFGBlock
*
b
:
full_blocks
)
{
printf
(
" %d"
,
b
->
idx
);
}
printf
(
"
\n
"
);
printf
(
"Ending partial:"
);
for
(
CFGBlock
*
b
:
partial_blocks
)
{
printf
(
"Ending:"
);
for
(
CFGBlock
*
b
:
blocks
)
{
printf
(
" %d"
,
b
->
idx
);
}
printf
(
"
\n
"
);
...
...
@@ -983,19 +955,19 @@ CompiledFunction* doCompile(SourceInfo* source, ParamNames* param_names, const O
_t2
.
split
();
BlockSet
full_blocks
,
partial_
blocks
;
BlockSet
blocks
;
if
(
entry_descriptor
==
NULL
)
{
for
(
CFGBlock
*
b
:
source
->
cfg
->
blocks
)
{
full_
blocks
.
insert
(
b
);
blocks
.
insert
(
b
);
}
}
else
{
full_
blocks
.
insert
(
entry_descriptor
->
backedge
->
target
);
computeBlockSetClosure
(
full_blocks
,
partial_
blocks
);
blocks
.
insert
(
entry_descriptor
->
backedge
->
target
);
computeBlockSetClosure
(
blocks
);
}
IRGenState
irstate
(
cf
,
source
,
param_names
,
getGCBuilder
(),
dbg_funcinfo
);
emitBBs
(
&
irstate
,
types
,
entry_descriptor
,
full_blocks
,
partial_
blocks
);
emitBBs
(
&
irstate
,
types
,
entry_descriptor
,
blocks
);
// De-opt handling:
...
...
src/codegen/irgen/irgenerator.cpp
View file @
0e60f0d3
...
...
@@ -290,7 +290,6 @@ private:
TypeAnalysis
*
types
;
enum
State
{
PARTIAL
,
// running through a partial block, waiting to hit the first in_guard
RUNNING
,
// normal
DEAD
,
// passed a Return statement; still syntatically valid but the code should not be compiled
FINISHED
,
// passed a pseudo-node such as Branch or Jump; internal error if there are any more statements
...
...
@@ -298,9 +297,9 @@ private:
public:
IRGeneratorImpl
(
IRGenState
*
irstate
,
std
::
unordered_map
<
CFGBlock
*
,
llvm
::
BasicBlock
*>&
entry_blocks
,
CFGBlock
*
myblock
,
TypeAnalysis
*
types
,
bool
is_partial
)
CFGBlock
*
myblock
,
TypeAnalysis
*
types
)
:
irstate
(
irstate
),
curblock
(
entry_blocks
[
myblock
]),
emitter
(
irstate
,
curblock
,
this
),
entry_blocks
(
entry_blocks
),
myblock
(
myblock
),
types
(
types
),
state
(
is_partial
?
PARTIAL
:
RUNNING
)
{}
entry_blocks
(
entry_blocks
),
myblock
(
myblock
),
types
(
types
),
state
(
RUNNING
)
{}
~
IRGeneratorImpl
()
{
delete
emitter
.
getBuilder
();
}
...
...
@@ -362,8 +361,6 @@ private:
}
CompilerVariable
*
evalAttribute
(
AST_Attribute
*
node
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
CompilerVariable
*
value
=
evalExpr
(
node
->
value
,
unw_info
);
CompilerVariable
*
rtn
=
value
->
getattr
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
),
&
node
->
attr
.
str
(),
false
);
...
...
@@ -372,8 +369,6 @@ private:
}
CompilerVariable
*
evalClsAttribute
(
AST_ClsAttribute
*
node
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
CompilerVariable
*
value
=
evalExpr
(
node
->
value
,
unw_info
);
CompilerVariable
*
rtn
=
value
->
getattr
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
),
&
node
->
attr
.
str
(),
true
);
value
->
decvref
(
emitter
);
...
...
@@ -637,8 +632,6 @@ private:
CompilerVariable
*
_evalBinExp
(
AST
*
node
,
CompilerVariable
*
left
,
CompilerVariable
*
right
,
AST_TYPE
::
AST_TYPE
type
,
BinExpType
exp_type
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
assert
(
left
);
assert
(
right
);
...
...
@@ -650,8 +643,6 @@ private:
}
CompilerVariable
*
evalBinOp
(
AST_BinOp
*
node
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
CompilerVariable
*
left
=
evalExpr
(
node
->
left
,
unw_info
);
CompilerVariable
*
right
=
evalExpr
(
node
->
right
,
unw_info
);
...
...
@@ -664,8 +655,6 @@ private:
}
CompilerVariable
*
evalAugBinOp
(
AST_AugBinOp
*
node
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
CompilerVariable
*
left
=
evalExpr
(
node
->
left
,
unw_info
);
CompilerVariable
*
right
=
evalExpr
(
node
->
right
,
unw_info
);
...
...
@@ -678,8 +667,6 @@ private:
}
CompilerVariable
*
evalCompare
(
AST_Compare
*
node
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
RELEASE_ASSERT
(
node
->
ops
.
size
()
==
1
,
""
);
CompilerVariable
*
left
=
evalExpr
(
node
->
left
,
unw_info
);
...
...
@@ -695,8 +682,6 @@ private:
}
CompilerVariable
*
evalCall
(
AST_Call
*
node
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
bool
is_callattr
;
bool
callattr_clsonly
=
false
;
const
std
::
string
*
attr
=
NULL
;
...
...
@@ -774,8 +759,6 @@ private:
}
CompilerVariable
*
evalDict
(
AST_Dict
*
node
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
llvm
::
Value
*
v
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
createDict
);
ConcreteCompilerVariable
*
rtn
=
new
ConcreteCompilerVariable
(
DICT
,
v
,
true
);
if
(
node
->
keys
.
size
())
{
...
...
@@ -810,15 +793,9 @@ private:
inst
->
setMetadata
(
message
,
mdnode
);
}
CompilerVariable
*
evalIndex
(
AST_Index
*
node
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
return
evalExpr
(
node
->
value
,
unw_info
);
}
CompilerVariable
*
evalIndex
(
AST_Index
*
node
,
UnwindInfo
unw_info
)
{
return
evalExpr
(
node
->
value
,
unw_info
);
}
CompilerVariable
*
evalLambda
(
AST_Lambda
*
node
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
AST_Return
*
expr
=
new
AST_Return
();
expr
->
value
=
node
->
body
;
...
...
@@ -832,8 +809,6 @@ private:
CompilerVariable
*
evalList
(
AST_List
*
node
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
std
::
vector
<
CompilerVariable
*>
elts
;
for
(
int
i
=
0
;
i
<
node
->
elts
.
size
();
i
++
)
{
CompilerVariable
*
value
=
evalExpr
(
node
->
elts
[
i
],
unw_info
);
...
...
@@ -887,8 +862,6 @@ private:
}
CompilerVariable
*
evalName
(
AST_Name
*
node
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
auto
scope_info
=
irstate
->
getScopeInfo
();
bool
is_kill
=
irstate
->
getSourceInfo
()
->
liveness
->
isKill
(
node
,
myblock
);
...
...
@@ -959,8 +932,6 @@ private:
}
CompilerVariable
*
evalNum
(
AST_Num
*
node
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
if
(
node
->
num_type
==
AST_Num
::
INT
)
return
makeInt
(
node
->
n_int
);
else
if
(
node
->
num_type
==
AST_Num
::
FLOAT
)
...
...
@@ -972,8 +943,6 @@ private:
}
CompilerVariable
*
evalRepr
(
AST_Repr
*
node
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
CompilerVariable
*
var
=
evalExpr
(
node
->
value
,
unw_info
);
ConcreteCompilerVariable
*
cvar
=
var
->
makeConverted
(
emitter
,
var
->
getBoxType
());
var
->
decvref
(
emitter
);
...
...
@@ -987,8 +956,6 @@ private:
}
CompilerVariable
*
evalSet
(
AST_Set
*
node
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
std
::
vector
<
CompilerVariable
*>
elts
;
for
(
int
i
=
0
;
i
<
node
->
elts
.
size
();
i
++
)
{
CompilerVariable
*
value
=
evalExpr
(
node
->
elts
[
i
],
unw_info
);
...
...
@@ -1013,8 +980,6 @@ private:
}
CompilerVariable
*
evalSlice
(
AST_Slice
*
node
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
CompilerVariable
*
start
,
*
stop
,
*
step
;
start
=
node
->
lower
?
evalExpr
(
node
->
lower
,
unw_info
)
:
getNone
();
stop
=
node
->
upper
?
evalExpr
(
node
->
upper
,
unw_info
)
:
getNone
();
...
...
@@ -1040,15 +1005,9 @@ private:
return
new
ConcreteCompilerVariable
(
SLICE
,
rtn
,
true
);
}
CompilerVariable
*
evalStr
(
AST_Str
*
node
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
return
makeStr
(
&
node
->
s
);
}
CompilerVariable
*
evalStr
(
AST_Str
*
node
,
UnwindInfo
unw_info
)
{
return
makeStr
(
&
node
->
s
);
}
CompilerVariable
*
evalSubscript
(
AST_Subscript
*
node
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
CompilerVariable
*
value
=
evalExpr
(
node
->
value
,
unw_info
);
CompilerVariable
*
slice
=
evalExpr
(
node
->
slice
,
unw_info
);
...
...
@@ -1059,8 +1018,6 @@ private:
}
CompilerVariable
*
evalTuple
(
AST_Tuple
*
node
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
std
::
vector
<
CompilerVariable
*>
elts
;
for
(
int
i
=
0
;
i
<
node
->
elts
.
size
();
i
++
)
{
CompilerVariable
*
value
=
evalExpr
(
node
->
elts
[
i
],
unw_info
);
...
...
@@ -1076,8 +1033,6 @@ private:
}
CompilerVariable
*
evalUnaryOp
(
AST_UnaryOp
*
node
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
CompilerVariable
*
operand
=
evalExpr
(
node
->
operand
,
unw_info
);
if
(
node
->
op_type
==
AST_TYPE
::
Not
)
{
...
...
@@ -1105,8 +1060,6 @@ private:
}
CompilerVariable
*
evalYield
(
AST_Yield
*
node
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
CompilerVariable
*
generator
=
_getFake
(
internString
(
PASSED_GENERATOR_NAME
),
false
);
ConcreteCompilerVariable
*
convertedGenerator
=
generator
->
makeConverted
(
emitter
,
generator
->
getBoxType
());
...
...
@@ -1124,8 +1077,6 @@ private:
}
ConcreteCompilerVariable
*
unboxVar
(
ConcreteCompilerType
*
t
,
llvm
::
Value
*
v
,
bool
grabbed
)
{
assert
(
state
!=
PARTIAL
);
if
(
t
==
BOXED_INT
)
{
llvm
::
Value
*
unboxed
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
unboxInt
,
v
);
ConcreteCompilerVariable
*
rtn
=
new
ConcreteCompilerVariable
(
INT
,
unboxed
,
true
);
...
...
@@ -1151,7 +1102,6 @@ private:
}
CompilerVariable
*
rtn
=
NULL
;
if
(
state
!=
PARTIAL
)
{
switch
(
node
->
type
)
{
case
AST_TYPE
:
:
Attribute
:
rtn
=
evalAttribute
(
ast_cast
<
AST_Attribute
>
(
node
),
unw_info
);
...
...
@@ -1251,9 +1201,8 @@ private:
rtn
=
unboxVar
(
speculated_type
,
old_rtn
->
getValue
(),
true
);
}
}
assert
(
rtn
||
state
==
PARTIAL
);
assert
(
rtn
);
return
rtn
;
}
...
...
@@ -1320,14 +1269,12 @@ private:
}
void
_doSetattr
(
AST_Attribute
*
target
,
CompilerVariable
*
val
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
CompilerVariable
*
t
=
evalExpr
(
target
->
value
,
unw_info
);
t
->
setattr
(
emitter
,
getEmptyOpInfo
(
unw_info
),
&
target
->
attr
.
str
(),
val
);
t
->
decvref
(
emitter
);
}
void
_doSetitem
(
AST_Subscript
*
target
,
CompilerVariable
*
val
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
CompilerVariable
*
tget
=
evalExpr
(
target
->
value
,
unw_info
);
CompilerVariable
*
slice
=
evalExpr
(
target
->
slice
,
unw_info
);
...
...
@@ -1362,7 +1309,6 @@ private:
}
void
_doUnpackTuple
(
AST_Tuple
*
target
,
CompilerVariable
*
val
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
int
ntargets
=
target
->
elts
.
size
();
std
::
vector
<
CompilerVariable
*>
unpacked
=
val
->
unpack
(
emitter
,
getOpInfoForNode
(
target
,
unw_info
),
ntargets
);
...
...
@@ -1382,7 +1328,6 @@ private:
}
void
_doSet
(
AST
*
target
,
CompilerVariable
*
val
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
switch
(
target
->
type
)
{
case
AST_TYPE
:
:
Attribute
:
_doSetattr
(
ast_cast
<
AST_Attribute
>
(
target
),
val
,
unw_info
);
...
...
@@ -1427,8 +1372,6 @@ private:
void
doAssign
(
AST_Assign
*
node
,
UnwindInfo
unw_info
)
{
CompilerVariable
*
val
=
evalExpr
(
node
->
value
,
unw_info
);
if
(
state
==
PARTIAL
)
return
;
for
(
int
i
=
0
;
i
<
node
->
targets
.
size
();
i
++
)
{
_doSet
(
node
->
targets
[
i
],
val
,
unw_info
);
...
...
@@ -1437,9 +1380,6 @@ private:
}
void
doClassDef
(
AST_ClassDef
*
node
,
UnwindInfo
unw_info
)
{
if
(
state
==
PARTIAL
)
return
;
assert
(
node
->
type
==
AST_TYPE
::
ClassDef
);
ScopeInfo
*
scope_info
=
irstate
->
getScopeInfoForNode
(
node
);
assert
(
scope_info
);
...
...
@@ -1503,7 +1443,6 @@ private:
}
void
doDelete
(
AST_Delete
*
node
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
for
(
AST_expr
*
target
:
node
->
targets
)
{
switch
(
target
->
type
)
{
case
AST_TYPE
:
:
Subscript
:
...
...
@@ -1524,7 +1463,6 @@ private:
// invoke delitem in objmodel.cpp, which will invoke the listDelitem of list
void
_doDelitem
(
AST_Subscript
*
target
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
CompilerVariable
*
tget
=
evalExpr
(
target
->
value
,
unw_info
);
CompilerVariable
*
slice
=
evalExpr
(
target
->
slice
,
unw_info
);
...
...
@@ -1643,9 +1581,6 @@ private:
}
void
doFunctionDef
(
AST_FunctionDef
*
node
,
UnwindInfo
unw_info
)
{
if
(
state
==
PARTIAL
)
return
;
std
::
vector
<
CompilerVariable
*>
decorators
;
for
(
auto
d
:
node
->
decorator_list
)
{
decorators
.
push_back
(
evalExpr
(
d
,
unw_info
));
...
...
@@ -1663,9 +1598,6 @@ private:
}
void
doPrint
(
AST_Print
*
node
,
UnwindInfo
unw_info
)
{
if
(
state
==
PARTIAL
)
return
;
ConcreteCompilerVariable
*
dest
=
NULL
;
if
(
node
->
dest
)
{
auto
d
=
evalExpr
(
node
->
dest
,
unw_info
);
...
...
@@ -1750,7 +1682,6 @@ private:
}
else
{
val
=
evalExpr
(
node
->
value
,
unw_info
);
}
assert
(
state
!=
PARTIAL
);
assert
(
val
);
// If we ask the return variable to become UNKNOWN (the typical return type),
...
...
@@ -1787,7 +1718,6 @@ private:
assert
(
node
->
iffalse
->
idx
>
myblock
->
idx
);
CompilerVariable
*
val
=
evalExpr
(
node
->
test
,
unw_info
);
assert
(
state
!=
PARTIAL
);
assert
(
val
);
// We could call nonzero here if there is no try-catch block?
...
...
@@ -1806,15 +1736,11 @@ private:
void
doExpr
(
AST_Expr
*
node
,
UnwindInfo
unw_info
)
{
CompilerVariable
*
var
=
evalExpr
(
node
->
value
,
unw_info
);
if
(
state
==
PARTIAL
)
return
;
var
->
decvref
(
emitter
);
}
void
doOSRExit
(
llvm
::
BasicBlock
*
normal_target
,
AST_Jump
*
osr_key
)
{
assert
(
state
!=
PARTIAL
);
llvm
::
BasicBlock
*
starting_block
=
curblock
;
llvm
::
BasicBlock
*
onramp
=
llvm
::
BasicBlock
::
Create
(
g
.
context
,
"onramp"
,
irstate
->
getLLVMFunction
());
...
...
@@ -1967,8 +1893,6 @@ private:
}
void
doJump
(
AST_Jump
*
node
,
UnwindInfo
unw_info
)
{
assert
(
state
!=
PARTIAL
);
endBlock
(
FINISHED
);
llvm
::
BasicBlock
*
target
=
entry_blocks
[
node
->
target
];
...
...
@@ -2413,8 +2337,8 @@ public:
};
IRGenerator
*
createIRGenerator
(
IRGenState
*
irstate
,
std
::
unordered_map
<
CFGBlock
*
,
llvm
::
BasicBlock
*>&
entry_blocks
,
CFGBlock
*
myblock
,
TypeAnalysis
*
types
,
bool
is_partial
)
{
return
new
IRGeneratorImpl
(
irstate
,
entry_blocks
,
myblock
,
types
,
is_partial
);
CFGBlock
*
myblock
,
TypeAnalysis
*
types
)
{
return
new
IRGeneratorImpl
(
irstate
,
entry_blocks
,
myblock
,
types
);
}
CLFunction
*
wrapFunction
(
AST
*
node
,
AST_arguments
*
args
,
const
std
::
vector
<
AST_stmt
*>&
body
,
SourceInfo
*
source
)
{
...
...
src/codegen/irgen/irgenerator.h
View file @
0e60f0d3
...
...
@@ -126,7 +126,7 @@ public:
class
IREmitter
;
IREmitter
*
createIREmitter
(
IRGenState
*
irstate
,
llvm
::
BasicBlock
*&
curblock
,
IRGenerator
*
irgenerator
=
NULL
);
IRGenerator
*
createIRGenerator
(
IRGenState
*
irstate
,
std
::
unordered_map
<
CFGBlock
*
,
llvm
::
BasicBlock
*>&
entry_blocks
,
CFGBlock
*
myblock
,
TypeAnalysis
*
types
,
bool
is_partial
);
CFGBlock
*
myblock
,
TypeAnalysis
*
types
);
CLFunction
*
wrapFunction
(
AST
*
node
,
AST_arguments
*
args
,
const
std
::
vector
<
AST_stmt
*>&
body
,
SourceInfo
*
source
);
}
...
...
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