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
d94088be
Commit
d94088be
authored
Apr 06, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reformat
parent
9e42fe36
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
19 deletions
+30
-19
src/analysis/scoping_analysis.cpp
src/analysis/scoping_analysis.cpp
+17
-11
src/codegen/ast_interpreter.cpp
src/codegen/ast_interpreter.cpp
+7
-4
src/codegen/ast_interpreter.h
src/codegen/ast_interpreter.h
+2
-2
src/runtime/generator.cpp
src/runtime/generator.cpp
+2
-1
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+2
-1
No files found.
src/analysis/scoping_analysis.cpp
View file @
d94088be
...
@@ -278,8 +278,10 @@ private:
...
@@ -278,8 +278,10 @@ private:
bool
globals_from_module
;
bool
globals_from_module
;
public:
public:
ScopeInfoBase
(
ScopeInfo
*
parent
,
ScopingAnalysis
::
ScopeNameUsage
*
usage
,
AST
*
ast
,
bool
usesNameLookup
,
bool
globals_from_module
)
ScopeInfoBase
(
ScopeInfo
*
parent
,
ScopingAnalysis
::
ScopeNameUsage
*
usage
,
AST
*
ast
,
bool
usesNameLookup
,
:
parent
(
parent
),
usage
(
usage
),
ast
(
ast
),
usesNameLookup_
(
usesNameLookup
),
allDerefVarsAndInfoCached
(
false
),
globals_from_module
(
globals_from_module
)
{
bool
globals_from_module
)
:
parent
(
parent
),
usage
(
usage
),
ast
(
ast
),
usesNameLookup_
(
usesNameLookup
),
allDerefVarsAndInfoCached
(
false
),
globals_from_module
(
globals_from_module
)
{
assert
(
usage
);
assert
(
usage
);
assert
(
ast
);
assert
(
ast
);
...
@@ -817,8 +819,8 @@ void ScopingAnalysis::processNameUsages(ScopingAnalysis::NameUsageMap* usages) {
...
@@ -817,8 +819,8 @@ void ScopingAnalysis::processNameUsages(ScopingAnalysis::NameUsageMap* usages) {
switch
(
node
->
type
)
{
switch
(
node
->
type
)
{
case
AST_TYPE
:
:
ClassDef
:
{
case
AST_TYPE
:
:
ClassDef
:
{
ScopeInfoBase
*
scopeInfo
ScopeInfoBase
*
scopeInfo
=
new
ScopeInfoBase
(
parent_info
,
usage
,
usage
->
node
,
true
/* usesNameLookup */
,
=
new
ScopeInfoBase
(
parent_info
,
usage
,
usage
->
node
,
true
/* usesNameLookup */
,
globals_from_module
);
globals_from_module
);
this
->
scopes
[
node
]
=
scopeInfo
;
this
->
scopes
[
node
]
=
scopeInfo
;
break
;
break
;
}
}
...
@@ -827,10 +829,11 @@ void ScopingAnalysis::processNameUsages(ScopingAnalysis::NameUsageMap* usages) {
...
@@ -827,10 +829,11 @@ void ScopingAnalysis::processNameUsages(ScopingAnalysis::NameUsageMap* usages) {
case
AST_TYPE
:
:
GeneratorExp
:
case
AST_TYPE
:
:
GeneratorExp
:
case
AST_TYPE
:
:
DictComp
:
case
AST_TYPE
:
:
DictComp
:
case
AST_TYPE
:
:
SetComp
:
{
case
AST_TYPE
:
:
SetComp
:
{
ScopeInfoBase
*
scopeInfo
=
new
ScopeInfoBase
(
parent_info
,
usage
,
usage
->
node
,
ScopeInfoBase
*
scopeInfo
usage
->
hasNameForcingSyntax
()
/* usesNameLookup */
,
=
new
ScopeInfoBase
(
parent_info
,
usage
,
usage
->
node
,
globals_from_module
);
usage
->
hasNameForcingSyntax
()
/* usesNameLookup */
,
globals_from_module
);
this
->
scopes
[
node
]
=
scopeInfo
;
break
;
this
->
scopes
[
node
]
=
scopeInfo
;
break
;
}
}
default:
default:
RELEASE_ASSERT
(
0
,
"%d"
,
usage
->
node
->
type
);
RELEASE_ASSERT
(
0
,
"%d"
,
usage
->
node
->
type
);
...
@@ -884,16 +887,19 @@ ScopeInfo* ScopingAnalysis::getScopeInfoForNode(AST* node) {
...
@@ -884,16 +887,19 @@ ScopeInfo* ScopingAnalysis::getScopeInfoForNode(AST* node) {
return
analyzeSubtree
(
node
);
return
analyzeSubtree
(
node
);
}
}
ScopingAnalysis
::
ScopingAnalysis
(
AST_Module
*
m
)
:
parent_module
(
m
),
interned_strings
(
*
m
->
interned_strings
.
get
()),
globals_from_module
(
true
)
{
ScopingAnalysis
::
ScopingAnalysis
(
AST_Module
*
m
)
:
parent_module
(
m
),
interned_strings
(
*
m
->
interned_strings
.
get
()),
globals_from_module
(
true
)
{
scopes
[
m
]
=
new
ModuleScopeInfo
();
scopes
[
m
]
=
new
ModuleScopeInfo
();
}
}
ScopingAnalysis
::
ScopingAnalysis
(
AST_Expression
*
e
,
bool
globals_from_module
)
:
interned_strings
(
*
e
->
interned_strings
.
get
()),
globals_from_module
(
globals_from_module
)
{
ScopingAnalysis
::
ScopingAnalysis
(
AST_Expression
*
e
,
bool
globals_from_module
)
:
interned_strings
(
*
e
->
interned_strings
.
get
()),
globals_from_module
(
globals_from_module
)
{
// It's an expression, so it can't have a `global` statement
// It's an expression, so it can't have a `global` statement
scopes
[
e
]
=
new
EvalExprScopeInfo
(
globals_from_module
);
scopes
[
e
]
=
new
EvalExprScopeInfo
(
globals_from_module
);
}
}
ScopingAnalysis
::
ScopingAnalysis
(
AST_Suite
*
s
,
bool
globals_from_module
)
:
interned_strings
(
*
s
->
interned_strings
.
get
()),
globals_from_module
(
globals_from_module
)
{
ScopingAnalysis
::
ScopingAnalysis
(
AST_Suite
*
s
,
bool
globals_from_module
)
:
interned_strings
(
*
s
->
interned_strings
.
get
()),
globals_from_module
(
globals_from_module
)
{
scopes
[
s
]
=
new
EvalExprScopeInfo
(
s
,
globals_from_module
);
scopes
[
s
]
=
new
EvalExprScopeInfo
(
s
,
globals_from_module
);
}
}
}
}
src/codegen/ast_interpreter.cpp
View file @
d94088be
...
@@ -742,7 +742,8 @@ Box* ASTInterpreter::createFunction(AST* node, AST_arguments* args, const std::v
...
@@ -742,7 +742,8 @@ Box* ASTInterpreter::createFunction(AST* node, AST_arguments* args, const std::v
}
}
assert
(
closure
);
assert
(
closure
);
}
}
return
boxCLFunction
(
cl
,
closure
,
is_generator
,
globals
->
cls
==
dict_cls
?
static_cast
<
BoxedDict
*>
(
globals
)
:
NULL
,
u
.
il
);
return
boxCLFunction
(
cl
,
closure
,
is_generator
,
globals
->
cls
==
dict_cls
?
static_cast
<
BoxedDict
*>
(
globals
)
:
NULL
,
u
.
il
);
}
}
Value
ASTInterpreter
::
visit_makeFunction
(
AST_MakeFunction
*
mkfn
)
{
Value
ASTInterpreter
::
visit_makeFunction
(
AST_MakeFunction
*
mkfn
)
{
...
@@ -778,7 +779,9 @@ Value ASTInterpreter::visit_makeClass(AST_MakeClass* mkclass) {
...
@@ -778,7 +779,9 @@ Value ASTInterpreter::visit_makeClass(AST_MakeClass* mkclass) {
BoxedClosure
*
closure
=
scope_info
->
takesClosure
()
?
created_closure
:
0
;
BoxedClosure
*
closure
=
scope_info
->
takesClosure
()
?
created_closure
:
0
;
CLFunction
*
cl
=
wrapFunction
(
node
,
nullptr
,
node
->
body
,
source_info
);
CLFunction
*
cl
=
wrapFunction
(
node
,
nullptr
,
node
->
body
,
source_info
);
Box
*
attrDict
=
runtimeCall
(
boxCLFunction
(
cl
,
closure
,
false
,
globals
->
cls
==
dict_cls
?
static_cast
<
BoxedDict
*>
(
globals
)
:
NULL
,
{}),
ArgPassSpec
(
0
),
0
,
0
,
0
,
0
,
0
);
Box
*
attrDict
=
runtimeCall
(
boxCLFunction
(
cl
,
closure
,
false
,
globals
->
cls
==
dict_cls
?
static_cast
<
BoxedDict
*>
(
globals
)
:
NULL
,
{}),
ArgPassSpec
(
0
),
0
,
0
,
0
,
0
,
0
);
Box
*
classobj
=
createUserClass
(
&
node
->
name
.
str
(),
basesTuple
,
attrDict
);
Box
*
classobj
=
createUserClass
(
&
node
->
name
.
str
(),
basesTuple
,
attrDict
);
...
@@ -1164,8 +1167,8 @@ Value ASTInterpreter::visit_attribute(AST_Attribute* node) {
...
@@ -1164,8 +1167,8 @@ Value ASTInterpreter::visit_attribute(AST_Attribute* node) {
const
void
*
interpreter_instr_addr
=
(
void
*
)
&
ASTInterpreter
::
execute
;
const
void
*
interpreter_instr_addr
=
(
void
*
)
&
ASTInterpreter
::
execute
;
Box
*
astInterpretFunction
(
CompiledFunction
*
cf
,
int
nargs
,
Box
*
closure
,
Box
*
generator
,
BoxedDict
*
globals
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
astInterpretFunction
(
CompiledFunction
*
cf
,
int
nargs
,
Box
*
closure
,
Box
*
generator
,
BoxedDict
*
globals
,
Box
*
arg1
,
Box
*
arg3
,
Box
**
args
)
{
Box
*
arg
2
,
Box
*
arg
3
,
Box
**
args
)
{
if
(
unlikely
(
cf
->
times_called
>
REOPT_THRESHOLD_INTERPRETER
&&
ENABLE_REOPT
&&
!
FORCE_INTERPRETER
))
{
if
(
unlikely
(
cf
->
times_called
>
REOPT_THRESHOLD_INTERPRETER
&&
ENABLE_REOPT
&&
!
FORCE_INTERPRETER
))
{
CompiledFunction
*
optimized
=
reoptCompiledFuncInternal
(
cf
);
CompiledFunction
*
optimized
=
reoptCompiledFuncInternal
(
cf
);
if
(
closure
&&
generator
)
if
(
closure
&&
generator
)
...
...
src/codegen/ast_interpreter.h
View file @
d94088be
...
@@ -33,8 +33,8 @@ struct LineInfo;
...
@@ -33,8 +33,8 @@ struct LineInfo;
extern
const
void
*
interpreter_instr_addr
;
extern
const
void
*
interpreter_instr_addr
;
Box
*
astInterpretFunction
(
CompiledFunction
*
f
,
int
nargs
,
Box
*
closure
,
Box
*
generator
,
BoxedDict
*
globals
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
*
astInterpretFunction
(
CompiledFunction
*
f
,
int
nargs
,
Box
*
closure
,
Box
*
generator
,
BoxedDict
*
globals
,
Box
*
arg1
,
Box
**
args
);
Box
*
arg2
,
Box
*
arg3
,
Box
*
*
args
);
Box
*
astInterpretFunctionEval
(
CompiledFunction
*
cf
,
BoxedDict
*
globals
,
Box
*
boxedLocals
);
Box
*
astInterpretFunctionEval
(
CompiledFunction
*
cf
,
BoxedDict
*
globals
,
Box
*
boxedLocals
);
Box
*
astInterpretFrom
(
CompiledFunction
*
cf
,
AST_expr
*
after_expr
,
AST_stmt
*
enclosing_stmt
,
Box
*
expr_val
,
Box
*
astInterpretFrom
(
CompiledFunction
*
cf
,
AST_expr
*
after_expr
,
AST_stmt
*
enclosing_stmt
,
Box
*
expr_val
,
FrameStackState
frame_state
);
FrameStackState
frame_state
);
...
...
src/runtime/generator.cpp
View file @
d94088be
...
@@ -95,7 +95,8 @@ void generatorEntry(BoxedGenerator* g) {
...
@@ -95,7 +95,8 @@ void generatorEntry(BoxedGenerator* g) {
BoxedFunctionBase
*
func
=
g
->
function
;
BoxedFunctionBase
*
func
=
g
->
function
;
Box
**
args
=
g
->
args
?
&
g
->
args
->
elts
[
0
]
:
nullptr
;
Box
**
args
=
g
->
args
?
&
g
->
args
->
elts
[
0
]
:
nullptr
;
callCLFunc
(
func
->
f
,
nullptr
,
func
->
f
->
numReceivedArgs
(),
func
->
closure
,
g
,
func
->
globals
,
g
->
arg1
,
g
->
arg2
,
g
->
arg3
,
args
);
callCLFunc
(
func
->
f
,
nullptr
,
func
->
f
->
numReceivedArgs
(),
func
->
closure
,
g
,
func
->
globals
,
g
->
arg1
,
g
->
arg2
,
g
->
arg3
,
args
);
}
catch
(
ExcInfo
e
)
{
}
catch
(
ExcInfo
e
)
{
// unhandled exception: propagate the exception to the caller
// unhandled exception: propagate the exception to the caller
g
->
exception
=
e
;
g
->
exception
=
e
;
...
...
src/runtime/objmodel.cpp
View file @
d94088be
...
@@ -2936,7 +2936,8 @@ Box* callCLFunc(CLFunction* f, CallRewriteArgs* rewrite_args, int num_output_arg
...
@@ -2936,7 +2936,8 @@ Box* callCLFunc(CLFunction* f, CallRewriteArgs* rewrite_args, int num_output_arg
assert
(
chosen_cf
->
is_interpreted
==
(
chosen_cf
->
code
==
NULL
));
assert
(
chosen_cf
->
is_interpreted
==
(
chosen_cf
->
code
==
NULL
));
if
(
chosen_cf
->
is_interpreted
)
{
if
(
chosen_cf
->
is_interpreted
)
{
return
astInterpretFunction
(
chosen_cf
,
num_output_args
,
closure
,
generator
,
globals
,
oarg1
,
oarg2
,
oarg3
,
oargs
);
return
astInterpretFunction
(
chosen_cf
,
num_output_args
,
closure
,
generator
,
globals
,
oarg1
,
oarg2
,
oarg3
,
oargs
);
}
}
if
(
rewrite_args
)
{
if
(
rewrite_args
)
{
...
...
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