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
9b485b19
Commit
9b485b19
authored
Mar 24, 2015
by
Chris Toshok
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use a ContiguousMap for the ast interpreter's symbol table to speed up scanning
parent
527289ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
12 deletions
+10
-12
src/codegen/ast_interpreter.cpp
src/codegen/ast_interpreter.cpp
+10
-12
No files found.
src/codegen/ast_interpreter.cpp
View file @
9b485b19
...
...
@@ -30,6 +30,7 @@
#include "core/ast.h"
#include "core/cfg.h"
#include "core/common.h"
#include "core/contiguous_map.h"
#include "core/stats.h"
#include "core/thread_utils.h"
#include "core/util.h"
...
...
@@ -69,7 +70,7 @@ union Value {
class
ASTInterpreter
{
public:
typedef
llvm
::
Dense
Map
<
InternedString
,
Box
*>
SymMap
;
typedef
Contiguous
Map
<
InternedString
,
Box
*>
SymMap
;
ASTInterpreter
(
CompiledFunction
*
compiled_function
);
...
...
@@ -195,10 +196,7 @@ void ASTInterpreter::setFrameInfo(const FrameInfo* frame_info) {
}
void
ASTInterpreter
::
gcVisit
(
GCVisitor
*
visitor
)
{
for
(
const
auto
&
p2
:
getSymbolTable
())
{
visitor
->
visitPotential
(
p2
.
second
);
}
visitor
->
visitRange
((
void
*
const
*
)
&
sym_table
.
vector
()[
0
],
(
void
*
const
*
)
&
sym_table
.
vector
()[
sym_table
.
size
()]);
if
(
passed_closure
)
visitor
->
visit
(
passed_closure
);
if
(
created_closure
)
...
...
@@ -315,7 +313,7 @@ void ASTInterpreter::eraseDeadSymbols() {
source_info
->
liveness
,
scope_info
);
std
::
vector
<
InternedString
>
dead_symbols
;
for
(
auto
&
&
it
:
sym_table
)
{
for
(
auto
&
it
:
sym_table
)
{
if
(
!
source_info
->
liveness
->
isLiveAtEnd
(
it
.
first
,
current_block
))
{
dead_symbols
.
push_back
(
it
.
first
);
}
else
if
(
source_info
->
phis
->
isRequiredAfter
(
it
.
first
,
current_block
))
{
...
...
@@ -455,11 +453,11 @@ Value ASTInterpreter::visit_jump(AST_Jump* node) {
// TODO only mangle once
sorted_symbol_table
[
getIsDefinedName
(
name
,
source_info
->
getInternedStrings
())]
=
(
Box
*
)
is_defined
;
if
(
is_defined
)
assert
(
it
->
second
!=
NULL
);
sorted_symbol_table
[
name
]
=
is_defined
?
it
->
second
:
NULL
;
assert
(
sym_table
.
getMapped
(
it
->
second
)
!=
NULL
);
sorted_symbol_table
[
name
]
=
is_defined
?
sym_table
.
getMapped
(
it
->
second
)
:
NULL
;
}
else
{
ASSERT
(
it
!=
sym_table
.
end
(),
"%s"
,
name
.
c_str
());
sorted_symbol_table
[
it
->
first
]
=
it
->
second
;
sorted_symbol_table
[
it
->
first
]
=
sym_table
.
getMapped
(
it
->
second
)
;
}
}
...
...
@@ -1088,7 +1086,7 @@ Value ASTInterpreter::visit_name(AST_Name* node) {
case
ScopeInfo
:
:
VarScopeType
::
CLOSURE
:
{
SymMap
::
iterator
it
=
sym_table
.
find
(
node
->
id
);
if
(
it
!=
sym_table
.
end
())
return
it
->
second
;
return
sym_table
.
getMapped
(
it
->
second
)
;
assertNameDefined
(
0
,
node
->
id
.
c_str
(),
UnboundLocalError
,
true
);
return
Value
();
...
...
@@ -1269,11 +1267,11 @@ BoxedDict* localsForInterpretedFrame(void* frame_ptr, bool only_user_visible) {
ASTInterpreter
*
interpreter
=
s_interpreterMap
[
frame_ptr
];
assert
(
interpreter
);
BoxedDict
*
rtn
=
new
BoxedDict
();
for
(
auto
&
&
l
:
interpreter
->
getSymbolTable
())
{
for
(
auto
&
l
:
interpreter
->
getSymbolTable
())
{
if
(
only_user_visible
&&
(
l
.
first
.
str
()[
0
]
==
'!'
||
l
.
first
.
str
()[
0
]
==
'#'
))
continue
;
rtn
->
d
[
new
BoxedString
(
l
.
first
.
str
())]
=
l
.
second
;
rtn
->
d
[
boxString
(
l
.
first
.
str
())]
=
interpreter
->
getSymbolTable
().
getMapped
(
l
.
second
)
;
}
return
rtn
;
...
...
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