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
6e413130
Commit
6e413130
authored
Jul 14, 2015
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Slightly speedup ASTInterpreter::initArguments
parent
9f7a8d19
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
16 deletions
+34
-16
src/codegen/ast_interpreter.cpp
src/codegen/ast_interpreter.cpp
+14
-12
src/codegen/irgen/hooks.cpp
src/codegen/irgen/hooks.cpp
+12
-3
src/core/types.h
src/core/types.h
+8
-1
No files found.
src/codegen/ast_interpreter.cpp
View file @
6e413130
...
...
@@ -35,6 +35,7 @@
#include "core/stats.h"
#include "core/thread_utils.h"
#include "core/util.h"
#include "gc/roots.h"
#include "runtime/generator.h"
#include "runtime/import.h"
#include "runtime/inline/boxing.h"
...
...
@@ -299,24 +300,25 @@ void ASTInterpreter::initArguments(int nargs, BoxedClosure* _closure, BoxedGener
if
(
scope_info
->
createsClosure
())
created_closure
=
createClosure
(
passed_closure
,
scope_info
->
getClosureSize
());
std
::
vector
<
Box
*
,
StlCompatAllocator
<
Box
*>>
argsArray
{
arg1
,
arg2
,
arg3
};
for
(
int
i
=
3
;
i
<
nargs
;
++
i
)
argsArray
.
push_back
(
args
[
i
-
3
]);
const
ParamNames
&
param_names
=
clfunc
->
param_names
;
// make sure the AST_Name nodes are set
assert
(
param_names
.
args
.
size
()
==
param_names
.
arg_names
.
size
());
assert
(
param_names
.
vararg
.
empty
()
==
(
param_names
.
vararg_name
==
NULL
));
assert
(
param_names
.
kwarg
.
empty
()
==
(
param_names
.
kwarg_name
==
NULL
));
int
i
=
0
;
for
(
auto
&
name
:
param_names
.
args
)
{
doStore
(
source_info
->
getInternedStrings
().
get
(
name
),
Value
(
argsArray
[
i
++
]
,
0
));
for
(
auto
&
name
:
param_names
.
arg
_name
s
)
{
doStore
(
name
,
Value
(
getArg
(
i
++
,
arg1
,
arg2
,
arg3
,
args
)
,
0
));
}
if
(
!
param_names
.
vararg
.
str
().
empty
())
{
doStore
(
source_info
->
getInternedStrings
().
get
(
param_names
.
vararg
),
Value
(
argsArray
[
i
++
],
0
));
}
if
(
param_names
.
vararg_name
)
doStore
(
param_names
.
vararg_name
,
Value
(
getArg
(
i
++
,
arg1
,
arg2
,
arg3
,
args
),
0
));
if
(
!
param_names
.
kwarg
.
str
().
empty
())
{
doStore
(
source_info
->
getInternedStrings
().
get
(
param_names
.
kwarg
),
Value
(
argsArray
[
i
++
],
0
));
}
if
(
param_names
.
kwarg_name
)
doStore
(
param_names
.
kwarg_name
,
Value
(
getArg
(
i
++
,
arg1
,
arg2
,
arg3
,
args
),
0
));
assert
(
nargs
==
i
);
}
RegisterHelper
::
RegisterHelper
()
:
frame_addr
(
NULL
),
interpreter
(
NULL
)
{
...
...
src/codegen/irgen/hooks.cpp
View file @
6e413130
...
...
@@ -45,7 +45,8 @@
namespace
pyston
{
// TODO terrible place for these!
ParamNames
::
ParamNames
(
AST
*
ast
,
InternedStringPool
&
pool
)
:
takes_param_names
(
true
)
{
ParamNames
::
ParamNames
(
AST
*
ast
,
InternedStringPool
&
pool
)
:
takes_param_names
(
true
),
vararg_name
(
NULL
),
kwarg_name
(
NULL
)
{
if
(
ast
->
type
==
AST_TYPE
::
Module
||
ast
->
type
==
AST_TYPE
::
ClassDef
||
ast
->
type
==
AST_TYPE
::
Expression
||
ast
->
type
==
AST_TYPE
::
Suite
)
{
kwarg
=
""
;
...
...
@@ -56,22 +57,30 @@ ParamNames::ParamNames(AST* ast, InternedStringPool& pool) : takes_param_names(t
for
(
int
i
=
0
;
i
<
arguments
->
args
.
size
();
i
++
)
{
AST_expr
*
arg
=
arguments
->
args
[
i
];
if
(
arg
->
type
==
AST_TYPE
::
Name
)
{
args
.
push_back
(
ast_cast
<
AST_Name
>
(
arg
)
->
id
.
s
());
AST_Name
*
name
=
ast_cast
<
AST_Name
>
(
arg
);
arg_names
.
push_back
(
name
);
args
.
push_back
(
name
->
id
.
s
());
}
else
{
InternedString
dot_arg_name
=
pool
.
get
(
"."
+
std
::
to_string
(
i
));
arg_names
.
push_back
(
new
AST_Name
(
dot_arg_name
,
AST_TYPE
::
Param
,
arg
->
lineno
,
arg
->
col_offset
));
args
.
push_back
(
dot_arg_name
.
s
());
}
}
vararg
=
arguments
->
vararg
.
s
();
if
(
vararg
.
size
())
vararg_name
=
new
AST_Name
(
pool
.
get
(
vararg
),
AST_TYPE
::
Param
,
arguments
->
lineno
,
arguments
->
col_offset
);
kwarg
=
arguments
->
kwarg
.
s
();
if
(
kwarg
.
size
())
kwarg_name
=
new
AST_Name
(
pool
.
get
(
kwarg
),
AST_TYPE
::
Param
,
arguments
->
lineno
,
arguments
->
col_offset
);
}
else
{
RELEASE_ASSERT
(
0
,
"%d"
,
ast
->
type
);
}
}
ParamNames
::
ParamNames
(
const
std
::
vector
<
llvm
::
StringRef
>&
args
,
llvm
::
StringRef
vararg
,
llvm
::
StringRef
kwarg
)
:
takes_param_names
(
true
)
{
:
takes_param_names
(
true
)
,
vararg_name
(
NULL
),
kwarg_name
(
NULL
)
{
this
->
args
=
args
;
this
->
vararg
=
vararg
;
this
->
kwarg
=
kwarg
;
...
...
src/core/types.h
View file @
6e413130
...
...
@@ -95,6 +95,7 @@ class AST;
class
AST_FunctionDef
;
class
AST_arguments
;
class
AST_expr
;
class
AST_Name
;
class
AST_stmt
;
class
PhiAnalysis
;
...
...
@@ -147,6 +148,12 @@ struct ParamNames {
std
::
vector
<
llvm
::
StringRef
>
args
;
llvm
::
StringRef
vararg
,
kwarg
;
// This members are only set if the InternedStringPool& constructor is used (aka. source is available)!
// They are used as an optimization while interpreting because the AST_Names nodes cache important stuff
// (InternedString, lookup_type) which would otherwise have to get recomputed all the time.
std
::
vector
<
AST_Name
*>
arg_names
;
AST_Name
*
vararg_name
,
*
kwarg_name
;
explicit
ParamNames
(
AST
*
ast
,
InternedStringPool
&
pool
);
ParamNames
(
const
std
::
vector
<
llvm
::
StringRef
>&
args
,
llvm
::
StringRef
vararg
,
llvm
::
StringRef
kwarg
);
static
ParamNames
empty
()
{
return
ParamNames
();
}
...
...
@@ -156,7 +163,7 @@ struct ParamNames {
}
private:
ParamNames
()
:
takes_param_names
(
false
)
{}
ParamNames
()
:
takes_param_names
(
false
)
,
vararg_name
(
NULL
),
kwarg_name
(
NULL
)
{}
};
// Probably overkill to copy this from ArgPassSpec
...
...
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