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
d8f237b3
Commit
d8f237b3
authored
Aug 04, 2016
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete the llvm module
this saves a lot of memory
parent
fca39ba9
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
37 additions
and
28 deletions
+37
-28
src/codegen/compvars.cpp
src/codegen/compvars.cpp
+3
-2
src/codegen/irgen.cpp
src/codegen/irgen.cpp
+7
-7
src/codegen/irgen.h
src/codegen/irgen.h
+3
-3
src/codegen/irgen/hooks.cpp
src/codegen/irgen/hooks.cpp
+16
-10
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+3
-2
src/codegen/irgen/irgenerator.h
src/codegen/irgen/irgenerator.h
+5
-3
src/core/types.h
src/core/types.h
+0
-1
No files found.
src/codegen/compvars.cpp
View file @
d8f237b3
...
...
@@ -637,7 +637,8 @@ _call(IREmitter& emitter, const OpInfo& info, llvm::Value* func, ExceptionStyle
// Don't use the IRBuilder since we want to specifically put this in the entry block so it only gets called
// once.
// TODO we could take this further and use the same alloca for all function calls?
llvm
::
Instruction
*
insertion_point
=
emitter
.
currentFunction
()
->
func
->
getEntryBlock
().
getFirstInsertionPt
();
llvm
::
Instruction
*
insertion_point
=
emitter
.
getBuilder
()
->
GetInsertBlock
()
->
getParent
()
->
getEntryBlock
().
getFirstInsertionPt
();
arg_array
=
new
llvm
::
AllocaInst
(
g
.
llvm_value_type_ptr
,
n_varargs
,
"arg_scratch"
,
insertion_point
);
for
(
int
i
=
3
;
i
<
args
.
size
();
i
++
)
{
...
...
@@ -1928,7 +1929,7 @@ public:
llvm
::
FunctionType
*
ft
=
llvm
::
FunctionType
::
get
(
cf
->
spec
->
rtn_type
->
llvmType
(),
arg_types
,
false
);
llvm
::
Value
*
linked_function
;
if
(
cf
->
func
)
// for JITed functions we need to make the desination address relocatable.
if
(
cf
->
md
->
source
)
// for JITed functions we need to make the desination address relocatable.
linked_function
=
embedRelocatablePtr
(
cf
->
code
,
ft
->
getPointerTo
());
else
linked_function
=
embedConstantPtr
(
cf
->
code
,
ft
->
getPointerTo
());
...
...
src/codegen/irgen.cpp
View file @
d8f237b3
...
...
@@ -1023,9 +1023,11 @@ static std::string getUniqueFunctionName(std::string nameprefix, EffortLevel eff
return
os
.
str
();
}
CompiledFunction
*
doCompile
(
FunctionMetadata
*
md
,
SourceInfo
*
source
,
ParamNames
*
param_names
,
const
OSREntryDescriptor
*
entry_descriptor
,
EffortLevel
effort
,
ExceptionStyle
exception_style
,
FunctionSpecialization
*
spec
,
llvm
::
StringRef
nameprefix
)
{
std
::
pair
<
CompiledFunction
*
,
llvm
::
Function
*>
doCompile
(
FunctionMetadata
*
md
,
SourceInfo
*
source
,
ParamNames
*
param_names
,
const
OSREntryDescriptor
*
entry_descriptor
,
EffortLevel
effort
,
ExceptionStyle
exception_style
,
FunctionSpecialization
*
spec
,
llvm
::
StringRef
nameprefix
)
{
Timer
_t
(
"in doCompile"
);
Timer
_t2
;
long
irgen_us
=
0
;
...
...
@@ -1096,8 +1098,6 @@ CompiledFunction* doCompile(FunctionMetadata* md, SourceInfo* source, ParamNames
llvm
::
Function
*
f
=
llvm
::
Function
::
Create
(
ft
,
llvm
::
Function
::
ExternalLinkage
,
name
,
g
.
cur_module
);
cf
->
func
=
f
;
// g.func_registry.registerFunction(f, g.cur_module);
llvm
::
MDNode
*
dbg_funcinfo
=
setupDebugInfo
(
source
,
f
,
nameprefix
);
...
...
@@ -1138,7 +1138,7 @@ CompiledFunction* doCompile(FunctionMetadata* md, SourceInfo* source, ParamNames
RefcountTracker
refcounter
;
IRGenState
irstate
(
md
,
cf
,
source
,
std
::
move
(
phis
),
param_names
,
getGCBuilder
(),
dbg_funcinfo
,
&
refcounter
);
IRGenState
irstate
(
md
,
cf
,
f
,
source
,
std
::
move
(
phis
),
param_names
,
getGCBuilder
(),
dbg_funcinfo
,
&
refcounter
);
emitBBs
(
&
irstate
,
types
,
entry_descriptor
,
blocks
);
assert
(
!
llvm
::
verifyFunction
(
*
f
,
&
llvm
::
errs
()));
...
...
@@ -1187,7 +1187,7 @@ CompiledFunction* doCompile(FunctionMetadata* md, SourceInfo* source, ParamNames
g
.
cur_module
=
NULL
;
return
cf
;
return
std
::
make_pair
(
cf
,
f
)
;
}
...
...
src/codegen/irgen.h
View file @
d8f237b3
...
...
@@ -137,9 +137,9 @@ extern const std::string PASSED_GENERATOR_NAME;
InternedString
getIsDefinedName
(
InternedString
name
,
InternedStringPool
&
interned_strings
);
bool
isIsDefinedName
(
llvm
::
StringRef
name
);
CompiledFunction
*
doCompile
(
FunctionMetadata
*
md
,
SourceInfo
*
source
,
ParamNames
*
param_names
,
const
OSREntryDescriptor
*
entry_descriptor
,
EffortLevel
effort
,
ExceptionStyle
exception_style
,
FunctionSpecialization
*
spec
,
llvm
::
StringRef
nameprefix
);
std
::
pair
<
CompiledFunction
*
,
llvm
::
Function
*>
doCompile
(
FunctionMetadata
*
md
,
SourceInfo
*
source
,
ParamNames
*
param_names
,
const
OSREntryDescriptor
*
entry_descriptor
,
EffortLevel
effort
,
ExceptionStyle
exception_style
,
FunctionSpecialization
*
spec
,
llvm
::
StringRef
nameprefix
);
// A common pattern is to branch based off whether a variable is defined but only if it is
// potentially-undefined. If it is potentially-undefined, we have to generate control-flow
...
...
src/codegen/irgen/hooks.cpp
View file @
d8f237b3
...
...
@@ -157,23 +157,25 @@ LivenessAnalysis* SourceInfo::getLiveness() {
return
liveness_info
.
get
();
}
static
void
compileIR
(
CompiledFunction
*
cf
,
EffortLevel
effort
)
{
static
void
compileIR
(
CompiledFunction
*
cf
,
llvm
::
Function
*
func
,
EffortLevel
effort
)
{
assert
(
cf
);
assert
(
cf
->
func
);
assert
(
func
);
void
*
compiled
=
NULL
;
cf
->
code
=
NULL
;
{
Timer
_t
(
"to jit the IR"
);
llvm
::
Module
*
module
=
func
->
getParent
();
#if LLVMREV < 215967
g
.
engine
->
addModule
(
cf
->
func
->
getParent
()
);
g
.
engine
->
addModule
(
module
);
#else
g
.
engine
->
addModule
(
std
::
unique_ptr
<
llvm
::
Module
>
(
cf
->
func
->
getParent
()
));
g
.
engine
->
addModule
(
std
::
unique_ptr
<
llvm
::
Module
>
(
module
));
#endif
g
.
cur_cf
=
cf
;
void
*
compiled
=
(
void
*
)
g
.
engine
->
getFunctionAddress
(
cf
->
func
->
getName
());
void
*
compiled
=
(
void
*
)
g
.
engine
->
getFunctionAddress
(
func
->
getName
());
g
.
cur_cf
=
NULL
;
assert
(
compiled
);
ASSERT
(
compiled
==
cf
->
code
,
"cf->code should have gotten filled in"
);
...
...
@@ -185,9 +187,12 @@ static void compileIR(CompiledFunction* cf, EffortLevel effort) {
num_jits
.
log
();
if
(
VERBOSITY
()
>=
1
&&
us
>
100000
)
{
printf
(
"Took %.1fs to compile %s
\n
"
,
us
*
0.000001
,
cf
->
func
->
getName
().
data
());
printf
(
"Has %ld basic blocks
\n
"
,
cf
->
func
->
getBasicBlockList
().
size
());
printf
(
"Took %.1fs to compile %s
\n
"
,
us
*
0.000001
,
func
->
getName
().
data
());
printf
(
"Has %ld basic blocks
\n
"
,
func
->
getBasicBlockList
().
size
());
}
g
.
engine
->
removeModule
(
module
);
delete
module
;
}
if
(
VERBOSITY
(
"irgen"
)
>=
2
)
{
...
...
@@ -275,9 +280,11 @@ CompiledFunction* compileFunction(FunctionMetadata* f, FunctionSpecialization* s
}
CompiledFunction
*
cf
CompiledFunction
*
cf
=
NULL
;
llvm
::
Function
*
func
=
NULL
;
std
::
tie
(
cf
,
func
)
=
doCompile
(
f
,
source
,
&
f
->
param_names
,
entry_descriptor
,
effort
,
exception_style
,
spec
,
name
->
s
());
compileIR
(
cf
,
effort
);
compileIR
(
cf
,
func
,
effort
);
f
->
addVersion
(
cf
);
...
...
@@ -684,7 +691,6 @@ std::unordered_set<CompiledFunction*> all_compiled_functions;
CompiledFunction
::
CompiledFunction
(
FunctionMetadata
*
md
,
FunctionSpecialization
*
spec
,
void
*
code
,
EffortLevel
effort
,
ExceptionStyle
exception_style
,
const
OSREntryDescriptor
*
entry_descriptor
)
:
md
(
md
),
func
(
NULL
),
effort
(
effort
),
exception_style
(
exception_style
),
spec
(
spec
),
...
...
src/codegen/irgen/irgenerator.cpp
View file @
d8f237b3
...
...
@@ -44,11 +44,12 @@ extern "C" void dumpLLVM(void* _v) {
v
->
dump
();
}
IRGenState
::
IRGenState
(
FunctionMetadata
*
md
,
CompiledFunction
*
cf
,
SourceInfo
*
source_info
,
IRGenState
::
IRGenState
(
FunctionMetadata
*
md
,
CompiledFunction
*
cf
,
llvm
::
Function
*
func
,
SourceInfo
*
source_info
,
std
::
unique_ptr
<
PhiAnalysis
>
phis
,
ParamNames
*
param_names
,
GCBuilder
*
gc
,
llvm
::
MDNode
*
func_dbg_info
,
RefcountTracker
*
refcount_tracker
)
:
md
(
md
),
cf
(
cf
),
func
(
func
),
source_info
(
source_info
),
phis
(
std
::
move
(
phis
)),
param_names
(
param_names
),
...
...
@@ -61,7 +62,7 @@ IRGenState::IRGenState(FunctionMetadata* md, CompiledFunction* cf, SourceInfo* s
vregs
(
NULL
),
stmt
(
NULL
),
scratch_size
(
0
)
{
assert
(
cf
->
func
);
assert
(
func
);
assert
(
cf
->
md
->
source
.
get
()
==
source_info
);
// I guess this is duplicate now
}
...
...
src/codegen/irgen/irgenerator.h
View file @
d8f237b3
...
...
@@ -63,6 +63,7 @@ private:
// to md at the end of irgen.
FunctionMetadata
*
md
;
CompiledFunction
*
cf
;
llvm
::
Function
*
func
;
SourceInfo
*
source_info
;
std
::
unique_ptr
<
PhiAnalysis
>
phis
;
ParamNames
*
param_names
;
...
...
@@ -82,8 +83,9 @@ private:
int
scratch_size
;
public:
IRGenState
(
FunctionMetadata
*
md
,
CompiledFunction
*
cf
,
SourceInfo
*
source_info
,
std
::
unique_ptr
<
PhiAnalysis
>
phis
,
ParamNames
*
param_names
,
GCBuilder
*
gc
,
llvm
::
MDNode
*
func_dbg_info
,
RefcountTracker
*
refcount_tracker
);
IRGenState
(
FunctionMetadata
*
md
,
CompiledFunction
*
cf
,
llvm
::
Function
*
func
,
SourceInfo
*
source_info
,
std
::
unique_ptr
<
PhiAnalysis
>
phis
,
ParamNames
*
param_names
,
GCBuilder
*
gc
,
llvm
::
MDNode
*
func_dbg_info
,
RefcountTracker
*
refcount_tracker
);
~
IRGenState
();
CFG
*
getCFG
()
{
return
getSourceInfo
()
->
cfg
;
}
...
...
@@ -93,7 +95,7 @@ public:
ExceptionStyle
getExceptionStyle
()
{
return
cf
->
exception_style
;
}
llvm
::
Function
*
getLLVMFunction
()
{
return
cf
->
func
;
}
llvm
::
Function
*
getLLVMFunction
()
{
return
func
;
}
EffortLevel
getEffortLevel
()
{
return
cf
->
effort
;
}
...
...
src/core/types.h
View file @
d8f237b3
...
...
@@ -335,7 +335,6 @@ struct CompiledFunction {
private:
public:
FunctionMetadata
*
md
;
llvm
::
Function
*
func
;
// the llvm IR object
// Some compilation settings:
EffortLevel
effort
;
...
...
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