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
2f4b5238
Commit
2f4b5238
authored
Nov 04, 2014
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track some stats about the memory we allocate for the JIT
parent
3420ef7e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
13 deletions
+19
-13
src/codegen/memmgr.cpp
src/codegen/memmgr.cpp
+19
-13
No files found.
src/codegen/memmgr.cpp
View file @
2f4b5238
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#include "llvm/Support/Memory.h"
#include "llvm/Support/Memory.h"
#include "core/common.h"
#include "core/common.h"
#include "core/stats.h"
#include "core/util.h"
#include "core/util.h"
// This code was copy-pasted from SectionMemoryManager.cpp;
// This code was copy-pasted from SectionMemoryManager.cpp;
...
@@ -33,29 +34,30 @@ namespace pyston {
...
@@ -33,29 +34,30 @@ namespace pyston {
class
PystonMemoryManager
:
public
RTDyldMemoryManager
{
class
PystonMemoryManager
:
public
RTDyldMemoryManager
{
public:
public:
PystonMemoryManager
()
{}
PystonMemoryManager
()
{}
virtual
~
PystonMemoryManager
()
;
~
PystonMemoryManager
()
override
;
virtual
uint8_t
*
allocateCodeSection
(
uintptr_t
Size
,
unsigned
Alignment
,
unsigned
SectionID
,
StringRef
SectionName
);
uint8_t
*
allocateCodeSection
(
uintptr_t
Size
,
unsigned
Alignment
,
unsigned
SectionID
,
StringRef
SectionName
)
override
;
virtual
uint8_t
*
allocateDataSection
(
uintptr_t
Size
,
unsigned
Alignment
,
unsigned
SectionID
,
StringRef
SectionName
,
uint8_t
*
allocateDataSection
(
uintptr_t
Size
,
unsigned
Alignment
,
unsigned
SectionID
,
StringRef
SectionName
,
bool
isReadOnly
)
;
bool
isReadOnly
)
override
;
virtual
bool
finalizeMemory
(
std
::
string
*
ErrMsg
=
0
);
bool
finalizeMemory
(
std
::
string
*
ErrMsg
=
0
)
override
;
virtual
void
invalidateInstructionCache
();
private:
private:
void
invalidateInstructionCache
();
struct
MemoryGroup
{
struct
MemoryGroup
{
SmallVector
<
sys
::
MemoryBlock
,
16
>
AllocatedMem
;
SmallVector
<
sys
::
MemoryBlock
,
16
>
AllocatedMem
;
SmallVector
<
sys
::
MemoryBlock
,
16
>
FreeMem
;
SmallVector
<
sys
::
MemoryBlock
,
16
>
FreeMem
;
sys
::
MemoryBlock
Near
;
sys
::
MemoryBlock
Near
;
};
};
uint8_t
*
allocateSection
(
MemoryGroup
&
MemGroup
,
uintptr_t
Size
,
unsigned
Alignment
);
uint8_t
*
allocateSection
(
MemoryGroup
&
MemGroup
,
uintptr_t
Size
,
unsigned
Alignment
,
StringRef
SectionName
);
llvm_error_code
applyMemoryGroupPermissions
(
MemoryGroup
&
MemGroup
,
unsigned
Permissions
);
llvm_error_code
applyMemoryGroupPermissions
(
MemoryGroup
&
MemGroup
,
unsigned
Permissions
);
virtual
uint64_t
getSymbolAddress
(
const
std
::
string
&
Name
)
;
uint64_t
getSymbolAddress
(
const
std
::
string
&
Name
)
override
;
MemoryGroup
CodeMem
;
MemoryGroup
CodeMem
;
MemoryGroup
RWDataMem
;
MemoryGroup
RWDataMem
;
...
@@ -67,17 +69,18 @@ uint8_t* PystonMemoryManager::allocateDataSection(uintptr_t Size, unsigned Align
...
@@ -67,17 +69,18 @@ uint8_t* PystonMemoryManager::allocateDataSection(uintptr_t Size, unsigned Align
// printf("allocating data section: %ld %d %d %s %d\n", Size, Alignment, SectionID, SectionName.data(), IsReadOnly);
// printf("allocating data section: %ld %d %d %s %d\n", Size, Alignment, SectionID, SectionName.data(), IsReadOnly);
// assert(SectionName != ".llvm_stackmaps");
// assert(SectionName != ".llvm_stackmaps");
if
(
IsReadOnly
)
if
(
IsReadOnly
)
return
allocateSection
(
RODataMem
,
Size
,
Alignment
);
return
allocateSection
(
RODataMem
,
Size
,
Alignment
,
SectionName
);
return
allocateSection
(
RWDataMem
,
Size
,
Alignment
);
return
allocateSection
(
RWDataMem
,
Size
,
Alignment
,
SectionName
);
}
}
uint8_t
*
PystonMemoryManager
::
allocateCodeSection
(
uintptr_t
Size
,
unsigned
Alignment
,
unsigned
SectionID
,
uint8_t
*
PystonMemoryManager
::
allocateCodeSection
(
uintptr_t
Size
,
unsigned
Alignment
,
unsigned
SectionID
,
StringRef
SectionName
)
{
StringRef
SectionName
)
{
// printf("allocating code section: %ld %d %d %s\n", Size, Alignment, SectionID, SectionName.data());
// printf("allocating code section: %ld %d %d %s\n", Size, Alignment, SectionID, SectionName.data());
return
allocateSection
(
CodeMem
,
Size
,
Alignment
);
return
allocateSection
(
CodeMem
,
Size
,
Alignment
,
SectionName
);
}
}
uint8_t
*
PystonMemoryManager
::
allocateSection
(
MemoryGroup
&
MemGroup
,
uintptr_t
Size
,
unsigned
Alignment
)
{
uint8_t
*
PystonMemoryManager
::
allocateSection
(
MemoryGroup
&
MemGroup
,
uintptr_t
Size
,
unsigned
Alignment
,
StringRef
SectionName
)
{
if
(
!
Alignment
)
if
(
!
Alignment
)
Alignment
=
16
;
Alignment
=
16
;
...
@@ -118,6 +121,9 @@ uint8_t* PystonMemoryManager::allocateSection(MemoryGroup& MemGroup, uintptr_t S
...
@@ -118,6 +121,9 @@ uint8_t* PystonMemoryManager::allocateSection(MemoryGroup& MemGroup, uintptr_t S
return
NULL
;
return
NULL
;
}
}
std
::
string
stat_name
=
"mem_section_"
+
std
::
string
(
SectionName
);
Stats
::
log
(
Stats
::
getStatId
(
stat_name
),
MB
.
size
());
// Save this address as the basis for our next request
// Save this address as the basis for our next request
MemGroup
.
Near
=
MB
;
MemGroup
.
Near
=
MB
;
...
...
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