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
a1100ede
Commit
a1100ede
authored
Apr 21, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #457 from undingen/speedup
Speed-up analysis and irgen
parents
14990c7f
63eddb94
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
18 deletions
+30
-18
src/analysis/function_analysis.cpp
src/analysis/function_analysis.cpp
+6
-6
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+9
-9
src/codegen/irgen/util.cpp
src/codegen/irgen/util.cpp
+12
-2
src/codegen/irgen/util.h
src/codegen/irgen/util.h
+3
-1
No files found.
src/analysis/function_analysis.cpp
View file @
a1100ede
...
@@ -169,8 +169,6 @@ bool LivenessAnalysis::isKill(AST_Name* node, CFGBlock* parent_block) {
...
@@ -169,8 +169,6 @@ bool LivenessAnalysis::isKill(AST_Name* node, CFGBlock* parent_block) {
}
}
bool
LivenessAnalysis
::
isLiveAtEnd
(
InternedString
name
,
CFGBlock
*
block
)
{
bool
LivenessAnalysis
::
isLiveAtEnd
(
InternedString
name
,
CFGBlock
*
block
)
{
Timer
_t
(
"LivenessAnalysis()"
,
10
);
if
(
name
.
str
()[
0
]
!=
'#'
)
if
(
name
.
str
()[
0
]
!=
'#'
)
return
true
;
return
true
;
...
@@ -178,6 +176,8 @@ bool LivenessAnalysis::isLiveAtEnd(InternedString name, CFGBlock* block) {
...
@@ -178,6 +176,8 @@ bool LivenessAnalysis::isLiveAtEnd(InternedString name, CFGBlock* block) {
return
false
;
return
false
;
if
(
!
result_cache
.
count
(
name
))
{
if
(
!
result_cache
.
count
(
name
))
{
Timer
_t
(
"LivenessAnalysis()"
,
10
);
llvm
::
DenseMap
<
CFGBlock
*
,
bool
>&
map
=
result_cache
[
name
];
llvm
::
DenseMap
<
CFGBlock
*
,
bool
>&
map
=
result_cache
[
name
];
// Approach:
// Approach:
...
@@ -208,11 +208,11 @@ bool LivenessAnalysis::isLiveAtEnd(InternedString name, CFGBlock* block) {
...
@@ -208,11 +208,11 @@ bool LivenessAnalysis::isLiveAtEnd(InternedString name, CFGBlock* block) {
}
}
}
}
}
}
}
// Note: this one gets counted as part of us_compiling_irgen as well:
// Note: this one gets counted as part of us_compiling_irgen as well:
static
StatCounter
us_liveness
(
"us_compiling_analysis_liveness"
);
static
StatCounter
us_liveness
(
"us_compiling_analysis_liveness"
);
us_liveness
.
log
(
_t
.
end
());
us_liveness
.
log
(
_t
.
end
());
}
return
result_cache
[
name
][
block
];
return
result_cache
[
name
][
block
];
}
}
...
...
src/codegen/irgen/irgenerator.cpp
View file @
a1100ede
...
@@ -910,14 +910,13 @@ private:
...
@@ -910,14 +910,13 @@ private:
}
}
ConcreteCompilerVariable
*
getNone
()
{
ConcreteCompilerVariable
*
getNone
()
{
ConcreteCompilerVariable
*
v
=
new
ConcreteCompilerVariable
(
llvm
::
Constant
*
none
=
embedRelocatablePtr
(
None
,
g
.
llvm_value_type_ptr
,
"cNone"
);
typeFromClass
(
none_cls
),
embedRelocatablePtr
(
None
,
g
.
llvm_value_type_ptr
),
false
);
return
new
ConcreteCompilerVariable
(
typeFromClass
(
none_cls
),
none
,
false
);
return
v
;
}
}
llvm
::
Constant
*
embedParentModulePtr
()
{
llvm
::
Constant
*
embedParentModulePtr
()
{
// TODO: We could reuse the name to reduce the number of relocatable pointers.
BoxedModule
*
parent_module
=
irstate
->
getSourceInfo
()
->
parent_module
;
return
embedRelocatablePtr
(
irstate
->
getSourceInfo
()
->
parent_module
,
g
.
llvm_module_type_ptr
);
return
embedRelocatablePtr
(
parent_module
,
g
.
llvm_module_type_ptr
,
"cParentModule"
);
}
}
ConcreteCompilerVariable
*
_getGlobal
(
AST_Name
*
node
,
UnwindInfo
unw_info
)
{
ConcreteCompilerVariable
*
_getGlobal
(
AST_Name
*
node
,
UnwindInfo
unw_info
)
{
...
@@ -2150,7 +2149,7 @@ private:
...
@@ -2150,7 +2149,7 @@ private:
v
->
decvref
(
emitter
);
v
->
decvref
(
emitter
);
args
.
push_back
(
converted
->
getValue
());
args
.
push_back
(
converted
->
getValue
());
}
else
{
}
else
{
args
.
push_back
(
embedRelocatablePtr
(
None
,
g
.
llvm_value_type_ptr
));
args
.
push_back
(
embedRelocatablePtr
(
None
,
g
.
llvm_value_type_ptr
,
"cNone"
));
}
}
}
}
...
@@ -2363,11 +2362,12 @@ public:
...
@@ -2363,11 +2362,12 @@ public:
if
(
ENABLE_FRAME_INTROSPECTION
)
{
if
(
ENABLE_FRAME_INTROSPECTION
)
{
// TODO: don't need to use a sorted symbol table if we're explicitly recording the names!
// TODO: don't need to use a sorted symbol table if we're explicitly recording the names!
// nice for debugging though.
// nice for debugging though.
SortedSymbolTable
sorted_symbol_table
(
symbol_table
.
begin
(),
symbol_table
.
end
());
typedef
std
::
pair
<
InternedString
,
CompilerVariable
*>
Entry
;
std
::
vector
<
Entry
>
sorted_symbol_table
(
symbol_table
.
begin
(),
symbol_table
.
end
());
std
::
sort
(
sorted_symbol_table
.
begin
(),
sorted_symbol_table
.
end
(),
[](
const
Entry
&
lhs
,
const
Entry
&
rhs
)
{
return
lhs
.
first
<
rhs
.
first
;
});
for
(
const
auto
&
p
:
sorted_symbol_table
)
{
for
(
const
auto
&
p
:
sorted_symbol_table
)
{
CompilerVariable
*
v
=
p
.
second
;
CompilerVariable
*
v
=
p
.
second
;
v
->
serializeToFrame
(
stackmap_args
);
v
->
serializeToFrame
(
stackmap_args
);
pp
->
addFrameVar
(
p
.
first
.
str
(),
v
->
getType
());
pp
->
addFrameVar
(
p
.
first
.
str
(),
v
->
getType
());
}
}
...
...
src/codegen/irgen/util.cpp
View file @
a1100ede
...
@@ -106,13 +106,23 @@ const void* getValueOfRelocatableSym(const std::string& str) {
...
@@ -106,13 +106,23 @@ const void* getValueOfRelocatableSym(const std::string& str) {
return
NULL
;
return
NULL
;
}
}
llvm
::
Constant
*
embedRelocatablePtr
(
const
void
*
addr
,
llvm
::
Type
*
type
)
{
llvm
::
Constant
*
embedRelocatablePtr
(
const
void
*
addr
,
llvm
::
Type
*
type
,
llvm
::
StringRef
shared_name
)
{
assert
(
addr
);
assert
(
addr
);
if
(
!
ENABLE_JIT_OBJECT_CACHE
)
if
(
!
ENABLE_JIT_OBJECT_CACHE
)
return
embedConstantPtr
(
addr
,
type
);
return
embedConstantPtr
(
addr
,
type
);
std
::
string
name
=
(
llvm
::
Twine
(
"c"
)
+
llvm
::
Twine
(
relocatable_syms
.
size
())).
str
();
std
::
string
name
;
if
(
!
shared_name
.
empty
())
{
llvm
::
GlobalVariable
*
gv
=
g
.
cur_module
->
getGlobalVariable
(
shared_name
,
true
);
if
(
gv
)
return
gv
;
assert
(
!
relocatable_syms
.
count
(
name
));
name
=
shared_name
;
}
else
{
name
=
(
llvm
::
Twine
(
"c"
)
+
llvm
::
Twine
(
relocatable_syms
.
size
())).
str
();
}
relocatable_syms
[
name
]
=
addr
;
relocatable_syms
[
name
]
=
addr
;
llvm
::
Type
*
var_type
=
type
->
getPointerElementType
();
llvm
::
Type
*
var_type
=
type
->
getPointerElementType
();
...
...
src/codegen/irgen/util.h
View file @
a1100ede
...
@@ -17,6 +17,8 @@
...
@@ -17,6 +17,8 @@
#include <string>
#include <string>
#include "llvm/ADT/StringRef.h"
namespace
llvm
{
namespace
llvm
{
class
Constant
;
class
Constant
;
class
Function
;
class
Function
;
...
@@ -27,7 +29,7 @@ namespace pyston {
...
@@ -27,7 +29,7 @@ namespace pyston {
llvm
::
Constant
*
getStringConstantPtr
(
const
std
::
string
&
str
);
llvm
::
Constant
*
getStringConstantPtr
(
const
std
::
string
&
str
);
llvm
::
Constant
*
getStringConstantPtr
(
const
char
*
str
);
llvm
::
Constant
*
getStringConstantPtr
(
const
char
*
str
);
llvm
::
Constant
*
embedRelocatablePtr
(
const
void
*
addr
,
llvm
::
Type
*
);
llvm
::
Constant
*
embedRelocatablePtr
(
const
void
*
addr
,
llvm
::
Type
*
,
llvm
::
StringRef
shared_name
=
llvm
::
StringRef
()
);
llvm
::
Constant
*
embedConstantPtr
(
const
void
*
addr
,
llvm
::
Type
*
);
llvm
::
Constant
*
embedConstantPtr
(
const
void
*
addr
,
llvm
::
Type
*
);
llvm
::
Constant
*
getConstantInt
(
int64_t
val
);
llvm
::
Constant
*
getConstantInt
(
int64_t
val
);
llvm
::
Constant
*
getConstantDouble
(
double
val
);
llvm
::
Constant
*
getConstantDouble
(
double
val
);
...
...
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