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
21ac70f4
Commit
21ac70f4
authored
Oct 06, 2016
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename ConstantVRegInfo to CodeConstants
parent
ff6ca0d4
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
80 additions
and
81 deletions
+80
-81
src/analysis/type_analysis.cpp
src/analysis/type_analysis.cpp
+16
-16
src/analysis/type_analysis.h
src/analysis/type_analysis.h
+3
-3
src/codegen/ast_interpreter.cpp
src/codegen/ast_interpreter.cpp
+5
-5
src/codegen/irgen.cpp
src/codegen/irgen.cpp
+3
-3
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+3
-3
src/core/bst.cpp
src/core/bst.cpp
+3
-3
src/core/bst.h
src/core/bst.h
+5
-5
src/core/cfg.cpp
src/core/cfg.cpp
+30
-30
src/core/cfg.h
src/core/cfg.h
+3
-3
src/runtime/code.cpp
src/runtime/code.cpp
+2
-2
src/runtime/types.h
src/runtime/types.h
+6
-7
src/runtime/util.cpp
src/runtime/util.cpp
+1
-1
No files found.
src/analysis/type_analysis.cpp
View file @
21ac70f4
...
@@ -89,17 +89,17 @@ private:
...
@@ -89,17 +89,17 @@ private:
ExprTypeMap
&
expr_types
;
ExprTypeMap
&
expr_types
;
TypeSpeculations
&
type_speculations
;
TypeSpeculations
&
type_speculations
;
TypeAnalysis
::
SpeculationLevel
speculation
;
TypeAnalysis
::
SpeculationLevel
speculation
;
const
Co
nstantVRegInfo
&
constant_vreg
s
;
const
Co
deConstants
&
code_constant
s
;
BasicBlockTypePropagator
(
CFGBlock
*
block
,
TypeMap
&
initial
,
ExprTypeMap
&
expr_types
,
BasicBlockTypePropagator
(
CFGBlock
*
block
,
TypeMap
&
initial
,
ExprTypeMap
&
expr_types
,
TypeSpeculations
&
type_speculations
,
TypeAnalysis
::
SpeculationLevel
speculation
,
TypeSpeculations
&
type_speculations
,
TypeAnalysis
::
SpeculationLevel
speculation
,
const
Co
nstantVRegInfo
&
constant_vreg
s
)
const
Co
deConstants
&
code_constant
s
)
:
block
(
block
),
:
block
(
block
),
sym_table
(
initial
),
sym_table
(
initial
),
expr_types
(
expr_types
),
expr_types
(
expr_types
),
type_speculations
(
type_speculations
),
type_speculations
(
type_speculations
),
speculation
(
speculation
),
speculation
(
speculation
),
co
nstant_vregs
(
constant_vreg
s
)
{}
co
de_constants
(
code_constant
s
)
{}
void
run
()
{
void
run
()
{
for
(
int
i
=
0
;
i
<
block
->
body
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
block
->
body
.
size
();
i
++
)
{
...
@@ -118,7 +118,7 @@ private:
...
@@ -118,7 +118,7 @@ private:
printf
(
"in propagator, speculating that %s would actually be %s, at "
,
printf
(
"in propagator, speculating that %s would actually be %s, at "
,
old_type
->
debugName
().
c_str
(),
speculated_type
->
debugName
().
c_str
());
old_type
->
debugName
().
c_str
(),
speculated_type
->
debugName
().
c_str
());
fflush
(
stdout
);
fflush
(
stdout
);
print_bst
(
node
,
co
nstant_vreg
s
);
print_bst
(
node
,
co
de_constant
s
);
llvm
::
outs
().
flush
();
llvm
::
outs
().
flush
();
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
...
@@ -131,7 +131,7 @@ private:
...
@@ -131,7 +131,7 @@ private:
}
}
CompilerType
*
getConstantType
(
int
vreg
)
{
CompilerType
*
getConstantType
(
int
vreg
)
{
Box
*
o
=
co
nstant_vreg
s
.
getConstant
(
vreg
);
Box
*
o
=
co
de_constant
s
.
getConstant
(
vreg
);
if
(
o
->
cls
==
int_cls
)
if
(
o
->
cls
==
int_cls
)
return
INT
;
return
INT
;
else
if
(
o
->
cls
==
float_cls
)
else
if
(
o
->
cls
==
float_cls
)
...
@@ -284,7 +284,7 @@ private:
...
@@ -284,7 +284,7 @@ private:
if
(
VERBOSITY
()
>=
2
&&
func
==
UNDEF
)
{
if
(
VERBOSITY
()
>=
2
&&
func
==
UNDEF
)
{
printf
(
"Think %s.%s is undefined, at %d
\n
"
,
t
->
debugName
().
c_str
(),
node
->
attr
.
c_str
(),
node
->
lineno
);
printf
(
"Think %s.%s is undefined, at %d
\n
"
,
t
->
debugName
().
c_str
(),
node
->
attr
.
c_str
(),
node
->
lineno
);
print_bst
(
node
,
co
nstant_vreg
s
);
print_bst
(
node
,
co
de_constant
s
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
...
@@ -297,7 +297,7 @@ private:
...
@@ -297,7 +297,7 @@ private:
if
(
VERBOSITY
()
>=
2
&&
func
==
UNDEF
)
{
if
(
VERBOSITY
()
>=
2
&&
func
==
UNDEF
)
{
printf
(
"Think %s.%s is undefined, at %d
\n
"
,
t
->
debugName
().
c_str
(),
node
->
attr
.
c_str
(),
node
->
lineno
);
printf
(
"Think %s.%s is undefined, at %d
\n
"
,
t
->
debugName
().
c_str
(),
node
->
attr
.
c_str
(),
node
->
lineno
);
print_bst
(
node
,
co
nstant_vreg
s
);
print_bst
(
node
,
co
de_constant
s
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
...
@@ -399,7 +399,7 @@ private:
...
@@ -399,7 +399,7 @@ private:
if
(
VERBOSITY
()
>=
2
&&
rtn
==
UNDEF
)
{
if
(
VERBOSITY
()
>=
2
&&
rtn
==
UNDEF
)
{
printf
(
"Think %s.%s is undefined, at %d
\n
"
,
t
->
debugName
().
c_str
(),
node
->
attr
.
c_str
(),
node
->
lineno
);
printf
(
"Think %s.%s is undefined, at %d
\n
"
,
t
->
debugName
().
c_str
(),
node
->
attr
.
c_str
(),
node
->
lineno
);
print_bst
(
node
,
co
nstant_vreg
s
);
print_bst
(
node
,
co
de_constant
s
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
_doSet
(
node
->
vreg_dst
,
rtn
);
_doSet
(
node
->
vreg_dst
,
rtn
);
...
@@ -551,9 +551,9 @@ private:
...
@@ -551,9 +551,9 @@ private:
public:
public:
static
TypeMap
propagate
(
CFGBlock
*
block
,
const
TypeMap
&
starting
,
ExprTypeMap
&
expr_types
,
static
TypeMap
propagate
(
CFGBlock
*
block
,
const
TypeMap
&
starting
,
ExprTypeMap
&
expr_types
,
TypeSpeculations
&
type_speculations
,
TypeAnalysis
::
SpeculationLevel
speculation
,
TypeSpeculations
&
type_speculations
,
TypeAnalysis
::
SpeculationLevel
speculation
,
const
Co
nstantVRegInfo
&
constant_vreg
s
)
{
const
Co
deConstants
&
code_constant
s
)
{
TypeMap
ending
=
starting
;
TypeMap
ending
=
starting
;
BasicBlockTypePropagator
(
block
,
ending
,
expr_types
,
type_speculations
,
speculation
,
co
nstant_vreg
s
).
run
();
BasicBlockTypePropagator
(
block
,
ending
,
expr_types
,
type_speculations
,
speculation
,
co
de_constant
s
).
run
();
return
ending
;
return
ending
;
}
}
};
};
...
@@ -632,7 +632,7 @@ public:
...
@@ -632,7 +632,7 @@ public:
}
}
static
PropagatingTypeAnalysis
*
doAnalysis
(
SpeculationLevel
speculation
,
TypeMap
&&
initial_types
,
static
PropagatingTypeAnalysis
*
doAnalysis
(
SpeculationLevel
speculation
,
TypeMap
&&
initial_types
,
CFGBlock
*
initial_block
,
const
Co
nstantVRegInfo
&
constant_vreg
s
)
{
CFGBlock
*
initial_block
,
const
Co
deConstants
&
code_constant
s
)
{
Timer
_t
(
"PropagatingTypeAnalysis::doAnalysis()"
);
Timer
_t
(
"PropagatingTypeAnalysis::doAnalysis()"
);
CFG
*
cfg
=
initial_block
->
cfg
;
CFG
*
cfg
=
initial_block
->
cfg
;
...
@@ -673,7 +673,7 @@ public:
...
@@ -673,7 +673,7 @@ public:
}
}
TypeMap
ending
=
BasicBlockTypePropagator
::
propagate
(
block
,
starting_types
.
find
(
block
)
->
second
,
expr_types
,
TypeMap
ending
=
BasicBlockTypePropagator
::
propagate
(
block
,
starting_types
.
find
(
block
)
->
second
,
expr_types
,
type_speculations
,
speculation
,
co
nstant_vreg
s
);
type_speculations
,
speculation
,
co
de_constant
s
);
if
(
VERBOSITY
(
"types"
)
>=
3
)
{
if
(
VERBOSITY
(
"types"
)
>=
3
)
{
printf
(
"before (after):
\n
"
);
printf
(
"before (after):
\n
"
);
...
@@ -730,7 +730,7 @@ public:
...
@@ -730,7 +730,7 @@ public:
// public entry point:
// public entry point:
TypeAnalysis
*
doTypeAnalysis
(
CFG
*
cfg
,
const
ParamNames
&
arg_names
,
const
std
::
vector
<
ConcreteCompilerType
*>&
arg_types
,
TypeAnalysis
*
doTypeAnalysis
(
CFG
*
cfg
,
const
ParamNames
&
arg_names
,
const
std
::
vector
<
ConcreteCompilerType
*>&
arg_types
,
EffortLevel
effort
,
TypeAnalysis
::
SpeculationLevel
speculation
,
EffortLevel
effort
,
TypeAnalysis
::
SpeculationLevel
speculation
,
const
Co
nstantVRegInfo
&
constant_vreg
s
)
{
const
Co
deConstants
&
code_constant
s
)
{
// if (effort == EffortLevel::INTERPRETED) {
// if (effort == EffortLevel::INTERPRETED) {
// return new NullTypeAnalysis();
// return new NullTypeAnalysis();
//}
//}
...
@@ -750,11 +750,11 @@ TypeAnalysis* doTypeAnalysis(CFG* cfg, const ParamNames& arg_names, const std::v
...
@@ -750,11 +750,11 @@ TypeAnalysis* doTypeAnalysis(CFG* cfg, const ParamNames& arg_names, const std::v
assert
(
i
==
arg_types
.
size
());
assert
(
i
==
arg_types
.
size
());
return
PropagatingTypeAnalysis
::
doAnalysis
(
speculation
,
std
::
move
(
initial_types
),
cfg
->
getStartingBlock
(),
return
PropagatingTypeAnalysis
::
doAnalysis
(
speculation
,
std
::
move
(
initial_types
),
cfg
->
getStartingBlock
(),
co
nstant_vreg
s
);
co
de_constant
s
);
}
}
TypeAnalysis
*
doTypeAnalysis
(
const
OSREntryDescriptor
*
entry_descriptor
,
EffortLevel
effort
,
TypeAnalysis
*
doTypeAnalysis
(
const
OSREntryDescriptor
*
entry_descriptor
,
EffortLevel
effort
,
TypeAnalysis
::
SpeculationLevel
speculation
,
const
Co
nstantVRegInfo
&
constant_vreg
s
)
{
TypeAnalysis
::
SpeculationLevel
speculation
,
const
Co
deConstants
&
code_constant
s
)
{
auto
cfg
=
entry_descriptor
->
code
->
source
->
cfg
;
auto
cfg
=
entry_descriptor
->
code
->
source
->
cfg
;
auto
&&
vreg_info
=
cfg
->
getVRegInfo
();
auto
&&
vreg_info
=
cfg
->
getVRegInfo
();
TypeMap
initial_types
(
vreg_info
.
getTotalNumOfVRegs
());
TypeMap
initial_types
(
vreg_info
.
getTotalNumOfVRegs
());
...
@@ -764,6 +764,6 @@ TypeAnalysis* doTypeAnalysis(const OSREntryDescriptor* entry_descriptor, EffortL
...
@@ -764,6 +764,6 @@ TypeAnalysis* doTypeAnalysis(const OSREntryDescriptor* entry_descriptor, EffortL
}
}
return
PropagatingTypeAnalysis
::
doAnalysis
(
speculation
,
std
::
move
(
initial_types
),
return
PropagatingTypeAnalysis
::
doAnalysis
(
speculation
,
std
::
move
(
initial_types
),
entry_descriptor
->
backedge
->
target
,
co
nstant_vreg
s
);
entry_descriptor
->
backedge
->
target
,
co
de_constant
s
);
}
}
}
}
src/analysis/type_analysis.h
View file @
21ac70f4
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
namespace
pyston
{
namespace
pyston
{
class
CFGBlock
;
class
CFGBlock
;
class
Co
nstantVRegInfo
;
class
Co
deConstants
;
class
BoxedClass
;
class
BoxedClass
;
class
BST_stmt_with_dest
;
class
BST_stmt_with_dest
;
class
OSREntryDescriptor
;
class
OSREntryDescriptor
;
...
@@ -45,9 +45,9 @@ public:
...
@@ -45,9 +45,9 @@ public:
TypeAnalysis
*
doTypeAnalysis
(
CFG
*
cfg
,
const
ParamNames
&
param_names
,
TypeAnalysis
*
doTypeAnalysis
(
CFG
*
cfg
,
const
ParamNames
&
param_names
,
const
std
::
vector
<
ConcreteCompilerType
*>&
arg_types
,
EffortLevel
effort
,
const
std
::
vector
<
ConcreteCompilerType
*>&
arg_types
,
EffortLevel
effort
,
TypeAnalysis
::
SpeculationLevel
speculation
,
const
Co
nstantVRegInfo
&
constant_vreg
s
);
TypeAnalysis
::
SpeculationLevel
speculation
,
const
Co
deConstants
&
code_constant
s
);
TypeAnalysis
*
doTypeAnalysis
(
const
OSREntryDescriptor
*
entry_descriptor
,
EffortLevel
effort
,
TypeAnalysis
*
doTypeAnalysis
(
const
OSREntryDescriptor
*
entry_descriptor
,
EffortLevel
effort
,
TypeAnalysis
::
SpeculationLevel
speculation
,
const
Co
nstantVRegInfo
&
constant_vreg
s
);
TypeAnalysis
::
SpeculationLevel
speculation
,
const
Co
deConstants
&
code_constant
s
);
}
}
#endif
#endif
src/codegen/ast_interpreter.cpp
View file @
21ac70f4
...
@@ -181,7 +181,7 @@ public:
...
@@ -181,7 +181,7 @@ public:
BoxedClosure
*
getPassedClosure
()
{
return
frame_info
.
passed_closure
;
}
BoxedClosure
*
getPassedClosure
()
{
return
frame_info
.
passed_closure
;
}
Box
**
getVRegs
()
{
return
vregs
;
}
Box
**
getVRegs
()
{
return
vregs
;
}
const
ScopingResults
&
getScopeInfo
()
{
return
scope_info
;
}
const
ScopingResults
&
getScopeInfo
()
{
return
scope_info
;
}
const
Co
nstantVRegInfo
&
getConstantVRegInfo
()
{
return
getCode
()
->
constant_vreg
s
;
}
const
Co
deConstants
&
getCodeConstants
()
{
return
getCode
()
->
code_constant
s
;
}
void
addSymbol
(
int
vreg
,
Box
*
value
,
bool
allow_duplicates
);
void
addSymbol
(
int
vreg
,
Box
*
value
,
bool
allow_duplicates
);
void
setGenerator
(
Box
*
gen
);
void
setGenerator
(
Box
*
gen
);
...
@@ -900,7 +900,7 @@ Value ASTInterpreter::visit_stmt(BST_stmt* node) {
...
@@ -900,7 +900,7 @@ Value ASTInterpreter::visit_stmt(BST_stmt* node) {
if
(
0
)
{
if
(
0
)
{
printf
(
"%20s % 2d "
,
getCode
()
->
name
->
c_str
(),
current_block
->
idx
);
printf
(
"%20s % 2d "
,
getCode
()
->
name
->
c_str
(),
current_block
->
idx
);
print_bst
(
node
,
getCo
nstantVRegInfo
());
print_bst
(
node
,
getCo
deConstants
());
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
...
@@ -1528,7 +1528,7 @@ Value ASTInterpreter::visit_set(BST_Set* node) {
...
@@ -1528,7 +1528,7 @@ Value ASTInterpreter::visit_set(BST_Set* node) {
Value
ASTInterpreter
::
getVReg
(
int
vreg
,
bool
is_kill
)
{
Value
ASTInterpreter
::
getVReg
(
int
vreg
,
bool
is_kill
)
{
assert
(
vreg
!=
VREG_UNDEFINED
);
assert
(
vreg
!=
VREG_UNDEFINED
);
if
(
vreg
<
0
)
{
if
(
vreg
<
0
)
{
Box
*
o
=
getCo
nstantVRegInfo
().
getConstant
(
vreg
);
Box
*
o
=
getCo
deConstants
().
getConstant
(
vreg
);
return
Value
(
incref
(
o
),
jit
?
jit
->
imm
(
o
)
->
setType
(
RefType
::
BORROWED
)
:
NULL
);
return
Value
(
incref
(
o
),
jit
?
jit
->
imm
(
o
)
->
setType
(
RefType
::
BORROWED
)
:
NULL
);
}
}
...
@@ -1564,10 +1564,10 @@ Value ASTInterpreter::getVReg(int vreg, bool is_kill) {
...
@@ -1564,10 +1564,10 @@ Value ASTInterpreter::getVReg(int vreg, bool is_kill) {
}
}
current_block
->
print
(
getCo
nstantVRegInfo
());
current_block
->
print
(
getCo
deConstants
());
printf
(
"vreg: %d num cross: %d
\n
"
,
vreg
,
getVRegInfo
().
getNumOfCrossBlockVRegs
());
printf
(
"vreg: %d num cross: %d
\n
"
,
vreg
,
getVRegInfo
().
getNumOfCrossBlockVRegs
());
printf
(
"
\n\n
"
);
printf
(
"
\n\n
"
);
current_block
->
cfg
->
print
(
getCo
nstantVRegInfo
());
current_block
->
cfg
->
print
(
getCo
deConstants
());
assert
(
0
);
assert
(
0
);
return
Value
();
return
Value
();
...
...
src/codegen/irgen.cpp
View file @
21ac70f4
...
@@ -1027,7 +1027,7 @@ std::pair<CompiledFunction*, llvm::Function*> doCompile(BoxedCode* code, SourceI
...
@@ -1027,7 +1027,7 @@ std::pair<CompiledFunction*, llvm::Function*> doCompile(BoxedCode* code, SourceI
assert
((
entry_descriptor
!=
NULL
)
+
(
spec
!=
NULL
)
==
1
);
assert
((
entry_descriptor
!=
NULL
)
+
(
spec
!=
NULL
)
==
1
);
if
(
VERBOSITY
(
"irgen"
)
>=
2
)
if
(
VERBOSITY
(
"irgen"
)
>=
2
)
source
->
cfg
->
print
(
code
->
co
nstant_vreg
s
);
source
->
cfg
->
print
(
code
->
co
de_constant
s
);
assert
(
g
.
cur_module
==
NULL
);
assert
(
g
.
cur_module
==
NULL
);
...
@@ -1101,10 +1101,10 @@ std::pair<CompiledFunction*, llvm::Function*> doCompile(BoxedCode* code, SourceI
...
@@ -1101,10 +1101,10 @@ std::pair<CompiledFunction*, llvm::Function*> doCompile(BoxedCode* code, SourceI
speculation_level
=
TypeAnalysis
::
SOME
;
speculation_level
=
TypeAnalysis
::
SOME
;
TypeAnalysis
*
types
;
TypeAnalysis
*
types
;
if
(
entry_descriptor
)
if
(
entry_descriptor
)
types
=
doTypeAnalysis
(
entry_descriptor
,
effort
,
speculation_level
,
code
->
co
nstant_vreg
s
);
types
=
doTypeAnalysis
(
entry_descriptor
,
effort
,
speculation_level
,
code
->
co
de_constant
s
);
else
else
types
=
doTypeAnalysis
(
source
->
cfg
,
*
param_names
,
spec
->
arg_types
,
effort
,
speculation_level
,
types
=
doTypeAnalysis
(
source
->
cfg
,
*
param_names
,
spec
->
arg_types
,
effort
,
speculation_level
,
code
->
co
nstant_vreg
s
);
code
->
co
de_constant
s
);
_t2
.
split
();
_t2
.
split
();
...
...
src/codegen/irgen/irgenerator.cpp
View file @
21ac70f4
...
@@ -1225,7 +1225,7 @@ private:
...
@@ -1225,7 +1225,7 @@ private:
CompilerVariable
*
evalVReg
(
int
vreg
,
bool
is_kill
=
true
)
{
CompilerVariable
*
evalVReg
(
int
vreg
,
bool
is_kill
=
true
)
{
assert
(
vreg
!=
VREG_UNDEFINED
);
assert
(
vreg
!=
VREG_UNDEFINED
);
if
(
vreg
<
0
)
{
if
(
vreg
<
0
)
{
Box
*
o
=
irstate
->
getCode
()
->
co
nstant_vreg
s
.
getConstant
(
vreg
);
Box
*
o
=
irstate
->
getCode
()
->
co
de_constant
s
.
getConstant
(
vreg
);
if
(
o
->
cls
==
int_cls
)
{
if
(
o
->
cls
==
int_cls
)
{
return
makeInt
(((
BoxedInt
*
)
o
)
->
n
);
return
makeInt
(((
BoxedInt
*
)
o
)
->
n
);
}
else
if
(
o
->
cls
==
float_cls
)
{
}
else
if
(
o
->
cls
==
float_cls
)
{
...
@@ -1612,7 +1612,7 @@ private:
...
@@ -1612,7 +1612,7 @@ private:
printf
(
"Speculating that %s is actually %s, at "
,
rtn
->
getType
()
->
debugName
().
c_str
(),
printf
(
"Speculating that %s is actually %s, at "
,
rtn
->
getType
()
->
debugName
().
c_str
(),
speculated_type
->
debugName
().
c_str
());
speculated_type
->
debugName
().
c_str
());
fflush
(
stdout
);
fflush
(
stdout
);
print_bst
(
node
,
irstate
->
getCode
()
->
co
nstant_vreg
s
);
print_bst
(
node
,
irstate
->
getCode
()
->
co
de_constant
s
);
llvm
::
outs
().
flush
();
llvm
::
outs
().
flush
();
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
...
@@ -1624,7 +1624,7 @@ private:
...
@@ -1624,7 +1624,7 @@ private:
auto
source
=
irstate
->
getSourceInfo
();
auto
source
=
irstate
->
getSourceInfo
();
printf
(
"On %s:%d, function %s:
\n
"
,
irstate
->
getCode
()
->
filename
->
c_str
(),
printf
(
"On %s:%d, function %s:
\n
"
,
irstate
->
getCode
()
->
filename
->
c_str
(),
irstate
->
getCode
()
->
firstlineno
,
irstate
->
getCode
()
->
name
->
c_str
());
irstate
->
getCode
()
->
firstlineno
,
irstate
->
getCode
()
->
name
->
c_str
());
irstate
->
getSourceInfo
()
->
cfg
->
print
(
irstate
->
getCode
()
->
co
nstant_vreg
s
);
irstate
->
getSourceInfo
()
->
cfg
->
print
(
irstate
->
getCode
()
->
co
de_constant
s
);
}
}
RELEASE_ASSERT
(
!
rtn
->
canConvertTo
(
speculated_type
),
"%s %s"
,
rtn
->
getType
()
->
debugName
().
c_str
(),
RELEASE_ASSERT
(
!
rtn
->
canConvertTo
(
speculated_type
),
"%s %s"
,
rtn
->
getType
()
->
debugName
().
c_str
(),
speculated_type
->
debugName
().
c_str
());
speculated_type
->
debugName
().
c_str
());
...
...
src/core/bst.cpp
View file @
21ac70f4
...
@@ -754,8 +754,8 @@ void BST_MakeSlice::accept_stmt(StmtVisitor* v) {
...
@@ -754,8 +754,8 @@ void BST_MakeSlice::accept_stmt(StmtVisitor* v) {
return
v
->
visit_makeslice
(
this
);
return
v
->
visit_makeslice
(
this
);
}
}
void
print_bst
(
BST_stmt
*
bst
,
const
Co
nstantVRegInfo
&
constant_vreg
s
)
{
void
print_bst
(
BST_stmt
*
bst
,
const
Co
deConstants
&
code_constant
s
)
{
PrintVisitor
v
(
co
nstant_vreg
s
,
0
,
llvm
::
outs
());
PrintVisitor
v
(
co
de_constant
s
,
0
,
llvm
::
outs
());
bst
->
accept
(
&
v
);
bst
->
accept
(
&
v
);
v
.
flush
();
v
.
flush
();
}
}
...
@@ -771,7 +771,7 @@ bool PrintVisitor::visit_vreg(int* vreg, bool is_dst) {
...
@@ -771,7 +771,7 @@ bool PrintVisitor::visit_vreg(int* vreg, bool is_dst) {
if
(
*
vreg
!=
VREG_UNDEFINED
)
{
if
(
*
vreg
!=
VREG_UNDEFINED
)
{
stream
<<
"%"
<<
*
vreg
;
stream
<<
"%"
<<
*
vreg
;
if
(
*
vreg
<
0
)
if
(
*
vreg
<
0
)
stream
<<
"|"
<<
autoDecref
(
repr
(
co
nstant_vreg
s
.
getConstant
(
*
vreg
)))
->
s
()
<<
"|"
;
stream
<<
"|"
<<
autoDecref
(
repr
(
co
de_constant
s
.
getConstant
(
*
vreg
)))
->
s
()
<<
"|"
;
}
else
}
else
stream
<<
"%undef"
;
stream
<<
"%undef"
;
...
...
src/core/bst.h
View file @
21ac70f4
...
@@ -906,20 +906,20 @@ public:
...
@@ -906,20 +906,20 @@ public:
virtual
void
visit_yield
(
BST_Yield
*
node
)
{
RELEASE_ASSERT
(
0
,
""
);
}
virtual
void
visit_yield
(
BST_Yield
*
node
)
{
RELEASE_ASSERT
(
0
,
""
);
}
};
};
class
Co
nstantVRegInfo
;
class
Co
deConstants
;
void
print_bst
(
BST_stmt
*
bst
,
const
Co
nstantVRegInfo
&
constant_vreg
s
);
void
print_bst
(
BST_stmt
*
bst
,
const
Co
deConstants
&
code_constant
s
);
class
PrintVisitor
:
public
BSTVisitor
{
class
PrintVisitor
:
public
BSTVisitor
{
private:
private:
llvm
::
raw_ostream
&
stream
;
llvm
::
raw_ostream
&
stream
;
const
Co
nstantVRegInfo
&
constant_vreg
s
;
const
Co
deConstants
&
code_constant
s
;
int
indent
;
int
indent
;
void
printIndent
();
void
printIndent
();
void
printOp
(
AST_TYPE
::
AST_TYPE
op_type
);
void
printOp
(
AST_TYPE
::
AST_TYPE
op_type
);
public:
public:
PrintVisitor
(
const
Co
nstantVRegInfo
&
constant_vreg
s
,
int
indent
,
llvm
::
raw_ostream
&
stream
)
PrintVisitor
(
const
Co
deConstants
&
code_constant
s
,
int
indent
,
llvm
::
raw_ostream
&
stream
)
:
BSTVisitor
(
false
/* visit child CFG */
),
stream
(
stream
),
co
nstant_vregs
(
constant_vreg
s
),
indent
(
indent
)
{}
:
BSTVisitor
(
false
/* visit child CFG */
),
stream
(
stream
),
co
de_constants
(
code_constant
s
),
indent
(
indent
)
{}
virtual
~
PrintVisitor
()
{}
virtual
~
PrintVisitor
()
{}
void
flush
()
{
stream
.
flush
();
}
void
flush
()
{
stream
.
flush
();
}
...
...
src/core/cfg.cpp
View file @
21ac70f4
...
@@ -185,7 +185,7 @@ void CFGBlock::unconnectFrom(CFGBlock* successor) {
...
@@ -185,7 +185,7 @@ void CFGBlock::unconnectFrom(CFGBlock* successor) {
successor
->
predecessors
.
end
());
successor
->
predecessors
.
end
());
}
}
void
CFGBlock
::
print
(
const
Co
nstantVRegInfo
&
constant_vreg
s
,
llvm
::
raw_ostream
&
stream
)
{
void
CFGBlock
::
print
(
const
Co
deConstants
&
code_constant
s
,
llvm
::
raw_ostream
&
stream
)
{
stream
<<
"Block "
<<
idx
;
stream
<<
"Block "
<<
idx
;
if
(
info
)
if
(
info
)
stream
<<
" '"
<<
info
<<
"'"
;
stream
<<
" '"
<<
info
<<
"'"
;
...
@@ -200,7 +200,7 @@ void CFGBlock::print(const ConstantVRegInfo& constant_vregs, llvm::raw_ostream&
...
@@ -200,7 +200,7 @@ void CFGBlock::print(const ConstantVRegInfo& constant_vregs, llvm::raw_ostream&
}
}
stream
<<
"
\n
"
;
stream
<<
"
\n
"
;
PrintVisitor
pv
(
co
nstant_vreg
s
,
4
,
stream
);
PrintVisitor
pv
(
co
de_constant
s
,
4
,
stream
);
for
(
int
j
=
0
;
j
<
body
.
size
();
j
++
)
{
for
(
int
j
=
0
;
j
<
body
.
size
();
j
++
)
{
stream
<<
" "
;
stream
<<
" "
;
body
[
j
]
->
accept
(
&
pv
);
body
[
j
]
->
accept
(
&
pv
);
...
@@ -246,10 +246,10 @@ public:
...
@@ -246,10 +246,10 @@ public:
AST
*
orig_node
);
AST
*
orig_node
);
};
};
static
std
::
pair
<
CFG
*
,
Co
nstantVRegInfo
>
computeCFG
(
llvm
::
ArrayRef
<
AST_stmt
*>
body
,
AST_TYPE
::
AST_TYPE
ast_type
,
static
std
::
pair
<
CFG
*
,
Co
deConstants
>
computeCFG
(
llvm
::
ArrayRef
<
AST_stmt
*>
body
,
AST_TYPE
::
AST_TYPE
ast_type
,
int
lineno
,
AST_arguments
*
args
,
BoxedString
*
filename
,
int
lineno
,
AST_arguments
*
args
,
BoxedString
*
filename
,
SourceInfo
*
source
,
const
ParamNames
&
param_names
,
SourceInfo
*
source
,
const
ParamNames
&
param_names
,
ScopeInfo
*
scoping
,
ScopeInfo
*
scoping
,
ModuleCFGProcessor
*
cfgizer
);
ModuleCFGProcessor
*
cfgizer
);
// This keeps track of the result of an instruction it's either a name, const or undefined.
// This keeps track of the result of an instruction it's either a name, const or undefined.
struct
TmpValue
{
struct
TmpValue
{
...
@@ -363,14 +363,14 @@ private:
...
@@ -363,14 +363,14 @@ private:
std
::
vector
<
ContInfo
>
continuations
;
std
::
vector
<
ContInfo
>
continuations
;
std
::
vector
<
ExcBlockInfo
>
exc_handlers
;
std
::
vector
<
ExcBlockInfo
>
exc_handlers
;
llvm
::
DenseMap
<
Box
*
,
int
>
consts
;
llvm
::
DenseMap
<
Box
*
,
int
>
consts
;
Co
nstantVRegInfo
constant_vreg
s
;
Co
deConstants
code_constant
s
;
unsigned
int
next_var_index
=
0
;
unsigned
int
next_var_index
=
0
;
friend
std
::
pair
<
CFG
*
,
Co
nstantVRegInfo
>
computeCFG
(
llvm
::
ArrayRef
<
AST_stmt
*>
body
,
AST_TYPE
::
AST_TYPE
ast_type
,
friend
std
::
pair
<
CFG
*
,
Co
deConstants
>
computeCFG
(
llvm
::
ArrayRef
<
AST_stmt
*>
body
,
AST_TYPE
::
AST_TYPE
ast_type
,
int
lineno
,
AST_arguments
*
args
,
BoxedString
*
filename
,
int
lineno
,
AST_arguments
*
args
,
BoxedString
*
filename
,
SourceInfo
*
source
,
const
ParamNames
&
param_names
,
SourceInfo
*
source
,
const
ParamNames
&
param_names
,
ScopeInfo
*
scoping
,
ModuleCFGProcessor
*
cfgizer
);
ScopeInfo
*
scoping
,
ModuleCFGProcessor
*
cfgizer
);
public:
public:
CFGVisitor
(
BoxedString
*
filename
,
SourceInfo
*
source
,
InternedStringPool
&
stringpool
,
ScopeInfo
*
scoping
,
CFGVisitor
(
BoxedString
*
filename
,
SourceInfo
*
source
,
InternedStringPool
&
stringpool
,
ScopeInfo
*
scoping
,
...
@@ -513,7 +513,7 @@ private:
...
@@ -513,7 +513,7 @@ private:
auto
it
=
consts
.
find
(
o
);
auto
it
=
consts
.
find
(
o
);
if
(
it
!=
consts
.
end
())
if
(
it
!=
consts
.
end
())
return
it
->
second
;
return
it
->
second
;
int
vreg
=
co
nstant_vregs
.
add
Constant
(
o
);
int
vreg
=
co
de_constants
.
createVRegEntryFor
Constant
(
o
);
consts
[
o
]
=
vreg
;
consts
[
o
]
=
vreg
;
return
vreg
;
return
vreg
;
}
}
...
@@ -2855,11 +2855,11 @@ public:
...
@@ -2855,11 +2855,11 @@ public:
}
}
};
};
void
CFG
::
print
(
const
Co
nstantVRegInfo
&
constant_vreg
s
,
llvm
::
raw_ostream
&
stream
)
{
void
CFG
::
print
(
const
Co
deConstants
&
code_constant
s
,
llvm
::
raw_ostream
&
stream
)
{
stream
<<
"CFG:
\n
"
;
stream
<<
"CFG:
\n
"
;
stream
<<
blocks
.
size
()
<<
" blocks
\n
"
;
stream
<<
blocks
.
size
()
<<
" blocks
\n
"
;
for
(
int
i
=
0
;
i
<
blocks
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
blocks
.
size
();
i
++
)
blocks
[
i
]
->
print
(
co
nstant_vreg
s
,
stream
);
blocks
[
i
]
->
print
(
co
de_constant
s
,
stream
);
stream
.
flush
();
stream
.
flush
();
}
}
...
@@ -3047,10 +3047,10 @@ void VRegInfo::assignVRegs(CFG* cfg, const ParamNames& param_names, llvm::DenseM
...
@@ -3047,10 +3047,10 @@ void VRegInfo::assignVRegs(CFG* cfg, const ParamNames& param_names, llvm::DenseM
}
}
static
std
::
pair
<
CFG
*
,
Co
nstantVRegInfo
>
computeCFG
(
llvm
::
ArrayRef
<
AST_stmt
*>
body
,
AST_TYPE
::
AST_TYPE
ast_type
,
static
std
::
pair
<
CFG
*
,
Co
deConstants
>
computeCFG
(
llvm
::
ArrayRef
<
AST_stmt
*>
body
,
AST_TYPE
::
AST_TYPE
ast_type
,
int
lineno
,
AST_arguments
*
args
,
BoxedString
*
filename
,
int
lineno
,
AST_arguments
*
args
,
BoxedString
*
filename
,
SourceInfo
*
source
,
const
ParamNames
&
param_names
,
SourceInfo
*
source
,
const
ParamNames
&
param_names
,
ScopeInfo
*
scoping
,
ScopeInfo
*
scoping
,
ModuleCFGProcessor
*
cfgizer
)
{
ModuleCFGProcessor
*
cfgizer
)
{
STAT_TIMER
(
t0
,
"us_timer_computecfg"
,
0
);
STAT_TIMER
(
t0
,
"us_timer_computecfg"
,
0
);
CFG
*
rtn
=
new
CFG
();
CFG
*
rtn
=
new
CFG
();
...
@@ -3139,7 +3139,7 @@ static std::pair<CFG*, ConstantVRegInfo> computeCFG(llvm::ArrayRef<AST_stmt*> bo
...
@@ -3139,7 +3139,7 @@ static std::pair<CFG*, ConstantVRegInfo> computeCFG(llvm::ArrayRef<AST_stmt*> bo
if
(
VERBOSITY
(
"cfg"
)
>=
3
)
{
if
(
VERBOSITY
(
"cfg"
)
>=
3
)
{
printf
(
"Before cfg checking and transformations:
\n
"
);
printf
(
"Before cfg checking and transformations:
\n
"
);
rtn
->
print
(
visitor
.
co
nstant_vreg
s
);
rtn
->
print
(
visitor
.
co
de_constant
s
);
}
}
#ifndef NDEBUG
#ifndef NDEBUG
...
@@ -3167,7 +3167,7 @@ static std::pair<CFG*, ConstantVRegInfo> computeCFG(llvm::ArrayRef<AST_stmt*> bo
...
@@ -3167,7 +3167,7 @@ static std::pair<CFG*, ConstantVRegInfo> computeCFG(llvm::ArrayRef<AST_stmt*> bo
if
(
b
->
predecessors
.
size
()
==
0
)
{
if
(
b
->
predecessors
.
size
()
==
0
)
{
if
(
b
!=
rtn
->
getStartingBlock
())
{
if
(
b
!=
rtn
->
getStartingBlock
())
{
rtn
->
print
(
visitor
.
co
nstant_vreg
s
);
rtn
->
print
(
visitor
.
co
de_constant
s
);
}
}
ASSERT
(
b
==
rtn
->
getStartingBlock
(),
"%d"
,
b
->
idx
);
ASSERT
(
b
==
rtn
->
getStartingBlock
(),
"%d"
,
b
->
idx
);
}
}
...
@@ -3222,13 +3222,13 @@ static std::pair<CFG*, ConstantVRegInfo> computeCFG(llvm::ArrayRef<AST_stmt*> bo
...
@@ -3222,13 +3222,13 @@ static std::pair<CFG*, ConstantVRegInfo> computeCFG(llvm::ArrayRef<AST_stmt*> bo
deduped
[
e
]
++
;
deduped
[
e
]
++
;
if
(
deduped
[
e
]
==
2
)
{
if
(
deduped
[
e
]
==
2
)
{
printf
(
"Duplicated: "
);
printf
(
"Duplicated: "
);
print_bst
(
e
,
visitor
.
co
nstant_vreg
s
);
print_bst
(
e
,
visitor
.
co
de_constant
s
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
no_dups
=
false
;
no_dups
=
false
;
}
}
}
}
if
(
!
no_dups
)
if
(
!
no_dups
)
rtn
->
print
(
visitor
.
co
nstant_vreg
s
);
rtn
->
print
(
visitor
.
co
de_constant
s
);
assert
(
no_dups
);
assert
(
no_dups
);
// Uncomment this for some heavy checking to make sure that we don't forget
// Uncomment this for some heavy checking to make sure that we don't forget
...
@@ -3331,10 +3331,10 @@ static std::pair<CFG*, ConstantVRegInfo> computeCFG(llvm::ArrayRef<AST_stmt*> bo
...
@@ -3331,10 +3331,10 @@ static std::pair<CFG*, ConstantVRegInfo> computeCFG(llvm::ArrayRef<AST_stmt*> bo
if
(
VERBOSITY
(
"cfg"
)
>=
2
)
{
if
(
VERBOSITY
(
"cfg"
)
>=
2
)
{
printf
(
"Final cfg:
\n
"
);
printf
(
"Final cfg:
\n
"
);
rtn
->
print
(
visitor
.
co
nstant_vreg
s
,
llvm
::
outs
());
rtn
->
print
(
visitor
.
co
de_constant
s
,
llvm
::
outs
());
}
}
return
std
::
make_pair
(
rtn
,
visitor
.
co
nstant_vreg
s
);
return
std
::
make_pair
(
rtn
,
visitor
.
co
de_constant
s
);
}
}
...
@@ -3381,17 +3381,17 @@ BoxedCode* ModuleCFGProcessor::runRecursively(llvm::ArrayRef<AST_stmt*> body, Bo
...
@@ -3381,17 +3381,17 @@ BoxedCode* ModuleCFGProcessor::runRecursively(llvm::ArrayRef<AST_stmt*> body, Bo
for
(
auto
e
:
param_names
.
allArgsAsName
())
for
(
auto
e
:
param_names
.
allArgsAsName
())
fillScopingInfo
(
e
,
scope_info
);
fillScopingInfo
(
e
,
scope_info
);
Co
nstantVRegInfo
constant_vreg
s
;
Co
deConstants
code_constant
s
;
std
::
tie
(
si
->
cfg
,
co
nstant_vreg
s
)
std
::
tie
(
si
->
cfg
,
co
de_constant
s
)
=
computeCFG
(
body
,
ast_type
,
lineno
,
args
,
fn
,
si
.
get
(),
param_names
,
scope_info
,
this
);
=
computeCFG
(
body
,
ast_type
,
lineno
,
args
,
fn
,
si
.
get
(),
param_names
,
scope_info
,
this
);
BoxedCode
*
code
;
BoxedCode
*
code
;
if
(
args
)
if
(
args
)
code
=
new
BoxedCode
(
args
->
args
.
size
(),
args
->
vararg
,
args
->
kwarg
,
lineno
,
std
::
move
(
si
),
code
=
new
BoxedCode
(
args
->
args
.
size
(),
args
->
vararg
,
args
->
kwarg
,
lineno
,
std
::
move
(
si
),
std
::
move
(
co
nstant_vreg
s
),
std
::
move
(
param_names
),
fn
,
name
,
std
::
move
(
co
de_constant
s
),
std
::
move
(
param_names
),
fn
,
name
,
autoDecref
(
getDocString
(
body
)));
autoDecref
(
getDocString
(
body
)));
else
else
code
=
new
BoxedCode
(
0
,
false
,
false
,
lineno
,
std
::
move
(
si
),
std
::
move
(
co
nstant_vreg
s
),
std
::
move
(
param_names
),
code
=
new
BoxedCode
(
0
,
false
,
false
,
lineno
,
std
::
move
(
si
),
std
::
move
(
co
de_constant
s
),
std
::
move
(
param_names
),
fn
,
name
,
autoDecref
(
getDocString
(
body
)));
fn
,
name
,
autoDecref
(
getDocString
(
body
)));
return
code
;
return
code
;
...
@@ -3403,7 +3403,7 @@ BoxedCode* computeAllCFGs(AST* ast, bool globals_from_module, FutureFlags future
...
@@ -3403,7 +3403,7 @@ BoxedCode* computeAllCFGs(AST* ast, bool globals_from_module, FutureFlags future
.
runRecursively
(
ast
->
getBody
(),
ast
->
getName
(),
ast
->
lineno
,
nullptr
,
ast
);
.
runRecursively
(
ast
->
getBody
(),
ast
->
getName
(),
ast
->
lineno
,
nullptr
,
ast
);
}
}
void
printCFG
(
CFG
*
cfg
,
const
Co
nstantVRegInfo
&
constant_vreg
s
)
{
void
printCFG
(
CFG
*
cfg
,
const
Co
deConstants
&
code_constant
s
)
{
cfg
->
print
(
co
nstant_vreg
s
);
cfg
->
print
(
co
de_constant
s
);
}
}
}
}
src/core/cfg.h
View file @
21ac70f4
...
@@ -88,7 +88,7 @@ public:
...
@@ -88,7 +88,7 @@ public:
void
unconnectFrom
(
CFGBlock
*
successor
);
void
unconnectFrom
(
CFGBlock
*
successor
);
void
push_back
(
BST_stmt
*
node
)
{
body
.
push_back
(
node
);
}
void
push_back
(
BST_stmt
*
node
)
{
body
.
push_back
(
node
);
}
void
print
(
const
Co
nstantVRegInfo
&
constant_vreg
s
,
llvm
::
raw_ostream
&
stream
=
llvm
::
outs
());
void
print
(
const
Co
deConstants
&
code_constant
s
,
llvm
::
raw_ostream
&
stream
=
llvm
::
outs
());
};
};
// the vregs are split into three parts.
// the vregs are split into three parts.
...
@@ -210,7 +210,7 @@ public:
...
@@ -210,7 +210,7 @@ public:
blocks
.
push_back
(
block
);
blocks
.
push_back
(
block
);
}
}
void
print
(
const
Co
nstantVRegInfo
&
constant_vreg
s
,
llvm
::
raw_ostream
&
stream
=
llvm
::
outs
());
void
print
(
const
Co
deConstants
&
code_constant
s
,
llvm
::
raw_ostream
&
stream
=
llvm
::
outs
());
};
};
class
VRegSet
{
class
VRegSet
{
...
@@ -331,7 +331,7 @@ public:
...
@@ -331,7 +331,7 @@ public:
BoxedCode
*
computeAllCFGs
(
AST
*
ast
,
bool
globals_from_module
,
FutureFlags
future_flags
,
BoxedString
*
fn
,
BoxedCode
*
computeAllCFGs
(
AST
*
ast
,
bool
globals_from_module
,
FutureFlags
future_flags
,
BoxedString
*
fn
,
BoxedModule
*
bm
);
BoxedModule
*
bm
);
void
printCFG
(
CFG
*
cfg
,
const
Co
nstantVRegInfo
&
constant_vreg
s
);
void
printCFG
(
CFG
*
cfg
,
const
Co
deConstants
&
code_constant
s
);
}
}
#endif
#endif
src/runtime/code.cpp
View file @
21ac70f4
...
@@ -113,10 +113,10 @@ void BoxedCode::dealloc(Box* b) noexcept {
...
@@ -113,10 +113,10 @@ void BoxedCode::dealloc(Box* b) noexcept {
}
}
BoxedCode
::
BoxedCode
(
int
num_args
,
bool
takes_varargs
,
bool
takes_kwargs
,
int
firstlineno
,
BoxedCode
::
BoxedCode
(
int
num_args
,
bool
takes_varargs
,
bool
takes_kwargs
,
int
firstlineno
,
std
::
unique_ptr
<
SourceInfo
>
source
,
Co
nstantVRegInfo
constant_vreg
s
,
ParamNames
param_names
,
std
::
unique_ptr
<
SourceInfo
>
source
,
Co
deConstants
code_constant
s
,
ParamNames
param_names
,
BoxedString
*
filename
,
BoxedString
*
name
,
Box
*
doc
)
BoxedString
*
filename
,
BoxedString
*
name
,
Box
*
doc
)
:
source
(
std
::
move
(
source
)),
:
source
(
std
::
move
(
source
)),
co
nstant_vregs
(
std
::
move
(
constant_vreg
s
)),
co
de_constants
(
std
::
move
(
code_constant
s
)),
filename
(
incref
(
filename
)),
filename
(
incref
(
filename
)),
name
(
incref
(
name
)),
name
(
incref
(
name
)),
firstlineno
(
firstlineno
),
firstlineno
(
firstlineno
),
...
...
src/runtime/types.h
View file @
21ac70f4
...
@@ -1070,17 +1070,17 @@ public:
...
@@ -1070,17 +1070,17 @@ public:
};
};
static_assert
(
sizeof
(
BoxedDict
)
==
sizeof
(
PyDictObject
),
""
);
static_assert
(
sizeof
(
BoxedDict
)
==
sizeof
(
PyDictObject
),
""
);
class
Co
nstantVRegInfo
{
class
Co
deConstants
{
private:
private:
std
::
vector
<
Box
*>
constants
;
std
::
vector
<
Box
*>
constants
;
public:
public:
Co
nstantVRegInfo
(){};
Co
deConstants
()
{}
Box
*
getConstant
(
int
vreg
)
const
{
return
constants
[
-
(
vreg
+
1
)];
}
Box
*
getConstant
(
int
vreg
)
const
{
return
constants
[
-
(
vreg
+
1
)];
}
// returns the vreg num for the constant (which is a negative number)
// returns the vreg num for the constant (which is a negative number)
int
add
Constant
(
Box
*
o
)
{
int
createVRegEntryFor
Constant
(
Box
*
o
)
{
constants
.
push_back
(
o
);
constants
.
push_back
(
o
);
return
-
constants
.
size
();
return
-
constants
.
size
();
}
}
...
@@ -1095,8 +1095,8 @@ public:
...
@@ -1095,8 +1095,8 @@ public:
// BoxedCode objects also keep track of any machine code that we have available for this function.
// BoxedCode objects also keep track of any machine code that we have available for this function.
class
BoxedCode
:
public
Box
{
class
BoxedCode
:
public
Box
{
public:
public:
std
::
unique_ptr
<
SourceInfo
>
source
;
// source can be NULL for functions defined in the C/C++ runtime
std
::
unique_ptr
<
SourceInfo
>
source
;
// source can be NULL for functions defined in the C/C++ runtime
const
Co
nstantVRegInfo
BORROWED
(
constant_vreg
s
);
// keeps track of all constants inside the bytecode
const
Co
deConstants
BORROWED
(
code_constant
s
);
// keeps track of all constants inside the bytecode
BoxedString
*
filename
=
nullptr
;
BoxedString
*
filename
=
nullptr
;
BoxedString
*
name
=
nullptr
;
BoxedString
*
name
=
nullptr
;
...
@@ -1135,8 +1135,7 @@ public:
...
@@ -1135,8 +1135,7 @@ public:
// Constructor for Python code objects:
// Constructor for Python code objects:
BoxedCode
(
int
num_args
,
bool
takes_varargs
,
bool
takes_kwargs
,
int
firstlineno
,
std
::
unique_ptr
<
SourceInfo
>
source
,
BoxedCode
(
int
num_args
,
bool
takes_varargs
,
bool
takes_kwargs
,
int
firstlineno
,
std
::
unique_ptr
<
SourceInfo
>
source
,
ConstantVRegInfo
constant_vregs
,
ParamNames
param_names
,
BoxedString
*
filename
,
BoxedString
*
name
,
CodeConstants
code_constants
,
ParamNames
param_names
,
BoxedString
*
filename
,
BoxedString
*
name
,
Box
*
doc
);
Box
*
doc
);
// Constructor for code objects created by the runtime:
// Constructor for code objects created by the runtime:
BoxedCode
(
int
num_args
,
bool
takes_varargs
,
bool
takes_kwargs
,
const
char
*
name
,
const
char
*
doc
=
""
,
BoxedCode
(
int
num_args
,
bool
takes_varargs
,
bool
takes_kwargs
,
const
char
*
name
,
const
char
*
doc
=
""
,
...
...
src/runtime/util.cpp
View file @
21ac70f4
...
@@ -254,7 +254,7 @@ extern "C" void dumpEx(void* p, int levels) {
...
@@ -254,7 +254,7 @@ extern "C" void dumpEx(void* p, int levels) {
printf
(
"Defined at %s:%d
\n
"
,
code
->
filename
->
c_str
(),
code
->
firstlineno
);
printf
(
"Defined at %s:%d
\n
"
,
code
->
filename
->
c_str
(),
code
->
firstlineno
);
if
(
code
->
source
->
cfg
&&
levels
>
0
)
{
if
(
code
->
source
->
cfg
&&
levels
>
0
)
{
code
->
source
->
cfg
->
print
(
code
->
co
nstant_vreg
s
);
code
->
source
->
cfg
->
print
(
code
->
co
de_constant
s
);
}
}
}
else
{
}
else
{
printf
(
"A builtin function
\n
"
);
printf
(
"A builtin function
\n
"
);
...
...
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