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
b145b008
Commit
b145b008
authored
Nov 06, 2015
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move calculateNumVRegs
parent
8e0e07c6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
16 deletions
+38
-16
src/codegen/ast_interpreter.cpp
src/codegen/ast_interpreter.cpp
+12
-16
src/codegen/ast_interpreter.h
src/codegen/ast_interpreter.h
+1
-0
src/codegen/codegen.cpp
src/codegen/codegen.cpp
+23
-0
src/core/types.h
src/core/types.h
+2
-0
No files found.
src/codegen/ast_interpreter.cpp
View file @
b145b008
...
...
@@ -1702,14 +1702,6 @@ static int calculateNumVRegs(FunctionMetadata* md) {
SourceInfo
*
source_info
=
md
->
source
.
get
();
CFG
*
cfg
=
source_info
->
cfg
;
// Note: due to some (avoidable) restrictions, this check is pretty constrained in where
// it can go, due to the fact that it can throw an exception.
// It can't go in the ASTInterpreter constructor, since that will cause the C++ runtime to
// delete the partially-constructed memory which we don't currently handle. It can't go into
// executeInner since we want the SyntaxErrors to happen *before* the stack frame is entered.
// (For instance, throwing the exception will try to fetch the current statement, but we determine
// that by looking at the cfg.)
if
(
!
cfg
)
cfg
=
source_info
->
cfg
=
computeCFG
(
source_info
,
source_info
->
body
);
...
...
@@ -1786,7 +1778,7 @@ Box* astInterpretFunction(FunctionMetadata* md, Box* closure, Box* generator, Bo
}
Box
**
vregs
=
NULL
;
int
num_vregs
=
calculateNumVRegs
(
md
);
int
num_vregs
=
md
->
calculateNumVRegs
(
);
if
(
num_vregs
>
0
)
{
vregs
=
(
Box
**
)
alloca
(
sizeof
(
Box
*
)
*
num_vregs
);
memset
(
vregs
,
0
,
sizeof
(
Box
*
)
*
num_vregs
);
...
...
@@ -1817,7 +1809,7 @@ Box* astInterpretFunctionEval(FunctionMetadata* md, Box* globals, Box* boxedLoca
++
md
->
times_interpreted
;
Box
**
vregs
=
NULL
;
int
num_vregs
=
calculateNumVRegs
(
md
);
int
num_vregs
=
md
->
calculateNumVRegs
(
);
if
(
num_vregs
>
0
)
{
vregs
=
(
Box
**
)
alloca
(
sizeof
(
Box
*
)
*
num_vregs
);
memset
(
vregs
,
0
,
sizeof
(
Box
*
)
*
num_vregs
);
...
...
@@ -1848,7 +1840,7 @@ static Box* astInterpretDeoptInner(FunctionMetadata* md, AST_expr* after_expr, A
SourceInfo
*
source_info
=
md
->
source
.
get
();
Box
**
vregs
=
NULL
;
int
num_vregs
=
calculateNumVRegs
(
md
);
int
num_vregs
=
md
->
calculateNumVRegs
(
);
if
(
num_vregs
>
0
)
{
vregs
=
(
Box
**
)
alloca
(
sizeof
(
Box
*
)
*
num_vregs
);
memset
(
vregs
,
0
,
sizeof
(
Box
*
)
*
num_vregs
);
...
...
@@ -1973,15 +1965,13 @@ FrameInfo* getFrameInfoForInterpretedFrame(void* frame_ptr) {
return
interpreter
->
getFrameInfo
();
}
BoxedDict
*
localsForInterpretedFrame
(
void
*
frame_ptr
,
bool
only_user_visible
)
{
ASTInterpreter
*
interpreter
=
getInterpreterFromFramePtr
(
frame_ptr
);
assert
(
interpreter
);
BoxedDict
*
localsForInterpretedFrame
(
Box
**
vregs
,
CFG
*
cfg
,
bool
only_user_visible
)
{
BoxedDict
*
rtn
=
new
BoxedDict
();
for
(
auto
&
l
:
interpreter
->
getSymVRegMap
()
)
{
for
(
auto
&
l
:
cfg
->
sym_vreg_map
)
{
if
(
only_user_visible
&&
(
l
.
first
.
s
()[
0
]
==
'!'
||
l
.
first
.
s
()[
0
]
==
'#'
))
continue
;
Box
*
val
=
interpreter
->
getVRegs
()
[
l
.
second
];
Box
*
val
=
vregs
[
l
.
second
];
if
(
val
)
{
assert
(
gc
::
isValidGCObject
(
val
));
rtn
->
d
[
l
.
first
.
getBox
()]
=
val
;
...
...
@@ -1991,6 +1981,12 @@ BoxedDict* localsForInterpretedFrame(void* frame_ptr, bool only_user_visible) {
return
rtn
;
}
BoxedDict
*
localsForInterpretedFrame
(
void
*
frame_ptr
,
bool
only_user_visible
)
{
ASTInterpreter
*
interpreter
=
getInterpreterFromFramePtr
(
frame_ptr
);
assert
(
interpreter
);
return
localsForInterpretedFrame
(
interpreter
->
getVRegs
(),
interpreter
->
getMD
()
->
source
->
cfg
,
only_user_visible
);
}
BoxedClosure
*
passedClosureForInterpretedFrame
(
void
*
frame_ptr
)
{
ASTInterpreter
*
interpreter
=
getInterpreterFromFramePtr
(
frame_ptr
);
assert
(
interpreter
);
...
...
src/codegen/ast_interpreter.h
View file @
b145b008
...
...
@@ -83,6 +83,7 @@ struct FrameInfo;
FrameInfo
*
getFrameInfoForInterpretedFrame
(
void
*
frame_ptr
);
BoxedClosure
*
passedClosureForInterpretedFrame
(
void
*
frame_ptr
);
BoxedDict
*
localsForInterpretedFrame
(
Box
**
vregs
,
CFG
*
cfg
,
bool
only_user_visible
);
BoxedDict
*
localsForInterpretedFrame
(
void
*
frame_ptr
,
bool
only_user_visible
);
// Executes the equivalent of CPython's PRINT_EXPR opcode (call sys.displayhook)
...
...
src/codegen/codegen.cpp
View file @
b145b008
...
...
@@ -30,6 +30,7 @@
#include "codegen/baseline_jit.h"
#include "codegen/compvars.h"
#include "core/ast.h"
#include "core/cfg.h"
#include "core/util.h"
#include "runtime/code.h"
#include "runtime/types.h"
...
...
@@ -72,6 +73,28 @@ BoxedCode* FunctionMetadata::getCode() {
return
code_obj
;
}
int
FunctionMetadata
::
calculateNumVRegs
()
{
SourceInfo
*
source_info
=
source
.
get
();
CFG
*
cfg
=
source_info
->
cfg
;
// Note: due to some (avoidable) restrictions, this check is pretty constrained in where
// it can go, due to the fact that it can throw an exception.
// It can't go in the ASTInterpreter constructor, since that will cause the C++ runtime to
// delete the partially-constructed memory which we don't currently handle. It can't go into
// executeInner since we want the SyntaxErrors to happen *before* the stack frame is entered.
// (For instance, throwing the exception will try to fetch the current statement, but we determine
// that by looking at the cfg.)
if
(
!
cfg
)
cfg
=
source_info
->
cfg
=
computeCFG
(
source_info
,
source_info
->
body
);
if
(
!
cfg
->
hasVregsAssigned
())
{
ScopeInfo
*
scope_info
=
source
->
getScopeInfo
();
cfg
->
assignVRegs
(
param_names
,
scope_info
);
}
return
cfg
->
sym_vreg_map
.
size
();
}
void
FunctionMetadata
::
addVersion
(
CompiledFunction
*
compiled
)
{
assert
(
compiled
);
assert
((
compiled
->
spec
!=
NULL
)
+
(
compiled
->
entry_descriptor
!=
NULL
)
==
1
);
...
...
src/core/types.h
View file @
b145b008
...
...
@@ -483,6 +483,8 @@ public:
void
addVersion
(
void
*
f
,
ConcreteCompilerType
*
rtn_type
,
const
std
::
vector
<
ConcreteCompilerType
*>&
arg_types
,
ExceptionStyle
exception_style
=
CXX
);
int
calculateNumVRegs
();
// Helper function, meant for the C++ runtime, which allocates a FunctionMetadata object and calls addVersion
// once to it.
static
FunctionMetadata
*
create
(
void
*
f
,
ConcreteCompilerType
*
rtn_type
,
int
nargs
,
bool
takes_varargs
,
...
...
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